Branch Coverage

inc/CryptX_PK_RSA.xs.inc
Criterion Covered Total %
branch 121 272 44.4


line true false branch
11 0 107 if (!RETVAL) croak("FATAL: Newz failed");
14 0 107 if (RETVAL->pindex == -1) {
19 0 107 if (rv != CRYPT_OK) {
35 0 1 if (rv != CRYPT_OK) croak("FATAL: rsa_make_key failed: %s", error_to_string(rv));
36 0 1 XPUSHs(ST(0)); /* return self */
47 128 0 data = (unsigned char *)SvPVbyte(key_data, data_len);
48 25 103 if (self->key.type != -1) { rsa_free(&self->key); self->key.type = -1; }
50 3 125 if (rv != CRYPT_OK) croak("FATAL: rsa_import failed: %s", error_to_string(rv));
51 0 125 XPUSHs(ST(0)); /* return self */
62 5 0 data = (unsigned char *)SvPVbyte(key_data, data_len);
63 3 2 if (SvOK(passwd)) {
3 0 if (SvOK(passwd)) {
0 3 if (SvOK(passwd)) {
64 2 0 pwd = (unsigned char *)SvPVbyte(passwd, pwd_len);
66 1 4 if (self->key.type != -1) { rsa_free(&self->key); self->key.type = -1; }
68 1 4 if (rv != CRYPT_OK) croak("FATAL: rsa_import_pkcs8 failed: %s", error_to_string(rv));
69 0 4 XPUSHs(ST(0)); /* return self */
80 2 0 data = (unsigned char *)SvPVbyte(key_data, data_len);
81 0 2 if (self->key.type != -1) { rsa_free(&self->key); self->key.type = -1; }
83 0 2 if (rv != CRYPT_OK) croak("FATAL: rsa_import_x509 failed: %s", error_to_string(rv));
84 0 2 XPUSHs(ST(0)); /* return self */
97 0 13 if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(N) failed: %s", error_to_string(rv));
99 0 13 if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(e) failed: %s", error_to_string(rv));
101 0 13 if (d && strlen(d) > 0) {
0 0 if (d && strlen(d) > 0) {
104 0 0 if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(d) failed: %s", error_to_string(rv));
106 0 0 if (rv != CRYPT_OK) croak("FATAL: rsa_set_key failed: %s", error_to_string(rv));
111 0 13 if (rv != CRYPT_OK) croak("FATAL: rsa_set_key failed: %s", error_to_string(rv));
114 0 13 if (p && strlen(p) > 0 && q && strlen(q) > 0) {
0 0 if (p && strlen(p) > 0 && q && strlen(q) > 0) {
0 0 if (p && strlen(p) > 0 && q && strlen(q) > 0) {
0 0 if (p && strlen(p) > 0 && q && strlen(q) > 0) {
117 0 0 if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(p) failed: %s", error_to_string(rv));
119 0 0 if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(q) failed: %s", error_to_string(rv));
121 0 0 if (rv != CRYPT_OK) croak("FATAL: rsa_set_factors failed: %s", error_to_string(rv));
124 0 13 if (dP && strlen(dP) > 0 && dQ && strlen(dQ) > 0 && qP && strlen(qP) > 0) {
0 0 if (dP && strlen(dP) > 0 && dQ && strlen(dQ) > 0 && qP && strlen(qP) > 0) {
0 0 if (dP && strlen(dP) > 0 && dQ && strlen(dQ) > 0 && qP && strlen(qP) > 0) {
0 0 if (dP && strlen(dP) > 0 && dQ && strlen(dQ) > 0 && qP && strlen(qP) > 0) {
0 0 if (dP && strlen(dP) > 0 && dQ && strlen(dQ) > 0 && qP && strlen(qP) > 0) {
0 0 if (dP && strlen(dP) > 0 && dQ && strlen(dQ) > 0 && qP && strlen(qP) > 0) {
127 0 0 if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(dP) failed: %s", error_to_string(rv));
129 0 0 if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(dQ) failed: %s", error_to_string(rv));
131 0 0 if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(qP) failed: %s", error_to_string(rv));
133 0 0 if (rv != CRYPT_OK) croak("FATAL: rsa_set_crt_params failed: %s", error_to_string(rv));
136 0 13 XPUSHs(ST(0)); /* return self */
142 70 0 if (self->key.type == -1 || self->key.N == NULL) XSRETURN_UNDEF;
0 70 if (self->key.type == -1 || self->key.N == NULL) XSRETURN_UNDEF;
150 1 0 if (self->key.type == -1 || self->key.N == NULL) XSRETURN_UNDEF;
0 1 if (self->key.type == -1 || self->key.N == NULL) XSRETURN_UNDEF;
163 109 0 if (self->key.type == -1 || self->key.N == NULL) XSRETURN_UNDEF;
0 109 if (self->key.type == -1 || self->key.N == NULL) XSRETURN_UNDEF;
167 109 0 siz = (self->key.e) ? mp_unsigned_bin_size(self->key.e) : 0;
168 0 109 if (siz>10000) {
171 109 0 if (siz>0) {
179 109 0 siz = (self->key.d) ? mp_unsigned_bin_size(self->key.d) : 0;
180 0 109 if (siz>10000) {
183 49 60 if (siz>0) {
191 109 0 siz = (self->key.N) ? nsize : 0;
192 0 109 if (siz>10000) {
195 109 0 if (siz>0) {
203 109 0 siz = (self->key.q) ? mp_unsigned_bin_size(self->key.q) : 0;
204 0 109 if (siz>10000) {
207 49 60 if (siz>0) {
215 109 0 siz = (self->key.p) ? mp_unsigned_bin_size(self->key.p) : 0;
216 0 109 if (siz>10000) {
219 49 60 if (siz>0) {
227 109 0 siz = (self->key.qP) ? mp_unsigned_bin_size(self->key.qP) : 0;
228 0 109 if (siz>10000) {
231 49 60 if (siz>0) {
239 109 0 siz = (self->key.dP) ? mp_unsigned_bin_size(self->key.dP) : 0;
240 0 109 if (siz>10000) {
243 49 60 if (siz>0) {
251 109 0 siz = (self->key.dQ) ? mp_unsigned_bin_size(self->key.dQ) : 0;
252 0 109 if (siz>10000) {
255 49 60 if (siz>0) {
280 2 3 if (strnEQ(type, "private", 7)) {
282 0 2 if (rv != CRYPT_OK) croak("FATAL: rsa_export(PK_PRIVATE) failed: %s", error_to_string(rv));
285 3 0 else if (strnEQ(type, "public", 6)) {
287 0 3 if (rv != CRYPT_OK) croak("FATAL: rsa_export(PK_PUBLIC|PK_STD) failed: %s", error_to_string(rv));
309 2 0 data_ptr = (unsigned char *)SvPVbyte(data, data_len);
312 1 1 if (strnEQ(padding, "oaep", 4)) {
314 0 1 if (hash_id == -1) croak("FATAL: find_hash failed for '%s'", oaep_hash);
315 0 1 if (oaep_lparam) lparam_ptr = (unsigned char *)SvPVbyte(oaep_lparam, lparam_len);
0 0 if (oaep_lparam) lparam_ptr = (unsigned char *)SvPVbyte(oaep_lparam, lparam_len);
319 0 1 if (rv != CRYPT_OK) croak("FATAL: rsa_encrypt_key_ex failed: %s", error_to_string(rv));
322 0 1 else if (strnEQ(padding, "v1.5", 4)) {
326 0 0 if (rv != CRYPT_OK) croak("FATAL: rsa_encrypt_key_ex failed: %s", error_to_string(rv));
329 1 0 else if (strnEQ(padding, "none", 4)) {
332 0 1 if (rv != CRYPT_OK) croak("FATAL: rsa_me failed: %s", error_to_string(rv));
354 38 0 data_ptr = (unsigned char *)SvPVbyte(data, data_len);
357 1 37 if (strnEQ(padding, "oaep", 4)) {
359 0 1 if (hash_id == -1) croak("FATAL: find_hash failed for '%s'", oaep_hash);
360 0 1 if (oaep_lparam) lparam_ptr = (unsigned char *)SvPVbyte(oaep_lparam, lparam_len);
0 0 if (oaep_lparam) lparam_ptr = (unsigned char *)SvPVbyte(oaep_lparam, lparam_len);
363 0 1 if (rv != CRYPT_OK) croak("FATAL: rsa_decrypt_key_ex failed: %s", error_to_string(rv));
364 0 1 if (stat != 1) croak("FATAL: rsa_decrypt - not valid OAEP packet");
367 36 1 else if (strnEQ(padding, "v1.5", 4)) {
370 0 36 if (rv != CRYPT_OK) croak("FATAL: rsa_decrypt_key_ex failed: %s", error_to_string(rv));
371 0 36 if (stat != 1) croak("FATAL: rsa_decrypt - invalid");
374 1 0 else if (strnEQ(padding, "none", 4)) {
377 0 1 if (rv != CRYPT_OK) croak("FATAL: rsa_me failed: %s", error_to_string(rv));
398 4 0 data_ptr = (unsigned char *)SvPVbyte(data, data_len);
399 2 2 if (ix == 1) {
401 0 2 if (hash_id == -1) croak("FATAL: find_hash failed for '%s'", hash_name);
403 0 2 if (rv != CRYPT_OK) croak("FATAL: hash_memory failed: %s", error_to_string(rv));
407 4 0 if (strnEQ(padding, "pss", 3)) {
409 0 4 if (hash_id == -1) croak("FATAL: find_hash failed for '%s'", hash_name);
413 0 4 if (rv != CRYPT_OK) croak("FATAL: rsa_sign_hash_ex failed: %s", error_to_string(rv));
416 0 0 else if (strnEQ(padding, "v1.5", 4)) {
418 0 0 if (hash_id == -1) croak("FATAL: find_hash failed for '%s'", hash_name);
422 0 0 if (rv != CRYPT_OK) croak("FATAL: rsa_sign_hash_ex failed: %s", error_to_string(rv));
425 0 0 else if (strnEQ(padding, "none", 4)) {
428 0 0 if (rv != CRYPT_OK) croak("FATAL: rsa_me failed: %s", error_to_string(rv));
449 109 0 data_ptr = (unsigned char *)SvPVbyte(data, data_len);
450 109 0 sig_ptr = (unsigned char *)SvPVbyte(sig, sig_len);
451 107 2 if (ix == 1) {
453 0 107 if (hash_id == -1) croak("FATAL: find_hash failed for '%s'", hash_name);
455 0 107 if (rv != CRYPT_OK) croak("FATAL: hash_memory failed: %s", error_to_string(rv));
461 4 105 if (strnEQ(padding, "pss", 3)) {
463 0 4 if (hash_id == -1) croak("FATAL: find_hash failed for '%s'", hash_name);
466 4 0 if (rv != CRYPT_OK || stat != 1) RETVAL = 0;
0 4 if (rv != CRYPT_OK || stat != 1) RETVAL = 0;
468 105 0 else if (strnEQ(padding, "v1.5", 4)) {
470 0 105 if (hash_id == -1) croak("FATAL: find_hash failed for '%s'", hash_name);
473 103 2 if (rv != CRYPT_OK || stat != 1) RETVAL = 0;
0 103 if (rv != CRYPT_OK || stat != 1) RETVAL = 0;
475 0 0 else if (strnEQ(padding, "none", 4)) {
479 0 0 if (rv != CRYPT_OK) croak("FATAL: rsa_me failed: %s", error_to_string(rv));
480 0 0 if (data_len <= buffer_len && buffer_len > 0 && data_len > 0) {
0 0 if (data_len <= buffer_len && buffer_len > 0 && data_len > 0) {
0 0 if (data_len <= buffer_len && buffer_len > 0 && data_len > 0) {
481 0 0 for (i = 0; i < buffer_len - data_len; i++) if (buffer[i] != 0) RETVAL = 0;
0 0 for (i = 0; i < buffer_len - data_len; i++) if (buffer[i] != 0) RETVAL = 0;
482 0 0 if (memNE(data_ptr, buffer + buffer_len - data_len, data_len)) RETVAL = 0;
498 107 0 if (self->key.type != -1) { rsa_free(&self->key); self->key.type = -1; }