Branch Coverage

src/ldns/keys.c
Criterion Covered Total %
branch 7 336 2.0


line true false branch
50 0 0 if (!key_list) {
65 0 0 if (!newkey) {
98 0 0 if(!k) return LDNS_STATUS_MEM_ERR;
101 0 0 if(!k->_key.key) {
106 0 0 if (!k->_key.key) {
127 1 1 if(gost_id) return gost_id;
131 0 1 if(meth) {
138 1 0 if(!e) {
144 0 1 if(!e) {
148 0 1 if(!ENGINE_set_default(e, ENGINE_METHOD_ALL)) {
155 0 1 if(!meth) {
171 0 0 if(ldns_gost_engine) {
189 0 0 if(!gost_id)
192 0 0 if (ldns_fget_keyword_data_l(fp, "GostAsn1", ": ", token, "\n",
195 0 0 while(strlen(token) < 96) {
197 0 0 if(ldns_fget_token_l(fp, token+strlen(token), "\n",
201 0 0 if(ldns_str2rdf_b64(&b64rdf, token) != LDNS_STATUS_OK)
219 0 0 if(!pub_key) return 0;
220 0 0 if(!EC_POINT_copy(pub_key, EC_GROUP_get0_generator(group))) {
224 0 0 if(!EC_POINT_mul(group, pub_key, EC_KEY_get0_private_key(ec),
229 0 0 if(EC_KEY_set_public_key(ec, pub_key) == 0) {
247 0 0 if (ldns_fget_keyword_data_l(fp, "PrivateKey", ": ", token, "\n",
250 0 0 if(ldns_str2rdf_b64(&b64rdf, token) != LDNS_STATUS_OK)
254 0 0 if(alg == LDNS_ECDSAP256SHA256)
256 0 0 else if(alg == LDNS_ECDSAP384SHA384)
259 0 0 if(!ec) {
265 0 0 if(!bn) {
271 0 0 if(!ldns_EC_KEY_calc_public(ec)) {
277 0 0 if(!evp_key) {
281 0 0 if (!EVP_PKEY_assign_EC_KEY(evp_key, ec)) {
307 0 0 if (!k || !d) {
0 0 if (!k || !d) {
322 0 0 if (ldns_fget_keyword_data_l(fp, "Private-key-format", ": ", d, "\n",
329 0 0 if (strncmp(d, "v1.", 3) != 0) {
337 0 0 if (ldns_fget_keyword_data_l(fp, "Algorithm", ": ", d, "\n",
345 0 0 if (strncmp(d, "1 RSA", 2) == 0) {
348 0 0 if (strncmp(d, "2 DH", 2) == 0) {
351 0 0 if (strncmp(d, "3 DSA", 2) == 0) {
354 0 0 if (strncmp(d, "4 ECC", 2) == 0) {
357 0 0 if (strncmp(d, "5 RSASHA1", 2) == 0) {
360 0 0 if (strncmp(d, "6 DSA", 2) == 0) {
363 0 0 if (strncmp(d, "7 RSASHA1", 2) == 0) {
367 0 0 if (strncmp(d, "8 RSASHA256", 2) == 0) {
377 0 0 if (strncmp(d, "10 RSASHA512", 3) == 0) {
387 0 0 if (strncmp(d, "12 ECC-GOST", 3) == 0) {
397 0 0 if (strncmp(d, "13 ECDSAP256SHA256", 3) == 0) {
407 0 0 if (strncmp(d, "14 ECDSAP384SHA384", 3) == 0) {
417 0 0 if (strncmp(d, "157 HMAC-MD5", 4) == 0) {
420 0 0 if (strncmp(d, "158 HMAC-SHA1", 4) == 0) {
423 0 0 if (strncmp(d, "159 HMAC-SHA256", 4) == 0) {
440 0 0 if (!rsa) {
452 0 0 if (!dsa) {
465 0 0 if (!hmac) {
476 0 0 if(!ldns_key_EVP_load_gost_id()) {
483 0 0 if(!k->_key.key) {
497 0 0 if(!k->_key.key) {
512 0 0 if (key) {
563 0 0 if (!d || !rsa || !buf) {
0 0 if (!d || !rsa || !buf) {
0 0 if (!d || !rsa || !buf) {
572 0 0 if (ldns_fget_keyword_data_l(f, "Modulus", ": ", d, "\n", LDNS_MAX_LINELEN, line_nr) == -1) {
578 0 0 if (!rsa->n) {
583 0 0 if (ldns_fget_keyword_data_l(f, "PublicExponent", ": ", d, "\n", LDNS_MAX_LINELEN, line_nr) == -1) {
588 0 0 if (!rsa->e) {
593 0 0 if (ldns_fget_keyword_data_l(f, "PrivateExponent", ": ", d, "\n", LDNS_MAX_LINELEN, line_nr) == -1) {
598 0 0 if (!rsa->d) {
603 0 0 if (ldns_fget_keyword_data_l(f, "Prime1", ": ", d, "\n", LDNS_MAX_LINELEN, line_nr) == -1) {
608 0 0 if (!rsa->p) {
613 0 0 if (ldns_fget_keyword_data_l(f, "Prime2", ": ", d, "\n", LDNS_MAX_LINELEN, line_nr) == -1) {
618 0 0 if (!rsa->q) {
623 0 0 if (ldns_fget_keyword_data_l(f, "Exponent1", ": ", d, "\n", LDNS_MAX_LINELEN, line_nr) == -1) {
628 0 0 if (!rsa->dmp1) {
633 0 0 if (ldns_fget_keyword_data_l(f, "Exponent2", ": ", d, "\n", LDNS_MAX_LINELEN, line_nr) == -1) {
638 0 0 if (!rsa->dmq1) {
643 0 0 if (ldns_fget_keyword_data_l(f, "Coefficient", ": ", d, "\n", LDNS_MAX_LINELEN, line_nr) == -1) {
648 0 0 if (!rsa->iqmp) {
681 0 0 if (!d || !dsa || !buf) {
0 0 if (!d || !dsa || !buf) {
0 0 if (!d || !dsa || !buf) {
688 0 0 if (ldns_fget_keyword_data_l(f, "Primep", ": ", d, "\n", LDNS_MAX_LINELEN, line_nr) == -1) {
694 0 0 if (!dsa->p) {
699 0 0 if (ldns_fget_keyword_data_l(f, "Subprimeq", ": ", d, "\n", LDNS_MAX_LINELEN, line_nr) == -1) {
704 0 0 if (!dsa->q) {
709 0 0 if (ldns_fget_keyword_data_l(f, "Baseg", ": ", d, "\n", LDNS_MAX_LINELEN, line_nr) == -1) {
714 0 0 if (!dsa->g) {
719 0 0 if (ldns_fget_keyword_data_l(f, "Private_valuex", ": ", d, "\n", LDNS_MAX_LINELEN, line_nr) == -1) {
724 0 0 if (!dsa->priv_key) {
729 0 0 if (ldns_fget_keyword_data_l(f, "Public_valuey", ": ", d, "\n", LDNS_MAX_LINELEN, line_nr) == -1) {
734 0 0 if (!dsa->pub_key) {
767 0 0 if (ldns_fget_keyword_data_l(f, "Key", ": ", d, "\n", LDNS_MAX_LINELEN, line_nr) == -1) {
791 0 0 if(!gost_id)
794 0 0 if(!ctx) {
798 0 0 if(EVP_PKEY_CTX_ctrl_str(ctx, "paramset", "A") <= 0) {
804 0 0 if(EVP_PKEY_keygen_init(ctx) <= 0) {
808 0 0 if(EVP_PKEY_keygen(ctx, &p) <= 0) {
835 0 0 if (!k) {
846 0 0 if(!r) {
850 0 0 if (RSA_check_key(r) != 1) {
862 0 0 if (!d) {
866 0 0 if (DSA_generate_key(d) != 1) {
886 0 0 if(!hmac) {
891 0 0 if (RAND_bytes(hmac, (int) size) != 1) {
915 0 0 if(!k->_key.key) {
928 0 0 if(alg == LDNS_SIGN_ECDSAP256SHA256)
930 0 0 else if(alg == LDNS_SIGN_ECDSAP384SHA384)
932 0 0 if(!ec) {
936 0 0 if(!EC_KEY_generate_key(ec)) {
943 0 0 if(!k->_key.key) {
948 0 0 if (!EVP_PKEY_assign_EC_KEY(k->_key.key, ec)) {
968 0 0 if (str) {
1089 0 0 if (nr < ldns_key_list_key_count(key)) {
1105 0 0 if (k) {
1113 0 0 if (k) {
1130 0 0 if (k->_key.key) {
1140 0 0 if (k->_key.key) {
1152 0 0 if (k->_key.hmac.key) {
1162 0 0 if (k->_key.hmac.size) {
1217 0 0 for (i = 0; i < ldns_key_list_key_count(keys); i++) {
1239 0 0 if (!keys) {
1258 0 0 if (!key_list) {
1263 0 0 if (key_count == 0) {
1271 0 0 if(a) {
1288 0 0 if (!k) {
1292 0 0 if (BN_num_bytes(k->e) <= 256) {
1300 0 0 } else if (BN_num_bytes(k->e) <= 65536) {
1320 0 0 if (!k) {
1328 0 0 if (T > 8) {
1353 0 0 if(i2d_PUBKEY(k, &pp) != 37 + 64) {
1359 0 0 for(i=0; i<64; i++)
1390 0 0 if (!k) {
1395 0 0 switch (ldns_key_algorithm(k)) {
1413 0 0 if (ldns_key_pubkey_owner(k)) {
1428 0 0 if (rsa) {
1430 0 0 if (!bin) {
1434 0 0 if (!ldns_key_rsa2bin(bin, rsa, &size)) {
1450 0 0 if (dsa) {
1452 0 0 if (!bin) {
1456 0 0 if (!ldns_key_dsa2bin(bin, dsa, &size)) {
1471 0 0 if (dsa) {
1473 0 0 if (!bin) {
1477 0 0 if (!ldns_key_dsa2bin(bin, dsa, &size)) {
1492 0 0 if (!bin) {
1497 0 0 if (!ldns_key_gost2bin(bin, k->_key.key, &size)) {
1520 0 0 if(!i2o_ECPublicKey(ec, &bin)) {
1525 0 0 if(size > 1) {
1547 0 0 if (!bin) {
1560 0 0 if (internal_data) {
1578 0 0 if (ldns_key_pubkey_owner(key)) {
1582 0 0 if (ldns_key_evp_key(key)) {
1586 0 0 if (ldns_key_hmac_key(key)) {
1597 0 0 for (i = 0; i < ldns_key_list_key_count(key_list); i++) {
1614 0 0 if(!line) {
1619 0 0 if (!fp) {
1627 0 0 while ((c = fgetc(fp)) && i+1 < LDNS_MAX_PACKETLEN && c != EOF) {
0 0 while ((c = fgetc(fp)) && i+1 < LDNS_MAX_PACKETLEN && c != EOF) {
0 0 while ((c = fgetc(fp)) && i+1 < LDNS_MAX_PACKETLEN && c != EOF) {
1635 0 0 if (i <= 0) {
1643 0 0 if (status == LDNS_STATUS_OK && (ldns_rr_get_type(r) == LDNS_RR_TYPE_DNSKEY || ldns_rr_get_type(r) == LDNS_RR_TYPE_DS)) {
0 0 if (status == LDNS_STATUS_OK && (ldns_rr_get_type(r) == LDNS_RR_TYPE_DNSKEY || ldns_rr_get_type(r) == LDNS_RR_TYPE_DS)) {
0 0 if (status == LDNS_STATUS_OK && (ldns_rr_get_type(r) == LDNS_RR_TYPE_DNSKEY || ldns_rr_get_type(r) == LDNS_RR_TYPE_DS)) {
1677 0 0 while(lt->name) {
1678 0 0 if(lt->id == algo)
1710 0 0 while(lt->name) {
1711 0 0 if(strcasecmp(lt->name, name) == 0)
1716 0 0 while(lt->name) {
1717 0 0 if(strcasecmp(lt->name, name) == 0)
1722 0 0 if (*name && !*endptr)
0 0 if (*name && !*endptr)