| line |
true |
false |
branch |
|
32
|
655 |
0 |
if (in == NULL || len == 0) return 0; |
|
|
0 |
655 |
if (in == NULL || len == 0) return 0; |
|
34
|
675 |
9 |
for (i = 0; i < len; i++) { |
|
35
|
10 |
665 |
if (in[i] == '=') { |
|
39
|
662 |
3 |
if (in[i] == ' ' || in[i] == '\t' || in[i] == '\n' || in[i] == '\r') { |
|
|
659 |
3 |
if (in[i] == ' ' || in[i] == '\t' || in[i] == '\n' || in[i] == '\r') { |
|
|
646 |
13 |
if (in[i] == ' ' || in[i] == '\t' || in[i] == '\n' || in[i] == '\r') { |
|
|
0 |
646 |
if (in[i] == ' ' || in[i] == '\t' || in[i] == '\n' || in[i] == '\r') { |
|
130
|
0 |
90 |
if (name == NULL) return 0; |
|
132
|
90 |
0 |
|| strcmp(name, "sha224") == 0 |
|
133
|
90 |
0 |
|| strcmp(name, "sha256") == 0; |
|
|
0 |
90 |
|| strcmp(name, "sha256") == 0; |
|
160
|
1 |
55 |
if (!oidmap || !oid_sv || !SvOK(oid_sv)) return NULL; |
|
|
1 |
0 |
if (!oidmap || !oid_sv || !SvOK(oid_sv)) return NULL; |
|
|
0 |
1 |
if (!oidmap || !oid_sv || !SvOK(oid_sv)) return NULL; |
|
164
|
1 |
0 |
if (!name_sv || !SvOK(*name_sv)) return NULL; |
|
|
0 |
1 |
if (!name_sv || !SvOK(*name_sv)) return NULL; |
|
172
|
56 |
0 |
if (!data || size == 0) return newSVpvn("", 0); |
|
|
0 |
56 |
if (!data || size == 0) return newSVpvn("", 0); |
|
173
|
6 |
50 |
if (bin_fmt == 1) { /* hex */ |
|
180
|
11 |
39 |
} else if (bin_fmt == 2) { /* base64 */ |
|
199
|
1 |
6 |
if (m <= 2) { y--; m += 12; } |
|
205
|
7 |
0 |
epoch += (off_dir ? offset : -offset); |
|
212
|
370 |
186 |
while (node != NULL && node->type != LTC_ASN1_EOL) { |
|
|
367 |
3 |
while (node != NULL && node->type != LTC_ASN1_EOL) { |
|
220
|
3 |
0 |
if (node->data) value_sv = newSViv(*(int *)node->data ? 1 : 0); |
|
225
|
44 |
0 |
if (mpi) { |
|
226
|
5 |
39 |
if (opts.int_fmt == 2) { /* bytes */ |
|
227
|
1 |
4 |
if (mp_isneg(mpi)) { |
|
232
|
1 |
3 |
if (mp_iszero(mpi)) { |
|
241
|
5 |
34 |
int radix = (opts.int_fmt == 1) ? 16 : 10; |
|
244
|
5 |
34 |
format_str = (opts.int_fmt == 1) ? "hex" : "decimal"; |
|
245
|
5 |
34 |
len = mp_count_bits(mpi) / (opts.int_fmt == 1 ? 4 : 3) + 4; |
|
248
|
5 |
34 |
if (opts.int_fmt == 1) { /* lowercase hex */ |
|
249
|
18 |
18 |
char *p; for (p = buf; *p; p++) if (*p >= 'A' && *p <= 'F') *p += 32; |
|
|
18 |
0 |
char *p; for (p = buf; *p; p++) if (*p >= 'A' && *p <= 'F') *p += 32; |
|
|
36 |
5 |
char *p; for (p = buf; *p; p++) if (*p >= 'A' && *p <= 'F') *p += 32; |
|
258
|
0 |
0 |
if (node->data) { |
|
260
|
0 |
0 |
if (opts.int_fmt == 1) { /* hex */ |
|
265
|
0 |
0 |
} else if (opts.int_fmt == 2) { /* bytes */ |
|
270
|
0 |
0 |
while (tmp) { b[n++] = (unsigned char)(tmp & 0xff); tmp >>= 8; } |
|
271
|
0 |
0 |
if (!n) { b[0] = 0; n = 1; } |
|
272
|
0 |
0 |
for (k = 0; k < n; k++) be[k] = b[n - 1 - k]; |
|
285
|
16 |
2 |
format_str = (opts.bin_fmt == 1) ? "hex" : (opts.bin_fmt == 2) ? "base64" : "bytes"; |
|
|
4 |
12 |
format_str = (opts.bin_fmt == 1) ? "hex" : (opts.bin_fmt == 2) ? "base64" : "bytes"; |
|
286
|
18 |
0 |
if (bits && nbytes > 0) { |
|
|
18 |
0 |
if (bits && nbytes > 0) { |
|
290
|
28056 |
18 |
for (i = 0; i < nbits; i++) |
|
291
|
13734 |
14322 |
if (bits[i]) packed[i/8] |= (unsigned char)(0x80u >> (i%8)); |
|
302
|
0 |
0 |
format_str = (opts.bin_fmt == 1) ? "hex" : (opts.bin_fmt == 2) ? "base64" : "bytes"; |
|
|
0 |
0 |
format_str = (opts.bin_fmt == 1) ? "hex" : (opts.bin_fmt == 2) ? "base64" : "bytes"; |
|
309
|
33 |
4 |
format_str = (opts.bin_fmt == 1) ? "hex" : (opts.bin_fmt == 2) ? "base64" : "bytes"; |
|
|
7 |
26 |
format_str = (opts.bin_fmt == 1) ? "hex" : (opts.bin_fmt == 2) ? "base64" : "bytes"; |
|
318
|
56 |
0 |
if (oid && node->size > 0) { |
|
|
56 |
0 |
if (oid && node->size > 0) { |
|
320
|
281 |
56 |
for (i = 0; i < node->size; i++) { |
|
321
|
225 |
56 |
if (i > 0) sv_catpv(s, "."); sv_catpvf(s, "%lu", oid[i]); |
|
326
|
1 |
55 |
if (name_sv) hv_stores(hv, "name", name_sv); |
|
333
|
2 |
0 |
if (node->data && node->size > 0) value_sv = newSVpvn((char *)node->data, node->size); |
|
|
2 |
0 |
if (node->data && node->size > 0) value_sv = newSVpvn((char *)node->data, node->size); |
|
337
|
2 |
0 |
if (node->data && node->size > 0) value_sv = newSVpvn((char *)node->data, node->size); |
|
|
2 |
0 |
if (node->data && node->size > 0) value_sv = newSVpvn((char *)node->data, node->size); |
|
341
|
0 |
0 |
if (node->data && node->size > 0) value_sv = newSVpvn((char *)node->data, node->size); |
|
|
0 |
0 |
if (node->data && node->size > 0) value_sv = newSVpvn((char *)node->data, node->size); |
|
346
|
14 |
0 |
if (wstr && node->size > 0) { |
|
|
14 |
0 |
if (wstr && node->size > 0) { |
|
349
|
64 |
14 |
for (i = 0; i < node->size; i++) { |
|
361
|
16 |
0 |
if (t) { |
|
362
|
0 |
16 |
unsigned YYYY = (t->YY >= 50) ? 1900 + t->YY : 2000 + t->YY; |
|
363
|
6 |
10 |
if (opts.dt_fmt == 1) { /* epoch */ |
|
370
|
10 |
0 |
if (t->off_dir == 0 && t->off_hh == 0 && t->off_mm == 0) |
|
|
10 |
0 |
if (t->off_dir == 0 && t->off_hh == 0 && t->off_mm == 0) |
|
|
10 |
0 |
if (t->off_dir == 0 && t->off_hh == 0 && t->off_mm == 0) |
|
376
|
0 |
0 |
t->off_dir ? '-' : '+', t->off_hh, t->off_mm); |
|
385
|
5 |
0 |
if (t) { |
|
386
|
1 |
4 |
if (opts.dt_fmt == 1) { /* epoch */ |
|
396
|
3 |
1 |
if (t->fs > 0) |
|
398
|
4 |
0 |
if (t->off_dir == 0 && t->off_hh == 0 && t->off_mm == 0) |
|
|
3 |
1 |
if (t->off_dir == 0 && t->off_hh == 0 && t->off_mm == 0) |
|
|
3 |
0 |
if (t->off_dir == 0 && t->off_hh == 0 && t->off_mm == 0) |
|
402
|
0 |
1 |
t->off_dir ? '-' : '+', t->off_hh, t->off_mm); |
|
410
|
115 |
0 |
value_sv = node->child ? newRV_noinc(s_ltc_asn1_to_perl(aTHX_ node->child, opts)) : newRV_noinc((SV *)newAV()); |
|
415
|
14 |
0 |
value_sv = node->child ? newRV_noinc(s_ltc_asn1_to_perl(aTHX_ node->child, opts)) : newRV_noinc((SV *)newAV()); |
|
420
|
21 |
0 |
hv_stores(hv, "class", newSVpv((cls < 4) ? s_asn1_class_names[cls] : "UNKNOWN", 0)); |
|
423
|
20 |
1 |
if (node->pc == LTC_ASN1_PC_CONSTRUCTED && node->child) { |
|
|
20 |
0 |
if (node->pc == LTC_ASN1_PC_CONSTRUCTED && node->child) { |
|
426
|
1 |
0 |
} else if (node->data && node->size > 0) { |
|
|
1 |
0 |
} else if (node->data && node->size > 0) { |
|
427
|
1 |
0 |
format_str = (opts.bin_fmt == 1) ? "hex" : (opts.bin_fmt == 2) ? "base64" : "bytes"; |
|
|
0 |
1 |
format_str = (opts.bin_fmt == 1) ? "hex" : (opts.bin_fmt == 2) ? "base64" : "bytes"; |
|
440
|
20 |
346 |
hv_stores(hv, "value", value_sv ? value_sv : newSV(0)); |
|
453
|
0 |
141 |
if (len > 0xffffffffUL) { |
|
456
|
123 |
18 |
if (len < 128) { |
|
459
|
0 |
18 |
} else if (len <= 0xffUL) { |
|
462
|
18 |
0 |
} else if (len <= 0xffffUL) { |
|
467
|
0 |
0 |
} else if (len <= 0xffffffUL) { |
|
490
|
117 |
13 |
if (clen > 0 && content) sv_catpvn(out, (const char *)content, clen); |
|
|
117 |
0 |
if (clen > 0 && content) sv_catpvn(out, (const char *)content, clen); |
|
503
|
11 |
0 |
if (tag < 31) { |
|
512
|
0 |
0 |
do { tmp[n++] = (unsigned char)(t & 0x7f); t >>= 7; } while (t > 0); |
|
514
|
0 |
0 |
for (i = n - 1; i >= 0; i--) tbuf[tlen++] = tmp[i] | (i > 0 ? 0x80 : 0x00); |
|
|
0 |
0 |
for (i = n - 1; i >= 0; i--) tbuf[tlen++] = tmp[i] | (i > 0 ? 0x80 : 0x00); |
|
519
|
10 |
1 |
if (clen > 0 && content) sv_catpvn(out, (const char *)content, clen); |
|
|
10 |
0 |
if (clen > 0 && content) sv_catpvn(out, (const char *)content, clen); |
|
527
|
0 |
115 |
I32 i, len = av_top_index(nodes); |
|
528
|
194 |
115 |
for (i = 0; i <= len; i++) { |
|
530
|
194 |
0 |
if (!elem || !SvROK(*elem) || SvTYPE(SvRV(*elem)) != SVt_PVHV) continue; |
|
|
194 |
0 |
if (!elem || !SvROK(*elem) || SvTYPE(SvRV(*elem)) != SVt_PVHV) continue; |
|
|
0 |
194 |
if (!elem || !SvROK(*elem) || SvTYPE(SvRV(*elem)) != SVt_PVHV) continue; |
|
541
|
194 |
0 |
if (!sv_type || !SvOK(*sv_type)) croak("FATAL: asn1_encode: node missing 'type'"); |
|
|
0 |
194 |
if (!sv_type || !SvOK(*sv_type)) croak("FATAL: asn1_encode: node missing 'type'"); |
|
544
|
4 |
190 |
if (strEQ(type, "BOOLEAN")) { |
|
545
|
4 |
0 |
int val = (sv_value && SvOK(*sv_value)) ? SvIV(*sv_value) : 0; |
|
|
4 |
0 |
int val = (sv_value && SvOK(*sv_value)) ? SvIV(*sv_value) : 0; |
|
546
|
2 |
2 |
unsigned char c = val ? 0xFF : 0x00; |
|
549
|
11 |
179 |
else if (strEQ(type, "NULL")) { |
|
552
|
25 |
154 |
else if (strEQ(type, "INTEGER")) { |
|
557
|
25 |
0 |
if (!sv_value || !SvOK(*sv_value)) croak("FATAL: asn1_encode: INTEGER missing value"); |
|
|
0 |
25 |
if (!sv_value || !SvOK(*sv_value)) croak("FATAL: asn1_encode: INTEGER missing value"); |
|
560
|
0 |
25 |
if (mp_init(&mpi) != MP_OKAY) croak("FATAL: asn1_encode: mp_init failed"); |
|
561
|
0 |
25 |
if (mp_read_radix(&mpi, str, 10) != MP_OKAY) { mp_clear(&mpi); croak("FATAL: asn1_encode: invalid INTEGER value '%s'", str); } |
|
564
|
0 |
25 |
if (rv != CRYPT_OK) { mp_clear(&mpi); croak("FATAL: asn1_encode: der_length_integer failed"); } |
|
569
|
0 |
25 |
if (rv != CRYPT_OK) { Safefree(buf); croak("FATAL: asn1_encode: der_encode_integer failed"); } |
|
574
|
28 |
126 |
else if (strEQ(type, "OID")) { |
|
579
|
28 |
0 |
if (!sv_value || !SvOK(*sv_value)) croak("FATAL: asn1_encode: OID missing value"); |
|
|
0 |
28 |
if (!sv_value || !SvOK(*sv_value)) croak("FATAL: asn1_encode: OID missing value"); |
|
583
|
138 |
28 |
while (*p && nwords < 64) { |
|
|
138 |
0 |
while (*p && nwords < 64) { |
|
585
|
110 |
28 |
if (*p == '.') p++; |
|
587
|
0 |
28 |
if (nwords < 2) croak("FATAL: asn1_encode: OID must have at least 2 arcs"); |
|
590
|
0 |
28 |
if (rv != CRYPT_OK) croak("FATAL: asn1_encode: der_length_object_identifier failed"); |
|
594
|
0 |
28 |
if (rv != CRYPT_OK) { Safefree(buf); croak("FATAL: asn1_encode: der_encode_object_identifier failed"); } |
|
599
|
17 |
109 |
else if (strEQ(type, "OCTET_STRING")) { |
|
601
|
17 |
0 |
const char *data = (sv_value && SvOK(*sv_value)) ? SvPVbyte(*sv_value, vlen) : ""; |
|
|
17 |
0 |
const char *data = (sv_value && SvOK(*sv_value)) ? SvPVbyte(*sv_value, vlen) : ""; |
|
604
|
11 |
98 |
else if (strEQ(type, "BIT_STRING")) { |
|
606
|
11 |
0 |
const char *data = (sv_value && SvOK(*sv_value)) ? SvPVbyte(*sv_value, vlen) : ""; |
|
|
11 |
0 |
const char *data = (sv_value && SvOK(*sv_value)) ? SvPVbyte(*sv_value, vlen) : ""; |
|
608
|
11 |
0 |
unsigned long nbits = (sv_bits && SvOK(*sv_bits)) ? (unsigned long)SvUV(*sv_bits) : (unsigned long)(vlen * 8); |
|
|
11 |
0 |
unsigned long nbits = (sv_bits && SvOK(*sv_bits)) ? (unsigned long)SvUV(*sv_bits) : (unsigned long)(vlen * 8); |
|
610
|
11 |
0 |
unsigned char unused = (nbytes > 0) ? (unsigned char)(8 * nbytes - nbits) : 0; |
|
616
|
11 |
0 |
if (nbytes > 0 && vlen > 0) { |
|
|
11 |
0 |
if (nbytes > 0 && vlen > 0) { |
|
618
|
1 |
10 |
if (unused > 0) content[nbytes] &= (unsigned char)(0xFF << unused); |
|
623
|
8 |
90 |
else if (strEQ(type, "UTF8_STRING")) { |
|
625
|
8 |
0 |
const char *data = (sv_value && SvOK(*sv_value)) ? SvPVutf8(*sv_value, vlen) : ""; |
|
|
8 |
0 |
const char *data = (sv_value && SvOK(*sv_value)) ? SvPVutf8(*sv_value, vlen) : ""; |
|
628
|
2 |
88 |
else if (strEQ(type, "IA5_STRING")) { |
|
630
|
2 |
0 |
const char *data = (sv_value && SvOK(*sv_value)) ? SvPVbyte(*sv_value, vlen) : ""; |
|
|
2 |
0 |
const char *data = (sv_value && SvOK(*sv_value)) ? SvPVbyte(*sv_value, vlen) : ""; |
|
633
|
2 |
86 |
else if (strEQ(type, "PRINTABLE_STRING")) { |
|
635
|
2 |
0 |
const char *data = (sv_value && SvOK(*sv_value)) ? SvPVbyte(*sv_value, vlen) : ""; |
|
|
2 |
0 |
const char *data = (sv_value && SvOK(*sv_value)) ? SvPVbyte(*sv_value, vlen) : ""; |
|
638
|
1 |
85 |
else if (strEQ(type, "TELETEX_STRING")) { |
|
640
|
1 |
0 |
const char *data = (sv_value && SvOK(*sv_value)) ? SvPVbyte(*sv_value, vlen) : ""; |
|
|
1 |
0 |
const char *data = (sv_value && SvOK(*sv_value)) ? SvPVbyte(*sv_value, vlen) : ""; |
|
643
|
10 |
75 |
else if (strEQ(type, "UTCTIME")) { |
|
645
|
10 |
0 |
const char *data = (sv_value && SvOK(*sv_value)) ? SvPV(*sv_value, vlen) : ""; |
|
|
10 |
0 |
const char *data = (sv_value && SvOK(*sv_value)) ? SvPV(*sv_value, vlen) : ""; |
|
648
|
1 |
74 |
else if (strEQ(type, "GENERALIZEDTIME")) { |
|
650
|
1 |
0 |
const char *data = (sv_value && SvOK(*sv_value)) ? SvPV(*sv_value, vlen) : ""; |
|
|
1 |
0 |
const char *data = (sv_value && SvOK(*sv_value)) ? SvPV(*sv_value, vlen) : ""; |
|
653
|
19 |
55 |
else if (strEQ(type, "SEQUENCE") || strEQ(type, "SET")) { |
|
|
8 |
11 |
else if (strEQ(type, "SEQUENCE") || strEQ(type, "SET")) { |
|
654
|
55 |
8 |
unsigned char tag = strEQ(type, "SEQUENCE") ? 0x30 : 0x31; |
|
655
|
63 |
0 |
if (sv_value && SvROK(*sv_value) && SvTYPE(SvRV(*sv_value)) == SVt_PVAV) { |
|
|
63 |
0 |
if (sv_value && SvROK(*sv_value) && SvTYPE(SvRV(*sv_value)) == SVt_PVAV) { |
|
|
63 |
0 |
if (sv_value && SvROK(*sv_value) && SvTYPE(SvRV(*sv_value)) == SVt_PVAV) { |
|
665
|
11 |
0 |
else if (strEQ(type, "CUSTOM")) { |
|
669
|
11 |
0 |
unsigned int klass = (sv_class && SvOK(*sv_class)) ? (unsigned int)SvIV(*sv_class) : 2; |
|
|
11 |
0 |
unsigned int klass = (sv_class && SvOK(*sv_class)) ? (unsigned int)SvIV(*sv_class) : 2; |
|
670
|
11 |
0 |
unsigned int pc = (sv_constr && SvOK(*sv_constr) && SvIV(*sv_constr)) ? 1 : 0; |
|
|
11 |
0 |
unsigned int pc = (sv_constr && SvOK(*sv_constr) && SvIV(*sv_constr)) ? 1 : 0; |
|
|
10 |
1 |
unsigned int pc = (sv_constr && SvOK(*sv_constr) && SvIV(*sv_constr)) ? 1 : 0; |
|
671
|
11 |
0 |
unsigned long tag = (sv_tag && SvOK(*sv_tag)) ? (unsigned long)SvUV(*sv_tag) : 0; |
|
|
11 |
0 |
unsigned long tag = (sv_tag && SvOK(*sv_tag)) ? (unsigned long)SvUV(*sv_tag) : 0; |
|
673
|
10 |
1 |
if (pc && sv_value && SvROK(*sv_value) && SvTYPE(SvRV(*sv_value)) == SVt_PVAV) { |
|
|
10 |
0 |
if (pc && sv_value && SvROK(*sv_value) && SvTYPE(SvRV(*sv_value)) == SVt_PVAV) { |
|
|
10 |
0 |
if (pc && sv_value && SvROK(*sv_value) && SvTYPE(SvRV(*sv_value)) == SVt_PVAV) { |
|
|
10 |
0 |
if (pc && sv_value && SvROK(*sv_value) && SvTYPE(SvRV(*sv_value)) == SVt_PVAV) { |
|
681
|
1 |
0 |
const char *data = (sv_value && SvOK(*sv_value)) ? SvPVbyte(*sv_value, vlen) : ""; |
|
|
1 |
0 |
const char *data = (sv_value && SvOK(*sv_value)) ? SvPVbyte(*sv_value, vlen) : ""; |
|
818
|
0 |
64 |
if (p == NULL) { |
|
822
|
64 |
0 |
if (passwd == NULL || !SvOK(passwd)) { |
|
|
0 |
64 |
if (passwd == NULL || !SvOK(passwd)) { |
|
828
|
64 |
0 |
if (pwd == NULL || pwd_len == 0) { |
|
|
0 |
64 |
if (pwd == NULL || pwd_len == 0) { |
|
834
|
0 |
64 |
if (*p == NULL) { |
|
850
|
401 |
0 |
if (*last_pid == curpid) return; |
|
852
|
0 |
0 |
if (rng_get_bytes(entropy_buf, sizeof(entropy_buf), NULL) != sizeof(entropy_buf)) { |
|
856
|
0 |
0 |
if (rv != CRYPT_OK) croak("FATAL: PRNG_add_entropy failed: %s", error_to_string(rv)); |
|
858
|
0 |
0 |
if (rv != CRYPT_OK) croak("FATAL: PRNG_ready failed: %s", error_to_string(rv)); |
|
864
|
53 |
0 |
if (prng != NULL && prng->desc != NULL && prng->desc->done != NULL) { |
|
|
53 |
0 |
if (prng != NULL && prng->desc != NULL && prng->desc->done != NULL) { |
|
|
53 |
0 |
if (prng != NULL && prng->desc != NULL && prng->desc->done != NULL) { |
|
875
|
36124 |
0 |
if (prng == NULL || prng->desc == NULL || prng->last_pid == curpid) return; |
|
|
36124 |
0 |
if (prng == NULL || prng->desc == NULL || prng->last_pid == curpid) return; |
|
|
36124 |
0 |
if (prng == NULL || prng->desc == NULL || prng->last_pid == curpid) return; |
|
877
|
0 |
0 |
if (rng_get_bytes(entropy_buf, sizeof(entropy_buf), NULL) != sizeof(entropy_buf)) { |
|
882
|
0 |
0 |
if (rv != CRYPT_OK) croak("FATAL: PRNG_add_entropy failed: %s", error_to_string(rv)); |
|
884
|
0 |
0 |
if (rv != CRYPT_OK) croak("FATAL: PRNG_ready failed: %s", error_to_string(rv)); |
|
897
|
0 |
1404 |
if (mp_isneg(a) == MP_YES) { |
|
903
|
0 |
1404 |
if (rv != MP_OKAY) { |
|
909
|
1404 |
0 |
if (len > 0 && len % 2 && len < maxlen-2) { |
|
|
279 |
1125 |
if (len > 0 && len % 2 && len < maxlen-2) { |
|
|
279 |
0 |
if (len > 0 && len % 2 && len < maxlen-2) { |
|
915
|
6 |
1398 |
if (len < minlen && minlen < maxlen-1) { |
|
|
6 |
0 |
if (len < minlen && minlen < maxlen-1) { |
|
926
|
15088 |
0 |
if (name == NULL || strlen(name) + 1 > ltclen) croak("FATAL: invalid name") ; |
|
|
0 |
15088 |
if (name == NULL || strlen(name) + 1 > ltclen) croak("FATAL: invalid name") ; |
|
928
|
110206 |
0 |
for (i = 0; i < ltclen && name[i] > 0; i++) { |
|
|
95118 |
15088 |
for (i = 0; i < ltclen && name[i] > 0; i++) { |
|
929
|
69752 |
25366 |
if (name[i] >= 'A' && name[i] <= 'Z') { |
|
|
49245 |
20507 |
if (name[i] >= 'A' && name[i] <= 'Z') { |
|
932
|
1859 |
44014 |
else if (name[i] == '_') { |
|
938
|
0 |
95118 |
if (name[i] == ':') start = i + 1; |
|
948
|
472 |
8223 |
if (strcmp(ltcname + start, "ripemd128") == 0) return find_hash("rmd128"); |
|
949
|
472 |
7751 |
if (strcmp(ltcname + start, "ripemd160") == 0) return find_hash("rmd160"); |
|
950
|
84 |
7667 |
if (strcmp(ltcname + start, "ripemd256") == 0) return find_hash("rmd256"); |
|
951
|
84 |
7583 |
if (strcmp(ltcname + start, "ripemd320") == 0) return find_hash("rmd320"); |
|
952
|
490 |
7093 |
if (strcmp(ltcname + start, "tiger192") == 0) return find_hash("tiger"); |
|
953
|
184 |
6909 |
if (strcmp(ltcname + start, "chaes") == 0) return find_hash("chc_hash"); |
|
954
|
0 |
6909 |
if (strcmp(ltcname + start, "chc-hash") == 0) return find_hash("chc_hash"); |
|
963
|
135 |
6204 |
if (strcmp(ltcname + start, "des-ede") == 0) return find_cipher("3des"); |
|
964
|
263 |
5941 |
if (strcmp(ltcname + start, "saferp") == 0) return find_cipher("safer+"); |
|
992
|
0 |
2 |
if ((err = ltc_mp.init(&tmp)) != CRYPT_OK) return; |
|
993
|
51 |
1 |
for (cu = ltc_ecc_curves; cu->prime != NULL; cu++) { |
|
994
|
0 |
51 |
if ((err = mp_read_radix(tmp, cu->prime, 16)) != CRYPT_OK) continue; |
|
995
|
49 |
2 |
if ((mp_cmp(tmp, key->dp.prime) != LTC_MP_EQ)) continue; |
|
996
|
0 |
2 |
if ((err = mp_read_radix(tmp, cu->order, 16)) != CRYPT_OK) continue; |
|
997
|
0 |
2 |
if ((mp_cmp(tmp, key->dp.order) != LTC_MP_EQ)) continue; |
|
998
|
0 |
2 |
if ((err = mp_read_radix(tmp, cu->A, 16)) != CRYPT_OK) continue; |
|
999
|
0 |
2 |
if ((mp_cmp(tmp, key->dp.A) != LTC_MP_EQ)) continue; |
|
1000
|
0 |
2 |
if ((err = mp_read_radix(tmp, cu->B, 16)) != CRYPT_OK) continue; |
|
1001
|
0 |
2 |
if ((mp_cmp(tmp, key->dp.B) != LTC_MP_EQ)) continue; |
|
1002
|
0 |
2 |
if ((err = mp_read_radix(tmp, cu->Gx, 16)) != CRYPT_OK) continue; |
|
1003
|
0 |
2 |
if ((mp_cmp(tmp, key->dp.base.x) != LTC_MP_EQ)) continue; |
|
1004
|
0 |
2 |
if ((err = mp_read_radix(tmp, cu->Gy, 16)) != CRYPT_OK) continue; |
|
1005
|
0 |
2 |
if ((mp_cmp(tmp, key->dp.base.y) != LTC_MP_EQ)) continue; |
|
1006
|
1 |
1 |
if (key->dp.cofactor != cu->cofactor) continue; |
|
1010
|
1 |
1 |
if (cu->prime && cu->OID) { |
|
|
1 |
0 |
if (cu->prime && cu->OID) { |
|
1011
|
16 |
1 |
for (i = 0; i < 16; i++) key->dp.oid[i] = 0; |
|
1012
|
12 |
1 |
for (i = 0, j = 0; i < strlen(cu->OID); i++) { |
|
1013
|
4 |
8 |
if (cu->OID[i] == '.') { |
|
1014
|
0 |
4 |
if (++j >= 16) return; |
|
1016
|
8 |
0 |
else if(cu->OID[i] >= '0' && cu->OID[i] <= '9') { |
|
|
8 |
0 |
else if(cu->OID[i] >= '0' && cu->OID[i] <= '9') { |
|
1037
|
0 |
199 |
if (!SvOK(curve)) croak("FATAL: undefined curve"); |
|
1039
|
199 |
0 |
if (SvPOK_spec(curve)) { |
|
|
2 |
197 |
if (SvPOK_spec(curve)) { |
|
|
2 |
0 |
if (SvPOK_spec(curve)) { |
|
|
0 |
2 |
if (SvPOK_spec(curve)) { |
|
|
0 |
0 |
if (SvPOK_spec(curve)) { |
|
1042
|
0 |
197 |
if ((hc = get_hv("Crypt::PK::ECC::curve", 0)) == NULL) croak("FATAL: no curve register"); |
|
1044
|
0 |
197 |
if (pref && SvOK(*pref)) { |
|
|
0 |
0 |
if (pref && SvOK(*pref)) { |
|
1051
|
2 |
0 |
else if (SvROK(curve) && SvTYPE(SvRV(curve)) == SVt_PVHV) { |
|
|
2 |
0 |
else if (SvROK(curve) && SvTYPE(SvRV(curve)) == SVt_PVHV) { |
|
1059
|
199 |
0 |
if (SvPOK_spec(sv_crv)) { |
|
|
2 |
197 |
if (SvPOK_spec(sv_crv)) { |
|
|
2 |
0 |
if (SvPOK_spec(sv_crv)) { |
|
|
0 |
2 |
if (SvPOK_spec(sv_crv)) { |
|
|
0 |
0 |
if (SvPOK_spec(sv_crv)) { |
|
1063
|
0 |
197 |
if (ecc_find_curve(ptr_crv, &cu) != CRYPT_OK) croak("FATAL: ecparams: unknown curve '%s'", ptr_crv); |
|
1070
|
0 |
2 |
if ((h = (HV*)(SvRV(sv_crv))) == NULL) croak("FATAL: ecparams: param is not valid hashref"); |
|
1072
|
0 |
2 |
if ((sv_prime = hv_fetchs(h, "prime", 0)) == NULL) croak("FATAL: ecparams: missing param prime"); |
|
1073
|
0 |
2 |
if ((sv_A = hv_fetchs(h, "A", 0)) == NULL) croak("FATAL: ecparams: missing param A"); |
|
1074
|
0 |
2 |
if ((sv_B = hv_fetchs(h, "B", 0)) == NULL) croak("FATAL: ecparams: missing param B"); |
|
1075
|
0 |
2 |
if ((sv_order = hv_fetchs(h, "order", 0)) == NULL) croak("FATAL: ecparams: missing param order"); |
|
1076
|
0 |
2 |
if ((sv_Gx = hv_fetchs(h, "Gx", 0)) == NULL) croak("FATAL: ecparams: missing param Gx"); |
|
1077
|
0 |
2 |
if ((sv_Gy = hv_fetchs(h, "Gy", 0)) == NULL) croak("FATAL: ecparams: missing param Gy"); |
|
1078
|
0 |
2 |
if ((sv_cofactor = hv_fetchs(h, "cofactor", 0)) == NULL) croak("FATAL: ecparams: missing param cofactor"); |
|
1080
|
0 |
2 |
if (!SvOK(*sv_prime )) croak("FATAL: ecparams: undefined param prime"); |
|
1081
|
0 |
2 |
if (!SvOK(*sv_A )) croak("FATAL: ecparams: undefined param A"); |
|
1082
|
0 |
2 |
if (!SvOK(*sv_B )) croak("FATAL: ecparams: undefined param B"); |
|
1083
|
0 |
2 |
if (!SvOK(*sv_order )) croak("FATAL: ecparams: undefined param order"); |
|
1084
|
0 |
2 |
if (!SvOK(*sv_Gx )) croak("FATAL: ecparams: undefined param Gx"); |
|
1085
|
0 |
2 |
if (!SvOK(*sv_Gy )) croak("FATAL: ecparams: undefined param Gy"); |
|
1086
|
0 |
2 |
if (!SvOK(*sv_cofactor)) croak("FATAL: ecparams: undefined param cofactor"); |
|
1089
|
0 |
2 |
cu.OID = (sv_oid && SvOK(*sv_oid)) ? SvPV_nolen(*sv_oid) : NULL; |
|
|
0 |
0 |
cu.OID = (sv_oid && SvOK(*sv_oid)) ? SvPV_nolen(*sv_oid) : NULL; |
|
1099
|
0 |
2 |
if ((err = ecc_set_curve(&cu, key)) != CRYPT_OK) return err; |
|
1100
|
2 |
0 |
if (key->dp.oidlen == 0) cryptx_internal_ecc_oid_lookup(key); |
|
1110
|
0 |
152 |
if(register_all_ciphers() != CRYPT_OK) { croak("FATAL: register_all_ciphers failed"); } |
|
1111
|
0 |
152 |
if(register_all_hashes() != CRYPT_OK) { croak("FATAL: register_all_hashes failed"); } |
|
1112
|
0 |
152 |
if(register_all_prngs() != CRYPT_OK) { croak("FATAL: register_all_prngs failed"); } |
|
1113
|
0 |
152 |
if(crypt_mp_init("ltm") != CRYPT_OK) { croak("FATAL: crypt_mp_init failed"); } |
|
1132
|
0 |
1 |
RETVAL = ltc_mp.bits_per_digit; |
|
1149
|
265 |
0 |
if (!SvPOK_spec(in) || radix < 2 || radix > 64) XSRETURN_UNDEF; |
|
|
0 |
265 |
if (!SvPOK_spec(in) || radix < 2 || radix > 64) XSRETURN_UNDEF; |
|
|
0 |
0 |
if (!SvPOK_spec(in) || radix < 2 || radix > 64) XSRETURN_UNDEF; |
|
|
0 |
0 |
if (!SvPOK_spec(in) || radix < 2 || radix > 64) XSRETURN_UNDEF; |
|
|
0 |
0 |
if (!SvPOK_spec(in) || radix < 2 || radix > 64) XSRETURN_UNDEF; |
|
|
265 |
0 |
if (!SvPOK_spec(in) || radix < 2 || radix > 64) XSRETURN_UNDEF; |
|
|
0 |
265 |
if (!SvPOK_spec(in) || radix < 2 || radix > 64) XSRETURN_UNDEF; |
|
1151
|
265 |
0 |
if (in_len > 0 && memchr(in_data, '\0', in_len) != NULL) XSRETURN_UNDEF; |
|
|
0 |
265 |
if (in_len > 0 && memchr(in_data, '\0', in_len) != NULL) XSRETURN_UNDEF; |
|
1152
|
0 |
265 |
if (mp_init(&mpi) != MP_OKAY) XSRETURN_UNDEF; |
|
1153
|
0 |
265 |
if (in_len == 0) { |
|
1156
|
265 |
0 |
else if (mp_read_radix(&mpi, in_data, radix) == MP_OKAY) { |
|
1158
|
0 |
265 |
if (len == 0) { |
|
1166
|
0 |
265 |
if (mp_to_ubin(&mpi, out_data, len, NULL) != MP_OKAY) { |
|
1192
|
290 |
0 |
if (!SvPOK_spec(in) || radix < 2 || radix > 64) XSRETURN_UNDEF; |
|
|
0 |
290 |
if (!SvPOK_spec(in) || radix < 2 || radix > 64) XSRETURN_UNDEF; |
|
|
0 |
0 |
if (!SvPOK_spec(in) || radix < 2 || radix > 64) XSRETURN_UNDEF; |
|
|
0 |
0 |
if (!SvPOK_spec(in) || radix < 2 || radix > 64) XSRETURN_UNDEF; |
|
|
0 |
0 |
if (!SvPOK_spec(in) || radix < 2 || radix > 64) XSRETURN_UNDEF; |
|
|
290 |
0 |
if (!SvPOK_spec(in) || radix < 2 || radix > 64) XSRETURN_UNDEF; |
|
|
0 |
290 |
if (!SvPOK_spec(in) || radix < 2 || radix > 64) XSRETURN_UNDEF; |
|
1194
|
0 |
290 |
if (mp_init_multi(&mpi, &tmp, NULL) != MP_OKAY) XSRETURN_UNDEF; |
|
1195
|
0 |
290 |
if (len == 0) { |
|
1199
|
290 |
0 |
if (mp_from_ubin(&mpi, in_data, (size_t)len) == MP_OKAY) { |
|
1201
|
5655 |
0 |
while (merr == MP_OKAY && mp_iszero(&tmp) == MP_NO) { |
|
|
5365 |
290 |
while (merr == MP_OKAY && mp_iszero(&tmp) == MP_NO) { |
|
1205
|
0 |
290 |
if (merr != MP_OKAY) { |
|
1208
|
25 |
265 |
else if (digits == 0) { |
|
1215
|
265 |
0 |
if (mp_to_radix(&mpi, out_data, digits + 2, NULL, radix) == MP_OKAY) { |
|
1245
|
153 |
1 |
if (!SvPOK_spec(in)) XSRETURN_UNDEF; |
|
|
1 |
152 |
if (!SvPOK_spec(in)) XSRETURN_UNDEF; |
|
|
1 |
0 |
if (!SvPOK_spec(in)) XSRETURN_UNDEF; |
|
|
1 |
0 |
if (!SvPOK_spec(in)) XSRETURN_UNDEF; |
|
|
0 |
1 |
if (!SvPOK_spec(in)) XSRETURN_UNDEF; |
|
1247
|
0 |
153 |
if (in_len == 0) { |
|
1255
|
59 |
94 |
if (ix == 1) |
|
1259
|
0 |
153 |
if (rv != CRYPT_OK) { |
|
1281
|
419 |
1 |
if (!SvPOK_spec(in)) XSRETURN_UNDEF; |
|
|
1 |
418 |
if (!SvPOK_spec(in)) XSRETURN_UNDEF; |
|
|
1 |
0 |
if (!SvPOK_spec(in)) XSRETURN_UNDEF; |
|
|
1 |
0 |
if (!SvPOK_spec(in)) XSRETURN_UNDEF; |
|
|
0 |
1 |
if (!SvPOK_spec(in)) XSRETURN_UNDEF; |
|
1283
|
0 |
419 |
if (in_len == 0) { |
|
1287
|
5 |
414 |
if (cryptx_internal_input_has_no_payload(in_data, in_len)) XSRETURN_UNDEF; |
|
1292
|
76 |
338 |
if (ix == 1) |
|
1296
|
0 |
414 |
if (rv != CRYPT_OK) { |
|
1320
|
234 |
1 |
if (!SvPOK_spec(in)) XSRETURN_UNDEF; |
|
|
1 |
233 |
if (!SvPOK_spec(in)) XSRETURN_UNDEF; |
|
|
1 |
0 |
if (!SvPOK_spec(in)) XSRETURN_UNDEF; |
|
|
1 |
0 |
if (!SvPOK_spec(in)) XSRETURN_UNDEF; |
|
|
0 |
1 |
if (!SvPOK_spec(in)) XSRETURN_UNDEF; |
|
1321
|
60 |
174 |
if (ix == 0) id = BASE32_RFC4648; |
|
1322
|
58 |
176 |
if (ix == 1) id = BASE32_BASE32HEX; |
|
1323
|
58 |
176 |
if (ix == 2) id = BASE32_ZBASE32; |
|
1324
|
58 |
176 |
if (ix == 3) id = BASE32_CROCKFORD; |
|
1325
|
0 |
234 |
if (id == -1) XSRETURN_UNDEF; |
|
1327
|
0 |
234 |
if (in_len == 0) { |
|
1336
|
0 |
234 |
if (err != CRYPT_OK) { |
|
1360
|
236 |
1 |
if (!SvPOK_spec(in)) XSRETURN_UNDEF; |
|
|
0 |
236 |
if (!SvPOK_spec(in)) XSRETURN_UNDEF; |
|
|
0 |
0 |
if (!SvPOK_spec(in)) XSRETURN_UNDEF; |
|
|
0 |
0 |
if (!SvPOK_spec(in)) XSRETURN_UNDEF; |
|
|
0 |
0 |
if (!SvPOK_spec(in)) XSRETURN_UNDEF; |
|
1361
|
60 |
176 |
if (ix == 0) id = BASE32_RFC4648; |
|
1362
|
59 |
177 |
if (ix == 1) id = BASE32_BASE32HEX; |
|
1363
|
58 |
178 |
if (ix == 2) id = BASE32_ZBASE32; |
|
1364
|
59 |
177 |
if (ix == 3) id = BASE32_CROCKFORD; |
|
1365
|
0 |
236 |
if (id == -1) XSRETURN_UNDEF; |
|
1367
|
0 |
236 |
if (in_len == 0) { |
|
1371
|
4 |
232 |
if (cryptx_internal_input_has_no_payload(in_data, in_len)) XSRETURN_UNDEF; |
|
1377
|
0 |
232 |
if (err != CRYPT_OK) { |
|
1394
|
6 |
0 |
if (!SvPOK_spec(in)) XSRETURN_UNDEF; |
|
|
0 |
6 |
if (!SvPOK_spec(in)) XSRETURN_UNDEF; |
|
|
0 |
0 |
if (!SvPOK_spec(in)) XSRETURN_UNDEF; |
|
|
0 |
0 |
if (!SvPOK_spec(in)) XSRETURN_UNDEF; |
|
|
0 |
0 |
if (!SvPOK_spec(in)) XSRETURN_UNDEF; |
|
1396
|
0 |
6 |
if (len == 0) { |
|
1405
|
11 |
2 |
while (i < len) { |
|
1407
|
4 |
7 |
if (0 != out_data[i]) break; |
|
1410
|
2 |
4 |
if (i == len) { |
|
1426
|
8 |
0 |
if (!SvPOK_spec(in)) XSRETURN_UNDEF; |
|
|
1 |
7 |
if (!SvPOK_spec(in)) XSRETURN_UNDEF; |
|
|
1 |
0 |
if (!SvPOK_spec(in)) XSRETURN_UNDEF; |
|
|
1 |
0 |
if (!SvPOK_spec(in)) XSRETURN_UNDEF; |
|
|
0 |
1 |
if (!SvPOK_spec(in)) XSRETURN_UNDEF; |
|
1428
|
0 |
8 |
if (len == 0) { |
|
1437
|
13 |
2 |
while (i < len) { |
|
1439
|
6 |
7 |
if (0 != out_data[len - 1 - i]) break; |
|
1442
|
2 |
6 |
if (i == len) { |
|
1460
|
8 |
1 |
if (!SvPOK_spec(a) || !SvPOK_spec(b)) XSRETURN_UNDEF; |
|
|
0 |
8 |
if (!SvPOK_spec(a) || !SvPOK_spec(b)) XSRETURN_UNDEF; |
|
|
0 |
0 |
if (!SvPOK_spec(a) || !SvPOK_spec(b)) XSRETURN_UNDEF; |
|
|
0 |
0 |
if (!SvPOK_spec(a) || !SvPOK_spec(b)) XSRETURN_UNDEF; |
|
|
0 |
0 |
if (!SvPOK_spec(a) || !SvPOK_spec(b)) XSRETURN_UNDEF; |
|
|
8 |
0 |
if (!SvPOK_spec(a) || !SvPOK_spec(b)) XSRETURN_UNDEF; |
|
|
0 |
8 |
if (!SvPOK_spec(a) || !SvPOK_spec(b)) XSRETURN_UNDEF; |
|
|
0 |
0 |
if (!SvPOK_spec(a) || !SvPOK_spec(b)) XSRETURN_UNDEF; |
|
|
0 |
0 |
if (!SvPOK_spec(a) || !SvPOK_spec(b)) XSRETURN_UNDEF; |
|
|
0 |
0 |
if (!SvPOK_spec(a) || !SvPOK_spec(b)) XSRETURN_UNDEF; |
|
1464
|
2 |
6 |
if (a_len != b_len) { first = b_data; result = 1; } |