| line |
true |
false |
branch |
|
180
|
0 |
64 |
if (p == NULL) { |
|
184
|
64 |
0 |
if (passwd == NULL || !SvOK(passwd)) { |
|
|
0 |
64 |
if (passwd == NULL || !SvOK(passwd)) { |
|
190
|
64 |
0 |
if (pwd == NULL || pwd_len == 0) { |
|
|
0 |
64 |
if (pwd == NULL || pwd_len == 0) { |
|
196
|
0 |
64 |
if (*p == NULL) { |
|
212
|
369 |
0 |
if (*last_pid == curpid) return; |
|
214
|
0 |
0 |
if (rng_get_bytes(entropy_buf, sizeof(entropy_buf), NULL) != sizeof(entropy_buf)) { |
|
218
|
0 |
0 |
if (rv != CRYPT_OK) croak("FATAL: PRNG_add_entropy failed: %s", error_to_string(rv)); |
|
220
|
0 |
0 |
if (rv != CRYPT_OK) croak("FATAL: PRNG_ready failed: %s", error_to_string(rv)); |
|
233
|
0 |
1330 |
if (mp_isneg(a) == MP_YES) { |
|
239
|
0 |
1330 |
if (rv != MP_OKAY) { |
|
245
|
1330 |
0 |
if (len > 0 && len % 2 && len < maxlen-2) { |
|
|
267 |
1063 |
if (len > 0 && len % 2 && len < maxlen-2) { |
|
|
267 |
0 |
if (len > 0 && len % 2 && len < maxlen-2) { |
|
251
|
6 |
1324 |
if (len < minlen && minlen < maxlen-1) { |
|
|
6 |
0 |
if (len < minlen && minlen < maxlen-1) { |
|
262
|
14371 |
0 |
if (name == NULL || strlen(name) + 1 > ltclen) croak("FATAL: invalid name") ; |
|
|
0 |
14371 |
if (name == NULL || strlen(name) + 1 > ltclen) croak("FATAL: invalid name") ; |
|
264
|
133175 |
0 |
for (i = 0; i < ltclen && name[i] > 0; i++) { |
|
|
118804 |
14371 |
for (i = 0; i < ltclen && name[i] > 0; i++) { |
|
265
|
87160 |
31644 |
if (name[i] >= 'A' && name[i] <= 'Z') { |
|
|
50747 |
36413 |
if (name[i] >= 'A' && name[i] <= 'Z') { |
|
268
|
1713 |
66344 |
else if (name[i] == '_') { |
|
274
|
7508 |
111296 |
if (name[i] == ':') start = i + 1; |
|
284
|
464 |
7858 |
if (strcmp(ltcname + start, "ripemd128") == 0) return find_hash("rmd128"); |
|
285
|
464 |
7394 |
if (strcmp(ltcname + start, "ripemd160") == 0) return find_hash("rmd160"); |
|
286
|
76 |
7318 |
if (strcmp(ltcname + start, "ripemd256") == 0) return find_hash("rmd256"); |
|
287
|
76 |
7242 |
if (strcmp(ltcname + start, "ripemd320") == 0) return find_hash("rmd320"); |
|
288
|
482 |
6760 |
if (strcmp(ltcname + start, "tiger192") == 0) return find_hash("tiger"); |
|
289
|
176 |
6584 |
if (strcmp(ltcname + start, "chaes") == 0) return find_hash("chc_hash"); |
|
290
|
0 |
6584 |
if (strcmp(ltcname + start, "chc-hash") == 0) return find_hash("chc_hash"); |
|
299
|
125 |
5905 |
if (strcmp(ltcname + start, "des-ede") == 0) return find_cipher("3des"); |
|
300
|
257 |
5648 |
if (strcmp(ltcname + start, "saferp") == 0) return find_cipher("safer+"); |
|
328
|
0 |
2 |
if ((err = ltc_mp.init(&tmp)) != CRYPT_OK) return; |
|
329
|
50 |
1 |
for (cu = ltc_ecc_curves; cu->prime != NULL; cu++) { |
|
330
|
0 |
50 |
if ((err = mp_read_radix(tmp, cu->prime, 16)) != CRYPT_OK) continue; |
|
331
|
48 |
2 |
if ((mp_cmp(tmp, key->dp.prime) != LTC_MP_EQ)) continue; |
|
332
|
0 |
2 |
if ((err = mp_read_radix(tmp, cu->order, 16)) != CRYPT_OK) continue; |
|
333
|
0 |
2 |
if ((mp_cmp(tmp, key->dp.order) != LTC_MP_EQ)) continue; |
|
334
|
0 |
2 |
if ((err = mp_read_radix(tmp, cu->A, 16)) != CRYPT_OK) continue; |
|
335
|
0 |
2 |
if ((mp_cmp(tmp, key->dp.A) != LTC_MP_EQ)) continue; |
|
336
|
0 |
2 |
if ((err = mp_read_radix(tmp, cu->B, 16)) != CRYPT_OK) continue; |
|
337
|
0 |
2 |
if ((mp_cmp(tmp, key->dp.B) != LTC_MP_EQ)) continue; |
|
338
|
0 |
2 |
if ((err = mp_read_radix(tmp, cu->Gx, 16)) != CRYPT_OK) continue; |
|
339
|
0 |
2 |
if ((mp_cmp(tmp, key->dp.base.x) != LTC_MP_EQ)) continue; |
|
340
|
0 |
2 |
if ((err = mp_read_radix(tmp, cu->Gy, 16)) != CRYPT_OK) continue; |
|
341
|
0 |
2 |
if ((mp_cmp(tmp, key->dp.base.y) != LTC_MP_EQ)) continue; |
|
342
|
1 |
1 |
if (key->dp.cofactor != cu->cofactor) continue; |
|
346
|
1 |
1 |
if (cu->prime && cu->OID) { |
|
|
1 |
0 |
if (cu->prime && cu->OID) { |
|
347
|
16 |
1 |
for (i = 0; i < 16; i++) key->dp.oid[i] = 0; |
|
348
|
12 |
1 |
for (i = 0, j = 0; i < strlen(cu->OID); i++) { |
|
349
|
4 |
8 |
if (cu->OID[i] == '.') { |
|
350
|
0 |
4 |
if (++j >= 16) return; |
|
352
|
8 |
0 |
else if(cu->OID[i] >= '0' && cu->OID[i] <= '9') { |
|
|
8 |
0 |
else if(cu->OID[i] >= '0' && cu->OID[i] <= '9') { |
|
373
|
0 |
195 |
if (!SvOK(curve)) croak("FATAL: undefined curve"); |
|
375
|
193 |
2 |
if (SvPOK(curve)) { |
|
378
|
0 |
193 |
if ((hc = get_hv("Crypt::PK::ECC::curve", 0)) == NULL) croak("FATAL: no curve register"); |
|
380
|
0 |
193 |
if (pref && SvOK(*pref)) { |
|
|
0 |
0 |
if (pref && SvOK(*pref)) { |
|
387
|
2 |
0 |
else if (SvROK(curve) && SvTYPE(SvRV(curve)) == SVt_PVHV) { |
|
|
2 |
0 |
else if (SvROK(curve) && SvTYPE(SvRV(curve)) == SVt_PVHV) { |
|
395
|
193 |
2 |
if (SvPOK(sv_crv)) { |
|
399
|
0 |
193 |
if (ecc_find_curve(ptr_crv, &cu) != CRYPT_OK) croak("FATAL: ecparams: unknown curve '%s'", ptr_crv); |
|
406
|
0 |
2 |
if ((h = (HV*)(SvRV(sv_crv))) == NULL) croak("FATAL: ecparams: param is not valid hashref"); |
|
408
|
0 |
2 |
if ((sv_prime = hv_fetchs(h, "prime", 0)) == NULL) croak("FATAL: ecparams: missing param prime"); |
|
409
|
0 |
2 |
if ((sv_A = hv_fetchs(h, "A", 0)) == NULL) croak("FATAL: ecparams: missing param A"); |
|
410
|
0 |
2 |
if ((sv_B = hv_fetchs(h, "B", 0)) == NULL) croak("FATAL: ecparams: missing param B"); |
|
411
|
0 |
2 |
if ((sv_order = hv_fetchs(h, "order", 0)) == NULL) croak("FATAL: ecparams: missing param order"); |
|
412
|
0 |
2 |
if ((sv_Gx = hv_fetchs(h, "Gx", 0)) == NULL) croak("FATAL: ecparams: missing param Gx"); |
|
413
|
0 |
2 |
if ((sv_Gy = hv_fetchs(h, "Gy", 0)) == NULL) croak("FATAL: ecparams: missing param Gy"); |
|
414
|
0 |
2 |
if ((sv_cofactor = hv_fetchs(h, "cofactor", 0)) == NULL) croak("FATAL: ecparams: missing param cofactor"); |
|
416
|
0 |
2 |
if (!SvOK(*sv_prime )) croak("FATAL: ecparams: undefined param prime"); |
|
417
|
0 |
2 |
if (!SvOK(*sv_A )) croak("FATAL: ecparams: undefined param A"); |
|
418
|
0 |
2 |
if (!SvOK(*sv_B )) croak("FATAL: ecparams: undefined param B"); |
|
419
|
0 |
2 |
if (!SvOK(*sv_order )) croak("FATAL: ecparams: undefined param order"); |
|
420
|
0 |
2 |
if (!SvOK(*sv_Gx )) croak("FATAL: ecparams: undefined param Gx"); |
|
421
|
0 |
2 |
if (!SvOK(*sv_Gy )) croak("FATAL: ecparams: undefined param Gy"); |
|
422
|
0 |
2 |
if (!SvOK(*sv_cofactor)) croak("FATAL: ecparams: undefined param cofactor"); |
|
425
|
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; |
|
435
|
0 |
2 |
if ((err = ecc_set_curve(&cu, key)) != CRYPT_OK) return err; |
|
436
|
2 |
0 |
if (key->dp.oidlen == 0) cryptx_internal_ecc_oid_lookup(key); |
|
446
|
0 |
134 |
if(register_all_ciphers() != CRYPT_OK) { croak("FATAL: register_all_ciphers failed"); } |
|
447
|
0 |
134 |
if(register_all_hashes() != CRYPT_OK) { croak("FATAL: register_all_hashes failed"); } |
|
448
|
0 |
134 |
if(register_all_prngs() != CRYPT_OK) { croak("FATAL: register_all_prngs failed"); } |
|
449
|
0 |
134 |
if(crypt_mp_init("ltm") != CRYPT_OK) { croak("FATAL: crypt_mp_init failed"); } |
|
468
|
0 |
1 |
RETVAL = ltc_mp.bits_per_digit; |
|
484
|
0 |
265 |
if (in == NULL) XSRETURN_UNDEF; |
|
485
|
0 |
265 |
if (mp_init(&mpi) != MP_OKAY) XSRETURN_UNDEF; |
|
486
|
0 |
265 |
if (strlen(in) == 0) { |
|
489
|
265 |
0 |
else if (mp_read_radix(&mpi, in, radix) == MP_OKAY) { |
|
491
|
0 |
265 |
if (len == 0) { |
|
499
|
0 |
265 |
if (mp_to_ubin(&mpi, out_data, len, NULL) != MP_OKAY) { |
|
525
|
290 |
0 |
if (!SvPOK(in) || radix < 2 || radix > 64) XSRETURN_UNDEF; |
|
|
290 |
0 |
if (!SvPOK(in) || radix < 2 || radix > 64) XSRETURN_UNDEF; |
|
|
0 |
290 |
if (!SvPOK(in) || radix < 2 || radix > 64) XSRETURN_UNDEF; |
|
527
|
0 |
290 |
if (mp_init_multi(&mpi, &tmp, NULL) != MP_OKAY) XSRETURN_UNDEF; |
|
528
|
0 |
290 |
if (len == 0) { |
|
532
|
290 |
0 |
if (mp_from_ubin(&mpi, in_data, (size_t)len) == MP_OKAY) { |
|
534
|
5655 |
0 |
while (merr == MP_OKAY && mp_iszero(&tmp) == MP_NO) { |
|
|
5365 |
290 |
while (merr == MP_OKAY && mp_iszero(&tmp) == MP_NO) { |
|
538
|
0 |
290 |
if (merr != MP_OKAY) { |
|
541
|
25 |
265 |
else if (digits == 0) { |
|
548
|
265 |
0 |
if (mp_to_radix(&mpi, out_data, digits + 2, NULL, radix) == MP_OKAY) { |
|
578
|
0 |
139 |
if (!SvPOK(in)) XSRETURN_UNDEF; |
|
580
|
0 |
139 |
if (in_len == 0) { |
|
588
|
59 |
80 |
if (ix == 1) |
|
592
|
0 |
139 |
if (rv != CRYPT_OK) { |
|
614
|
0 |
386 |
if (!SvPOK(in)) XSRETURN_UNDEF; |
|
616
|
0 |
386 |
if (in_len == 0) { |
|
624
|
76 |
310 |
if (ix == 1) |
|
628
|
0 |
386 |
if (rv != CRYPT_OK) { |
|
652
|
0 |
232 |
if (!SvPOK(in)) XSRETURN_UNDEF; |
|
653
|
58 |
174 |
if (ix == 0) id = BASE32_RFC4648; |
|
654
|
58 |
174 |
if (ix == 1) id = BASE32_BASE32HEX; |
|
655
|
58 |
174 |
if (ix == 2) id = BASE32_ZBASE32; |
|
656
|
58 |
174 |
if (ix == 3) id = BASE32_CROCKFORD; |
|
657
|
0 |
232 |
if (id == -1) XSRETURN_UNDEF; |
|
659
|
0 |
232 |
if (in_len == 0) { |
|
668
|
0 |
232 |
if (err != CRYPT_OK) { |
|
692
|
0 |
232 |
if (!SvPOK(in)) XSRETURN_UNDEF; |
|
693
|
58 |
174 |
if (ix == 0) id = BASE32_RFC4648; |
|
694
|
58 |
174 |
if (ix == 1) id = BASE32_BASE32HEX; |
|
695
|
58 |
174 |
if (ix == 2) id = BASE32_ZBASE32; |
|
696
|
58 |
174 |
if (ix == 3) id = BASE32_CROCKFORD; |
|
697
|
0 |
232 |
if (id == -1) XSRETURN_UNDEF; |
|
699
|
0 |
232 |
if (in_len == 0) { |
|
708
|
0 |
232 |
if (err != CRYPT_OK) { |
|
725
|
0 |
0 |
if (!SvPOK(in)) XSRETURN_UNDEF; |
|
727
|
0 |
0 |
if (len == 0) { |
|
736
|
0 |
0 |
while (i < len) { |
|
738
|
0 |
0 |
if (0 != out_data[i]) break; |
|
741
|
0 |
0 |
if (i == len) { |
|
757
|
0 |
0 |
if (!SvPOK(in)) XSRETURN_UNDEF; |
|
759
|
0 |
0 |
if (len == 0) { |
|
768
|
0 |
0 |
while (i < len) { |
|
770
|
0 |
0 |
if (0 != out_data[len - 1 - i]) break; |
|
773
|
0 |
0 |
if (i == len) { |