Lines Matching +full:1 +full:k
105 ldns_key_new_frm_fp(ldns_key **k, FILE *fp) in ldns_key_new_frm_fp() argument
107 return ldns_key_new_frm_fp_l(k, fp, NULL); in ldns_key_new_frm_fp()
114 ldns_key *k; in ldns_key_new_frm_engine() local
116 k = ldns_key_new(); in ldns_key_new_frm_engine()
117 if(!k) return LDNS_STATUS_MEM_ERR; in ldns_key_new_frm_engine()
119 k->_key.key = ENGINE_load_private_key(e, key_id, UI_OpenSSL(), NULL); in ldns_key_new_frm_engine()
120 if(!k->_key.key) { in ldns_key_new_frm_engine()
121 ldns_key_free(k); in ldns_key_new_frm_engine()
124 ldns_key_set_algorithm(k, (ldns_signing_algorithm) alg); in ldns_key_new_frm_engine()
125 if (!k->_key.key) { in ldns_key_new_frm_engine()
126 ldns_key_free(k); in ldns_key_new_frm_engine()
130 *key = k; in ldns_key_new_frm_engine()
149 meth = EVP_PKEY_asn1_find_str(NULL, "gost2001", -1); in ldns_key_EVP_load_gost_id()
173 meth = EVP_PKEY_asn1_find_str(&e, "gost2001", -1); in ldns_key_EVP_load_gost_id()
212 sizeof(token), line_nr) == -1) in ldns_key_new_frm_fp_gost_l()
217 sizeof(token)-strlen(token), line_nr) == -1) in ldns_key_new_frm_fp_gost_l()
253 return 1; in ldns_EC_KEY_calc_public()
267 sizeof(token), line_nr) == -1) in ldns_key_new_frm_fp_ecdsa_l()
338 buf[pre_len+i] = pkey[plen-1-i]; */ in ldns_ed25519_priv_raw()
351 sizeof(token), line_nr) == -1) in ldns_key_new_frm_fp_ed25519_l()
390 buf[pre_len+i] = pkey[plen-1-i]; */ in ldns_ed448_priv_raw()
403 sizeof(token), line_nr) == -1) in ldns_key_new_frm_fp_ed448_l()
419 ldns_key *k; in ldns_key_new_frm_fp_l() local
432 k = ldns_key_new(); in ldns_key_new_frm_fp_l()
435 if (!k || !d) { in ldns_key_new_frm_fp_l()
436 ldns_key_free(k); in ldns_key_new_frm_fp_l()
446 * Algorithm: 1 (RSA) in ldns_key_new_frm_fp_l()
451 LDNS_MAX_LINELEN, line_nr) == -1) { in ldns_key_new_frm_fp_l()
453 ldns_key_free(k); in ldns_key_new_frm_fp_l()
458 ldns_key_free(k); in ldns_key_new_frm_fp_l()
466 LDNS_MAX_LINELEN, line_nr) == -1) { in ldns_key_new_frm_fp_l()
468 ldns_key_free(k); in ldns_key_new_frm_fp_l()
473 if (strncmp(d, "1 RSA", 2) == 0) { in ldns_key_new_frm_fp_l()
615 ldns_key_set_algorithm(k, alg); in ldns_key_new_frm_fp_l()
619 ldns_key_free(k); in ldns_key_new_frm_fp_l()
622 ldns_key_assign_rsa_key(k, rsa); in ldns_key_new_frm_fp_l()
628 ldns_key_set_algorithm(k, alg); in ldns_key_new_frm_fp_l()
632 ldns_key_free(k); in ldns_key_new_frm_fp_l()
635 ldns_key_assign_dsa_key(k, dsa); in ldns_key_new_frm_fp_l()
645 ldns_key_set_algorithm(k, alg); in ldns_key_new_frm_fp_l()
649 ldns_key_free(k); in ldns_key_new_frm_fp_l()
652 ldns_key_set_hmac_size(k, hmac_size); in ldns_key_new_frm_fp_l()
653 ldns_key_set_hmac_key(k, hmac); in ldns_key_new_frm_fp_l()
657 ldns_key_set_algorithm(k, alg); in ldns_key_new_frm_fp_l()
660 ldns_key_free(k); in ldns_key_new_frm_fp_l()
663 ldns_key_set_evp_key(k, in ldns_key_new_frm_fp_l()
666 if(!k->_key.key) { in ldns_key_new_frm_fp_l()
667 ldns_key_free(k); in ldns_key_new_frm_fp_l()
676 ldns_key_set_algorithm(k, alg); in ldns_key_new_frm_fp_l()
677 ldns_key_set_evp_key(k, in ldns_key_new_frm_fp_l()
680 if(!k->_key.key) { in ldns_key_new_frm_fp_l()
681 ldns_key_free(k); in ldns_key_new_frm_fp_l()
689 ldns_key_set_algorithm(k, alg); in ldns_key_new_frm_fp_l()
690 ldns_key_set_evp_key(k, in ldns_key_new_frm_fp_l()
693 if(!k->_key.key) { in ldns_key_new_frm_fp_l()
694 ldns_key_free(k); in ldns_key_new_frm_fp_l()
702 ldns_key_set_algorithm(k, alg); in ldns_key_new_frm_fp_l()
703 ldns_key_set_evp_key(k, in ldns_key_new_frm_fp_l()
706 if(!k->_key.key) { in ldns_key_new_frm_fp_l()
707 ldns_key_free(k); in ldns_key_new_frm_fp_l()
714 ldns_key_free(k); in ldns_key_new_frm_fp_l()
717 key_rr = ldns_key2rr(k); in ldns_key_new_frm_fp_l()
718 ldns_key_set_keytag(k, ldns_calc_keytag(key_rr)); in ldns_key_new_frm_fp_l()
722 *key = k; in ldns_key_new_frm_fp_l()
725 ldns_key_free(k); in ldns_key_new_frm_fp_l()
758 * BIGNUM *dmp1; // d mod (p-1) in ldns_key_new_frm_fp_rsa_l()
759 * BIGNUM *dmq1; // d mod (q-1) in ldns_key_new_frm_fp_rsa_l()
760 * BIGNUM *iqmp; // q^-1 mod p in ldns_key_new_frm_fp_rsa_l()
783 if (ldns_fget_keyword_data_l(f, "Modulus", ": ", b, "\n", LDNS_MAX_LINELEN, line_nr) == -1) { in ldns_key_new_frm_fp_rsa_l()
794 …if (ldns_fget_keyword_data_l(f, "PublicExponent", ": ", b, "\n", LDNS_MAX_LINELEN, line_nr) == -1)… in ldns_key_new_frm_fp_rsa_l()
804 …if (ldns_fget_keyword_data_l(f, "PrivateExponent", ": ", b, "\n", LDNS_MAX_LINELEN, line_nr) == -1… in ldns_key_new_frm_fp_rsa_l()
814 if (ldns_fget_keyword_data_l(f, "Prime1", ": ", b, "\n", LDNS_MAX_LINELEN, line_nr) == -1) { in ldns_key_new_frm_fp_rsa_l()
824 if (ldns_fget_keyword_data_l(f, "Prime2", ": ", b, "\n", LDNS_MAX_LINELEN, line_nr) == -1) { in ldns_key_new_frm_fp_rsa_l()
834 if (ldns_fget_keyword_data_l(f, "Exponent1", ": ", b, "\n", LDNS_MAX_LINELEN, line_nr) == -1) { in ldns_key_new_frm_fp_rsa_l()
844 if (ldns_fget_keyword_data_l(f, "Exponent2", ": ", b, "\n", LDNS_MAX_LINELEN, line_nr) == -1) { in ldns_key_new_frm_fp_rsa_l()
854 if (ldns_fget_keyword_data_l(f, "Coefficient", ": ", b, "\n", LDNS_MAX_LINELEN, line_nr) == -1) { in ldns_key_new_frm_fp_rsa_l()
934 if (ldns_fget_keyword_data_l(f, "Primep", ": ", d, "\n", LDNS_MAX_LINELEN, line_nr) == -1) { in ldns_key_new_frm_fp_dsa_l()
945 if (ldns_fget_keyword_data_l(f, "Subprimeq", ": ", d, "\n", LDNS_MAX_LINELEN, line_nr) == -1) { in ldns_key_new_frm_fp_dsa_l()
955 if (ldns_fget_keyword_data_l(f, "Baseg", ": ", d, "\n", LDNS_MAX_LINELEN, line_nr) == -1) { in ldns_key_new_frm_fp_dsa_l()
965 …if (ldns_fget_keyword_data_l(f, "Private_valuex", ": ", d, "\n", LDNS_MAX_LINELEN, line_nr) == -1)… in ldns_key_new_frm_fp_dsa_l()
975 if (ldns_fget_keyword_data_l(f, "Public_valuey", ": ", d, "\n", LDNS_MAX_LINELEN, line_nr) == -1) { in ldns_key_new_frm_fp_dsa_l()
1038 LDNS_MAX_LINELEN, line_nr) == -1 in ldns_key_new_frm_fp_hmac_l()
1085 ldns_key *k; in ldns_key_new_frm_algorithm() local
1104 k = ldns_key_new(); in ldns_key_new_frm_algorithm()
1105 if (!k) { in ldns_key_new_frm_algorithm()
1118 ldns_key_free(k); in ldns_key_new_frm_algorithm()
1122 ldns_key_free(k); in ldns_key_new_frm_algorithm()
1127 ldns_key_free(k); in ldns_key_new_frm_algorithm()
1132 if (EVP_PKEY_keygen(ctx, &k->_key.key) <= 0) { in ldns_key_new_frm_algorithm()
1133 ldns_key_free(k); in ldns_key_new_frm_algorithm()
1142 ldns_key_free(k); in ldns_key_new_frm_algorithm()
1145 if (RSA_check_key(r) != 1) { in ldns_key_new_frm_algorithm()
1146 ldns_key_free(k); in ldns_key_new_frm_algorithm()
1149 ldns_key_set_rsa_key(k, r); in ldns_key_new_frm_algorithm()
1161 ldns_key_free(k); in ldns_key_new_frm_algorithm()
1167 ldns_key_free(k); in ldns_key_new_frm_algorithm()
1172 ldns_key_free(k); in ldns_key_new_frm_algorithm()
1176 if (DSA_generate_key(d) != 1) { in ldns_key_new_frm_algorithm()
1177 ldns_key_free(k); in ldns_key_new_frm_algorithm()
1180 ldns_key_set_dsa_key(k, d); in ldns_key_new_frm_algorithm()
1193 k->_key.key = NULL; in ldns_key_new_frm_algorithm()
1197 ldns_key_set_hmac_size(k, size); in ldns_key_new_frm_algorithm()
1201 ldns_key_free(k); in ldns_key_new_frm_algorithm()
1205 if (RAND_bytes(hmac, (int) size) != 1) { in ldns_key_new_frm_algorithm()
1207 ldns_key_free(k); in ldns_key_new_frm_algorithm()
1221 ldns_key_set_hmac_key(k, hmac); in ldns_key_new_frm_algorithm()
1223 ldns_key_set_flags(k, 0); in ldns_key_new_frm_algorithm()
1227 ldns_key_set_evp_key(k, ldns_gen_gost_key()); in ldns_key_new_frm_algorithm()
1229 if(!k->_key.key) { in ldns_key_new_frm_algorithm()
1230 ldns_key_free(k); in ldns_key_new_frm_algorithm()
1235 ldns_key_free(k); in ldns_key_new_frm_algorithm()
1247 ldns_key_free(k); in ldns_key_new_frm_algorithm()
1251 ldns_key_free(k); in ldns_key_new_frm_algorithm()
1256 k->_key.key = EVP_PKEY_new(); in ldns_key_new_frm_algorithm()
1257 if(!k->_key.key) { in ldns_key_new_frm_algorithm()
1258 ldns_key_free(k); in ldns_key_new_frm_algorithm()
1262 if (!EVP_PKEY_assign_EC_KEY(k->_key.key, ec)) { in ldns_key_new_frm_algorithm()
1263 ldns_key_free(k); in ldns_key_new_frm_algorithm()
1269 ldns_key_free(k); in ldns_key_new_frm_algorithm()
1278 ldns_key_free(k); in ldns_key_new_frm_algorithm()
1282 ldns_key_free(k); in ldns_key_new_frm_algorithm()
1286 if (EVP_PKEY_keygen(ctx, &k->_key.key) <= 0) { in ldns_key_new_frm_algorithm()
1287 ldns_key_free(k); in ldns_key_new_frm_algorithm()
1300 ldns_key_free(k); in ldns_key_new_frm_algorithm()
1304 ldns_key_free(k); in ldns_key_new_frm_algorithm()
1308 if (EVP_PKEY_keygen(ctx, &k->_key.key) <= 0) { in ldns_key_new_frm_algorithm()
1309 ldns_key_free(k); in ldns_key_new_frm_algorithm()
1318 ldns_key_set_algorithm(k, alg); in ldns_key_new_frm_algorithm()
1319 return k; in ldns_key_new_frm_algorithm()
1323 ldns_key_print(FILE *output, const ldns_key *k) in ldns_key_print() argument
1325 char *str = ldns_key2str(k); in ldns_key_print()
1336 ldns_key_set_algorithm(ldns_key *k, ldns_signing_algorithm l) in ldns_key_set_algorithm() argument
1338 k->_alg = l; in ldns_key_set_algorithm()
1342 ldns_key_set_flags(ldns_key *k, uint16_t f) in ldns_key_set_flags() argument
1344 k->_extra.dnssec.flags = f; in ldns_key_set_flags()
1350 ldns_key_set_evp_key(ldns_key *k, EVP_PKEY *e) in ldns_key_set_evp_key() argument
1352 k->_key.key = e; in ldns_key_set_evp_key()
1356 ldns_key_set_rsa_key(ldns_key *k, RSA *r) in ldns_key_set_rsa_key() argument
1360 k->_key.key = key; in ldns_key_set_rsa_key()
1364 ldns_key_set_dsa_key(ldns_key *k, DSA *d) in ldns_key_set_dsa_key() argument
1369 k->_key.key = key; in ldns_key_set_dsa_key()
1371 (void)k; (void)d; in ldns_key_set_dsa_key()
1376 ldns_key_assign_rsa_key(ldns_key *k, RSA *r) in ldns_key_assign_rsa_key() argument
1380 k->_key.key = key; in ldns_key_assign_rsa_key()
1384 ldns_key_assign_dsa_key(ldns_key *k, DSA *d) in ldns_key_assign_dsa_key() argument
1389 k->_key.key = key; in ldns_key_assign_dsa_key()
1391 (void)k; (void)d; in ldns_key_assign_dsa_key()
1398 ldns_key_set_hmac_key(ldns_key *k, unsigned char *hmac) in ldns_key_set_hmac_key() argument
1400 k->_key.hmac.key = hmac; in ldns_key_set_hmac_key()
1404 ldns_key_set_hmac_size(ldns_key *k, size_t hmac_size) in ldns_key_set_hmac_size() argument
1406 k->_key.hmac.size = hmac_size; in ldns_key_set_hmac_size()
1410 ldns_key_set_external_key(ldns_key *k, void *external_key) in ldns_key_set_external_key() argument
1412 k->_key.external_key = external_key; in ldns_key_set_external_key()
1416 ldns_key_set_origttl(ldns_key *k, uint32_t t) in ldns_key_set_origttl() argument
1418 k->_extra.dnssec.orig_ttl = t; in ldns_key_set_origttl()
1422 ldns_key_set_inception(ldns_key *k, uint32_t i) in ldns_key_set_inception() argument
1424 k->_extra.dnssec.inception = i; in ldns_key_set_inception()
1428 ldns_key_set_expiration(ldns_key *k, uint32_t e) in ldns_key_set_expiration() argument
1430 k->_extra.dnssec.expiration = e; in ldns_key_set_expiration()
1434 ldns_key_set_pubkey_owner(ldns_key *k, ldns_rdf *r) in ldns_key_set_pubkey_owner() argument
1436 k->_pubkey_owner = r; in ldns_key_set_pubkey_owner()
1440 ldns_key_set_keytag(ldns_key *k, uint16_t tag) in ldns_key_set_keytag() argument
1442 k->_extra.dnssec.keytag = tag; in ldns_key_set_keytag()
1463 ldns_key_algorithm(const ldns_key *k) in ldns_key_algorithm() argument
1465 return k->_alg; in ldns_key_algorithm()
1469 ldns_key_set_use(ldns_key *k, bool v) in ldns_key_set_use() argument
1471 if (k) { in ldns_key_set_use()
1472 k->_use = v; in ldns_key_set_use()
1477 ldns_key_use(const ldns_key *k) in ldns_key_use() argument
1479 if (k) { in ldns_key_use()
1480 return k->_use; in ldns_key_use()
1488 ldns_key_evp_key(const ldns_key *k) in ldns_key_evp_key() argument
1490 return k->_key.key; in ldns_key_evp_key()
1494 ldns_key_rsa_key(const ldns_key *k) in ldns_key_rsa_key() argument
1496 if (k->_key.key) { in ldns_key_rsa_key()
1497 return EVP_PKEY_get1_RSA(k->_key.key); in ldns_key_rsa_key()
1504 ldns_key_dsa_key(const ldns_key *k) in ldns_key_dsa_key() argument
1507 if (k->_key.key) { in ldns_key_dsa_key()
1508 return EVP_PKEY_get1_DSA(k->_key.key); in ldns_key_dsa_key()
1513 (void)k; in ldns_key_dsa_key()
1521 ldns_key_hmac_key(const ldns_key *k) in ldns_key_hmac_key() argument
1523 if (k->_key.hmac.key) { in ldns_key_hmac_key()
1524 return k->_key.hmac.key; in ldns_key_hmac_key()
1531 ldns_key_hmac_size(const ldns_key *k) in ldns_key_hmac_size() argument
1533 if (k->_key.hmac.size) { in ldns_key_hmac_size()
1534 return k->_key.hmac.size; in ldns_key_hmac_size()
1541 ldns_key_external_key(const ldns_key *k) in ldns_key_external_key() argument
1543 return k->_key.external_key; in ldns_key_external_key()
1547 ldns_key_origttl(const ldns_key *k) in ldns_key_origttl() argument
1549 return k->_extra.dnssec.orig_ttl; in ldns_key_origttl()
1553 ldns_key_flags(const ldns_key *k) in ldns_key_flags() argument
1555 return k->_extra.dnssec.flags; in ldns_key_flags()
1559 ldns_key_inception(const ldns_key *k) in ldns_key_inception() argument
1561 return k->_extra.dnssec.inception; in ldns_key_inception()
1565 ldns_key_expiration(const ldns_key *k) in ldns_key_expiration() argument
1567 return k->_extra.dnssec.expiration; in ldns_key_expiration()
1571 ldns_key_keytag(const ldns_key *k) in ldns_key_keytag() argument
1573 return k->_extra.dnssec.keytag; in ldns_key_keytag()
1577 ldns_key_pubkey_owner(const ldns_key *k) in ldns_key_pubkey_owner() argument
1579 return k->_pubkey_owner; in ldns_key_pubkey_owner()
1609 key_list->_keys, ldns_key *, key_count + 1); in ldns_key_list_push_key()
1618 ldns_key_list_set_key_count(key_list, key_count + 1); in ldns_key_list_push_key()
1641 a = LDNS_XREALLOC(key_list->_keys, ldns_key *, key_count - 1); in ldns_key_list_pop_key()
1646 ldns_key_list_set_key_count(key_list, key_count - 1); in ldns_key_list_pop_key()
1655 ldns_key_rsa2bin(unsigned char *data, RSA *k, uint16_t *size) in ldns_key_rsa2bin() argument
1660 if (!k) { in ldns_key_rsa2bin()
1664 n = k->n; in ldns_key_rsa2bin()
1665 e = k->e; in ldns_key_rsa2bin()
1667 RSA_get0_key(k, &n, &e, NULL); in ldns_key_rsa2bin()
1675 i = BN_bn2bin(e, data + 1); in ldns_key_rsa2bin()
1676 j = BN_bn2bin(n, data + i + 1); in ldns_key_rsa2bin()
1681 ldns_write_uint16(data + 1, (uint16_t) BN_num_bytes(e)); in ldns_key_rsa2bin()
1695 ldns_key_dsa2bin(unsigned char *data, DSA *k, uint16_t *size) in ldns_key_dsa2bin() argument
1701 if (!k) { in ldns_key_dsa2bin()
1707 DSA_get0_pqg(k, &p, &q, &g); in ldns_key_dsa2bin()
1709 p = k->p; q = k->q; g = k->g; in ldns_key_dsa2bin()
1712 DSA_get0_key(k, &pub_key, &priv_key); in ldns_key_dsa2bin()
1714 pub_key = k->pub_key; priv_key = k->priv_key; in ldns_key_dsa2bin()
1731 BN_bn2bin(q, data + 1 ); /* 20 octects */ in ldns_key_dsa2bin()
1742 ldns_key_gost2bin(unsigned char* data, EVP_PKEY* k, uint16_t* size) in ldns_key_gost2bin() argument
1746 if(i2d_PUBKEY(k, &pp) != 37 + 64) { in ldns_key_gost2bin()
1762 ldns_key_ed255192bin(unsigned char* data, EVP_PKEY* k, uint16_t* size) in ldns_key_ed255192bin() argument
1766 if(i2d_PUBKEY(k, &pp) != 12 + 32) { in ldns_key_ed255192bin()
1782 ldns_key_ed4482bin(unsigned char* data, EVP_PKEY* k, uint16_t* size) in ldns_key_ed4482bin() argument
1786 if(i2d_PUBKEY(k, &pp) != 12 + 57) { in ldns_key_ed4482bin()
1803 ldns_key2rr(const ldns_key *k) in ldns_key2rr() argument
1825 if (!k) { in ldns_key2rr()
1830 switch (ldns_key_algorithm(k)) { in ldns_key2rr()
1846 ldns_key_flags(k))); in ldns_key2rr()
1851 if (ldns_key_pubkey_owner(k)) { in ldns_key2rr()
1852 ldns_rr_set_owner(pubkey, ldns_rdf_clone(ldns_key_pubkey_owner(k))); in ldns_key2rr()
1856 switch(ldns_key_algorithm(k)) { in ldns_key2rr()
1863 ldns_native2rdf_int8(LDNS_RDF_TYPE_ALG, ldns_key_algorithm(k))); in ldns_key2rr()
1865 rsa = ldns_key_rsa_key(k); in ldns_key2rr()
1878 internal_data = 1; in ldns_key2rr()
1888 dsa = ldns_key_dsa_key(k); in ldns_key2rr()
1901 internal_data = 1; in ldns_key2rr()
1911 dsa = ldns_key_dsa_key(k); in ldns_key2rr()
1924 internal_data = 1; in ldns_key2rr()
1931 LDNS_RDF_TYPE_ALG, ldns_key_algorithm(k))); in ldns_key2rr()
1939 if (!ldns_key_gost2bin(bin, k->_key.key, &size)) { in ldns_key2rr()
1945 internal_data = 1; in ldns_key2rr()
1955 LDNS_RDF_TYPE_ALG, ldns_key_algorithm(k))); in ldns_key2rr()
1958 ec = EVP_PKEY_get1_EC_KEY(k->_key.key); in ldns_key2rr()
1967 if(size > 1) { in ldns_key2rr()
1973 size -= 1; in ldns_key2rr()
1974 memmove(bin, bin+1, size); in ldns_key2rr()
1979 internal_data = 1; in ldns_key2rr()
1988 LDNS_RDF_TYPE_ALG, ldns_key_algorithm(k))); in ldns_key2rr()
1994 if (!ldns_key_ed255192bin(bin, k->_key.key, &size)) { in ldns_key2rr()
1999 internal_data = 1; in ldns_key2rr()
2005 LDNS_RDF_TYPE_ALG, ldns_key_algorithm(k))); in ldns_key2rr()
2011 if (!ldns_key_ed4482bin(bin, k->_key.key, &size)) { in ldns_key2rr()
2016 internal_data = 1; in ldns_key2rr()
2025 bin = LDNS_XMALLOC(unsigned char, ldns_key_hmac_size(k)); in ldns_key2rr()
2032 ldns_key_algorithm(k))); in ldns_key2rr()
2033 size = ldns_key_hmac_size(k); in ldns_key2rr()
2034 memcpy(bin, ldns_key_hmac_key(k), size); in ldns_key2rr()
2035 internal_data = 1; in ldns_key2rr()
2106 while ((c = fgetc(fp)) && i+1 < LDNS_MAX_PACKETLEN && c != EOF) { in ldns_read_anchor_file()
2142 ldns_buffer_printf(buffer, "K"); in ldns_key_get_file_base_name()
2158 return 1; in ldns_key_algo_supported()