| line |
true |
false |
branch |
|
11
|
0 |
110 |
if (!RETVAL) croak("FATAL: Newz failed"); |
|
15
|
0 |
110 |
if (RETVAL->pindex == -1) { |
|
20
|
0 |
110 |
if (rv != CRYPT_OK) { |
|
37
|
0 |
2 |
if (rv != CRYPT_OK) croak("FATAL: rsa_make_key failed: %s", error_to_string(rv)); |
|
38
|
0 |
2 |
XPUSHs(ST(0)); /* return self */ |
|
50
|
2 |
89 |
if (self->key.type != -1) { rsa_free(&self->key); self->key.type = -1; } |
|
52
|
2 |
89 |
if (rv != CRYPT_OK) croak("FATAL: rsa_import failed: %s", error_to_string(rv)); |
|
53
|
0 |
89 |
XPUSHs(ST(0)); /* return self */ |
|
66
|
0 |
2 |
if (self->key.type != -1) { rsa_free(&self->key); self->key.type = -1; } |
|
67
|
1 |
1 |
if (SvOK(passwd)) { |
|
73
|
0 |
2 |
if (rv != CRYPT_OK) croak("FATAL: rsa_import_pkcs8 failed: %s", error_to_string(rv)); |
|
74
|
0 |
2 |
XPUSHs(ST(0)); /* return self */ |
|
88
|
36 |
18 |
if (self->key.type != -1) { rsa_free(&self->key); self->key.type = -1; } |
|
89
|
22 |
32 |
if (SvOK(passwd)) { |
|
95
|
0 |
54 |
if (rv != CRYPT_OK) croak("FATAL: pem_decode_pkcs failed: %s", error_to_string(rv)); |
|
96
|
0 |
54 |
if (key_from_pem.id != LTC_PKA_RSA) croak("FATAL: pem_decode_pkcs decoded non-RSA key"); |
|
98
|
0 |
54 |
XPUSHs(ST(0)); /* return self */ |
|
113
|
18 |
0 |
if (self->key.type != -1) { rsa_free(&self->key); self->key.type = -1; } |
|
114
|
6 |
12 |
if (SvOK(passwd)) { |
|
120
|
0 |
18 |
if (rv != CRYPT_OK) croak("FATAL: pem_decode_openssh failed: %s", error_to_string(rv)); |
|
121
|
0 |
18 |
if (key_from_pem.id != LTC_PKA_RSA) croak("FATAL: pem_decode_openssh decoded non-RSA key"); |
|
123
|
0 |
18 |
XPUSHs(ST(0)); /* return self */ |
|
135
|
0 |
0 |
if (self->key.type != -1) { rsa_free(&self->key); self->key.type = -1; } |
|
137
|
0 |
0 |
if (rv != CRYPT_OK) croak("FATAL: rsa_import_x509 failed: %s", error_to_string(rv)); |
|
138
|
0 |
0 |
XPUSHs(ST(0)); /* return self */ |
|
151
|
0 |
7 |
if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(N) failed: %s", error_to_string(rv)); |
|
153
|
0 |
7 |
if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(e) failed: %s", error_to_string(rv)); |
|
155
|
0 |
7 |
if (d && strlen(d) > 0) { |
|
|
0 |
0 |
if (d && strlen(d) > 0) { |
|
158
|
0 |
0 |
if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(d) failed: %s", error_to_string(rv)); |
|
160
|
0 |
0 |
if (rv != CRYPT_OK) croak("FATAL: rsa_set_key failed: %s", error_to_string(rv)); |
|
165
|
0 |
7 |
if (rv != CRYPT_OK) croak("FATAL: rsa_set_key failed: %s", error_to_string(rv)); |
|
168
|
0 |
7 |
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) { |
|
171
|
0 |
0 |
if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(p) failed: %s", error_to_string(rv)); |
|
173
|
0 |
0 |
if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(q) failed: %s", error_to_string(rv)); |
|
175
|
0 |
0 |
if (rv != CRYPT_OK) croak("FATAL: rsa_set_factors failed: %s", error_to_string(rv)); |
|
178
|
0 |
7 |
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) { |
|
181
|
0 |
0 |
if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(dP) failed: %s", error_to_string(rv)); |
|
183
|
0 |
0 |
if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(dQ) failed: %s", error_to_string(rv)); |
|
185
|
0 |
0 |
if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(qP) failed: %s", error_to_string(rv)); |
|
187
|
0 |
0 |
if (rv != CRYPT_OK) croak("FATAL: rsa_set_crt_params failed: %s", error_to_string(rv)); |
|
190
|
0 |
7 |
XPUSHs(ST(0)); /* return self */ |
|
196
|
88 |
0 |
if (self->key.type == -1 || self->key.N == NULL) XSRETURN_UNDEF; |
|
|
0 |
88 |
if (self->key.type == -1 || self->key.N == NULL) XSRETURN_UNDEF; |
|
197
|
68 |
20 |
RETVAL = (self->key.type == PK_PRIVATE) ? 1 : 0; |
|
204
|
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; |
|
217
|
134 |
0 |
if (self->key.type == -1 || self->key.N == NULL) XSRETURN_UNDEF; |
|
|
0 |
134 |
if (self->key.type == -1 || self->key.N == NULL) XSRETURN_UNDEF; |
|
221
|
134 |
0 |
siz = (self->key.e) ? mp_ubin_size(self->key.e) : 0; |
|
222
|
0 |
134 |
if (siz>10000) { |
|
225
|
134 |
0 |
if (siz>0) { |
|
233
|
134 |
0 |
siz = (self->key.d) ? mp_ubin_size(self->key.d) : 0; |
|
234
|
0 |
134 |
if (siz>10000) { |
|
237
|
74 |
60 |
if (siz>0) { |
|
245
|
134 |
0 |
siz = (self->key.N) ? nsize : 0; |
|
246
|
0 |
134 |
if (siz>10000) { |
|
249
|
134 |
0 |
if (siz>0) { |
|
257
|
134 |
0 |
siz = (self->key.q) ? mp_ubin_size(self->key.q) : 0; |
|
258
|
0 |
134 |
if (siz>10000) { |
|
261
|
74 |
60 |
if (siz>0) { |
|
269
|
134 |
0 |
siz = (self->key.p) ? mp_ubin_size(self->key.p) : 0; |
|
270
|
0 |
134 |
if (siz>10000) { |
|
273
|
74 |
60 |
if (siz>0) { |
|
281
|
134 |
0 |
siz = (self->key.qP) ? mp_ubin_size(self->key.qP) : 0; |
|
282
|
0 |
134 |
if (siz>10000) { |
|
285
|
74 |
60 |
if (siz>0) { |
|
293
|
134 |
0 |
siz = (self->key.dP) ? mp_ubin_size(self->key.dP) : 0; |
|
294
|
0 |
134 |
if (siz>10000) { |
|
297
|
74 |
60 |
if (siz>0) { |
|
305
|
134 |
0 |
siz = (self->key.dQ) ? mp_ubin_size(self->key.dQ) : 0; |
|
306
|
0 |
134 |
if (siz>10000) { |
|
309
|
74 |
60 |
if (siz>0) { |
|
334
|
2 |
3 |
if (strnEQ(type, "private", 7)) { |
|
336
|
0 |
2 |
if (rv != CRYPT_OK) croak("FATAL: rsa_export(PK_PRIVATE) failed: %s", error_to_string(rv)); |
|
339
|
3 |
0 |
else if (strnEQ(type, "public", 6)) { |
|
341
|
0 |
3 |
if (rv != CRYPT_OK) croak("FATAL: rsa_export(PK_PUBLIC|PK_STD) failed: %s", error_to_string(rv)); |
|
368
|
2 |
1 |
if (strnEQ(padding, "oaep", 4)) { |
|
370
|
0 |
2 |
if (mgf_hash_id == -1) croak("FATAL: find_hash failed for '%s'", mgf_hash); |
|
371
|
0 |
2 |
if (lparam_hash) { |
|
373
|
0 |
0 |
if (lparam_hash_id == -1) croak("FATAL: find_hash failed for '%s'", lparam_hash); |
|
378
|
0 |
2 |
if (oaep_lparam) lparam_ptr = (unsigned char *)SvPVbyte(oaep_lparam, lparam_len); |
|
388
|
0 |
2 |
if (rv != CRYPT_OK) croak("FATAL: rsa_encrypt_key_v2/oaep failed: %s", error_to_string(rv)); |
|
391
|
0 |
1 |
else if (strnEQ(padding, "v1.5", 4)) { |
|
401
|
0 |
0 |
if (rv != CRYPT_OK) croak("FATAL: rsa_encrypt_key_v2/v1.5 failed: %s", error_to_string(rv)); |
|
404
|
1 |
0 |
else if (strnEQ(padding, "none", 4)) { |
|
407
|
0 |
1 |
if (rv != CRYPT_OK) croak("FATAL: rsa_me failed: %s", error_to_string(rv)); |
|
434
|
1 |
37 |
if (strnEQ(padding, "oaep", 4)) { |
|
436
|
0 |
1 |
if (mgf_hash_id == -1) croak("FATAL: find_hash failed for '%s'", mgf_hash); |
|
437
|
0 |
1 |
if (lparam_hash) { |
|
439
|
0 |
0 |
if (lparam_hash_id == -1) croak("FATAL: find_hash failed for '%s'", lparam_hash); |
|
444
|
0 |
1 |
if (oaep_lparam) lparam_ptr = (unsigned char *)SvPVbyte(oaep_lparam, lparam_len); |
|
454
|
0 |
1 |
if (rv != CRYPT_OK) croak("FATAL: rsa_decrypt_key_v2 failed: %s", error_to_string(rv)); |
|
455
|
0 |
1 |
if (stat != 1) croak("FATAL: rsa_decrypt - not valid OAEP packet"); |
|
458
|
36 |
1 |
else if (strnEQ(padding, "v1.5", 4)) { |
|
468
|
0 |
36 |
if (rv != CRYPT_OK) croak("FATAL: rsa_decrypt_key_v2 failed: %s", error_to_string(rv)); |
|
469
|
0 |
36 |
if (stat != 1) croak("FATAL: rsa_decrypt - invalid"); |
|
472
|
1 |
0 |
else if (strnEQ(padding, "none", 4)) { |
|
475
|
0 |
1 |
if (rv != CRYPT_OK) croak("FATAL: rsa_me failed: %s", error_to_string(rv)); |
|
499
|
3 |
2 |
if (ix == 1) { |
|
501
|
0 |
3 |
if (hash_id == -1) croak("FATAL: find_hash failed for '%s'", hash_name); |
|
503
|
0 |
3 |
if (rv != CRYPT_OK) croak("FATAL: hash_memory failed: %s", error_to_string(rv)); |
|
507
|
5 |
0 |
if (strnEQ(padding, "pss", 3)) { |
|
509
|
0 |
5 |
if (hash_id == -1) croak("FATAL: find_hash failed for '%s'", hash_name); |
|
510
|
0 |
5 |
mgf_hash_id = mgf_hash_name ? cryptx_internal_find_hash(mgf_hash_name) : hash_id; |
|
511
|
0 |
5 |
if (mgf_hash_id == -1) croak("FATAL: find_hash failed for '%s'", mgf_hash_name); |
|
521
|
0 |
5 |
if (rv != CRYPT_OK) croak("FATAL: rsa_sign_hash_v2 failed: %s", error_to_string(rv)); |
|
524
|
0 |
0 |
else if (strnEQ(padding, "v1.5", 4)) { |
|
526
|
0 |
0 |
if (hash_id == -1) croak("FATAL: find_hash failed for '%s'", hash_name); |
|
536
|
0 |
0 |
if (rv != CRYPT_OK) croak("FATAL: rsa_sign_hash_v2 failed: %s", error_to_string(rv)); |
|
539
|
0 |
0 |
else if (strnEQ(padding, "v1.5.na1", 8)) { |
|
542
|
0 |
0 |
else if (strnEQ(padding, "none", 4)) { |
|
545
|
0 |
0 |
if (rv != CRYPT_OK) croak("FATAL: rsa_me failed: %s", error_to_string(rv)); |
|
570
|
107 |
2 |
if (ix == 1) { |
|
572
|
0 |
107 |
if (hash_id == -1) croak("FATAL: find_hash failed for '%s'", hash_name); |
|
574
|
0 |
107 |
if (rv != CRYPT_OK) croak("FATAL: hash_memory failed: %s", error_to_string(rv)); |
|
580
|
4 |
105 |
if (strnEQ(padding, "pss", 3)) { |
|
582
|
0 |
4 |
if (hash_id == -1) croak("FATAL: find_hash failed for '%s'", hash_name); |
|
583
|
0 |
4 |
mgf_hash_id = mgf_hash_name ? cryptx_internal_find_hash(mgf_hash_name) : hash_id; |
|
584
|
0 |
4 |
if (mgf_hash_id == -1) croak("FATAL: find_hash failed for '%s'", mgf_hash_name); |
|
594
|
4 |
0 |
if (rv != CRYPT_OK || stat != 1) RETVAL = 0; |
|
|
0 |
4 |
if (rv != CRYPT_OK || stat != 1) RETVAL = 0; |
|
596
|
105 |
0 |
else if (strnEQ(padding, "v1.5", 4)) { |
|
598
|
0 |
105 |
if (hash_id == -1) croak("FATAL: find_hash failed for '%s'", hash_name); |
|
608
|
105 |
0 |
if (rv != CRYPT_OK || stat != 1) RETVAL = 0; |
|
|
2 |
103 |
if (rv != CRYPT_OK || stat != 1) RETVAL = 0; |
|
610
|
0 |
0 |
else if (strnEQ(padding, "v1.5.na1", 8)) { |
|
613
|
0 |
0 |
else if (strnEQ(padding, "none", 4)) { |
|
617
|
0 |
0 |
if (rv != CRYPT_OK) croak("FATAL: rsa_me failed: %s", error_to_string(rv)); |
|
618
|
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) { |
|
619
|
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; |
|
620
|
0 |
0 |
if (memNE(data_ptr, buffer + buffer_len - data_len, data_len)) RETVAL = 0; |
|
636
|
110 |
0 |
if (self->key.type != -1) { rsa_free(&self->key); self->key.type = -1; } |