| line |
true |
false |
branch |
|
11
|
0 |
116 |
if (!RETVAL) croak("FATAL: Newz failed"); |
|
15
|
0 |
116 |
if (RETVAL->pindex == -1) { |
|
21
|
0 |
116 |
if (rv != CRYPT_OK) { |
|
37
|
1 |
3 |
if (self->key.type != -1) { rsa_free(&self->key); self->key.type = -1; } |
|
40
|
0 |
4 |
if (rv != CRYPT_OK) croak("FATAL: rsa_make_key failed: %s", error_to_string(rv)); |
|
41
|
0 |
4 |
XPUSHs(ST(0)); /* return self */ |
|
53
|
2 |
91 |
if (self->key.type != -1) { rsa_free(&self->key); self->key.type = -1; } |
|
55
|
2 |
91 |
if (rv != CRYPT_OK) croak("FATAL: rsa_import failed: %s", error_to_string(rv)); |
|
56
|
0 |
91 |
XPUSHs(ST(0)); /* return self */ |
|
69
|
0 |
2 |
if (self->key.type != -1) { rsa_free(&self->key); self->key.type = -1; } |
|
70
|
1 |
1 |
if (SvOK(passwd)) { |
|
76
|
0 |
2 |
if (rv != CRYPT_OK) croak("FATAL: rsa_import_pkcs8 failed: %s", error_to_string(rv)); |
|
77
|
0 |
2 |
XPUSHs(ST(0)); /* return self */ |
|
91
|
36 |
20 |
if (self->key.type != -1) { rsa_free(&self->key); self->key.type = -1; } |
|
92
|
22 |
34 |
if (SvOK(passwd)) { |
|
98
|
0 |
56 |
if (rv != CRYPT_OK) croak("FATAL: pem_decode_pkcs failed: %s", error_to_string(rv)); |
|
99
|
0 |
56 |
if (key_from_pem.id != LTC_PKA_RSA && key_from_pem.id != LTC_PKA_RSA_PSS) croak("FATAL: pem_decode_pkcs decoded non-RSA key"); |
|
|
0 |
0 |
if (key_from_pem.id != LTC_PKA_RSA && key_from_pem.id != LTC_PKA_RSA_PSS) croak("FATAL: pem_decode_pkcs decoded non-RSA key"); |
|
101
|
0 |
56 |
XPUSHs(ST(0)); /* return self */ |
|
116
|
18 |
0 |
if (self->key.type != -1) { rsa_free(&self->key); self->key.type = -1; } |
|
117
|
6 |
12 |
if (SvOK(passwd)) { |
|
123
|
0 |
18 |
if (rv != CRYPT_OK) croak("FATAL: pem_decode_openssh failed: %s", error_to_string(rv)); |
|
124
|
0 |
18 |
if (key_from_pem.id != LTC_PKA_RSA && key_from_pem.id != LTC_PKA_RSA_PSS) croak("FATAL: pem_decode_openssh decoded non-RSA key"); |
|
|
0 |
0 |
if (key_from_pem.id != LTC_PKA_RSA && key_from_pem.id != LTC_PKA_RSA_PSS) croak("FATAL: pem_decode_openssh decoded non-RSA key"); |
|
126
|
0 |
18 |
XPUSHs(ST(0)); /* return self */ |
|
138
|
0 |
0 |
if (self->key.type != -1) { rsa_free(&self->key); self->key.type = -1; } |
|
140
|
0 |
0 |
if (rv != CRYPT_OK) croak("FATAL: rsa_import_x509 failed: %s", error_to_string(rv)); |
|
141
|
0 |
0 |
XPUSHs(ST(0)); /* return self */ |
|
154
|
0 |
9 |
if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(N) failed: %s", error_to_string(rv)); |
|
156
|
0 |
9 |
if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(e) failed: %s", error_to_string(rv)); |
|
157
|
7 |
2 |
if (self->key.type != -1) { rsa_free(&self->key); self->key.type = -1; } |
|
159
|
2 |
7 |
if (d && strlen(d) > 0) { |
|
|
2 |
0 |
if (d && strlen(d) > 0) { |
|
162
|
0 |
2 |
if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(d) failed: %s", error_to_string(rv)); |
|
164
|
0 |
2 |
if (rv != CRYPT_OK) croak("FATAL: rsa_set_key failed: %s", error_to_string(rv)); |
|
169
|
0 |
7 |
if (rv != CRYPT_OK) croak("FATAL: rsa_set_key failed: %s", error_to_string(rv)); |
|
172
|
2 |
7 |
if (p && strlen(p) > 0 && q && strlen(q) > 0) { |
|
|
2 |
0 |
if (p && strlen(p) > 0 && q && strlen(q) > 0) { |
|
|
2 |
0 |
if (p && strlen(p) > 0 && q && strlen(q) > 0) { |
|
|
2 |
0 |
if (p && strlen(p) > 0 && q && strlen(q) > 0) { |
|
175
|
0 |
2 |
if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(p) failed: %s", error_to_string(rv)); |
|
177
|
0 |
2 |
if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(q) failed: %s", error_to_string(rv)); |
|
179
|
0 |
2 |
if (rv != CRYPT_OK) croak("FATAL: rsa_set_factors failed: %s", error_to_string(rv)); |
|
182
|
2 |
7 |
if (dP && strlen(dP) > 0 && dQ && strlen(dQ) > 0 && qP && strlen(qP) > 0) { |
|
|
2 |
0 |
if (dP && strlen(dP) > 0 && dQ && strlen(dQ) > 0 && qP && strlen(qP) > 0) { |
|
|
2 |
0 |
if (dP && strlen(dP) > 0 && dQ && strlen(dQ) > 0 && qP && strlen(qP) > 0) { |
|
|
2 |
0 |
if (dP && strlen(dP) > 0 && dQ && strlen(dQ) > 0 && qP && strlen(qP) > 0) { |
|
|
2 |
0 |
if (dP && strlen(dP) > 0 && dQ && strlen(dQ) > 0 && qP && strlen(qP) > 0) { |
|
|
2 |
0 |
if (dP && strlen(dP) > 0 && dQ && strlen(dQ) > 0 && qP && strlen(qP) > 0) { |
|
185
|
0 |
2 |
if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(dP) failed: %s", error_to_string(rv)); |
|
187
|
0 |
2 |
if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(dQ) failed: %s", error_to_string(rv)); |
|
189
|
0 |
2 |
if (rv != CRYPT_OK) croak("FATAL: radix_to_bin(qP) failed: %s", error_to_string(rv)); |
|
191
|
0 |
2 |
if (rv != CRYPT_OK) croak("FATAL: rsa_set_crt_params failed: %s", error_to_string(rv)); |
|
194
|
0 |
9 |
XPUSHs(ST(0)); /* return self */ |
|
200
|
89 |
0 |
if (self->key.type == -1 || self->key.N == NULL) XSRETURN_UNDEF; |
|
|
0 |
89 |
if (self->key.type == -1 || self->key.N == NULL) XSRETURN_UNDEF; |
|
201
|
68 |
21 |
RETVAL = (self->key.type == PK_PRIVATE) ? 1 : 0; |
|
208
|
2 |
0 |
if (self->key.type == -1 || self->key.N == NULL) XSRETURN_UNDEF; |
|
|
0 |
2 |
if (self->key.type == -1 || self->key.N == NULL) XSRETURN_UNDEF; |
|
221
|
141 |
0 |
if (self->key.type == -1 || self->key.N == NULL) XSRETURN_UNDEF; |
|
|
0 |
141 |
if (self->key.type == -1 || self->key.N == NULL) XSRETURN_UNDEF; |
|
225
|
141 |
0 |
siz = (self->key.e) ? mp_ubin_size(self->key.e) : 0; |
|
226
|
0 |
141 |
if (siz>10000) { |
|
229
|
141 |
0 |
if (siz>0) { |
|
237
|
141 |
0 |
siz = (self->key.d) ? mp_ubin_size(self->key.d) : 0; |
|
238
|
0 |
141 |
if (siz>10000) { |
|
241
|
81 |
60 |
if (siz>0) { |
|
249
|
141 |
0 |
siz = (self->key.N) ? nsize : 0; |
|
250
|
0 |
141 |
if (siz>10000) { |
|
253
|
141 |
0 |
if (siz>0) { |
|
261
|
141 |
0 |
siz = (self->key.q) ? mp_ubin_size(self->key.q) : 0; |
|
262
|
0 |
141 |
if (siz>10000) { |
|
265
|
81 |
60 |
if (siz>0) { |
|
273
|
141 |
0 |
siz = (self->key.p) ? mp_ubin_size(self->key.p) : 0; |
|
274
|
0 |
141 |
if (siz>10000) { |
|
277
|
81 |
60 |
if (siz>0) { |
|
285
|
141 |
0 |
siz = (self->key.qP) ? mp_ubin_size(self->key.qP) : 0; |
|
286
|
0 |
141 |
if (siz>10000) { |
|
289
|
81 |
60 |
if (siz>0) { |
|
297
|
141 |
0 |
siz = (self->key.dP) ? mp_ubin_size(self->key.dP) : 0; |
|
298
|
0 |
141 |
if (siz>10000) { |
|
301
|
81 |
60 |
if (siz>0) { |
|
309
|
141 |
0 |
siz = (self->key.dQ) ? mp_ubin_size(self->key.dQ) : 0; |
|
310
|
0 |
141 |
if (siz>10000) { |
|
313
|
81 |
60 |
if (siz>0) { |
|
338
|
2 |
3 |
if (strEQ(type, "private")) { |
|
340
|
0 |
2 |
if (rv != CRYPT_OK) croak("FATAL: rsa_export(PK_PRIVATE) failed: %s", error_to_string(rv)); |
|
343
|
3 |
0 |
else if (strEQ(type, "public")) { |
|
345
|
0 |
3 |
if (rv != CRYPT_OK) croak("FATAL: rsa_export(PK_PUBLIC|PK_STD) failed: %s", error_to_string(rv)); |
|
373
|
2 |
1 |
if (strnEQ(padding, "oaep", 4)) { |
|
375
|
0 |
2 |
if (mgf_hash_id == -1) croak("FATAL: find_hash failed for '%s'", mgf_hash); |
|
376
|
0 |
2 |
if (lparam_hash) { |
|
378
|
0 |
0 |
if (lparam_hash_id == -1) croak("FATAL: find_hash failed for '%s'", lparam_hash); |
|
383
|
0 |
2 |
if (oaep_lparam) lparam_ptr = (unsigned char *)SvPVbyte(oaep_lparam, lparam_len); |
|
393
|
0 |
2 |
if (rv != CRYPT_OK) croak("FATAL: rsa_encrypt_key_v2/oaep failed: %s", error_to_string(rv)); |
|
396
|
0 |
1 |
else if (strnEQ(padding, "v1.5", 4)) { |
|
406
|
0 |
0 |
if (rv != CRYPT_OK) croak("FATAL: rsa_encrypt_key_v2/v1.5 failed: %s", error_to_string(rv)); |
|
409
|
1 |
0 |
else if (strnEQ(padding, "none", 4)) { |
|
412
|
0 |
1 |
if (rv != CRYPT_OK) croak("FATAL: rsa_me failed: %s", error_to_string(rv)); |
|
440
|
3 |
37 |
if (strnEQ(padding, "oaep", 4)) { |
|
442
|
0 |
3 |
if (mgf_hash_id == -1) croak("FATAL: find_hash failed for '%s'", mgf_hash); |
|
443
|
2 |
1 |
if (lparam_hash) { |
|
445
|
0 |
2 |
if (lparam_hash_id == -1) croak("FATAL: find_hash failed for '%s'", lparam_hash); |
|
450
|
2 |
1 |
if (oaep_lparam) lparam_ptr = (unsigned char *)SvPVbyte(oaep_lparam, lparam_len); |
|
460
|
2 |
1 |
if (rv != CRYPT_OK) croak("FATAL: rsa_decrypt_key_v2 failed: %s", error_to_string(rv)); |
|
461
|
0 |
1 |
if (stat != 1) croak("FATAL: rsa_decrypt - not valid OAEP packet"); |
|
464
|
36 |
1 |
else if (strnEQ(padding, "v1.5", 4)) { |
|
474
|
0 |
36 |
if (rv != CRYPT_OK) croak("FATAL: rsa_decrypt_key_v2 failed: %s", error_to_string(rv)); |
|
475
|
0 |
36 |
if (stat != 1) croak("FATAL: rsa_decrypt - invalid"); |
|
478
|
1 |
0 |
else if (strnEQ(padding, "none", 4)) { |
|
481
|
0 |
1 |
if (rv != CRYPT_OK) croak("FATAL: rsa_me failed: %s", error_to_string(rv)); |
|
506
|
5 |
4 |
if (ix == 1) { |
|
508
|
0 |
5 |
if (hash_id == -1) croak("FATAL: find_hash failed for '%s'", hash_name); |
|
510
|
0 |
5 |
if (rv != CRYPT_OK) croak("FATAL: hash_memory failed: %s", error_to_string(rv)); |
|
514
|
9 |
0 |
if (strnEQ(padding, "pss", 3)) { |
|
516
|
0 |
9 |
if (hash_id == -1) croak("FATAL: find_hash failed for '%s'", hash_name); |
|
517
|
0 |
9 |
mgf_hash_id = mgf_hash_name ? cryptx_internal_find_hash(mgf_hash_name) : hash_id; |
|
518
|
0 |
9 |
if (mgf_hash_id == -1) croak("FATAL: find_hash failed for '%s'", mgf_hash_name); |
|
528
|
0 |
9 |
if (rv != CRYPT_OK) croak("FATAL: rsa_sign_hash_v2 failed: %s", error_to_string(rv)); |
|
531
|
0 |
0 |
else if (strnEQ(padding, "v1.5", 4)) { |
|
533
|
0 |
0 |
if (hash_id == -1) croak("FATAL: find_hash failed for '%s'", hash_name); |
|
543
|
0 |
0 |
if (rv != CRYPT_OK) croak("FATAL: rsa_sign_hash_v2 failed: %s", error_to_string(rv)); |
|
546
|
0 |
0 |
else if (strnEQ(padding, "v1.5.na1", 8)) { |
|
549
|
0 |
0 |
else if (strnEQ(padding, "none", 4)) { |
|
552
|
0 |
0 |
if (rv != CRYPT_OK) croak("FATAL: rsa_me failed: %s", error_to_string(rv)); |
|
579
|
111 |
4 |
if (ix == 1) { |
|
581
|
0 |
111 |
if (hash_id == -1) croak("FATAL: find_hash failed for '%s'", hash_name); |
|
583
|
0 |
111 |
if (rv != CRYPT_OK) croak("FATAL: hash_memory failed: %s", error_to_string(rv)); |
|
589
|
10 |
105 |
if (strnEQ(padding, "pss", 3)) { |
|
591
|
0 |
10 |
if (hash_id == -1) croak("FATAL: find_hash failed for '%s'", hash_name); |
|
592
|
0 |
10 |
mgf_hash_id = mgf_hash_name ? cryptx_internal_find_hash(mgf_hash_name) : hash_id; |
|
593
|
0 |
10 |
if (mgf_hash_id == -1) croak("FATAL: find_hash failed for '%s'", mgf_hash_name); |
|
603
|
10 |
0 |
if (rv != CRYPT_OK || stat != 1) RETVAL = 0; |
|
|
2 |
8 |
if (rv != CRYPT_OK || stat != 1) RETVAL = 0; |
|
605
|
105 |
0 |
else if (strnEQ(padding, "v1.5", 4)) { |
|
607
|
0 |
105 |
if (hash_id == -1) croak("FATAL: find_hash failed for '%s'", hash_name); |
|
617
|
105 |
0 |
if (rv != CRYPT_OK || stat != 1) RETVAL = 0; |
|
|
2 |
103 |
if (rv != CRYPT_OK || stat != 1) RETVAL = 0; |
|
619
|
0 |
0 |
else if (strnEQ(padding, "v1.5.na1", 8)) { |
|
622
|
0 |
0 |
else if (strnEQ(padding, "none", 4)) { |
|
626
|
0 |
0 |
if (rv != CRYPT_OK) croak("FATAL: rsa_me failed: %s", error_to_string(rv)); |
|
627
|
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) { |
|
628
|
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; |
|
629
|
0 |
0 |
if (memNE(data_ptr, buffer + buffer_len - data_len, data_len)) RETVAL = 0; |
|
645
|
116 |
0 |
if (self->key.type != -1) { rsa_free(&self->key); self->key.type = -1; } |
|
646
|
116 |
0 |
if (self->pindex >= 0 && prng_is_valid(self->pindex) == CRYPT_OK && prng_descriptor[self->pindex].done) { |
|
|
116 |
0 |
if (self->pindex >= 0 && prng_is_valid(self->pindex) == CRYPT_OK && prng_descriptor[self->pindex].done) { |
|
|
116 |
0 |
if (self->pindex >= 0 && prng_is_valid(self->pindex) == CRYPT_OK && prng_descriptor[self->pindex].done) { |