Branch Coverage

PKCS12.xs
Criterion Covered Total %
branch 248 414 59.9


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 89 CHECK_OPEN_SSL(BIO_flush(p_stringBio) == 1);
165 0 89 CHECK_OPEN_SSL(BIO_set_close(p_stringBio, BIO_CLOSE) == 1);
175 0 6 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 11 if (options & NOKEYS) return 1;
247 0 11 if ((p8 = PKCS12_decrypt_skey(bag, pass, passlen)) == NULL)
249 0 11 if ((pkey = EVP_PKCS82PKEY (p8)) == NULL) {
253 8 3 if (options & INFO) {
264 4 4 if (bag_hv) {
267 0 4 if((hv_store(bag_hv, "type", strlen("type"), str_bag, 0)) == NULL)
273 0 4 if((hv_store(bag_hv, "parameters", strlen("parameters"), newRV_inc((SV *) parameters_hv), 0)) == NULL)
277 0 4 if((hv_store(bag_hv, "type", strlen("type"), str_key_bag, 0)) == NULL)
284 0 4 CHECK_OPEN_SSL(keybio = BIO_new(BIO_s_mem()));
288 0 4 if((hv_store(bag_hv, "key", strlen("key"), key_sv, 0)) == NULL)
310 6 37 if (options & NOCERTS) return 1;
312 19 18 if (PKCS12_SAFEBAG_get0_attr(bag, NID_localKeyID)) {
314 1 18 if (options & CACERTS) return 1;
316 3 15 } else if (options & CLCERTS) {
321 0 33 if (PKCS12_SAFEBAG_get_bag_nid(bag) != NID_x509Certificate) return 1;
323 0 33 if ((x509 = PKCS12_SAFEBAG_get1_cert(bag)) == NULL) return 0;
324 28 5 if (options & INFO) {
325 14 14 if (bag_hv) {
327 0 14 CHECK_OPEN_SSL(keybio = BIO_new(BIO_s_mem()));
330 0 14 if((hv_store(bag_hv, "type", strlen("type"), value, 0)) == NULL)
332 0 14 if((hv_store(bag_hv, "subject", strlen("subject"), get_cert_subject_name(aTHX_ x509), 0)) == NULL)
334 0 14 if((hv_store(bag_hv, "issuer", strlen("issuer"), get_cert_issuer_name(aTHX_ x509), 0)) == NULL)
338 0 14 if((hv_store(bag_hv, "cert", strlen("cert"), key_sv, 0)) == NULL)
358 2 0 if (options & INFO) {
360 1 1 if (bag_hv){
362 0 1 if((hv_store(bag_hv, "type", strlen("type"), value, 0)) == NULL)
367 0 1 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 15 31 if(hash) {
424 65 46 for (i = 0; i < sk_PKCS12_SAFEBAG_num(bags); i++) {
425 21 44 if(hash)
427 0 65 if (!dump_certs_pkeys_bag (aTHX_ bio, sk_PKCS12_SAFEBAG_value (bags, i), pass, passlen, options, pempass, enc, bag_hv)) {
430 21 44 if(hash)
434 15 31 if (hash) {
437 15 0 if (hv_exists(bag_hv, "type", strlen("type"))) {
439 15 0 if (svp != NULL)
442 15 0 if (svp != NULL) {
443 1 14 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 14 if((hv_store(hash, "bags", strlen("bags"), newRV_inc((SV *) bags_av), 0)) == NULL)
467 0 24 if ((asafes = PKCS12_unpack_authsafes(p12)) == NULL) {
472 44 24 for (i = 0; i < sk_PKCS7_num(asafes); i++) {
474 14 30 if (orig_hash) {
483 24 20 if (bagnid == NID_pkcs7_data) {
485 16 8 if (options & INFO) {
486 8 8 if (orig_hash) {
495 20 0 } else if (bagnid == NID_pkcs7_encrypted) {
496 12 8 if (options & INFO) {
497 6 6 if (orig_hash) {
500 6 0 if (p7->d.encrypted != NULL)
502 0 6 if((hv_store(bag_hv, "parameters", strlen("parameters"), newRV_inc((SV *) parameters_hv), 0)) == NULL)
504 0 6 if((hv_store(orig_hash, "pkcs7_encrypted_data", strlen("pkcs7_encrypted_data"), newRV_inc((SV *) bag_hv), 0)) == NULL)
509 0 6 if (p7->d.encrypted == NULL) {
522 0 44 if (bags == NULL) return 0;
524 0 44 if (!dump_certs_pkeys_bags(aTHX_ bio, bags, pass, passlen, options, pempass, enc, bag_hv)) {
529 14 30 if (orig_hash) {
530 0 14 if((hv_store(orig_hash, "pkcs7_data", strlen("pkcs7_data"), newRV_inc((SV *) pkcs7_bags_av), 0)) == NULL)
532 0 14 if((hv_store(orig_hash, "pkcs7_encrypted_data", strlen("pkcs7_encrypted_data"), newRV_inc((SV *) pkcs7_enc_bags_av), 0)) == NULL)
572 0 56 nmflag_set ? nmflag : ESC_FLAGS | XN_FLAG_SEP_CPLUS_SPC | ASN1_STRFLGS_UTF8_CONVERT | XN_FLAG_SPC_EQ;
582 0 56 if (out == NULL)
584 56 0 if (title != NULL)
586 0 56 if ((lflags & XN_FLAG_SEP_MASK) == XN_FLAG_SEP_MULTILINE) {
590 0 56 if (lflags == XN_FLAG_COMPAT) {
596 0 56 if (mline)
613 0 14 CHECK_OPEN_SSL(bio = BIO_new(BIO_s_mem()));
623 0 14 CHECK_OPEN_SSL(bio = BIO_new(BIO_s_mem()));
633 194 15 for (i = 0; i < len; i++) {
634 15 179 if (i == (len-1))
644 194 15 for (i = 0; i < len; i++)
661 8 8 if(*attribute != NULL) {
671 1 1 if(*attribute != NULL) {
681 14 14 if(*attribute != NULL) {
692 1 1 if(*attribute != NULL) {
717 1 1 if(*attribute != NULL) {
736 22 30 if (!attrlst) {
737 11 11 if(hash) {
746 0 30 if (!sk_X509_ATTRIBUTE_num(attrlst)) {
747 0 0 if(hash) {
755 15 15 if(!hash)
759 48 30 for (i = 0; i < sk_X509_ATTRIBUTE_num(attrlst); i++) {
764 24 24 if (!hash) {
765 2 22 if (attr_nid == NID_undef) {
771 22 0 if (!hash) {
779 48 0 if (X509_ATTRIBUTE_count(attr)) {
780 48 48 for (j = 0; j < X509_ATTRIBUTE_count(attr); j++)
784 24 24 if(hash) {
788 22 2 if (attr_nid != NID_undef) {
791 22 0 if (attribute_id) {
792 0 22 if((hv_store(bag_hv, attribute_id, strlen(attribute_id), newSVpvn(attribute_value, strlen(attribute_value)), 0)) == NULL)
799 0 2 CHECK_OPEN_SSL(attr_bio = BIO_new(BIO_s_mem()));
802 0 2 CHECK_OPEN_SSL(BIO_flush(attr_bio) == 1);
805 2 0 if (bptr->length > 0) {
806 0 2 if((hv_store(bag_hv, bptr->data, bptr->length, newSVpvn(attribute_value, strlen(attribute_value)), 0)) == NULL)
810 0 2 CHECK_OPEN_SSL(BIO_set_close(attr_bio, BIO_CLOSE) == 1);
823 15 15 if (hash) {
824 0 15 if((hv_store(hash, name, strlen(name), newRV_inc((SV *) bag_hv), 0)) == NULL)
839 10 10 if (parameters_hash) {
841 0 10 if((hv_store(parameters_hash, "nid_long_name", strlen("nid_long_name"), nid_long_name, 0)) == NULL)
844 0 10 if((hv_store(parameters_hash, "nid_short_name", strlen("nid_short_name"), nid_short_name, 0)) == NULL)
853 10 10 if (pbenid == NID_pbes2) {
856 10 0 if (aparamtype == V_ASN1_SEQUENCE)
858 0 10 if (pbe2 == NULL) {
867 5 5 if (parameters_hash) {
869 0 5 if((hv_store(parameters_hash, "nid_long_name", strlen("nid_long_name"), nid_long_name, 0)) == NULL)
872 0 5 if((hv_store(parameters_hash, "nid_short_name", strlen("nid_short_name"), nid_short_name, 0)) == NULL)
878 10 0 if (pbenid == NID_id_pbkdf2) {
881 10 0 if (aparamtype == V_ASN1_SEQUENCE)
883 0 10 if (kdf == NULL) {
888 0 10 if (kdf->prf == NULL) {
894 5 5 if (parameters_hash) {
896 0 5 if((hv_store(parameters_hash, "iteration", strlen("iteration"), iteration, 0)) == NULL)
905 0 0 } else if (pbenid == NID_id_scrypt) {
908 0 0 if (aparamtype == V_ASN1_SEQUENCE)
910 0 0 if (kdf == NULL) {
914 0 0 if (parameters_hash) {
915 0 0 if((hv_store(parameters_hash, "salt_length", strlen("salt_length"), newSViv(ASN1_STRING_length(kdf->salt)), 0)) == NULL)
917 0 0 if((hv_store(parameters_hash, "cost", strlen("cost"), newSViv(ASN1_INTEGER_get(kdf->costParameter)), 0)) == NULL)
919 0 0 if((hv_store(parameters_hash, "block_size", strlen("block_size"), newSViv(ASN1_INTEGER_get(kdf->blockSize)), 0)) == NULL)
921 0 0 if((hv_store(parameters_hash, "parallelism", strlen("parallelism"), newSViv(ASN1_INTEGER_get(kdf->parallelizationParameter)), 0)) == NULL)
937 10 0 if (aparamtype == V_ASN1_SEQUENCE)
939 0 10 if (pbe == NULL) {
943 5 5 if (parameters_hash) {
946 0 5 if((hv_store(parameters_hash, "iteration", strlen("iteration"), iteration, 0)) == NULL)
953 10 10 if(!parameters_hash)
981 65 13 for (i = 0; (name = Crypt__OpenSSL__PKCS12__const[i].n); i++) {
992 0 0 if ((RETVAL = PKCS12_new()) == NULL) {
1005 1 0 if (legacy)
1027 0 33 SvGETMAGIC(string);
0 0 SvGETMAGIC(string);
1031 0 33 if (legacy == NULL) {
1035 0 33 if (deflt == NULL) {
1041 12 21 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)) {
1042 12 13 if (ix == 1) {
1051 4 9 if (SvUTF8(string)) {
1060 21 0 if (!str_ptr || !str_len) croak("PKCS12_new_from: No string or file was passed.");
0 21 if (!str_ptr || !str_len) croak("PKCS12_new_from: No string or file was passed.");
1062 12 9 if (ix == 1) {
1068 0 21 if (!bio) croak("Failed to create BIO");
1071 6 15 if ((RETVAL = d2i_PKCS12_bio(bio, 0)) == NULL) {
1087 15 0 if (pkcs12) {
1112 0 3 CHECK_OPEN_SSL(bio = BIO_new(BIO_s_mem()));
1114 0 3 if (!(i2d_PKCS12_bio(bio, pkcs12))) {
1131 0 7 if (!(PKCS12_verify_mac(pkcs12, pwd, strlen(pwd)))) {
1135 7 0 RETVAL = (PKCS12_verify_mac(pkcs12, pwd, strlen(pwd))) ? &PL_sv_yes : &PL_sv_no;
1148 0 0 if (!(PKCS12_newpass(pkcs12, oldpwd, newpwd))) {
1170 0 3 STACK_OF(X509) *cert_chain = NULL;
1178 0 3 if (!p12) {
1183 0 3 if (!(fp = fopen(file, "wb"))) {
1209 0 1 STACK_OF(X509) *cert_chain = NULL;
1217 0 1 if (!p12) {
1222 0 1 CHECK_OPEN_SSL(bio = BIO_new(BIO_s_mem()));
1238 4 0 STACK_OF(PKCS7) *asafes = NULL;
1242 0 4 CHECK_OPEN_SSL(bio = BIO_new(BIO_s_mem()));
1244 0 4 if ((asafes = PKCS12_unpack_authsafes(pkcs12)) == NULL)
1261 1 0 STACK_OF(PKCS7) *asafes = NULL;
1265 0 1 CHECK_OPEN_SSL(bio = BIO_new(BIO_s_mem()));
1267 0 1 if ((asafes = PKCS12_unpack_authsafes(pkcs12)) == NULL)
1287 0 3 CHECK_OPEN_SSL(bio = BIO_new(BIO_s_mem()));
1304 8 0 STACK_OF(PKCS7) *asafes = NULL;
1318 0 8 CHECK_OPEN_SSL(bio = BIO_new(BIO_s_mem()));
1320 0 8 if ((asafes = PKCS12_unpack_authsafes(pkcs12)) == NULL)
1330 0 8 if((hv_store(mac, "digest", strlen("digest"), value, 0)) == NULL)
1335 8 0 SV * mac_iteration = newSViv (tmaciter != NULL ? ASN1_INTEGER_get(tmaciter) : 1L);
1337 0 8 if((hv_store(mac, "iteration", strlen("iteration"), mac_iteration, 0)) == NULL)
1339 0 8 CHECK_OPEN_SSL(bio = BIO_new(BIO_s_mem()));
1342 8 0 SV * mac_len = newSViv(tmac != NULL ? ASN1_STRING_length(tmac) : 0L);
1343 8 0 SV * salt_len = newSViv(tsalt != NULL ? ASN1_STRING_length(tsalt) : 0L);
1345 0 8 if((hv_store(mac, "length", 6, mac_len, 0)) == NULL)
1351 0 8 if((hv_store(mac, "salt_length", strlen("salt_length"), INT2PTR(SV*, salt_len), 0)) == NULL)
1354 0 8 if((hv_store(RETVAL, "mac", strlen("mac"), newRV_inc((SV *) mac), 0)) == NULL)
1360 0 8 if (SvPOK(end)) {
1361 0 0 if (SvCUR(end) != 0)
1378 8 0 STACK_OF(PKCS7) *asafes = NULL;
1389 0 8 CHECK_OPEN_SSL(bio = BIO_new(BIO_s_mem()));
1391 0 8 if ((asafes = PKCS12_unpack_authsafes(pkcs12)) == NULL)
1403 8 0 tmaciter != NULL ? ASN1_INTEGER_get(tmaciter) : 1L);
1405 8 0 tmac != NULL ? ASN1_STRING_length(tmac) : 0L,
1406 8 0 tsalt != NULL ? ASN1_STRING_length(tsalt) : 0L);