| line |
true |
false |
branch |
|
96
|
0 |
4 |
if (!strncmp(keyString, "----", 4)) { |
|
98
|
0 |
0 |
CHECK_OPEN_SSL(stringBIO = BIO_new_mem_buf(keyString, strlen(keyString))); |
|
102
|
0 |
4 |
CHECK_OPEN_SSL(stringBIO = BIO_new_file(keyString, "r")); |
|
110
|
0 |
4 |
CHECK_OPEN_SSL(pkey); |
|
121
|
0 |
4 |
if (!strncmp(keyString, "----", 4)) { |
|
122
|
0 |
0 |
CHECK_OPEN_SSL(stringBIO = BIO_new_mem_buf(keyString, strlen(keyString))); |
|
124
|
0 |
4 |
CHECK_OPEN_SSL(stringBIO = BIO_new_file(keyString, "r")); |
|
128
|
4 |
4 |
for (i = 0; i < sk_X509_INFO_num(xis); i++) { |
|
130
|
4 |
0 |
if (xi->x509 != NULL && stack != NULL) { |
|
|
4 |
0 |
if (xi->x509 != NULL && stack != NULL) { |
|
131
|
0 |
4 |
CHECK_OPEN_SSL(xi->x509); |
|
132
|
0 |
4 |
if (!sk_X509_push(stack, xi->x509)) |
|
149
|
0 |
0 |
if (sv) sv_free(sv); |
|
160
|
0 |
207 |
CHECK_OPEN_SSL(BIO_flush(p_stringBio) == 1); |
|
165
|
0 |
207 |
CHECK_OPEN_SSL(BIO_set_close(p_stringBio, BIO_CLOSE) == 1); |
|
175
|
0 |
7 |
CHECK_OPEN_SSL(bio = BIO_new(BIO_s_mem())); |
|
206
|
0 |
2 |
if (options & NOKEYS) return 1; |
|
210
|
0 |
2 |
if (!(pkey = EVP_PKCS82PKEY (p8))) return 0; |
|
212
|
2 |
0 |
if (options & INFO) { |
|
214
|
1 |
1 |
if (bag_hv) { |
|
216
|
0 |
1 |
if((hv_store(bag_hv, "type", strlen("type"), value, 0)) == NULL) |
|
221
|
0 |
1 |
CHECK_OPEN_SSL(keybio = BIO_new(BIO_s_mem())); |
|
225
|
0 |
1 |
if((hv_store(bag_hv, "key", strlen("key"), key_sv, 0)) == NULL) |
|
245
|
5 |
13 |
if (options & NOKEYS) return 1; |
|
247
|
0 |
13 |
if ((p8 = PKCS12_decrypt_skey(bag, pass, passlen)) == NULL) |
|
249
|
0 |
13 |
if ((pkey = EVP_PKCS82PKEY (p8)) == NULL) { |
|
253
|
10 |
3 |
if (options & INFO) { |
|
264
|
5 |
5 |
if (bag_hv) { |
|
267
|
0 |
5 |
if((hv_store(bag_hv, "type", strlen("type"), str_bag, 0)) == NULL) |
|
273
|
0 |
5 |
if((hv_store(bag_hv, "parameters", strlen("parameters"), newRV_inc((SV *) parameters_hv), 0)) == NULL) |
|
277
|
0 |
5 |
if((hv_store(bag_hv, "type", strlen("type"), str_key_bag, 0)) == NULL) |
|
284
|
0 |
5 |
CHECK_OPEN_SSL(keybio = BIO_new(BIO_s_mem())); |
|
288
|
0 |
5 |
if((hv_store(bag_hv, "key", strlen("key"), key_sv, 0)) == NULL) |
|
310
|
6 |
42 |
if (options & NOCERTS) return 1; |
|
312
|
21 |
21 |
if (PKCS12_SAFEBAG_get0_attr(bag, NID_localKeyID)) { |
|
314
|
1 |
20 |
if (options & CACERTS) return 1; |
|
316
|
3 |
18 |
} else if (options & CLCERTS) { |
|
321
|
0 |
38 |
if (PKCS12_SAFEBAG_get_bag_nid(bag) != NID_x509Certificate) return 1; |
|
323
|
0 |
38 |
if ((x509 = PKCS12_SAFEBAG_get1_cert(bag)) == NULL) return 0; |
|
324
|
33 |
5 |
if (options & INFO) { |
|
325
|
17 |
16 |
if (bag_hv) { |
|
327
|
0 |
17 |
CHECK_OPEN_SSL(keybio = BIO_new(BIO_s_mem())); |
|
330
|
0 |
17 |
if((hv_store(bag_hv, "type", strlen("type"), value, 0)) == NULL) |
|
332
|
0 |
17 |
if((hv_store(bag_hv, "subject", strlen("subject"), get_cert_subject_name(aTHX_ x509), 0)) == NULL) |
|
334
|
0 |
17 |
if((hv_store(bag_hv, "issuer", strlen("issuer"), get_cert_issuer_name(aTHX_ x509), 0)) == NULL) |
|
338
|
0 |
17 |
if((hv_store(bag_hv, "cert", strlen("cert"), key_sv, 0)) == NULL) |
|
358
|
53 |
0 |
if (options & INFO) { |
|
360
|
52 |
1 |
if (bag_hv){ |
|
362
|
0 |
52 |
if((hv_store(bag_hv, "type", strlen("type"), value, 0)) == NULL) |
|
367
|
0 |
52 |
if(hv_store(bag_hv, "bag_value", strlen("bag_value"), newSVpvn(attribute_value, strlen(attribute_value)), 0) == NULL) |
|
380
|
0 |
0 |
if (!bag_hv) |
|
386
|
2 |
0 |
if (options & INFO) { |
|
387
|
1 |
1 |
if(bag_hv) { |
|
389
|
0 |
1 |
if((hv_store(bag_hv, "type", strlen("type"), value, 0)) == NULL) |
|
405
|
0 |
0 |
if(bag_hv) |
|
421
|
69 |
33 |
if(hash) { |
|
424
|
123 |
102 |
for (i = 0; i < sk_PKCS12_SAFEBAG_num(bags); i++) { |
|
425
|
76 |
47 |
if(hash) |
|
427
|
0 |
123 |
if (!dump_certs_pkeys_bag (aTHX_ bio, sk_PKCS12_SAFEBAG_value (bags, i), pass, passlen, options, pempass, enc, bag_hv)) { |
|
430
|
76 |
47 |
if(hash) |
|
434
|
69 |
33 |
if (hash) { |
|
437
|
69 |
0 |
if (hv_exists(bag_hv, "type", strlen("type"))) { |
|
439
|
69 |
0 |
if (svp != NULL) |
|
442
|
69 |
0 |
if (svp != NULL) { |
|
443
|
1 |
68 |
if (strcmp(type, "safe_contents_bag") == 0 ) { |
|
444
|
0 |
1 |
if((hv_store(hash, "safe_contents_bag", strlen("safe_contents_bag"), newRV_inc((SV *) bags_av), 0)) == NULL) |
|
447
|
0 |
68 |
if((hv_store(hash, "bags", strlen("bags"), newRV_inc((SV *) bags_av), 0)) == NULL) |
|
467
|
0 |
78 |
if ((asafes = PKCS12_unpack_authsafes(p12)) == NULL) { |
|
472
|
100 |
78 |
for (i = 0; i < sk_PKCS7_num(asafes); i++) { |
|
474
|
68 |
32 |
if (orig_hash) { |
|
483
|
27 |
73 |
if (bagnid == NID_pkcs7_data) { |
|
485
|
19 |
8 |
if (options & INFO) { |
|
486
|
10 |
9 |
if (orig_hash) { |
|
495
|
73 |
0 |
} else if (bagnid == NID_pkcs7_encrypted) { |
|
496
|
65 |
8 |
if (options & INFO) { |
|
497
|
58 |
7 |
if (orig_hash) { |
|
500
|
58 |
0 |
if (p7->d.encrypted != NULL) |
|
502
|
0 |
58 |
if((hv_store(bag_hv, "parameters", strlen("parameters"), newRV_inc((SV *) parameters_hv), 0)) == NULL) |
|
504
|
0 |
58 |
if((hv_store(orig_hash, "pkcs7_encrypted_data", strlen("pkcs7_encrypted_data"), newRV_inc((SV *) bag_hv), 0)) == NULL) |
|
509
|
0 |
7 |
if (p7->d.encrypted == NULL) { |
|
522
|
0 |
100 |
if (bags == NULL) return 0; |
|
524
|
0 |
100 |
if (!dump_certs_pkeys_bags(aTHX_ bio, bags, pass, passlen, options, pempass, enc, bag_hv)) { |
|
529
|
68 |
32 |
if (orig_hash) { |
|
530
|
0 |
68 |
if((hv_store(orig_hash, "pkcs7_data", strlen("pkcs7_data"), newRV_inc((SV *) pkcs7_bags_av), 0)) == NULL) |
|
532
|
0 |
68 |
if((hv_store(orig_hash, "pkcs7_encrypted_data", strlen("pkcs7_encrypted_data"), newRV_inc((SV *) pkcs7_enc_bags_av), 0)) == NULL) |
|
572
|
0 |
66 |
nmflag_set ? nmflag : ESC_FLAGS | XN_FLAG_SEP_CPLUS_SPC | ASN1_STRFLGS_UTF8_CONVERT | XN_FLAG_SPC_EQ; |
|
582
|
0 |
66 |
if (out == NULL) |
|
584
|
66 |
0 |
if (title != NULL) |
|
586
|
0 |
66 |
if ((lflags & XN_FLAG_SEP_MASK) == XN_FLAG_SEP_MULTILINE) { |
|
590
|
0 |
66 |
if (lflags == XN_FLAG_COMPAT) { |
|
596
|
0 |
66 |
if (mline) |
|
613
|
0 |
17 |
CHECK_OPEN_SSL(bio = BIO_new(BIO_s_mem())); |
|
623
|
0 |
17 |
CHECK_OPEN_SSL(bio = BIO_new(BIO_s_mem())); |
|
633
|
1607 |
121 |
for (i = 0; i < len; i++) { |
|
634
|
119 |
1488 |
if (i == (len-1)) |
|
645
|
230 |
17 |
for (i = 0; i < len; i++) |
|
662
|
73 |
0 |
if (length < 0 || length > (INT_MAX - 1)) |
|
|
0 |
73 |
if (length < 0 || length > (INT_MAX - 1)) |
|
665
|
62 |
11 |
if(*attribute != NULL) { |
|
676
|
52 |
1 |
if(*attribute != NULL) { |
|
677
|
52 |
0 |
if (length < 0 || length > (INT_MAX - 1)) |
|
|
0 |
52 |
if (length < 0 || length > (INT_MAX - 1)) |
|
680
|
52 |
0 |
if (length) |
|
690
|
119 |
16 |
if(*attribute != NULL) { |
|
691
|
119 |
0 |
if (length < 0 || length > INT_MAX / 4) |
|
|
0 |
119 |
if (length < 0 || length > INT_MAX / 4) |
|
703
|
2 |
1 |
if(*attribute != NULL) { |
|
704
|
2 |
0 |
if (length < 0 || length > INT_MAX / 4) |
|
|
0 |
2 |
if (length < 0 || length > INT_MAX / 4) |
|
729
|
2 |
2 |
if(*attribute != NULL) { |
|
749
|
24 |
88 |
if (!attrlst) { |
|
750
|
12 |
12 |
if(hash) { |
|
759
|
0 |
88 |
if (!sk_X509_ATTRIBUTE_num(attrlst)) { |
|
760
|
0 |
0 |
if(hash) { |
|
768
|
18 |
70 |
if(!hash) |
|
772
|
215 |
88 |
for (i = 0; i < sk_X509_ATTRIBUTE_num(attrlst); i++) { |
|
777
|
30 |
185 |
if (!hash) { |
|
778
|
3 |
27 |
if (attr_nid == NID_undef) { |
|
784
|
27 |
0 |
if (!hash) { |
|
792
|
215 |
0 |
if (X509_ATTRIBUTE_count(attr)) { |
|
793
|
215 |
215 |
for (j = 0; j < X509_ATTRIBUTE_count(attr); j++) |
|
797
|
185 |
30 |
if(hash) { |
|
801
|
129 |
56 |
if (attr_nid != NID_undef) { |
|
804
|
129 |
0 |
if (attribute_id) { |
|
805
|
0 |
129 |
if((hv_store(bag_hv, attribute_id, strlen(attribute_id), newSVpvn(attribute_value, strlen(attribute_value)), 0)) == NULL) |
|
812
|
0 |
56 |
CHECK_OPEN_SSL(attr_bio = BIO_new(BIO_s_mem())); |
|
815
|
0 |
56 |
CHECK_OPEN_SSL(BIO_flush(attr_bio) == 1); |
|
818
|
56 |
0 |
if (bptr->length > 0) { |
|
819
|
0 |
56 |
if((hv_store(bag_hv, bptr->data, bptr->length, newSVpvn(attribute_value, strlen(attribute_value)), 0)) == NULL) |
|
823
|
0 |
56 |
CHECK_OPEN_SSL(BIO_set_close(attr_bio, BIO_CLOSE) == 1); |
|
836
|
70 |
18 |
if (hash) { |
|
837
|
0 |
70 |
if((hv_store(hash, name, strlen(name), newRV_inc((SV *) bag_hv), 0)) == NULL) |
|
852
|
63 |
12 |
if (parameters_hash) { |
|
854
|
0 |
63 |
if((hv_store(parameters_hash, "nid_long_name", strlen("nid_long_name"), nid_long_name, 0)) == NULL) |
|
857
|
0 |
63 |
if((hv_store(parameters_hash, "nid_short_name", strlen("nid_short_name"), nid_short_name, 0)) == NULL) |
|
866
|
14 |
61 |
if (pbenid == NID_pbes2) { |
|
869
|
14 |
0 |
if (aparamtype == V_ASN1_SEQUENCE) |
|
871
|
0 |
14 |
if (pbe2 == NULL) { |
|
880
|
7 |
7 |
if (parameters_hash) { |
|
882
|
0 |
7 |
if((hv_store(parameters_hash, "nid_long_name", strlen("nid_long_name"), nid_long_name, 0)) == NULL) |
|
885
|
0 |
7 |
if((hv_store(parameters_hash, "nid_short_name", strlen("nid_short_name"), nid_short_name, 0)) == NULL) |
|
891
|
14 |
0 |
if (pbenid == NID_id_pbkdf2) { |
|
894
|
14 |
0 |
if (aparamtype == V_ASN1_SEQUENCE) |
|
896
|
0 |
14 |
if (kdf == NULL) { |
|
901
|
0 |
14 |
if (kdf->prf == NULL) { |
|
907
|
7 |
7 |
if (parameters_hash) { |
|
909
|
0 |
7 |
if((hv_store(parameters_hash, "iteration", strlen("iteration"), iteration, 0)) == NULL) |
|
918
|
0 |
0 |
} else if (pbenid == NID_id_scrypt) { |
|
921
|
0 |
0 |
if (aparamtype == V_ASN1_SEQUENCE) |
|
923
|
0 |
0 |
if (kdf == NULL) { |
|
927
|
0 |
0 |
if (parameters_hash) { |
|
928
|
0 |
0 |
if((hv_store(parameters_hash, "salt_length", strlen("salt_length"), newSViv(ASN1_STRING_length(kdf->salt)), 0)) == NULL) |
|
930
|
0 |
0 |
if((hv_store(parameters_hash, "cost", strlen("cost"), newSViv(ASN1_INTEGER_get(kdf->costParameter)), 0)) == NULL) |
|
932
|
0 |
0 |
if((hv_store(parameters_hash, "block_size", strlen("block_size"), newSViv(ASN1_INTEGER_get(kdf->blockSize)), 0)) == NULL) |
|
934
|
0 |
0 |
if((hv_store(parameters_hash, "parallelism", strlen("parallelism"), newSViv(ASN1_INTEGER_get(kdf->parallelizationParameter)), 0)) == NULL) |
|
950
|
61 |
0 |
if (aparamtype == V_ASN1_SEQUENCE) |
|
952
|
0 |
61 |
if (pbe == NULL) { |
|
956
|
56 |
5 |
if (parameters_hash) { |
|
959
|
0 |
56 |
if((hv_store(parameters_hash, "iteration", strlen("iteration"), iteration, 0)) == NULL) |
|
966
|
12 |
63 |
if(!parameters_hash) |
|
994
|
85 |
17 |
for (i = 0; (name = Crypt__OpenSSL__PKCS12__const[i].n); i++) { |
|
1005
|
0 |
0 |
if ((RETVAL = PKCS12_new()) == NULL) { |
|
1018
|
1 |
0 |
if (legacy) |
|
1040
|
0 |
37 |
SvGETMAGIC(string); |
|
|
0 |
0 |
SvGETMAGIC(string); |
|
1044
|
0 |
37 |
if (legacy == NULL) { |
|
1048
|
0 |
37 |
if (deflt == NULL) { |
|
1054
|
12 |
25 |
if (SvPOKp(string) || SvNOKp(string) || SvIOKp(string)) { |
|
|
10 |
2 |
if (SvPOKp(string) || SvNOKp(string) || SvIOKp(string)) { |
|
|
2 |
8 |
if (SvPOKp(string) || SvNOKp(string) || SvIOKp(string)) { |
|
1055
|
16 |
13 |
if (ix == 1) { |
|
1064
|
4 |
9 |
if (SvUTF8(string)) { |
|
1073
|
25 |
0 |
if (!str_ptr || !str_len) croak("PKCS12_new_from: No string or file was passed."); |
|
|
0 |
25 |
if (!str_ptr || !str_len) croak("PKCS12_new_from: No string or file was passed."); |
|
1075
|
16 |
9 |
if (ix == 1) { |
|
1081
|
0 |
25 |
if (!bio) croak("Failed to create BIO"); |
|
1084
|
6 |
19 |
if ((RETVAL = d2i_PKCS12_bio(bio, 0)) == NULL) { |
|
1100
|
19 |
0 |
if (pkcs12) { |
|
1125
|
0 |
3 |
CHECK_OPEN_SSL(bio = BIO_new(BIO_s_mem())); |
|
1127
|
0 |
3 |
if (!(i2d_PKCS12_bio(bio, pkcs12))) { |
|
1144
|
9 |
0 |
const char *pwd_str = ""; |
|
1148
|
9 |
0 |
if (SvOK(pwd)) { |
|
1150
|
0 |
9 |
if (pwd_len > (STRLEN)INT_MAX) |
|
1154
|
1 |
8 |
if (!(PKCS12_verify_mac(pkcs12, pwd_str, (int)pwd_len))) |
|
1171
|
0 |
0 |
const char *newpwd_str = ""; |
|
1175
|
0 |
0 |
if (SvOK(oldpwd)) { |
|
1177
|
0 |
0 |
if (memchr(oldpwd_str, '\0', oldpwd_len) != NULL) |
|
1181
|
0 |
0 |
if (SvOK(newpwd)) { |
|
1183
|
0 |
0 |
if (memchr(newpwd_str, '\0', newpwd_len) != NULL) |
|
1188
|
0 |
0 |
if (!(PKCS12_newpass(pkcs12, oldpwd_str, newpwd_str))) { |
|
1212
|
0 |
4 |
const char *pass_str = NULL; |
|
1216
|
4 |
0 |
if (SvOK(pass)) { |
|
1218
|
1 |
3 |
if (memchr(pass_str, '\0', pass_len) != NULL) |
|
1227
|
0 |
3 |
if (!p12) { |
|
1232
|
0 |
3 |
if (!(fp = fopen(file, "wb"))) { |
|
1260
|
0 |
2 |
const char *pass_str = NULL; |
|
1264
|
2 |
0 |
if (SvOK(pass)) { |
|
1266
|
1 |
1 |
if (memchr(pass_str, '\0', pass_len) != NULL) |
|
1275
|
0 |
1 |
if (!p12) { |
|
1280
|
0 |
1 |
CHECK_OPEN_SSL(bio = BIO_new(BIO_s_mem())); |
|
1298
|
4 |
0 |
const char *pwd_str = ""; |
|
1302
|
4 |
0 |
if (SvOK(pwd)) { |
|
1304
|
0 |
4 |
if (pwd_len > (STRLEN)INT_MAX) |
|
1308
|
0 |
4 |
CHECK_OPEN_SSL(bio = BIO_new(BIO_s_mem())); |
|
1310
|
0 |
4 |
if ((asafes = PKCS12_unpack_authsafes(pkcs12)) == NULL) |
|
1329
|
1 |
0 |
const char *pwd_str = ""; |
|
1333
|
1 |
0 |
if (SvOK(pwd)) { |
|
1335
|
0 |
1 |
if (pwd_len > (STRLEN)INT_MAX) |
|
1339
|
0 |
1 |
CHECK_OPEN_SSL(bio = BIO_new(BIO_s_mem())); |
|
1341
|
0 |
1 |
if ((asafes = PKCS12_unpack_authsafes(pkcs12)) == NULL) |
|
1359
|
3 |
0 |
const char *pwd_str = ""; |
|
1363
|
3 |
0 |
if (SvOK(pwd)) { |
|
1365
|
0 |
3 |
if (pwd_len > (STRLEN)INT_MAX) |
|
1369
|
0 |
3 |
CHECK_OPEN_SSL(bio = BIO_new(BIO_s_mem())); |
|
1388
|
61 |
0 |
const char *pwd_str = ""; |
|
1400
|
61 |
0 |
if (SvOK(pwd)) { |
|
1402
|
0 |
61 |
if (pwd_len > (STRLEN)INT_MAX) |
|
1407
|
0 |
61 |
CHECK_OPEN_SSL(bio = BIO_new(BIO_s_mem())); |
|
1409
|
0 |
61 |
if ((asafes = PKCS12_unpack_authsafes(pkcs12)) == NULL) |
|
1419
|
0 |
61 |
if((hv_store(mac, "digest", strlen("digest"), value, 0)) == NULL) |
|
1424
|
61 |
0 |
SV * mac_iteration = newSViv (tmaciter != NULL ? ASN1_INTEGER_get(tmaciter) : 1L); |
|
1426
|
0 |
61 |
if((hv_store(mac, "iteration", strlen("iteration"), mac_iteration, 0)) == NULL) |
|
1428
|
0 |
61 |
CHECK_OPEN_SSL(bio = BIO_new(BIO_s_mem())); |
|
1431
|
61 |
0 |
SV * mac_len = newSViv(tmac != NULL ? ASN1_STRING_length(tmac) : 0L); |
|
1432
|
61 |
0 |
SV * salt_len = newSViv(tsalt != NULL ? ASN1_STRING_length(tsalt) : 0L); |
|
1434
|
0 |
61 |
if((hv_store(mac, "length", 6, mac_len, 0)) == NULL) |
|
1440
|
0 |
61 |
if((hv_store(mac, "salt_length", strlen("salt_length"), INT2PTR(SV*, salt_len), 0)) == NULL) |
|
1443
|
0 |
61 |
if((hv_store(RETVAL, "mac", strlen("mac"), newRV_inc((SV *) mac), 0)) == NULL) |
|
1449
|
0 |
61 |
if (SvPOK(end)) { |
|
1450
|
0 |
0 |
if (SvCUR(end) != 0) |
|
1469
|
9 |
0 |
const char *pwd_str = ""; |
|
1480
|
9 |
0 |
if (SvOK(pwd)) { |
|
1482
|
0 |
9 |
if (pwd_len > (STRLEN)INT_MAX) |
|
1486
|
0 |
9 |
CHECK_OPEN_SSL(bio = BIO_new(BIO_s_mem())); |
|
1488
|
0 |
9 |
if ((asafes = PKCS12_unpack_authsafes(pkcs12)) == NULL) |
|
1500
|
9 |
0 |
tmaciter != NULL ? ASN1_INTEGER_get(tmaciter) : 1L); |
|
1502
|
9 |
0 |
tmac != NULL ? ASN1_STRING_length(tmac) : 0L, |
|
1503
|
9 |
0 |
tsalt != NULL ? ASN1_STRING_length(tsalt) : 0L); |