Branch Coverage

CryptX.xs
Criterion Covered Total %
branch 161 274 58.7


line true false branch
174 0 64 if (p == NULL) {
178 64 0 if (passwd == NULL || !SvOK(passwd)) {
0 64 if (passwd == NULL || !SvOK(passwd)) {
184 64 0 if (pwd == NULL || pwd_len == 0) {
0 64 if (pwd == NULL || pwd_len == 0) {
190 0 64 if (*p == NULL) {
209 0 1304 if (mp_isneg(a) == MP_YES) {
215 0 1304 if (rv != MP_OKAY) {
221 1304 0 if (len > 0 && len % 2 && len < maxlen-2) {
259 1045 if (len > 0 && len % 2 && len < maxlen-2) {
259 0 if (len > 0 && len % 2 && len < maxlen-2) {
227 6 1298 if (len < minlen && minlen < maxlen-1) {
6 0 if (len < minlen && minlen < maxlen-1) {
238 14319 0 if (name == NULL || strlen(name) + 1 > ltclen) croak("FATAL: invalid name") ;
0 14319 if (name == NULL || strlen(name) + 1 > ltclen) croak("FATAL: invalid name") ;
240 132777 0 for (i = 0; i < ltclen && name[i] > 0; i++) {
118458 14319 for (i = 0; i < ltclen && name[i] > 0; i++) {
241 86945 31513 if (name[i] >= 'A' && name[i] <= 'Z') {
50575 36370 if (name[i] >= 'A' && name[i] <= 'Z') {
244 1713 66170 else if (name[i] == '_') {
250 7488 110970 if (name[i] == ':') start = i + 1;
260 464 7813 if (strcmp(ltcname + start, "ripemd128") == 0) return find_hash("rmd128");
261 464 7349 if (strcmp(ltcname + start, "ripemd160") == 0) return find_hash("rmd160");
262 76 7273 if (strcmp(ltcname + start, "ripemd256") == 0) return find_hash("rmd256");
263 76 7197 if (strcmp(ltcname + start, "ripemd320") == 0) return find_hash("rmd320");
264 482 6715 if (strcmp(ltcname + start, "tiger192") == 0) return find_hash("tiger");
265 176 6539 if (strcmp(ltcname + start, "chaes") == 0) return find_hash("chc_hash");
266 0 6539 if (strcmp(ltcname + start, "chc-hash") == 0) return find_hash("chc_hash");
275 125 5904 if (strcmp(ltcname + start, "des-ede") == 0) return find_cipher("3des");
276 257 5647 if (strcmp(ltcname + start, "saferp") == 0) return find_cipher("safer+");
304 0 2 if ((err = ltc_mp.init(&tmp)) != CRYPT_OK) return;
305 50 1 for (cu = ltc_ecc_curves; cu->prime != NULL; cu++) {
306 0 50 if ((err = mp_read_radix(tmp, cu->prime, 16)) != CRYPT_OK) continue;
307 48 2 if ((mp_cmp(tmp, key->dp.prime) != LTC_MP_EQ)) continue;
308 0 2 if ((err = mp_read_radix(tmp, cu->order, 16)) != CRYPT_OK) continue;
309 0 2 if ((mp_cmp(tmp, key->dp.order) != LTC_MP_EQ)) continue;
310 0 2 if ((err = mp_read_radix(tmp, cu->A, 16)) != CRYPT_OK) continue;
311 0 2 if ((mp_cmp(tmp, key->dp.A) != LTC_MP_EQ)) continue;
312 0 2 if ((err = mp_read_radix(tmp, cu->B, 16)) != CRYPT_OK) continue;
313 0 2 if ((mp_cmp(tmp, key->dp.B) != LTC_MP_EQ)) continue;
314 0 2 if ((err = mp_read_radix(tmp, cu->Gx, 16)) != CRYPT_OK) continue;
315 0 2 if ((mp_cmp(tmp, key->dp.base.x) != LTC_MP_EQ)) continue;
316 0 2 if ((err = mp_read_radix(tmp, cu->Gy, 16)) != CRYPT_OK) continue;
317 0 2 if ((mp_cmp(tmp, key->dp.base.y) != LTC_MP_EQ)) continue;
318 1 1 if (key->dp.cofactor != cu->cofactor) continue;
322 1 1 if (cu->prime && cu->OID) {
1 0 if (cu->prime && cu->OID) {
323 16 1 for (i = 0; i < 16; i++) key->dp.oid[i] = 0;
324 12 1 for (i = 0, j = 0; i < strlen(cu->OID); i++) {
325 4 8 if (cu->OID[i] == '.') {
326 0 4 if (++j >= 16) return;
328 8 0 else if(cu->OID[i] >= '0' && cu->OID[i] <= '9') {
8 0 else if(cu->OID[i] >= '0' && cu->OID[i] <= '9') {
349 0 193 if (!SvOK(curve)) croak("FATAL: undefined curve");
351 191 2 if (SvPOK(curve)) {
354 0 191 if ((hc = get_hv("Crypt::PK::ECC::curve", 0)) == NULL) croak("FATAL: no curve register");
356 0 191 if (pref && SvOK(*pref)) {
0 0 if (pref && SvOK(*pref)) {
363 2 0 else if (SvROK(curve) && SvTYPE(SvRV(curve)) == SVt_PVHV) {
2 0 else if (SvROK(curve) && SvTYPE(SvRV(curve)) == SVt_PVHV) {
371 191 2 if (SvPOK(sv_crv)) {
375 0 191 if (ecc_find_curve(ptr_crv, &cu) != CRYPT_OK) croak("FATAL: ecparams: unknown curve '%s'", ptr_crv);
382 0 2 if ((h = (HV*)(SvRV(sv_crv))) == NULL) croak("FATAL: ecparams: param is not valid hashref");
384 0 2 if ((sv_prime = hv_fetchs(h, "prime", 0)) == NULL) croak("FATAL: ecparams: missing param prime");
385 0 2 if ((sv_A = hv_fetchs(h, "A", 0)) == NULL) croak("FATAL: ecparams: missing param A");
386 0 2 if ((sv_B = hv_fetchs(h, "B", 0)) == NULL) croak("FATAL: ecparams: missing param B");
387 0 2 if ((sv_order = hv_fetchs(h, "order", 0)) == NULL) croak("FATAL: ecparams: missing param order");
388 0 2 if ((sv_Gx = hv_fetchs(h, "Gx", 0)) == NULL) croak("FATAL: ecparams: missing param Gx");
389 0 2 if ((sv_Gy = hv_fetchs(h, "Gy", 0)) == NULL) croak("FATAL: ecparams: missing param Gy");
390 0 2 if ((sv_cofactor = hv_fetchs(h, "cofactor", 0)) == NULL) croak("FATAL: ecparams: missing param cofactor");
392 0 2 if (!SvOK(*sv_prime )) croak("FATAL: ecparams: undefined param prime");
393 0 2 if (!SvOK(*sv_A )) croak("FATAL: ecparams: undefined param A");
394 0 2 if (!SvOK(*sv_B )) croak("FATAL: ecparams: undefined param B");
395 0 2 if (!SvOK(*sv_order )) croak("FATAL: ecparams: undefined param order");
396 0 2 if (!SvOK(*sv_Gx )) croak("FATAL: ecparams: undefined param Gx");
397 0 2 if (!SvOK(*sv_Gy )) croak("FATAL: ecparams: undefined param Gy");
398 0 2 if (!SvOK(*sv_cofactor)) croak("FATAL: ecparams: undefined param cofactor");
401 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;
411 0 2 if ((err = ecc_set_curve(&cu, key)) != CRYPT_OK) return err;
412 2 0 if (key->dp.oidlen == 0) cryptx_internal_ecc_oid_lookup(key);
422 0 133 if(register_all_ciphers() != CRYPT_OK) { croak("FATAL: register_all_ciphers failed"); }
423 0 133 if(register_all_hashes() != CRYPT_OK) { croak("FATAL: register_all_hashes failed"); }
424 0 133 if(register_all_prngs() != CRYPT_OK) { croak("FATAL: register_all_prngs failed"); }
425 0 133 if(crypt_mp_init("ltm") != CRYPT_OK) { croak("FATAL: crypt_mp_init failed"); }
444 0 1 RETVAL = ltc_mp.bits_per_digit;
460 0 265 if (in == NULL) XSRETURN_UNDEF;
461 0 265 if (mp_init(&mpi) != MP_OKAY) XSRETURN_UNDEF;
462 0 265 if (strlen(in) == 0) {
465 265 0 else if (mp_read_radix(&mpi, in, radix) == MP_OKAY) {
467 0 265 if (len == 0) {
475 0 265 if (mp_to_ubin(&mpi, out_data, len, NULL) != MP_OKAY) {
501 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;
503 0 290 if (mp_init_multi(&mpi, &tmp, NULL) != MP_OKAY) XSRETURN_UNDEF;
504 0 290 if (len == 0) {
508 290 0 if (mp_from_ubin(&mpi, in_data, (size_t)len) == MP_OKAY) {
510 5655 0 while (merr == MP_OKAY && mp_iszero(&tmp) == MP_NO) {
5365 290 while (merr == MP_OKAY && mp_iszero(&tmp) == MP_NO) {
514 0 290 if (merr != MP_OKAY) {
517 25 265 else if (digits == 0) {
524 265 0 if (mp_to_radix(&mpi, out_data, digits + 2, NULL, radix) == MP_OKAY) {
554 0 139 if (!SvPOK(in)) XSRETURN_UNDEF;
556 0 139 if (in_len == 0) {
564 59 80 if (ix == 1)
568 0 139 if (rv != CRYPT_OK) {
590 0 386 if (!SvPOK(in)) XSRETURN_UNDEF;
592 0 386 if (in_len == 0) {
600 76 310 if (ix == 1)
604 0 386 if (rv != CRYPT_OK) {
628 0 232 if (!SvPOK(in)) XSRETURN_UNDEF;
629 58 174 if (ix == 0) id = BASE32_RFC4648;
630 58 174 if (ix == 1) id = BASE32_BASE32HEX;
631 58 174 if (ix == 2) id = BASE32_ZBASE32;
632 58 174 if (ix == 3) id = BASE32_CROCKFORD;
633 0 232 if (id == -1) XSRETURN_UNDEF;
635 0 232 if (in_len == 0) {
644 0 232 if (err != CRYPT_OK) {
668 0 232 if (!SvPOK(in)) XSRETURN_UNDEF;
669 58 174 if (ix == 0) id = BASE32_RFC4648;
670 58 174 if (ix == 1) id = BASE32_BASE32HEX;
671 58 174 if (ix == 2) id = BASE32_ZBASE32;
672 58 174 if (ix == 3) id = BASE32_CROCKFORD;
673 0 232 if (id == -1) XSRETURN_UNDEF;
675 0 232 if (in_len == 0) {
684 0 232 if (err != CRYPT_OK) {
701 0 0 if (!SvPOK(in)) XSRETURN_UNDEF;
703 0 0 if (len == 0) {
712 0 0 while (i < len) {
714 0 0 if (0 != out_data[i]) break;
717 0 0 if (i == len) {
733 0 0 if (!SvPOK(in)) XSRETURN_UNDEF;
735 0 0 if (len == 0) {
744 0 0 while (i < len) {
746 0 0 if (0 != out_data[len - 1 - i]) break;
749 0 0 if (i == len) {