line |
true |
false |
branch |
168
|
0 |
970 |
if (mp_isneg(a) == MP_YES) { |
174
|
0 |
970 |
if (rv != MP_OKAY) { |
180
|
970 |
0 |
if (len > 0 && len % 2 && len < maxlen-2) { |
|
189 |
781 |
if (len > 0 && len % 2 && len < maxlen-2) { |
|
189 |
0 |
if (len > 0 && len % 2 && len < maxlen-2) { |
186
|
1 |
969 |
if (len < minlen && minlen < maxlen-1) { |
|
1 |
0 |
if (len < minlen && minlen < maxlen-1) { |
197
|
14431 |
0 |
if (name == NULL || strlen(name) + 1 > ltclen) croak("FATAL: invalid name") ; |
|
0 |
14431 |
if (name == NULL || strlen(name) + 1 > ltclen) croak("FATAL: invalid name") ; |
199
|
133345 |
0 |
for (i = 0; i < ltclen && name[i] > 0; i++) { |
|
118914 |
14431 |
for (i = 0; i < ltclen && name[i] > 0; i++) { |
200
|
87353 |
31561 |
if (name[i] >= 'A' && name[i] <= 'Z') { |
|
50977 |
36376 |
if (name[i] >= 'A' && name[i] <= 'Z') { |
203
|
1719 |
66218 |
else if (name[i] == '_') { |
209
|
7488 |
111426 |
if (name[i] == ':') start = i + 1; |
219
|
464 |
7861 |
if (strcmp(ltcname + start, "ripemd128") == 0) return find_hash("rmd128"); |
220
|
464 |
7397 |
if (strcmp(ltcname + start, "ripemd160") == 0) return find_hash("rmd160"); |
221
|
76 |
7321 |
if (strcmp(ltcname + start, "ripemd256") == 0) return find_hash("rmd256"); |
222
|
76 |
7245 |
if (strcmp(ltcname + start, "ripemd320") == 0) return find_hash("rmd320"); |
223
|
482 |
6763 |
if (strcmp(ltcname + start, "tiger192") == 0) return find_hash("tiger"); |
224
|
176 |
6587 |
if (strcmp(ltcname + start, "chaes") == 0) return find_hash("chc_hash"); |
225
|
0 |
6587 |
if (strcmp(ltcname + start, "chc-hash") == 0) return find_hash("chc_hash"); |
234
|
131 |
5962 |
if (strcmp(ltcname + start, "des-ede") == 0) return find_cipher("3des"); |
235
|
257 |
5705 |
if (strcmp(ltcname + start, "saferp") == 0) return find_cipher("safer+"); |
263
|
0 |
2 |
if ((err = ltc_mp.init(&tmp)) != CRYPT_OK) return; |
264
|
50 |
1 |
for (cu = ltc_ecc_curves; cu->prime != NULL; cu++) { |
265
|
0 |
50 |
if ((err = mp_read_radix(tmp, cu->prime, 16)) != CRYPT_OK) continue; |
266
|
48 |
2 |
if ((mp_cmp(tmp, key->dp.prime) != LTC_MP_EQ)) continue; |
267
|
0 |
2 |
if ((err = mp_read_radix(tmp, cu->order, 16)) != CRYPT_OK) continue; |
268
|
0 |
2 |
if ((mp_cmp(tmp, key->dp.order) != LTC_MP_EQ)) continue; |
269
|
0 |
2 |
if ((err = mp_read_radix(tmp, cu->A, 16)) != CRYPT_OK) continue; |
270
|
0 |
2 |
if ((mp_cmp(tmp, key->dp.A) != LTC_MP_EQ)) continue; |
271
|
0 |
2 |
if ((err = mp_read_radix(tmp, cu->B, 16)) != CRYPT_OK) continue; |
272
|
0 |
2 |
if ((mp_cmp(tmp, key->dp.B) != LTC_MP_EQ)) continue; |
273
|
0 |
2 |
if ((err = mp_read_radix(tmp, cu->Gx, 16)) != CRYPT_OK) continue; |
274
|
0 |
2 |
if ((mp_cmp(tmp, key->dp.base.x) != LTC_MP_EQ)) continue; |
275
|
0 |
2 |
if ((err = mp_read_radix(tmp, cu->Gy, 16)) != CRYPT_OK) continue; |
276
|
0 |
2 |
if ((mp_cmp(tmp, key->dp.base.y) != LTC_MP_EQ)) continue; |
277
|
1 |
1 |
if (key->dp.cofactor != cu->cofactor) continue; |
281
|
1 |
1 |
if (cu->prime && cu->OID) { |
|
1 |
0 |
if (cu->prime && cu->OID) { |
282
|
16 |
1 |
for (i = 0; i < 16; i++) key->dp.oid[i] = 0; |
283
|
12 |
1 |
for (i = 0, j = 0; i < strlen(cu->OID); i++) { |
284
|
4 |
8 |
if (cu->OID[i] == '.') { |
285
|
0 |
4 |
if (++j >= 16) return; |
287
|
8 |
0 |
else if(cu->OID[i] >= '0' && cu->OID[i] <= '9') { |
|
8 |
0 |
else if(cu->OID[i] >= '0' && cu->OID[i] <= '9') { |
308
|
0 |
190 |
if (!SvOK(curve)) croak("FATAL: undefined curve"); |
|
0 |
0 |
if (!SvOK(curve)) croak("FATAL: undefined curve"); |
|
0 |
0 |
if (!SvOK(curve)) croak("FATAL: undefined curve"); |
310
|
188 |
2 |
if (SvPOK(curve)) { |
312
|
188 |
0 |
ptr_crv = SvPV(curve, len_crv); |
313
|
0 |
188 |
if ((hc = get_hv("Crypt::PK::ECC::curve", 0)) == NULL) croak("FATAL: no curve register"); |
315
|
0 |
188 |
if (pref && SvOK(*pref)) { |
|
0 |
0 |
if (pref && SvOK(*pref)) { |
|
0 |
0 |
if (pref && SvOK(*pref)) { |
|
0 |
0 |
if (pref && SvOK(*pref)) { |
322
|
2 |
0 |
else if (SvROK(curve) && SvTYPE(SvRV(curve)) == SVt_PVHV) { |
|
2 |
0 |
else if (SvROK(curve) && SvTYPE(SvRV(curve)) == SVt_PVHV) { |
330
|
188 |
2 |
if (SvPOK(sv_crv)) { |
333
|
188 |
0 |
ptr_crv = SvPV(sv_crv, len_crv); |
334
|
0 |
188 |
if (ecc_find_curve(ptr_crv, &cu) != CRYPT_OK) croak("FATAL: ecparams: unknown curve '%s'", ptr_crv); |
341
|
0 |
2 |
if ((h = (HV*)(SvRV(sv_crv))) == NULL) croak("FATAL: ecparams: param is not valid hashref"); |
343
|
0 |
2 |
if ((sv_prime = hv_fetchs(h, "prime", 0)) == NULL) croak("FATAL: ecparams: missing param prime"); |
344
|
0 |
2 |
if ((sv_A = hv_fetchs(h, "A", 0)) == NULL) croak("FATAL: ecparams: missing param A"); |
345
|
0 |
2 |
if ((sv_B = hv_fetchs(h, "B", 0)) == NULL) croak("FATAL: ecparams: missing param B"); |
346
|
0 |
2 |
if ((sv_order = hv_fetchs(h, "order", 0)) == NULL) croak("FATAL: ecparams: missing param order"); |
347
|
0 |
2 |
if ((sv_Gx = hv_fetchs(h, "Gx", 0)) == NULL) croak("FATAL: ecparams: missing param Gx"); |
348
|
0 |
2 |
if ((sv_Gy = hv_fetchs(h, "Gy", 0)) == NULL) croak("FATAL: ecparams: missing param Gy"); |
349
|
0 |
2 |
if ((sv_cofactor = hv_fetchs(h, "cofactor", 0)) == NULL) croak("FATAL: ecparams: missing param cofactor"); |
351
|
0 |
2 |
if (!SvOK(*sv_prime )) croak("FATAL: ecparams: undefined param prime"); |
|
0 |
0 |
if (!SvOK(*sv_prime )) croak("FATAL: ecparams: undefined param prime"); |
|
0 |
0 |
if (!SvOK(*sv_prime )) croak("FATAL: ecparams: undefined param prime"); |
352
|
0 |
2 |
if (!SvOK(*sv_A )) croak("FATAL: ecparams: undefined param A"); |
|
0 |
0 |
if (!SvOK(*sv_A )) croak("FATAL: ecparams: undefined param A"); |
|
0 |
0 |
if (!SvOK(*sv_A )) croak("FATAL: ecparams: undefined param A"); |
353
|
0 |
2 |
if (!SvOK(*sv_B )) croak("FATAL: ecparams: undefined param B"); |
|
0 |
0 |
if (!SvOK(*sv_B )) croak("FATAL: ecparams: undefined param B"); |
|
0 |
0 |
if (!SvOK(*sv_B )) croak("FATAL: ecparams: undefined param B"); |
354
|
0 |
2 |
if (!SvOK(*sv_order )) croak("FATAL: ecparams: undefined param order"); |
|
0 |
0 |
if (!SvOK(*sv_order )) croak("FATAL: ecparams: undefined param order"); |
|
0 |
0 |
if (!SvOK(*sv_order )) croak("FATAL: ecparams: undefined param order"); |
355
|
0 |
2 |
if (!SvOK(*sv_Gx )) croak("FATAL: ecparams: undefined param Gx"); |
|
0 |
0 |
if (!SvOK(*sv_Gx )) croak("FATAL: ecparams: undefined param Gx"); |
|
0 |
0 |
if (!SvOK(*sv_Gx )) croak("FATAL: ecparams: undefined param Gx"); |
356
|
0 |
2 |
if (!SvOK(*sv_Gy )) croak("FATAL: ecparams: undefined param Gy"); |
|
0 |
0 |
if (!SvOK(*sv_Gy )) croak("FATAL: ecparams: undefined param Gy"); |
|
0 |
0 |
if (!SvOK(*sv_Gy )) croak("FATAL: ecparams: undefined param Gy"); |
357
|
0 |
2 |
if (!SvOK(*sv_cofactor)) croak("FATAL: ecparams: undefined param cofactor"); |
|
0 |
0 |
if (!SvOK(*sv_cofactor)) croak("FATAL: ecparams: undefined param cofactor"); |
|
0 |
0 |
if (!SvOK(*sv_cofactor)) croak("FATAL: ecparams: undefined param cofactor"); |
360
|
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; |
|
0 |
0 |
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; |
|
0 |
0 |
cu.OID = (sv_oid && SvOK(*sv_oid)) ? SvPV_nolen(*sv_oid) : NULL; |
362
|
2 |
0 |
cu.prime = SvPV_nolen(*sv_prime); |
363
|
2 |
0 |
cu.A = SvPV_nolen(*sv_A); |
364
|
2 |
0 |
cu.B = SvPV_nolen(*sv_B); |
365
|
2 |
0 |
cu.order = SvPV_nolen(*sv_order); |
366
|
2 |
0 |
cu.Gx = SvPV_nolen(*sv_Gx); |
367
|
2 |
0 |
cu.Gy = SvPV_nolen(*sv_Gy); |
368
|
0 |
2 |
cu.cofactor = (unsigned long)SvUV(*sv_cofactor); |
370
|
0 |
2 |
if ((err = ecc_set_curve(&cu, key)) != CRYPT_OK) return err; |
371
|
2 |
0 |
if (key->dp.oidlen == 0) cryptx_internal_ecc_oid_lookup(key); |
381
|
0 |
129 |
if(register_all_ciphers() != CRYPT_OK) { croak("FATAL: register_all_ciphers failed"); } |
382
|
0 |
129 |
if(register_all_hashes() != CRYPT_OK) { croak("FATAL: register_all_hashes failed"); } |
383
|
0 |
129 |
if(register_all_prngs() != CRYPT_OK) { croak("FATAL: register_all_prngs failed"); } |
384
|
0 |
129 |
if(crypt_mp_init("ltm") != CRYPT_OK) { croak("FATAL: crypt_mp_init failed"); } |
419
|
0 |
265 |
if (in == NULL) XSRETURN_UNDEF; |
420
|
0 |
265 |
if (mp_init(&mpi) != MP_OKAY) XSRETURN_UNDEF; |
421
|
0 |
265 |
if (strlen(in) == 0) { |
424
|
265 |
0 |
else if (mp_read_radix(&mpi, in, radix) == CRYPT_OK) { |
426
|
0 |
265 |
if (len == 0) { |
434
|
0 |
265 |
if (mp_to_unsigned_bin(&mpi, out_data) != MP_OKAY) { |
460
|
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; |
461
|
290 |
0 |
in_data = (unsigned char *) SvPVbyte(in, len); |
462
|
0 |
290 |
if (mp_init_multi(&mpi, &tmp, NULL) != MP_OKAY) XSRETURN_UNDEF; |
463
|
0 |
290 |
if (len == 0) { |
467
|
290 |
0 |
if (mp_read_unsigned_bin(&mpi, in_data, (unsigned long)len) == CRYPT_OK) { |
469
|
5655 |
0 |
while (merr == MP_OKAY && mp_iszero(&tmp) == MP_NO) { |
|
5365 |
290 |
while (merr == MP_OKAY && mp_iszero(&tmp) == MP_NO) { |
473
|
0 |
290 |
if (merr != MP_OKAY) { |
476
|
25 |
265 |
else if (digits == 0) { |
483
|
265 |
0 |
if (mp_toradix(&mpi, out_data, radix) == MP_OKAY) { |
513
|
0 |
137 |
if (!SvPOK(in)) XSRETURN_UNDEF; |
514
|
137 |
0 |
in_data = (unsigned char *) SvPVbyte(in, in_len); |
515
|
0 |
137 |
if (in_len == 0) { |
523
|
59 |
78 |
if (ix == 1) |
527
|
0 |
137 |
if (rv != CRYPT_OK) { |
549
|
0 |
486 |
if (!SvPOK(in)) XSRETURN_UNDEF; |
550
|
486 |
0 |
in_data = SvPVbyte(in, in_len); |
551
|
0 |
486 |
if (in_len == 0) { |
559
|
76 |
410 |
if (ix == 1) |
563
|
0 |
486 |
if (rv != CRYPT_OK) { |
587
|
0 |
232 |
if (!SvPOK(in)) XSRETURN_UNDEF; |
588
|
58 |
174 |
if (ix == 0) id = BASE32_RFC4648; |
589
|
58 |
174 |
if (ix == 1) id = BASE32_BASE32HEX; |
590
|
58 |
174 |
if (ix == 2) id = BASE32_ZBASE32; |
591
|
58 |
174 |
if (ix == 3) id = BASE32_CROCKFORD; |
592
|
0 |
232 |
if (id == -1) XSRETURN_UNDEF; |
593
|
232 |
0 |
in_data = (unsigned char *) SvPVbyte(in, in_len); |
594
|
0 |
232 |
if (in_len == 0) { |
603
|
0 |
232 |
if (err != CRYPT_OK) { |
627
|
0 |
232 |
if (!SvPOK(in)) XSRETURN_UNDEF; |
628
|
58 |
174 |
if (ix == 0) id = BASE32_RFC4648; |
629
|
58 |
174 |
if (ix == 1) id = BASE32_BASE32HEX; |
630
|
58 |
174 |
if (ix == 2) id = BASE32_ZBASE32; |
631
|
58 |
174 |
if (ix == 3) id = BASE32_CROCKFORD; |
632
|
0 |
232 |
if (id == -1) XSRETURN_UNDEF; |
633
|
232 |
0 |
in_data = SvPVbyte(in, in_len); |
634
|
0 |
232 |
if (in_len == 0) { |
643
|
0 |
232 |
if (err != CRYPT_OK) { |
660
|
0 |
0 |
if (!SvPOK(in)) XSRETURN_UNDEF; |
661
|
0 |
0 |
in_data = (unsigned char *)SvPVbyte(in, len); |
662
|
0 |
0 |
if (len == 0) { |
671
|
0 |
0 |
while (i < len) { |
673
|
0 |
0 |
if (0 != out_data[i]) break; |
676
|
0 |
0 |
if (i == len) { |
692
|
0 |
0 |
if (!SvPOK(in)) XSRETURN_UNDEF; |
693
|
0 |
0 |
in_data = (unsigned char *)SvPVbyte(in, len); |
694
|
0 |
0 |
if (len == 0) { |
703
|
0 |
0 |
while (i < len) { |
705
|
0 |
0 |
if (0 != out_data[len - 1 - i]) break; |
708
|
0 |
0 |
if (i == len) { |