Lines Matching refs:key

50 static isc_result_t hmacmd5_fromdns(dst_key_t *key, isc_buffer_t *data);
53 unsigned char key[ISC_MD5_BLOCK_LENGTH];
58 getkeybits(dst_key_t *key, struct dst_private_element *element) {
63 key->key_bits = (element->data[0] << 8) + element->data[1];
70 hmacmd5_createctx(dst_key_t *key, dst_context_t *dctx) {
72 dst_hmacmd5_key_t *hkey = key->keydata.hmacmd5;
77 isc_hmacmd5_init(hmacmd5ctx, hkey->key, ISC_MD5_BLOCK_LENGTH);
140 if (isc_safe_memequal(hkey1->key, hkey2->key, ISC_MD5_BLOCK_LENGTH))
147 hmacmd5_generate(dst_key_t *key, int pseudorandom_ok, void (*callback)(int)) {
155 bytes = (key->key_size + 7) / 8;
158 key->key_size = ISC_MD5_BLOCK_LENGTH * 8;
169 ret = hmacmd5_fromdns(key, &b);
176 hmacmd5_isprivate(const dst_key_t *key) {
177 UNUSED(key);
182 hmacmd5_destroy(dst_key_t *key) {
183 dst_hmacmd5_key_t *hkey = key->keydata.hmacmd5;
186 isc_mem_put(key->mctx, hkey, sizeof(*hkey));
187 key->keydata.hmacmd5 = NULL;
191 hmacmd5_todns(const dst_key_t *key, isc_buffer_t *data) {
195 REQUIRE(key->keydata.hmacmd5 != NULL);
197 hkey = key->keydata.hmacmd5;
199 bytes = (key->key_size + 7) / 8;
202 isc_buffer_putmem(data, hkey->key, bytes);
208 hmacmd5_fromdns(dst_key_t *key, isc_buffer_t *data) {
218 hkey = isc_mem_get(key->mctx, sizeof(dst_hmacmd5_key_t));
222 memset(hkey->key, 0, sizeof(hkey->key));
227 isc_md5_final(&md5ctx, hkey->key);
230 memmove(hkey->key, r.base, r.length);
234 key->key_size = keylen * 8;
235 key->keydata.hmacmd5 = hkey;
243 hmacmd5_tofile(const dst_key_t *key, const char *directory) {
247 int bytes = (key->key_size + 7) / 8;
250 if (key->keydata.hmacmd5 == NULL)
253 if (key->external)
256 hkey = key->keydata.hmacmd5;
260 priv.elements[cnt++].data = hkey->key;
262 buf[0] = (key->key_bits >> 8) & 0xffU;
263 buf[1] = key->key_bits & 0xffU;
269 return (dst__privstruct_writefile(key, &priv, directory));
273 hmacmd5_parse(dst_key_t *key, isc_lex_t *lexer, dst_key_t *pub) {
277 isc_mem_t *mctx = key->mctx;
281 /* read private key file */
282 result = dst__privstruct_parse(key, DST_ALG_HMACMD5, lexer, mctx,
287 if (key->external)
290 key->key_bits = 0;
297 tresult = hmacmd5_fromdns(key, &b);
302 tresult = getkeybits(key, &priv.elements[i]);
371 static isc_result_t hmacsha1_fromdns(dst_key_t *key, isc_buffer_t *data);
374 unsigned char key[ISC_SHA1_BLOCK_LENGTH];
378 hmacsha1_createctx(dst_key_t *key, dst_context_t *dctx) {
380 dst_hmacsha1_key_t *hkey = key->keydata.hmacsha1;
385 isc_hmacsha1_init(hmacsha1ctx, hkey->key, ISC_SHA1_BLOCK_LENGTH);
448 if (isc_safe_memequal(hkey1->key, hkey2->key, ISC_SHA1_BLOCK_LENGTH))
455 hmacsha1_generate(dst_key_t *key, int pseudorandom_ok, void (*callback)(int)) {
463 bytes = (key->key_size + 7) / 8;
466 key->key_size = ISC_SHA1_BLOCK_LENGTH * 8;
477 ret = hmacsha1_fromdns(key, &b);
484 hmacsha1_isprivate(const dst_key_t *key) {
485 UNUSED(key);
490 hmacsha1_destroy(dst_key_t *key) {
491 dst_hmacsha1_key_t *hkey = key->keydata.hmacsha1;
494 isc_mem_put(key->mctx, hkey, sizeof(*hkey));
495 key->keydata.hmacsha1 = NULL;
499 hmacsha1_todns(const dst_key_t *key, isc_buffer_t *data) {
503 REQUIRE(key->keydata.hmacsha1 != NULL);
505 hkey = key->keydata.hmacsha1;
507 bytes = (key->key_size + 7) / 8;
510 isc_buffer_putmem(data, hkey->key, bytes);
516 hmacsha1_fromdns(dst_key_t *key, isc_buffer_t *data) {
526 hkey = isc_mem_get(key->mctx, sizeof(dst_hmacsha1_key_t));
530 memset(hkey->key, 0, sizeof(hkey->key));
535 isc_sha1_final(&sha1ctx, hkey->key);
538 memmove(hkey->key, r.base, r.length);
542 key->key_size = keylen * 8;
543 key->keydata.hmacsha1 = hkey;
551 hmacsha1_tofile(const dst_key_t *key, const char *directory) {
555 int bytes = (key->key_size + 7) / 8;
558 if (key->keydata.hmacsha1 == NULL)
561 if (key->external)
564 hkey = key->keydata.hmacsha1;
568 priv.elements[cnt++].data = hkey->key;
570 buf[0] = (key->key_bits >> 8) & 0xffU;
571 buf[1] = key->key_bits & 0xffU;
577 return (dst__privstruct_writefile(key, &priv, directory));
581 hmacsha1_parse(dst_key_t *key, isc_lex_t *lexer, dst_key_t *pub) {
585 isc_mem_t *mctx = key->mctx;
589 /* read private key file */
590 result = dst__privstruct_parse(key, DST_ALG_HMACSHA1, lexer, mctx,
595 if (key->external)
598 key->key_bits = 0;
605 tresult = hmacsha1_fromdns(key, &b);
610 tresult = getkeybits(key, &priv.elements[i]);
662 static isc_result_t hmacsha224_fromdns(dst_key_t *key, isc_buffer_t *data);
665 unsigned char key[ISC_SHA224_BLOCK_LENGTH];
669 hmacsha224_createctx(dst_key_t *key, dst_context_t *dctx) {
671 dst_hmacsha224_key_t *hkey = key->keydata.hmacsha224;
676 isc_hmacsha224_init(hmacsha224ctx, hkey->key, ISC_SHA224_BLOCK_LENGTH);
739 if (isc_safe_memequal(hkey1->key, hkey2->key, ISC_SHA224_BLOCK_LENGTH))
746 hmacsha224_generate(dst_key_t *key, int pseudorandom_ok,
756 bytes = (key->key_size + 7) / 8;
759 key->key_size = ISC_SHA224_BLOCK_LENGTH * 8;
770 ret = hmacsha224_fromdns(key, &b);
777 hmacsha224_isprivate(const dst_key_t *key) {
778 UNUSED(key);
783 hmacsha224_destroy(dst_key_t *key) {
784 dst_hmacsha224_key_t *hkey = key->keydata.hmacsha224;
787 isc_mem_put(key->mctx, hkey, sizeof(*hkey));
788 key->keydata.hmacsha224 = NULL;
792 hmacsha224_todns(const dst_key_t *key, isc_buffer_t *data) {
796 REQUIRE(key->keydata.hmacsha224 != NULL);
798 hkey = key->keydata.hmacsha224;
800 bytes = (key->key_size + 7) / 8;
803 isc_buffer_putmem(data, hkey->key, bytes);
809 hmacsha224_fromdns(dst_key_t *key, isc_buffer_t *data) {
819 hkey = isc_mem_get(key->mctx, sizeof(dst_hmacsha224_key_t));
823 memset(hkey->key, 0, sizeof(hkey->key));
828 isc_sha224_final(hkey->key, &sha224ctx);
831 memmove(hkey->key, r.base, r.length);
835 key->key_size = keylen * 8;
836 key->keydata.hmacsha224 = hkey;
844 hmacsha224_tofile(const dst_key_t *key, const char *directory) {
848 int bytes = (key->key_size + 7) / 8;
851 if (key->keydata.hmacsha224 == NULL)
854 if (key->external)
857 hkey = key->keydata.hmacsha224;
861 priv.elements[cnt++].data = hkey->key;
863 buf[0] = (key->key_bits >> 8) & 0xffU;
864 buf[1] = key->key_bits & 0xffU;
870 return (dst__privstruct_writefile(key, &priv, directory));
874 hmacsha224_parse(dst_key_t *key, isc_lex_t *lexer, dst_key_t *pub) {
878 isc_mem_t *mctx = key->mctx;
882 /* read private key file */
883 result = dst__privstruct_parse(key, DST_ALG_HMACSHA224, lexer, mctx,
888 if (key->external)
891 key->key_bits = 0;
898 tresult = hmacsha224_fromdns(key, &b);
903 tresult = getkeybits(key, &priv.elements[i]);
949 static isc_result_t hmacsha256_fromdns(dst_key_t *key, isc_buffer_t *data);
952 unsigned char key[ISC_SHA256_BLOCK_LENGTH];
956 hmacsha256_createctx(dst_key_t *key, dst_context_t *dctx) {
958 dst_hmacsha256_key_t *hkey = key->keydata.hmacsha256;
963 isc_hmacsha256_init(hmacsha256ctx, hkey->key, ISC_SHA256_BLOCK_LENGTH);
1026 if (isc_safe_memequal(hkey1->key, hkey2->key, ISC_SHA256_BLOCK_LENGTH))
1033 hmacsha256_generate(dst_key_t *key, int pseudorandom_ok,
1043 bytes = (key->key_size + 7) / 8;
1046 key->key_size = ISC_SHA256_BLOCK_LENGTH * 8;
1057 ret = hmacsha256_fromdns(key, &b);
1064 hmacsha256_isprivate(const dst_key_t *key) {
1065 UNUSED(key);
1070 hmacsha256_destroy(dst_key_t *key) {
1071 dst_hmacsha256_key_t *hkey = key->keydata.hmacsha256;
1074 isc_mem_put(key->mctx, hkey, sizeof(*hkey));
1075 key->keydata.hmacsha256 = NULL;
1079 hmacsha256_todns(const dst_key_t *key, isc_buffer_t *data) {
1083 REQUIRE(key->keydata.hmacsha256 != NULL);
1085 hkey = key->keydata.hmacsha256;
1087 bytes = (key->key_size + 7) / 8;
1090 isc_buffer_putmem(data, hkey->key, bytes);
1096 hmacsha256_fromdns(dst_key_t *key, isc_buffer_t *data) {
1106 hkey = isc_mem_get(key->mctx, sizeof(dst_hmacsha256_key_t));
1110 memset(hkey->key, 0, sizeof(hkey->key));
1115 isc_sha256_final(hkey->key, &sha256ctx);
1118 memmove(hkey->key, r.base, r.length);
1122 key->key_size = keylen * 8;
1123 key->keydata.hmacsha256 = hkey;
1131 hmacsha256_tofile(const dst_key_t *key, const char *directory) {
1135 int bytes = (key->key_size + 7) / 8;
1138 if (key->keydata.hmacsha256 == NULL)
1141 if (key->external)
1144 hkey = key->keydata.hmacsha256;
1148 priv.elements[cnt++].data = hkey->key;
1150 buf[0] = (key->key_bits >> 8) & 0xffU;
1151 buf[1] = key->key_bits & 0xffU;
1157 return (dst__privstruct_writefile(key, &priv, directory));
1161 hmacsha256_parse(dst_key_t *key, isc_lex_t *lexer, dst_key_t *pub) {
1165 isc_mem_t *mctx = key->mctx;
1169 /* read private key file */
1170 result = dst__privstruct_parse(key, DST_ALG_HMACSHA256, lexer, mctx,
1175 if (key->external)
1178 key->key_bits = 0;
1185 tresult = hmacsha256_fromdns(key, &b);
1190 tresult = getkeybits(key, &priv.elements[i]);
1236 static isc_result_t hmacsha384_fromdns(dst_key_t *key, isc_buffer_t *data);
1239 unsigned char key[ISC_SHA384_BLOCK_LENGTH];
1243 hmacsha384_createctx(dst_key_t *key, dst_context_t *dctx) {
1245 dst_hmacsha384_key_t *hkey = key->keydata.hmacsha384;
1250 isc_hmacsha384_init(hmacsha384ctx, hkey->key, ISC_SHA384_BLOCK_LENGTH);
1313 if (isc_safe_memequal(hkey1->key, hkey2->key, ISC_SHA384_BLOCK_LENGTH))
1320 hmacsha384_generate(dst_key_t *key, int pseudorandom_ok,
1330 bytes = (key->key_size + 7) / 8;
1333 key->key_size = ISC_SHA384_BLOCK_LENGTH * 8;
1344 ret = hmacsha384_fromdns(key, &b);
1351 hmacsha384_isprivate(const dst_key_t *key) {
1352 UNUSED(key);
1357 hmacsha384_destroy(dst_key_t *key) {
1358 dst_hmacsha384_key_t *hkey = key->keydata.hmacsha384;
1361 isc_mem_put(key->mctx, hkey, sizeof(*hkey));
1362 key->keydata.hmacsha384 = NULL;
1366 hmacsha384_todns(const dst_key_t *key, isc_buffer_t *data) {
1370 REQUIRE(key->keydata.hmacsha384 != NULL);
1372 hkey = key->keydata.hmacsha384;
1374 bytes = (key->key_size + 7) / 8;
1377 isc_buffer_putmem(data, hkey->key, bytes);
1383 hmacsha384_fromdns(dst_key_t *key, isc_buffer_t *data) {
1393 hkey = isc_mem_get(key->mctx, sizeof(dst_hmacsha384_key_t));
1397 memset(hkey->key, 0, sizeof(hkey->key));
1402 isc_sha384_final(hkey->key, &sha384ctx);
1405 memmove(hkey->key, r.base, r.length);
1409 key->key_size = keylen * 8;
1410 key->keydata.hmacsha384 = hkey;
1418 hmacsha384_tofile(const dst_key_t *key, const char *directory) {
1422 int bytes = (key->key_size + 7) / 8;
1425 if (key->keydata.hmacsha384 == NULL)
1428 if (key->external)
1431 hkey = key->keydata.hmacsha384;
1435 priv.elements[cnt++].data = hkey->key;
1437 buf[0] = (key->key_bits >> 8) & 0xffU;
1438 buf[1] = key->key_bits & 0xffU;
1444 return (dst__privstruct_writefile(key, &priv, directory));
1448 hmacsha384_parse(dst_key_t *key, isc_lex_t *lexer, dst_key_t *pub) {
1452 isc_mem_t *mctx = key->mctx;
1456 /* read private key file */
1457 result = dst__privstruct_parse(key, DST_ALG_HMACSHA384, lexer, mctx,
1462 if (key->external)
1465 key->key_bits = 0;
1472 tresult = hmacsha384_fromdns(key, &b);
1477 tresult = getkeybits(key, &priv.elements[i]);
1523 static isc_result_t hmacsha512_fromdns(dst_key_t *key, isc_buffer_t *data);
1526 unsigned char key[ISC_SHA512_BLOCK_LENGTH];
1530 hmacsha512_createctx(dst_key_t *key, dst_context_t *dctx) {
1532 dst_hmacsha512_key_t *hkey = key->keydata.hmacsha512;
1537 isc_hmacsha512_init(hmacsha512ctx, hkey->key, ISC_SHA512_BLOCK_LENGTH);
1600 if (isc_safe_memequal(hkey1->key, hkey2->key, ISC_SHA512_BLOCK_LENGTH))
1607 hmacsha512_generate(dst_key_t *key, int pseudorandom_ok,
1617 bytes = (key->key_size + 7) / 8;
1620 key->key_size = ISC_SHA512_BLOCK_LENGTH * 8;
1631 ret = hmacsha512_fromdns(key, &b);
1638 hmacsha512_isprivate(const dst_key_t *key) {
1639 UNUSED(key);
1644 hmacsha512_destroy(dst_key_t *key) {
1645 dst_hmacsha512_key_t *hkey = key->keydata.hmacsha512;
1648 isc_mem_put(key->mctx, hkey, sizeof(*hkey));
1649 key->keydata.hmacsha512 = NULL;
1653 hmacsha512_todns(const dst_key_t *key, isc_buffer_t *data) {
1657 REQUIRE(key->keydata.hmacsha512 != NULL);
1659 hkey = key->keydata.hmacsha512;
1661 bytes = (key->key_size + 7) / 8;
1664 isc_buffer_putmem(data, hkey->key, bytes);
1670 hmacsha512_fromdns(dst_key_t *key, isc_buffer_t *data) {
1680 hkey = isc_mem_get(key->mctx, sizeof(dst_hmacsha512_key_t));
1684 memset(hkey->key, 0, sizeof(hkey->key));
1689 isc_sha512_final(hkey->key, &sha512ctx);
1692 memmove(hkey->key, r.base, r.length);
1696 key->key_size = keylen * 8;
1697 key->keydata.hmacsha512 = hkey;
1705 hmacsha512_tofile(const dst_key_t *key, const char *directory) {
1709 int bytes = (key->key_size + 7) / 8;
1712 if (key->keydata.hmacsha512 == NULL)
1715 if (key->external)
1718 hkey = key->keydata.hmacsha512;
1722 priv.elements[cnt++].data = hkey->key;
1724 buf[0] = (key->key_bits >> 8) & 0xffU;
1725 buf[1] = key->key_bits & 0xffU;
1731 return (dst__privstruct_writefile(key, &priv, directory));
1735 hmacsha512_parse(dst_key_t *key, isc_lex_t *lexer, dst_key_t *pub) {
1739 isc_mem_t *mctx = key->mctx;
1743 /* read private key file */
1744 result = dst__privstruct_parse(key, DST_ALG_HMACSHA512, lexer, mctx,
1749 if (key->external)
1752 key->key_bits = 0;
1759 tresult = hmacsha512_fromdns(key, &b);
1764 tresult = getkeybits(key, &priv.elements[i]);