| 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') { |
|
135
|
0 |
93 |
if (name == NULL) return 0; |
|
137
|
93 |
0 |
|| strcmp(name, "sha224") == 0 |
|
138
|
93 |
0 |
|| strcmp(name, "sha256") == 0; |
|
|
0 |
93 |
|| strcmp(name, "sha256") == 0; |
|
165
|
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; |
|
169
|
1 |
0 |
if (!name_sv || !SvOK(*name_sv)) return NULL; |
|
|
0 |
1 |
if (!name_sv || !SvOK(*name_sv)) return NULL; |
|
177
|
56 |
0 |
if (!data || size == 0) return newSVpvn("", 0); |
|
|
0 |
56 |
if (!data || size == 0) return newSVpvn("", 0); |
|
178
|
6 |
50 |
if (bin_fmt == 1) { /* hex */ |
|
185
|
11 |
39 |
} else if (bin_fmt == 2) { /* base64 */ |
|
204
|
1 |
6 |
if (m <= 2) { y--; m += 12; } |
|
210
|
7 |
0 |
epoch += (off_dir ? offset : -offset); |
|
217
|
370 |
186 |
while (node != NULL && node->type != LTC_ASN1_EOL) { |
|
|
367 |
3 |
while (node != NULL && node->type != LTC_ASN1_EOL) { |
|
225
|
3 |
0 |
if (node->data) value_sv = newSViv(*(int *)node->data ? 1 : 0); |
|
230
|
44 |
0 |
if (mpi) { |
|
231
|
5 |
39 |
if (opts.int_fmt == 2) { /* bytes */ |
|
232
|
1 |
4 |
if (mp_isneg(mpi)) { |
|
237
|
1 |
3 |
if (mp_iszero(mpi)) { |
|
246
|
5 |
34 |
int radix = (opts.int_fmt == 1) ? 16 : 10; |
|
249
|
5 |
34 |
format_str = (opts.int_fmt == 1) ? "hex" : "decimal"; |
|
250
|
5 |
34 |
len = mp_count_bits(mpi) / (opts.int_fmt == 1 ? 4 : 3) + 4; |
|
253
|
5 |
34 |
if (opts.int_fmt == 1) { /* lowercase hex */ |
|
254
|
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; |
|
263
|
0 |
0 |
if (node->data) { |
|
265
|
0 |
0 |
if (opts.int_fmt == 1) { /* hex */ |
|
270
|
0 |
0 |
} else if (opts.int_fmt == 2) { /* bytes */ |
|
275
|
0 |
0 |
while (tmp) { b[n++] = (unsigned char)(tmp & 0xff); tmp >>= 8; } |
|
276
|
0 |
0 |
if (!n) { b[0] = 0; n = 1; } |
|
277
|
0 |
0 |
for (k = 0; k < n; k++) be[k] = b[n - 1 - k]; |
|
290
|
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"; |
|
291
|
18 |
0 |
if (bits && nbytes > 0) { |
|
|
18 |
0 |
if (bits && nbytes > 0) { |
|
295
|
28056 |
18 |
for (i = 0; i < nbits; i++) |
|
296
|
13734 |
14322 |
if (bits[i]) packed[i/8] |= (unsigned char)(0x80u >> (i%8)); |
|
307
|
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"; |
|
314
|
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"; |
|
323
|
56 |
0 |
if (oid && node->size > 0) { |
|
|
56 |
0 |
if (oid && node->size > 0) { |
|
325
|
281 |
56 |
for (i = 0; i < node->size; i++) { |
|
326
|
225 |
56 |
if (i > 0) sv_catpv(s, "."); sv_catpvf(s, "%lu", oid[i]); |
|
331
|
1 |
55 |
if (name_sv) hv_stores(hv, "name", name_sv); |
|
338
|
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); |
|
342
|
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); |
|
346
|
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); |
|
351
|
14 |
0 |
if (wstr && node->size > 0) { |
|
|
14 |
0 |
if (wstr && node->size > 0) { |
|
354
|
64 |
14 |
for (i = 0; i < node->size; i++) { |
|
366
|
16 |
0 |
if (t) { |
|
367
|
0 |
16 |
unsigned YYYY = (t->YY >= 50) ? 1900 + t->YY : 2000 + t->YY; |
|
368
|
6 |
10 |
if (opts.dt_fmt == 1) { /* epoch */ |
|
375
|
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) |
|
381
|
0 |
0 |
t->off_dir ? '-' : '+', t->off_hh, t->off_mm); |
|
390
|
5 |
0 |
if (t) { |
|
391
|
1 |
4 |
if (opts.dt_fmt == 1) { /* epoch */ |
|
401
|
3 |
1 |
if (t->fs > 0) |
|
403
|
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) |
|
407
|
0 |
1 |
t->off_dir ? '-' : '+', t->off_hh, t->off_mm); |
|
415
|
115 |
0 |
value_sv = node->child ? newRV_noinc(s_ltc_asn1_to_perl(aTHX_ node->child, opts)) : newRV_noinc((SV *)newAV()); |
|
420
|
14 |
0 |
value_sv = node->child ? newRV_noinc(s_ltc_asn1_to_perl(aTHX_ node->child, opts)) : newRV_noinc((SV *)newAV()); |
|
425
|
21 |
0 |
hv_stores(hv, "class", newSVpv((cls < 4) ? s_asn1_class_names[cls] : "UNKNOWN", 0)); |
|
428
|
20 |
1 |
if (node->pc == LTC_ASN1_PC_CONSTRUCTED && node->child) { |
|
|
20 |
0 |
if (node->pc == LTC_ASN1_PC_CONSTRUCTED && node->child) { |
|
431
|
1 |
0 |
} else if (node->data && node->size > 0) { |
|
|
1 |
0 |
} else if (node->data && node->size > 0) { |
|
432
|
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"; |
|
445
|
20 |
346 |
hv_stores(hv, "value", value_sv ? value_sv : newSV(0)); |
|
458
|
0 |
141 |
if (len > 0xffffffffUL) { |
|
461
|
123 |
18 |
if (len < 128) { |
|
464
|
0 |
18 |
} else if (len <= 0xffUL) { |
|
467
|
18 |
0 |
} else if (len <= 0xffffUL) { |
|
472
|
0 |
0 |
} else if (len <= 0xffffffUL) { |
|
495
|
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); |
|
508
|
11 |
0 |
if (tag < 31) { |
|
517
|
0 |
0 |
do { tmp[n++] = (unsigned char)(t & 0x7f); t >>= 7; } while (t > 0); |
|
519
|
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); |
|
524
|
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); |
|
532
|
0 |
115 |
I32 i, len = av_top_index(nodes); |
|
533
|
194 |
115 |
for (i = 0; i <= len; i++) { |
|
535
|
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; |
|
546
|
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'"); |
|
549
|
4 |
190 |
if (strEQ(type, "BOOLEAN")) { |
|
550
|
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; |
|
551
|
2 |
2 |
unsigned char c = val ? 0xFF : 0x00; |
|
554
|
11 |
179 |
else if (strEQ(type, "NULL")) { |
|
557
|
25 |
154 |
else if (strEQ(type, "INTEGER")) { |
|
562
|
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"); |
|
565
|
0 |
25 |
if (mp_init(&mpi) != MP_OKAY) croak("FATAL: asn1_encode: mp_init failed"); |
|
566
|
0 |
25 |
if (mp_read_radix(&mpi, str, 10) != MP_OKAY) { mp_clear(&mpi); croak("FATAL: asn1_encode: invalid INTEGER value '%s'", str); } |
|
569
|
0 |
25 |
if (rv != CRYPT_OK) { mp_clear(&mpi); croak("FATAL: asn1_encode: der_length_integer failed"); } |
|
574
|
0 |
25 |
if (rv != CRYPT_OK) { Safefree(buf); croak("FATAL: asn1_encode: der_encode_integer failed"); } |
|
579
|
28 |
126 |
else if (strEQ(type, "OID")) { |
|
584
|
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"); |
|
588
|
138 |
28 |
while (*p && nwords < 64) { |
|
|
138 |
0 |
while (*p && nwords < 64) { |
|
590
|
110 |
28 |
if (*p == '.') p++; |
|
592
|
0 |
28 |
if (nwords < 2) croak("FATAL: asn1_encode: OID must have at least 2 arcs"); |
|
595
|
0 |
28 |
if (rv != CRYPT_OK) croak("FATAL: asn1_encode: der_length_object_identifier failed"); |
|
599
|
0 |
28 |
if (rv != CRYPT_OK) { Safefree(buf); croak("FATAL: asn1_encode: der_encode_object_identifier failed"); } |
|
604
|
17 |
109 |
else if (strEQ(type, "OCTET_STRING")) { |
|
606
|
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) : ""; |
|
609
|
11 |
98 |
else if (strEQ(type, "BIT_STRING")) { |
|
611
|
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) : ""; |
|
613
|
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); |
|
615
|
11 |
0 |
unsigned char unused = (nbytes > 0) ? (unsigned char)(8 * nbytes - nbits) : 0; |
|
621
|
11 |
0 |
if (nbytes > 0 && vlen > 0) { |
|
|
11 |
0 |
if (nbytes > 0 && vlen > 0) { |
|
623
|
1 |
10 |
if (unused > 0) content[nbytes] &= (unsigned char)(0xFF << unused); |
|
628
|
8 |
90 |
else if (strEQ(type, "UTF8_STRING")) { |
|
630
|
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) : ""; |
|
633
|
2 |
88 |
else if (strEQ(type, "IA5_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
|
2 |
86 |
else if (strEQ(type, "PRINTABLE_STRING")) { |
|
640
|
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) : ""; |
|
643
|
1 |
85 |
else if (strEQ(type, "TELETEX_STRING")) { |
|
645
|
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) : ""; |
|
648
|
10 |
75 |
else if (strEQ(type, "UTCTIME")) { |
|
650
|
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) : ""; |
|
653
|
1 |
74 |
else if (strEQ(type, "GENERALIZEDTIME")) { |
|
655
|
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) : ""; |
|
658
|
19 |
55 |
else if (strEQ(type, "SEQUENCE") || strEQ(type, "SET")) { |
|
|
8 |
11 |
else if (strEQ(type, "SEQUENCE") || strEQ(type, "SET")) { |
|
659
|
55 |
8 |
unsigned char tag = strEQ(type, "SEQUENCE") ? 0x30 : 0x31; |
|
660
|
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) { |
|
670
|
11 |
0 |
else if (strEQ(type, "CUSTOM")) { |
|
674
|
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; |
|
675
|
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; |
|
676
|
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; |
|
678
|
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) { |
|
686
|
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) : ""; |
|
823
|
0 |
64 |
if (p == NULL) { |
|
827
|
64 |
0 |
if (passwd == NULL || !SvOK(passwd)) { |
|
|
0 |
64 |
if (passwd == NULL || !SvOK(passwd)) { |
|
833
|
64 |
0 |
if (pwd == NULL || pwd_len == 0) { |
|
|
0 |
64 |
if (pwd == NULL || pwd_len == 0) { |
|
839
|
0 |
64 |
if (*p == NULL) { |
|
855
|
401 |
0 |
if (*last_pid == curpid) return; |
|
857
|
0 |
0 |
if (rng_get_bytes(entropy_buf, sizeof(entropy_buf), NULL) != sizeof(entropy_buf)) { |
|
861
|
0 |
0 |
if (rv != CRYPT_OK) croak("FATAL: PRNG_add_entropy failed: %s", error_to_string(rv)); |
|
863
|
0 |
0 |
if (rv != CRYPT_OK) croak("FATAL: PRNG_ready failed: %s", error_to_string(rv)); |
|
869
|
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) { |
|
880
|
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; |
|
882
|
0 |
0 |
if (rng_get_bytes(entropy_buf, sizeof(entropy_buf), NULL) != sizeof(entropy_buf)) { |
|
887
|
0 |
0 |
if (rv != CRYPT_OK) croak("FATAL: PRNG_add_entropy failed: %s", error_to_string(rv)); |
|
889
|
0 |
0 |
if (rv != CRYPT_OK) croak("FATAL: PRNG_ready failed: %s", error_to_string(rv)); |
|
902
|
0 |
1404 |
if (mp_isneg(a) == MP_YES) { |
|
908
|
0 |
1404 |
if (rv != MP_OKAY) { |
|
914
|
1404 |
0 |
if (len > 0 && len % 2 && len < maxlen-2) { |
|
|
280 |
1124 |
if (len > 0 && len % 2 && len < maxlen-2) { |
|
|
280 |
0 |
if (len > 0 && len % 2 && len < maxlen-2) { |
|
920
|
6 |
1398 |
if (len < minlen && minlen < maxlen-1) { |
|
|
6 |
0 |
if (len < minlen && minlen < maxlen-1) { |
|
931
|
15241 |
0 |
if (name == NULL || strlen(name) + 1 > ltclen) croak("FATAL: invalid name") ; |
|
|
0 |
15241 |
if (name == NULL || strlen(name) + 1 > ltclen) croak("FATAL: invalid name") ; |
|
933
|
110862 |
0 |
for (i = 0; i < ltclen && name[i] > 0; i++) { |
|
|
95621 |
15241 |
for (i = 0; i < ltclen && name[i] > 0; i++) { |
|
934
|
70171 |
25450 |
if (name[i] >= 'A' && name[i] <= 'Z') { |
|
|
49664 |
20507 |
if (name[i] >= 'A' && name[i] <= 'Z') { |
|
937
|
1859 |
44098 |
else if (name[i] == '_') { |
|
943
|
0 |
95621 |
if (name[i] == ':') start = i + 1; |
|
953
|
472 |
8307 |
if (strcmp(ltcname + start, "ripemd128") == 0) return find_hash("rmd128"); |
|
954
|
472 |
7835 |
if (strcmp(ltcname + start, "ripemd160") == 0) return find_hash("rmd160"); |
|
955
|
84 |
7751 |
if (strcmp(ltcname + start, "ripemd256") == 0) return find_hash("rmd256"); |
|
956
|
84 |
7667 |
if (strcmp(ltcname + start, "ripemd320") == 0) return find_hash("rmd320"); |
|
957
|
490 |
7177 |
if (strcmp(ltcname + start, "tiger192") == 0) return find_hash("tiger"); |
|
958
|
184 |
6993 |
if (strcmp(ltcname + start, "chaes") == 0) return find_hash("chc_hash"); |
|
959
|
0 |
6993 |
if (strcmp(ltcname + start, "chc-hash") == 0) return find_hash("chc_hash"); |
|
968
|
135 |
6273 |
if (strcmp(ltcname + start, "des-ede") == 0) return find_cipher("3des"); |
|
969
|
263 |
6010 |
if (strcmp(ltcname + start, "saferp") == 0) return find_cipher("safer+"); |
|
997
|
0 |
2 |
if ((err = ltc_mp.init(&tmp)) != CRYPT_OK) return; |
|
998
|
51 |
1 |
for (cu = ltc_ecc_curves; cu->prime != NULL; cu++) { |
|
999
|
0 |
51 |
if ((err = mp_read_radix(tmp, cu->prime, 16)) != CRYPT_OK) continue; |
|
1000
|
49 |
2 |
if ((mp_cmp(tmp, key->dp.prime) != LTC_MP_EQ)) continue; |
|
1001
|
0 |
2 |
if ((err = mp_read_radix(tmp, cu->order, 16)) != CRYPT_OK) continue; |
|
1002
|
0 |
2 |
if ((mp_cmp(tmp, key->dp.order) != LTC_MP_EQ)) continue; |
|
1003
|
0 |
2 |
if ((err = mp_read_radix(tmp, cu->A, 16)) != CRYPT_OK) continue; |
|
1004
|
0 |
2 |
if ((mp_cmp(tmp, key->dp.A) != LTC_MP_EQ)) continue; |
|
1005
|
0 |
2 |
if ((err = mp_read_radix(tmp, cu->B, 16)) != CRYPT_OK) continue; |
|
1006
|
0 |
2 |
if ((mp_cmp(tmp, key->dp.B) != LTC_MP_EQ)) continue; |
|
1007
|
0 |
2 |
if ((err = mp_read_radix(tmp, cu->Gx, 16)) != CRYPT_OK) continue; |
|
1008
|
0 |
2 |
if ((mp_cmp(tmp, key->dp.base.x) != LTC_MP_EQ)) continue; |
|
1009
|
0 |
2 |
if ((err = mp_read_radix(tmp, cu->Gy, 16)) != CRYPT_OK) continue; |
|
1010
|
0 |
2 |
if ((mp_cmp(tmp, key->dp.base.y) != LTC_MP_EQ)) continue; |
|
1011
|
1 |
1 |
if (key->dp.cofactor != cu->cofactor) continue; |
|
1015
|
1 |
1 |
if (cu->prime && cu->OID) { |
|
|
1 |
0 |
if (cu->prime && cu->OID) { |
|
1016
|
16 |
1 |
for (i = 0; i < 16; i++) key->dp.oid[i] = 0; |
|
1017
|
12 |
1 |
for (i = 0, j = 0; i < strlen(cu->OID); i++) { |
|
1018
|
4 |
8 |
if (cu->OID[i] == '.') { |
|
1019
|
0 |
4 |
if (++j >= 16) return; |
|
1021
|
8 |
0 |
else if(cu->OID[i] >= '0' && cu->OID[i] <= '9') { |
|
|
8 |
0 |
else if(cu->OID[i] >= '0' && cu->OID[i] <= '9') { |
|
1042
|
0 |
199 |
if (!SvOK(curve)) croak("FATAL: undefined curve"); |
|
1044
|
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)) { |
|
1047
|
0 |
197 |
if ((hc = get_hv("Crypt::PK::ECC::curve", 0)) == NULL) croak("FATAL: no curve register"); |
|
1049
|
0 |
197 |
if (pref && SvOK(*pref)) { |
|
|
0 |
0 |
if (pref && SvOK(*pref)) { |
|
1056
|
2 |
0 |
else if (SvROK(curve) && SvTYPE(SvRV(curve)) == SVt_PVHV) { |
|
|
2 |
0 |
else if (SvROK(curve) && SvTYPE(SvRV(curve)) == SVt_PVHV) { |
|
1064
|
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)) { |
|
1068
|
0 |
197 |
if (ecc_find_curve(ptr_crv, &cu) != CRYPT_OK) croak("FATAL: ecparams: unknown curve '%s'", ptr_crv); |
|
1075
|
0 |
2 |
if ((h = (HV*)(SvRV(sv_crv))) == NULL) croak("FATAL: ecparams: param is not valid hashref"); |
|
1077
|
0 |
2 |
if ((sv_prime = hv_fetchs(h, "prime", 0)) == NULL) croak("FATAL: ecparams: missing param prime"); |
|
1078
|
0 |
2 |
if ((sv_A = hv_fetchs(h, "A", 0)) == NULL) croak("FATAL: ecparams: missing param A"); |
|
1079
|
0 |
2 |
if ((sv_B = hv_fetchs(h, "B", 0)) == NULL) croak("FATAL: ecparams: missing param B"); |
|
1080
|
0 |
2 |
if ((sv_order = hv_fetchs(h, "order", 0)) == NULL) croak("FATAL: ecparams: missing param order"); |
|
1081
|
0 |
2 |
if ((sv_Gx = hv_fetchs(h, "Gx", 0)) == NULL) croak("FATAL: ecparams: missing param Gx"); |
|
1082
|
0 |
2 |
if ((sv_Gy = hv_fetchs(h, "Gy", 0)) == NULL) croak("FATAL: ecparams: missing param Gy"); |
|
1083
|
0 |
2 |
if ((sv_cofactor = hv_fetchs(h, "cofactor", 0)) == NULL) croak("FATAL: ecparams: missing param cofactor"); |
|
1085
|
0 |
2 |
if (!SvOK(*sv_prime )) croak("FATAL: ecparams: undefined param prime"); |
|
1086
|
0 |
2 |
if (!SvOK(*sv_A )) croak("FATAL: ecparams: undefined param A"); |
|
1087
|
0 |
2 |
if (!SvOK(*sv_B )) croak("FATAL: ecparams: undefined param B"); |
|
1088
|
0 |
2 |
if (!SvOK(*sv_order )) croak("FATAL: ecparams: undefined param order"); |
|
1089
|
0 |
2 |
if (!SvOK(*sv_Gx )) croak("FATAL: ecparams: undefined param Gx"); |
|
1090
|
0 |
2 |
if (!SvOK(*sv_Gy )) croak("FATAL: ecparams: undefined param Gy"); |
|
1091
|
0 |
2 |
if (!SvOK(*sv_cofactor)) croak("FATAL: ecparams: undefined param cofactor"); |
|
1094
|
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; |
|
1104
|
0 |
2 |
if ((err = ecc_set_curve(&cu, key)) != CRYPT_OK) return err; |
|
1105
|
2 |
0 |
if (key->dp.oidlen == 0) cryptx_internal_ecc_oid_lookup(key); |
|
1115
|
0 |
156 |
if(register_all_ciphers() != CRYPT_OK) { croak("FATAL: register_all_ciphers failed"); } |
|
1116
|
0 |
156 |
if(register_all_hashes() != CRYPT_OK) { croak("FATAL: register_all_hashes failed"); } |
|
1117
|
0 |
156 |
if(register_all_prngs() != CRYPT_OK) { croak("FATAL: register_all_prngs failed"); } |
|
1118
|
0 |
156 |
if(crypt_mp_init("ltm") != CRYPT_OK) { croak("FATAL: crypt_mp_init failed"); } |
|
1137
|
0 |
1 |
RETVAL = ltc_mp.bits_per_digit; |
|
1154
|
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; |
|
1156
|
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; |
|
1157
|
0 |
265 |
if (mp_init(&mpi) != MP_OKAY) XSRETURN_UNDEF; |
|
1158
|
0 |
265 |
if (in_len == 0) { |
|
1161
|
265 |
0 |
else if (mp_read_radix(&mpi, in_data, radix) == MP_OKAY) { |
|
1163
|
0 |
265 |
if (len == 0) { |
|
1171
|
0 |
265 |
if (mp_to_ubin(&mpi, out_data, len, NULL) != MP_OKAY) { |
|
1197
|
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; |
|
1199
|
0 |
290 |
if (mp_init_multi(&mpi, &tmp, NULL) != MP_OKAY) XSRETURN_UNDEF; |
|
1200
|
0 |
290 |
if (len == 0) { |
|
1204
|
290 |
0 |
if (mp_from_ubin(&mpi, in_data, (size_t)len) == MP_OKAY) { |
|
1206
|
5655 |
0 |
while (merr == MP_OKAY && mp_iszero(&tmp) == MP_NO) { |
|
|
5365 |
290 |
while (merr == MP_OKAY && mp_iszero(&tmp) == MP_NO) { |
|
1210
|
0 |
290 |
if (merr != MP_OKAY) { |
|
1213
|
25 |
265 |
else if (digits == 0) { |
|
1220
|
265 |
0 |
if (mp_to_radix(&mpi, out_data, digits + 2, NULL, radix) == MP_OKAY) { |
|
1250
|
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; |
|
1252
|
0 |
153 |
if (in_len == 0) { |
|
1260
|
59 |
94 |
if (ix == 1) |
|
1264
|
0 |
153 |
if (rv != CRYPT_OK) { |
|
1286
|
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; |
|
1288
|
0 |
419 |
if (in_len == 0) { |
|
1292
|
5 |
414 |
if (cryptx_internal_input_has_no_payload(in_data, in_len)) XSRETURN_UNDEF; |
|
1297
|
76 |
338 |
if (ix == 1) |
|
1301
|
0 |
414 |
if (rv != CRYPT_OK) { |
|
1325
|
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; |
|
1326
|
60 |
174 |
if (ix == 0) id = BASE32_RFC4648; |
|
1327
|
58 |
176 |
if (ix == 1) id = BASE32_BASE32HEX; |
|
1328
|
58 |
176 |
if (ix == 2) id = BASE32_ZBASE32; |
|
1329
|
58 |
176 |
if (ix == 3) id = BASE32_CROCKFORD; |
|
1330
|
0 |
234 |
if (id == -1) XSRETURN_UNDEF; |
|
1332
|
0 |
234 |
if (in_len == 0) { |
|
1341
|
0 |
234 |
if (err != CRYPT_OK) { |
|
1365
|
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; |
|
1366
|
60 |
176 |
if (ix == 0) id = BASE32_RFC4648; |
|
1367
|
59 |
177 |
if (ix == 1) id = BASE32_BASE32HEX; |
|
1368
|
58 |
178 |
if (ix == 2) id = BASE32_ZBASE32; |
|
1369
|
59 |
177 |
if (ix == 3) id = BASE32_CROCKFORD; |
|
1370
|
0 |
236 |
if (id == -1) XSRETURN_UNDEF; |
|
1372
|
0 |
236 |
if (in_len == 0) { |
|
1376
|
4 |
232 |
if (cryptx_internal_input_has_no_payload(in_data, in_len)) XSRETURN_UNDEF; |
|
1382
|
0 |
232 |
if (err != CRYPT_OK) { |
|
1399
|
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; |
|
1401
|
0 |
6 |
if (len == 0) { |
|
1410
|
11 |
2 |
while (i < len) { |
|
1412
|
4 |
7 |
if (0 != out_data[i]) break; |
|
1415
|
2 |
4 |
if (i == len) { |
|
1431
|
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; |
|
1433
|
0 |
8 |
if (len == 0) { |
|
1442
|
13 |
2 |
while (i < len) { |
|
1444
|
6 |
7 |
if (0 != out_data[len - 1 - i]) break; |
|
1447
|
2 |
6 |
if (i == len) { |
|
1465
|
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; |
|
1469
|
2 |
6 |
if (a_len != b_len) { first = b_data; result = 1; } |