Branch Coverage

src/ldns/dnssec_verify.c
Criterion Covered Total %
branch 55 590 9.3


line true false branch
22 0 0 if(!nc) return NULL;
49 0 0 if (chain->parent) {
61 0 0 if (chain) {
63 0 0 if (ldns_rr_list_rr_count(chain->rrset) > 0) {
66 0 0 if (rcode) {
71 0 0 if (rr_descriptor && rr_descriptor->_name) {
0 0 if (rr_descriptor && rr_descriptor->_name) {
73 0 0 } else if (chain->packet_qtype != 0) {
77 0 0 if (chain->packet_nodata) {
108 0 0 if (signatures && ldns_rr_list_rr_count(signatures) > 0) {
0 0 if (signatures && ldns_rr_list_rr_count(signatures) > 0) {
118 0 0 if (!keys) {
124 0 0 if (my_pkt) {
179 0 0 if (my_pkt) {
185 0 0 if (dss) {
202 0 0 if (my_pkt) {
207 0 0 if (signatures2) {
208 0 0 if (new_chain->signatures) {
232 0 0 if (orig_rr) {
234 0 0 } else if (rrset && ldns_rr_list_rr_count(rrset) > 0) {
0 0 } else if (rrset && ldns_rr_list_rr_count(rrset) > 0) {
246 0 0 if (!my_pkt) {
250 0 0 if (ldns_pkt_ancount(my_pkt) > 0) {
293 0 0 if (!ldns_dnssec_pkt_has_rrsigs(pkt)) {
299 0 0 if (orig_rr) {
309 0 0 if (ldns_pkt_ancount(pkt) == 0) {
315 0 0 if (!rrset || ldns_rr_list_rr_count(rrset) < 1) {
0 0 if (!rrset || ldns_rr_list_rr_count(rrset) < 1) {
319 0 0 if (pkt) {
324 0 0 if (my_rrset) {
325 0 0 if (ldns_rr_list_rr_count(my_rrset) > 0) {
337 0 0 if (my_rrset) {
338 0 0 if (ldns_rr_list_rr_count(my_rrset) > 0) {
358 0 0 if (my_rrset && ldns_rr_list_rr_count(my_rrset) > 0) {
0 0 if (my_rrset && ldns_rr_list_rr_count(my_rrset) > 0) {
365 0 0 if (other_rrset) {
373 0 0 if (type == LDNS_RR_TYPE_NSEC || type == LDNS_RR_TYPE_NSEC3) {
0 0 if (type == LDNS_RR_TYPE_NSEC || type == LDNS_RR_TYPE_NSEC3) {
376 0 0 if (pkt) {
380 0 0 if (my_pkt) {
386 0 0 if (pkt) {
392 0 0 if (!signatures) {
394 0 0 if (my_pkt) {
404 0 0 if (signatures && ldns_rr_list_rr_count(signatures) > 0) {
0 0 if (signatures && ldns_rr_list_rr_count(signatures) > 0) {
407 0 0 if (!key_name) {
408 0 0 if (signatures) {
417 0 0 if (type != LDNS_RR_TYPE_DNSKEY) {
435 0 0 if (signatures) {
446 0 0 if(!new_tree) return NULL;
458 0 0 if (tree) {
459 0 0 for (i = 0; i < tree->parent_count; i++) {
473 0 0 for (i = 0; i < tree->parent_count; i++) {
475 0 0 if (parent > result) {
487 0 0 for (i = 0; i < nr; i++) {
488 0 0 if (i == nr - 1) {
490 0 0 } else if (map && i < treedepth && map[i] == 1) {
0 0 } else if (map && i < treedepth && map[i] == 1) {
0 0 } else if (map && i < treedepth && map[i] == 1) {
511 0 0 if (!sibmap) {
514 0 0 if(!sibmap)
520 0 0 if (tree) {
521 0 0 if (tree->rr) {
526 0 0 if (descriptor->_name) {
532 0 0 if (tabs > 0) {
533 0 0 if (ldns_rr_get_type(tree->rr) == LDNS_RR_TYPE_DNSKEY) {
540 0 0 } else if (ldns_rr_get_type(tree->rr) == LDNS_RR_TYPE_DS) {
546 0 0 if (ldns_rr_get_type(tree->rr) == LDNS_RR_TYPE_NSEC) {
555 0 0 for (i = 0; i < tree->parent_count; i++) {
556 0 0 if (tree->parent_count > 1 && i < tree->parent_count - 1) {
0 0 if (tree->parent_count > 1 && i < tree->parent_count - 1) {
562 0 0 if (ldns_rr_get_type(tree->parents[i]->rr) ==
563 0 0 LDNS_RR_TYPE_NSEC ||
566 0 0 if (tree->parent_status[i] == LDNS_STATUS_OK) {
569 0 0 ldns_rr_get_type(tree->rr) == LDNS_RR_TYPE_NS &&
577 0 0 if (ldns_rr_get_type(tree->rr) == LDNS_RR_TYPE_NS) {
588 0 0 if (tree->parent_status[i] != LDNS_STATUS_OK) {
594 0 0 if (tree->parent_status[i]
626 0 0 if (mapset) {
658 0 0 if (tree
659 0 0 && parent
660 0 0 && tree->parent_count < LDNS_DNSSEC_TRUST_TREE_MAX_PARENTS) {
693 0 0 if(!new_tree)
696 0 0 if (data_chain && data_chain->rrset) {
0 0 if (data_chain && data_chain->rrset) {
701 0 0 if (rr) {
705 0 0 if (!cur_rr && ldns_rr_list_rr_count(cur_rrset) > 0) {
0 0 if (!cur_rr && ldns_rr_list_rr_count(cur_rrset) > 0) {
709 0 0 if (cur_rr) {
720 0 0 if (cur_sigs) {
721 0 0 for (i = 0; i < ldns_rr_list_rr_count(cur_sigs); i++) {
725 0 0 if (ldns_rr_get_type(cur_rr) == LDNS_RR_TYPE_NSEC) {
726 0 0 if (ldns_dname_compare(ldns_rr_owner(cur_sig_rr),
731 0 0 for (j = 0;
732 0 0 j < ldns_rr_list_rr_count(cur_rrset) &&
738 0 0 if (ldns_dname_compare(ldns_rr_owner(cur_sig_rr),
747 0 0 if (data_chain->parent) {
803 0 0 for (j = 0; j < ldns_rr_list_rr_count(data_chain->parent->rrset); j++) {
805 0 0 if (ldns_rr_get_type(cur_parent_rr) == LDNS_RR_TYPE_DNSKEY) {
806 0 0 if (ldns_calc_keytag(cur_parent_rr) == cur_keytag) {
809 0 0 if (cur_rrset && ldns_rr_list_rr_count(cur_rrset) > 0) {
0 0 if (cur_rrset && ldns_rr_list_rr_count(cur_rrset) > 0) {
811 0 0 if (ldns_rr_get_type(ldns_rr_list_rr(cur_rrset, 0))
812 0 0 == LDNS_RR_TYPE_NSEC ||
823 0 0 ldns_rr_list_rr_count(cur_rrset) > 0 &&
838 0 0 if (tmp_rrset && tmp_rrset != cur_rrset
0 0 if (tmp_rrset && tmp_rrset != cur_rrset
845 0 0 for (i = 0; i < new_tree->parent_count; i++) {
846 0 0 if (cur_parent_rr == new_tree->parents[i]->rr) {
894 0 0 for (j = 0; j < ldns_rr_list_rr_count(cur_rrset); j++) {
898 0 0 if (ldns_calc_keytag(cur_parent_rr) == cur_keytag
936 0 0 if (ldns_rr_get_type(cur_rr) == LDNS_RR_TYPE_DNSKEY &&
0 0 if (ldns_rr_get_type(cur_rr) == LDNS_RR_TYPE_DNSKEY &&
937 0 0 data_chain->parent &&
940 0 0 for (j = 0;
944 0 0 if (ldns_rr_get_type(cur_parent_rr) == LDNS_RR_TYPE_DS) {
945 0 0 for (h = 0; h < ldns_rr_list_rr_count(cur_rrset); h++) {
947 0 0 if (ldns_rr_compare_ds(cur_rr, cur_parent_rr)) {
988 0 0 if (data_chain->parent && data_chain->parent->rrset) {
0 0 if (data_chain->parent && data_chain->parent->rrset) {
991 0 0 if (cur_rrset && ldns_rr_list_rr_count(cur_rrset) > 0) {
0 0 if (cur_rrset && ldns_rr_list_rr_count(cur_rrset) > 0) {
992 0 0 if (ldns_rr_get_type(ldns_rr_list_rr(cur_rrset, 0)) ==
1001 0 0 } else if (ldns_rr_get_type(ldns_rr_list_rr(cur_rrset, 0)) ==
1014 0 0 for (i = 0; i < ldns_rr_list_rr_count(cur_rrset); i++) {
1049 0 0 if (tree && trusted_keys && ldns_rr_list_rr_count(trusted_keys) > 0)
0 0 if (tree && trusted_keys && ldns_rr_list_rr_count(trusted_keys) > 0)
0 0 if (tree && trusted_keys && ldns_rr_list_rr_count(trusted_keys) > 0)
1050 0 0 { if (tree->rr) {
1051 0 0 for (i = 0; i < ldns_rr_list_rr_count(trusted_keys); i++) {
1055 0 0 if (equal) {
1061 0 0 for (i = 0; i < tree->parent_count; i++) {
1065 0 0 if (parent_result != LDNS_STATUS_CRYPTO_NO_DNSKEY) {
1066 0 0 if (tree->parent_status[i] != LDNS_STATUS_OK) {
1071 0 0 == LDNS_RR_TYPE_NSEC &&
1101 5 0 if (!rrset || !rrsig || !keys) {
5 0 if (!rrset || !rrsig || !keys) {
0 5 if (!rrset || !rrsig || !keys) {
1105 0 5 if (ldns_rr_list_rr_count(rrset) < 1) {
1109 0 5 if (ldns_rr_list_rr_count(rrsig) < 1) {
1113 0 5 if (ldns_rr_list_rr_count(keys) < 1) {
1116 5 5 for (i = 0; i < ldns_rr_list_rr_count(rrsig); i++) {
1121 1 4 if(s == LDNS_STATUS_OK) {
1123 4 0 } else if(verify_result == LDNS_STATUS_ERR)
1125 0 0 else if(s != LDNS_STATUS_ERR && verify_result ==
0 0 else if(s != LDNS_STATUS_ERR && verify_result ==
1147 0 0 if (!rrset || !rrsig || !keys) {
0 0 if (!rrset || !rrsig || !keys) {
0 0 if (!rrset || !rrsig || !keys) {
1151 0 0 if (ldns_rr_list_rr_count(rrset) < 1) {
1155 0 0 if (ldns_rr_list_rr_count(rrsig) < 1) {
1159 0 0 if (ldns_rr_list_rr_count(keys) < 1) {
1162 0 0 for (i = 0; i < ldns_rr_list_rr_count(rrsig); i++) {
1167 0 0 if (s == LDNS_STATUS_OK) {
1169 0 0 } else if (verify_result == LDNS_STATUS_ERR) {
1171 0 0 } else if (s != LDNS_STATUS_ERR && verify_result ==
0 0 } else if (s != LDNS_STATUS_ERR && verify_result ==
1193 0 0 if (res && domain && keys) {
0 0 if (res && domain && keys) {
0 0 if (res && domain && keys) {
1195 0 0 if ((trusted_keys = ldns_validate_domain_dnskey_time(res,
1206 0 0 if ((parent_keys =
1213 0 0 if ((ds_keys =
1240 0 0 if (parent_domain) {
1278 0 0 if (keypkt) {
1287 0 0 for (key_i=0; key_i< ldns_rr_list_rr_count(domain_keys); key_i++) {
1290 0 0 for (key_j=0; key_j
1291 0 0 if (ldns_rr_compare_ds(ldns_rr_list_rr(keys, key_j),
1297 0 0 for (sig_i=0;
1302 0 0 if (ldns_rdf2native_int16(
1305 0 0 if (ldns_verify_rrsig_time(
1314 0 0 for (key_k=0;
1377 0 0 if (dspkt) {
1386 0 0 if (ldns_verify_time(rrset, sigs, keys, check_time, NULL)
1389 0 0 for (key_i=0; key_i
1431 0 0 if (!res || !rrset || !rrsigs) {
0 0 if (!res || !rrset || !rrsigs) {
0 0 if (!res || !rrset || !rrsigs) {
1435 0 0 if (ldns_rr_list_rr_count(rrset) < 1) {
1439 0 0 if (ldns_rr_list_rr_count(rrsigs) < 1) {
1444 0 0 for (sig_i=0; sig_i < ldns_rr_list_rr_count(rrsigs); sig_i++) {
1448 0 0 if ((trusted_keys = ldns_fetch_valid_domain_keys_time(
1455 0 0 for (key_i = 0;
1460 0 0 if ((result = ldns_verify_rrsig_time(rrset,
1465 0 0 if (validating_keys) {
1515 0 0 if (result != LDNS_STATUS_OK) {
1519 0 0 for (i = 0; i < ldns_rr_list_rr_count(nsecs); i++) {
1521 0 0 if (ldns_dname_compare(rr_name, ldns_rr_owner(cur_nsec)) == 0) {
1529 0 0 if (rrsig && ldns_rdf2native_int8(ldns_rr_rrsig_labels(rrsig))
0 0 if (rrsig && ldns_rdf2native_int8(ldns_rr_rrsig_labels(rrsig))
1534 0 0 if (ldns_nsec_bitmap_covers_type(ldns_nsec_get_bitmap(cur_nsec),
1539 0 0 if (ldns_nsec_covers_name(cur_nsec, rr_name)) {
1543 0 0 if (ldns_dname_compare(wildcard_name,
1545 0 0 if (ldns_nsec_bitmap_covers_type(ldns_nsec_get_bitmap(cur_nsec),
1551 0 0 if (ldns_nsec_covers_name(cur_nsec, wildcard_name)) {
1559 0 0 if (type_covered || !name_covered) {
0 0 if (type_covered || !name_covered) {
1563 0 0 if (wildcard_type_covered || !wildcard_covered) {
0 0 if (wildcard_type_covered || !wildcard_covered) {
1592 0 0 if (match) {
1599 0 0 if (packet_rcode == LDNS_RCODE_NXDOMAIN) {
1604 0 0 if(!closest_encloser) {
1612 0 0 for (i = 0; i < ldns_rr_list_rr_count(nsecs); i++) {
1619 0 0 if (ldns_nsec_covers_name(ldns_rr_list_rr(nsecs, i),
1622 0 0 if (match) {
1629 0 0 if (! wildcard_covered) {
1637 0 0 } else if (packet_nodata && packet_qtype != LDNS_RR_TYPE_DS) {
0 0 } else if (packet_nodata && packet_qtype != LDNS_RR_TYPE_DS) {
1643 0 0 for (i = 0; i < ldns_rr_list_rr_count(nsecs); i++) {
1644 0 0 if (ldns_dname_compare(hashed_name,
1647 0 0 if (!ldns_nsec_bitmap_covers_type(
1650 0 0 &&
1655 0 0 if (match) {
1668 0 0 if(!closest_encloser) {
1674 0 0 for (i = 0; i < ldns_rr_list_rr_count(nsecs); i++) {
1680 0 0 if (ldns_dname_compare(hashed_wildcard_name,
1683 0 0 if (!ldns_nsec_bitmap_covers_type(
1686 0 0 &&
1691 0 0 if (match) {
1697 0 0 if (result == LDNS_STATUS_OK) {
1703 0 0 } else if (packet_nodata && packet_qtype == LDNS_RR_TYPE_DS) {
0 0 } else if (packet_nodata && packet_qtype == LDNS_RR_TYPE_DS) {
1711 0 0 for (i = 0; i < ldns_rr_list_rr_count(nsecs); i++) {
1712 0 0 if (ldns_dname_compare(hashed_name,
1716 0 0 if (!ldns_nsec_bitmap_covers_type(
1719 0 0 &&
1724 0 0 if (match) {
1739 0 0 if(!closest_encloser) {
1745 0 0 if (ldns_dname_label_count(closest_encloser) + 1
1767 0 0 for (i = 0; i < ldns_rr_list_rr_count(nsecs); i++) {
1768 0 0 if (ldns_nsec_covers_name(ldns_rr_list_rr(nsecs, i),
1769 0 0 hashed_next_closer) &&
1773 0 0 if (match) {
1779 0 0 if (ldns_dname_label_count(closest_encloser) + 1
1821 0 0 if(keylen != 64) {
1843 0 0 if(!evp_key) {
1866 0 0 if(algo == LDNS_ECDSAP256SHA256) {
1867 0 0 if(keylen != 2*256/8) return NULL;
1869 0 0 } else if(algo == LDNS_ECDSAP384SHA384) {
1870 0 0 if(keylen != 2*384/8) return NULL;
1873 0 0 if(!ec) return NULL;
1874 0 0 if(keylen+1 > sizeof(buf))
1880 0 0 if(!o2i_ECPublicKey(&ec, &pp, (int)keylen+1)) {
1885 0 0 if(!evp_key) {
1889 0 0 if (!EVP_PKEY_assign_EC_KEY(evp_key, ec)) {
1906 0 0 if(!evp_key) {
1910 0 0 if(algo == LDNS_ECDSAP256SHA256)
2014 5 0 if ((rrsig == NULL) || ldns_rr_rd_count(rrsig) < 4) {
0 5 if ((rrsig == NULL) || ldns_rr_rd_count(rrsig) < 4) {
2021 5 5 for(i = 0; i < ldns_rr_list_rr_count(rrset_clone); i++) {
2022 0 5 if (label_count <
2028 0 0 while (label_count < ldns_dname_label_count(wildcard_chopped)) {
2058 0 5 if (rrsig == NULL) {
2061 0 5 if (ldns_rr_rdf(rrsig, 1) == NULL) {
2083 0 5 if (ldns_rr_rdf(rrsig, 8) == NULL) {
2086 0 5 if (ldns_rdf2buffer_wire(rawsig_buf, ldns_rr_rdf(rrsig, 8))
2094 0 0 if (ldns_rr_rdf(rrsig, 8) == NULL) {
2097 0 0 if (ldns_convert_dsa_rrsig_rdf2asn1(
2112 0 0 if (ldns_rr_rdf(rrsig, 8) == NULL) {
2115 0 0 if (ldns_convert_ecdsa_rrsig_rdf2asn1(
2149 0 3 if (expiration - inception < 0) {
2153 0 3 if (((int32_t) now) - inception < 0) {
2157 2 1 if (expiration - ((int32_t) now) < 0) {
2182 0 5 if (ldns_rdf2rr_type(ldns_rr_rrsig_typecovered(rrsig)) !=
2188 0 5 if(result != LDNS_STATUS_OK)
2199 0 5 if (ldns_rrsig2buffer_wire(verify_buf, rrsig) != LDNS_STATUS_OK)
2203 0 5 if(ldns_rr_list2buffer_wire(verify_buf, rrset_clone)
2225 0 8 if (rrsig == NULL) {
2228 0 8 if (ldns_rr_rdf(rrsig, 1) == NULL) {
2234 3 5 if (ldns_calc_keytag(key)
2243 0 3 if (ldns_rr_rdf(key, 3) == NULL) {
2247 0 3 if (ldns_rdf2buffer_wire(key_buf, ldns_rr_rdf(key, 3))
2256 0 3 if (ldns_rr_rdf(key, 2) == NULL) {
2259 3 0 else if (sig_algo == ldns_rdf2native_int8(
2296 0 5 if (!valid)
2300 2 3 if(result != LDNS_STATUS_OK) {
2307 2 1 if(result != LDNS_STATUS_OK) {
2349 0 5 if (!rrset) {
2354 0 5 if (!validkeys) {
2367 0 5 if(result != LDNS_STATUS_OK) {
2376 8 5 for(i = 0; i < ldns_rr_list_rr_count(keys); i++) {
2379 3 5 if (status == LDNS_STATUS_OK) {
2384 0 3 if (!ldns_rr_list_push_rr(validkeys,
2397 5 3 if (result == LDNS_STATUS_CRYPTO_NO_MATCHING_KEYTAG_DNSKEY) {
2407 2 3 if (ldns_rr_list_rr_count(validkeys) == 0) {
2432 0 0 if (!rrset) {
2443 0 0 if(result != LDNS_STATUS_OK) {
2457 0 0 if(result == LDNS_STATUS_OK)
2501 3 0 if (res == 1) {
2503 0 0 } else if (res == 0) {
2552 0 0 if (EVP_PKEY_assign_DSA(evp_key, ldns_key_buf2dsa_raw(key, keylen))) {
2574 3 0 if (EVP_PKEY_assign_RSA(evp_key, ldns_key_buf2rsa_raw(key, keylen))) {
2600 0 0 if (EVP_PKEY_assign_RSA(evp_key, ldns_key_buf2rsa_raw(key, keylen))) {
2635 0 0 if (EVP_PKEY_assign_RSA(evp_key, ldns_key_buf2rsa_raw(key, keylen))) {
2670 0 0 if (EVP_PKEY_assign_RSA(evp_key, ldns_key_buf2rsa_raw(key, keylen))) {