Branch Coverage

inc/CryptX_PK_ECC.xs.inc
Criterion Covered Total %
branch 144 220 65.4


line true false branch
11 0 274 if (!RETVAL) croak("FATAL: Newz failed");
15 0 274 if (RETVAL->pindex == -1) {
21 0 274 if (rv != CRYPT_OK) {
38 0 11 if (rv != CRYPT_OK) croak("FATAL: ecc_set_curve failed: %s", error_to_string(rv));
41 0 11 if (rv != CRYPT_OK) croak("FATAL: ecc_generate_key failed: %s", error_to_string(rv));
42 0 11 XPUSHs(ST(0)); /* return self */
54 3 38 if (self->key.type != -1) { ecc_free(&self->key); self->key.type = -1; }
56 9 32 if (rv != CRYPT_OK) croak("FATAL: ecc_import_openssl failed: %s", error_to_string(rv));
57 0 32 XPUSHs(ST(0)); /* return self */
69 0 18 if (self->key.type != -1) { ecc_free(&self->key); self->key.type = -1; }
71 10 8 if (rv != CRYPT_OK) croak("FATAL: ecc_import failed: %s", error_to_string(rv));
72 0 8 XPUSHs(ST(0)); /* return self */
85 0 5 if (self->key.type != -1) { ecc_free(&self->key); self->key.type = -1; }
86 2 3 if (SvOK(passwd)) {
92 0 5 if (rv != CRYPT_OK) croak("FATAL: ecc_import_pkcs8 failed: %s", error_to_string(rv));
93 0 5 XPUSHs(ST(0)); /* return self */
107 18 43 if (self->key.type != -1) { ecc_free(&self->key); self->key.type = -1; }
108 17 44 if (SvOK(passwd)) {
114 9 52 if (rv != CRYPT_OK) croak("FATAL: pem_decode_pkcs failed: %s", error_to_string(rv));
115 0 52 if (key_from_pem.id != LTC_PKA_EC) croak("FATAL: pem_decode_pkcs decoded non-ECC key");
117 0 52 XPUSHs(ST(0)); /* return self */
131 9 0 if (self->key.type != -1) { ecc_free(&self->key); self->key.type = -1; }
132 3 6 if (SvOK(passwd)) {
138 0 9 if (rv != CRYPT_OK) croak("FATAL: pem_decode_openssh failed: %s", error_to_string(rv));
139 0 9 if (key_from_pem.id != LTC_PKA_EC) croak("FATAL: pem_decode_openssh decoded non-ECC key");
141 0 9 XPUSHs(ST(0)); /* return self */
153 0 0 if (self->key.type != -1) { ecc_free(&self->key); self->key.type = -1; }
155 0 0 if (rv != CRYPT_OK) croak("FATAL: ecc_import_x509 failed: %s", error_to_string(rv));
156 0 0 XPUSHs(ST(0)); /* return self */
168 3 181 if (self->key.type != -1) { ecc_free(&self->key); self->key.type = -1; }
171 0 184 if (rv != CRYPT_OK) croak("FATAL: ecc_set_curve failed: %s", error_to_string(rv));
175 0 184 if (rv != CRYPT_OK) croak("FATAL: ecc_set_key failed: %s", error_to_string(rv));
176 0 184 XPUSHs(ST(0)); /* return self */
182 0 79 if (self->key.type == -1) XSRETURN_UNDEF;
183 57 22 RETVAL = (self->key.type == PK_PRIVATE) ? 1 : 0;
190 0 5 if (self->key.type == -1) XSRETURN_UNDEF;
204 0 45 if (self->key.type == -1) XSRETURN_UNDEF;
208 45 0 siz = (self->key.k) ? mp_ubin_size(self->key.k) : 0;
209 0 45 if (siz>10000) {
212 32 13 if (siz>0) {
220 45 0 siz = (self->key.pubkey.x) ? mp_ubin_size(self->key.pubkey.x) : 0;
221 0 45 if (siz>10000) {
224 45 0 if (siz>0) {
232 45 0 siz = (self->key.pubkey.y) ? mp_ubin_size(self->key.pubkey.y) : 0;
233 0 45 if (siz>10000) {
236 45 0 if (siz>0) {
261 43 2 if (self->key.dp.oidlen > 0) {
270 210 43 for(i = 0; i < self->key.dp.oidlen - 1; i++) sv_catpvf(oid, "%lu.", self->key.dp.oid[i]);
276 43 0 if ((h = get_hv("Crypt::PK::ECC::curve_oid2name", 0)) != NULL) {
278 43 0 if (pref) {
304 1 26 if (self->key.type == -1) croak("FATAL: export_key_der no key");
305 5 21 if (strEQ(type, "private_short")) {
307 1 4 if (rv != CRYPT_OK) croak("FATAL: ecc_export_openssl(PK_PRIVATE|PK_CURVEOID) failed: %s", error_to_string(rv));
310 0 21 else if (strEQ(type, "private_compressed")) {
312 0 0 if (rv != CRYPT_OK) croak("FATAL: ecc_export_openssl(PK_PRIVATE|PK_CURVEOID|PK_COMPRESSED) failed: %s", error_to_string(rv));
315 10 11 else if (strEQ(type, "private")) {
317 0 10 if (rv != CRYPT_OK) croak("FATAL: ecc_export_openssl(PK_PRIVATE) failed: %s", error_to_string(rv));
320 0 11 else if (strEQ(type, "public_compressed")) {
322 0 0 if (rv != CRYPT_OK) croak("FATAL: ecc_export_openssl(PK_PUBLIC|PK_CURVEOID|PK_COMPRESSED) failed: %s", error_to_string(rv));
325 3 8 else if (strEQ(type, "public_short")) {
327 0 3 if (rv != CRYPT_OK) croak("FATAL: ecc_export_openssl(PK_PUBLIC|PK_CURVEOID) failed: %s", error_to_string(rv));
330 8 0 else if (strEQ(type, "public")) {
332 0 8 if (rv != CRYPT_OK) croak("FATAL: ecc_export_openssl(PK_PUBLIC) failed: %s", error_to_string(rv));
351 0 428 if (self->key.type == -1) croak("FATAL: export_key_raw no key");
352 60 368 if (strEQ(type, "private")) {
354 0 60 if (rv != CRYPT_OK) croak("FATAL: ecc_get_key(private) failed: %s", error_to_string(rv));
357 180 188 else if (strEQ(type, "public_compressed")) {
359 0 180 if (rv != CRYPT_OK) croak("FATAL: ecc_get_key(public_compressed) failed: %s", error_to_string(rv));
362 188 0 else if (strEQ(type, "public")) {
364 0 188 if (rv != CRYPT_OK) croak("FATAL: ecc_get_key(public) failed: %s", error_to_string(rv));
389 0 3 if (hash_id == -1) croak("FATAL: find_hash failed for '%s'", hash_name);
393 0 3 if (rv != CRYPT_OK) croak("FATAL: ecc_encrypt_key failed: %s", error_to_string(rv));
413 0 2 if (rv != CRYPT_OK) croak("FATAL: ecc_decrypt_key failed: %s", error_to_string(rv));
443 23 7 if ((ix == 0 || ix == 3 || ix == 4) && hash_name != NULL && hash_rfc6979_name == NULL) {
18 5 if ((ix == 0 || ix == 3 || ix == 4) && hash_name != NULL && hash_rfc6979_name == NULL) {
6 12 if ((ix == 0 || ix == 3 || ix == 4) && hash_name != NULL && hash_rfc6979_name == NULL) {
12 6 if ((ix == 0 || ix == 3 || ix == 4) && hash_name != NULL && hash_rfc6979_name == NULL) {
12 0 if ((ix == 0 || ix == 3 || ix == 4) && hash_name != NULL && hash_rfc6979_name == NULL) {
449 23 7 if (ix == 1 || ix == 2) {
5 18 if (ix == 1 || ix == 2) {
451 7 5 if (hash_name == NULL) {
455 0 12 if (id == -1) croak("FATAL: find_hash failed for '%s'", hash_name);
457 0 12 if (rv != CRYPT_OK) croak("FATAL: hash_memory failed: %s", error_to_string(rv));
462 21 9 if (hash_rfc6979_name != NULL) {
465 0 21 if (hash_rfc6979_id == -1) croak("FATAL: find_hash failed for rfc6979 hash '%s'", hash_rfc6979_name);
469 25 5 if (ix == 2 || ix == 3) {
5 20 if (ix == 2 || ix == 3) {
473 6 14 else if (ix == 4) {
482 0 30 if (rv != CRYPT_OK) croak("FATAL: ecc_sign_hash_v2 failed: %s", error_to_string(rv));
515 15 124 if (ix == 1 || ix == 2) {
3 12 if (ix == 1 || ix == 2) {
517 0 127 if (id == -1) croak("FATAL: find_hash failed for '%s'", hash_name);
519 0 127 if (rv != CRYPT_OK) croak("FATAL: hash_memory failed: %s", error_to_string(rv));
525 136 3 if (ix == 2 || ix == 3) {
3 133 if (ix == 2 || ix == 3) {
529 4 129 else if (ix == 4) {
538 139 0 if (rv != CRYPT_OK || stat != 1) RETVAL = 0;
0 139 if (rv != CRYPT_OK || stat != 1) RETVAL = 0;
552 0 4 if (rv != CRYPT_OK) croak("FATAL: ecc_shared_secret failed: %s", error_to_string(rv));
578 5 1 if (recid != NULL) {
582 0 1 else if (ix != 2) {
583 0 0 if (ix == 1) {
593 2 4 if (ix == 1) {
596 2 2 else if (ix == 2) {
603 0 6 if (rv != CRYPT_OK) croak("FATAL: ecc_recover_key failed: %s", error_to_string(rv));
604 0 6 RETVAL = 1;
612 268 6 if (self->key.type != -1) { ecc_free(&self->key); self->key.type = -1; }
613 274 0 if (self->pindex >= 0 && prng_is_valid(self->pindex) == CRYPT_OK && prng_descriptor[self->pindex].done) {
274 0 if (self->pindex >= 0 && prng_is_valid(self->pindex) == CRYPT_OK && prng_descriptor[self->pindex].done) {
274 0 if (self->pindex >= 0 && prng_is_valid(self->pindex) == CRYPT_OK && prng_descriptor[self->pindex].done) {