Lines Matching refs:key

58 static isc_result_t hmacmd5_fromdns(dst_key_t *key, isc_buffer_t *data);
61 unsigned char key[HMAC_LEN];
65 getkeybits(dst_key_t *key, struct dst_private_element *element) {
70 key->key_bits = (element->data[0] << 8) + element->data[1];
76 hmacmd5_createctx(dst_key_t *key, dst_context_t *dctx) {
78 dst_hmacmd5_key_t *hkey = key->keydata.hmacmd5;
83 isc_hmacmd5_init(hmacmd5ctx, hkey->key, HMAC_LEN);
146 if (isc_safe_memcmp(hkey1->key, hkey2->key, HMAC_LEN))
153 hmacmd5_generate(dst_key_t *key, int pseudorandom_ok) {
159 bytes = (key->key_size + 7) / 8;
162 key->key_size = HMAC_LEN * 8;
173 ret = hmacmd5_fromdns(key, &b);
180 hmacmd5_isprivate(const dst_key_t *key) {
181 UNUSED(key);
186 hmacmd5_destroy(dst_key_t *key) {
187 dst_hmacmd5_key_t *hkey = key->keydata.hmacmd5;
189 isc_mem_put(key->mctx, hkey, sizeof(dst_hmacmd5_key_t));
190 key->keydata.hmacmd5 = NULL;
194 hmacmd5_todns(const dst_key_t *key, isc_buffer_t *data) {
198 REQUIRE(key->keydata.hmacmd5 != NULL);
200 hkey = key->keydata.hmacmd5;
202 bytes = (key->key_size + 7) / 8;
205 isc_buffer_putmem(data, hkey->key, bytes);
211 hmacmd5_fromdns(dst_key_t *key, isc_buffer_t *data) {
221 hkey = isc_mem_get(key->mctx, sizeof(dst_hmacmd5_key_t));
225 memset(hkey->key, 0, sizeof(hkey->key));
230 isc_md5_final(&md5ctx, hkey->key);
233 memmove(hkey->key, r.base, r.length);
237 key->key_size = keylen * 8;
238 key->keydata.hmacmd5 = hkey;
244 hmacmd5_tofile(const dst_key_t *key, const char *directory) {
248 int bytes = (key->key_size + 7) / 8;
251 if (key->keydata.hmacmd5 == NULL)
254 hkey = key->keydata.hmacmd5;
258 priv.elements[cnt++].data = hkey->key;
260 buf[0] = (key->key_bits >> 8) & 0xffU;
261 buf[1] = key->key_bits & 0xffU;
267 return (dst__privstruct_writefile(key, &priv, directory));
271 hmacmd5_parse(dst_key_t *key, isc_lex_t *lexer) {
275 isc_mem_t *mctx = key->mctx;
278 /* read private key file */
279 result = dst__privstruct_parse(key, DST_ALG_HMACMD5, lexer, mctx, &priv);
283 key->key_bits = 0;
290 tresult = hmacmd5_fromdns(key, &b);
295 tresult = getkeybits(key, &priv.elements[i]);
337 static isc_result_t hmacsha1_fromdns(dst_key_t *key, isc_buffer_t *data);
340 unsigned char key[ISC_SHA1_DIGESTLENGTH];
344 hmacsha1_createctx(dst_key_t *key, dst_context_t *dctx) {
346 dst_hmacsha1_key_t *hkey = key->keydata.hmacsha1;
351 isc_hmacsha1_init(hmacsha1ctx, hkey->key, ISC_SHA1_DIGESTLENGTH);
414 if (isc_safe_memcmp(hkey1->key, hkey2->key, ISC_SHA1_DIGESTLENGTH))
421 hmacsha1_generate(dst_key_t *key, int pseudorandom_ok) {
427 bytes = (key->key_size + 7) / 8;
430 key->key_size = HMAC_LEN * 8;
441 ret = hmacsha1_fromdns(key, &b);
448 hmacsha1_isprivate(const dst_key_t *key) {
449 UNUSED(key);
454 hmacsha1_destroy(dst_key_t *key) {
455 dst_hmacsha1_key_t *hkey = key->keydata.hmacsha1;
457 isc_mem_put(key->mctx, hkey, sizeof(dst_hmacsha1_key_t));
458 key->keydata.hmacsha1 = NULL;
462 hmacsha1_todns(const dst_key_t *key, isc_buffer_t *data) {
466 REQUIRE(key->keydata.hmacsha1 != NULL);
468 hkey = key->keydata.hmacsha1;
470 bytes = (key->key_size + 7) / 8;
473 isc_buffer_putmem(data, hkey->key, bytes);
479 hmacsha1_fromdns(dst_key_t *key, isc_buffer_t *data) {
489 hkey = isc_mem_get(key->mctx, sizeof(dst_hmacsha1_key_t));
493 memset(hkey->key, 0, sizeof(hkey->key));
498 isc_sha1_final(&sha1ctx, hkey->key);
501 memmove(hkey->key, r.base, r.length);
505 key->key_size = keylen * 8;
506 key->keydata.hmacsha1 = hkey;
512 hmacsha1_tofile(const dst_key_t *key, const char *directory) {
516 int bytes = (key->key_size + 7) / 8;
519 if (key->keydata.hmacsha1 == NULL)
522 hkey = key->keydata.hmacsha1;
526 priv.elements[cnt++].data = hkey->key;
528 buf[0] = (key->key_bits >> 8) & 0xffU;
529 buf[1] = key->key_bits & 0xffU;
535 return (dst__privstruct_writefile(key, &priv, directory));
539 hmacsha1_parse(dst_key_t *key, isc_lex_t *lexer) {
543 isc_mem_t *mctx = key->mctx;
546 /* read private key file */
547 result = dst__privstruct_parse(key, DST_ALG_HMACSHA1, lexer, mctx,
552 key->key_bits = 0;
559 tresult = hmacsha1_fromdns(key, &b);
564 tresult = getkeybits(key, &priv.elements[i]);
606 static isc_result_t hmacsha224_fromdns(dst_key_t *key, isc_buffer_t *data);
609 unsigned char key[ISC_SHA224_DIGESTLENGTH];
613 hmacsha224_createctx(dst_key_t *key, dst_context_t *dctx) {
615 dst_hmacsha224_key_t *hkey = key->keydata.hmacsha224;
620 isc_hmacsha224_init(hmacsha224ctx, hkey->key, ISC_SHA224_DIGESTLENGTH);
683 if (isc_safe_memcmp(hkey1->key, hkey2->key, ISC_SHA224_DIGESTLENGTH))
690 hmacsha224_generate(dst_key_t *key, int pseudorandom_ok) {
696 bytes = (key->key_size + 7) / 8;
699 key->key_size = HMAC_LEN * 8;
710 ret = hmacsha224_fromdns(key, &b);
717 hmacsha224_isprivate(const dst_key_t *key) {
718 UNUSED(key);
723 hmacsha224_destroy(dst_key_t *key) {
724 dst_hmacsha224_key_t *hkey = key->keydata.hmacsha224;
726 isc_mem_put(key->mctx, hkey, sizeof(dst_hmacsha224_key_t));
727 key->keydata.hmacsha224 = NULL;
731 hmacsha224_todns(const dst_key_t *key, isc_buffer_t *data) {
735 REQUIRE(key->keydata.hmacsha224 != NULL);
737 hkey = key->keydata.hmacsha224;
739 bytes = (key->key_size + 7) / 8;
742 isc_buffer_putmem(data, hkey->key, bytes);
748 hmacsha224_fromdns(dst_key_t *key, isc_buffer_t *data) {
758 hkey = isc_mem_get(key->mctx, sizeof(dst_hmacsha224_key_t));
762 memset(hkey->key, 0, sizeof(hkey->key));
767 isc_sha224_final(hkey->key, &sha224ctx);
770 memmove(hkey->key, r.base, r.length);
774 key->key_size = keylen * 8;
775 key->keydata.hmacsha224 = hkey;
781 hmacsha224_tofile(const dst_key_t *key, const char *directory) {
785 int bytes = (key->key_size + 7) / 8;
788 if (key->keydata.hmacsha224 == NULL)
791 hkey = key->keydata.hmacsha224;
795 priv.elements[cnt++].data = hkey->key;
797 buf[0] = (key->key_bits >> 8) & 0xffU;
798 buf[1] = key->key_bits & 0xffU;
804 return (dst__privstruct_writefile(key, &priv, directory));
808 hmacsha224_parse(dst_key_t *key, isc_lex_t *lexer) {
812 isc_mem_t *mctx = key->mctx;
815 /* read private key file */
816 result = dst__privstruct_parse(key, DST_ALG_HMACSHA224, lexer, mctx,
821 key->key_bits = 0;
828 tresult = hmacsha224_fromdns(key, &b);
833 tresult = getkeybits(key, &priv.elements[i]);
875 static isc_result_t hmacsha256_fromdns(dst_key_t *key, isc_buffer_t *data);
878 unsigned char key[ISC_SHA256_DIGESTLENGTH];
882 hmacsha256_createctx(dst_key_t *key, dst_context_t *dctx) {
884 dst_hmacsha256_key_t *hkey = key->keydata.hmacsha256;
889 isc_hmacsha256_init(hmacsha256ctx, hkey->key, ISC_SHA256_DIGESTLENGTH);
952 if (isc_safe_memcmp(hkey1->key, hkey2->key, ISC_SHA256_DIGESTLENGTH))
959 hmacsha256_generate(dst_key_t *key, int pseudorandom_ok) {
965 bytes = (key->key_size + 7) / 8;
968 key->key_size = HMAC_LEN * 8;
979 ret = hmacsha256_fromdns(key, &b);
986 hmacsha256_isprivate(const dst_key_t *key) {
987 UNUSED(key);
992 hmacsha256_destroy(dst_key_t *key) {
993 dst_hmacsha256_key_t *hkey = key->keydata.hmacsha256;
995 isc_mem_put(key->mctx, hkey, sizeof(dst_hmacsha256_key_t));
996 key->keydata.hmacsha256 = NULL;
1000 hmacsha256_todns(const dst_key_t *key, isc_buffer_t *data) {
1004 REQUIRE(key->keydata.hmacsha256 != NULL);
1006 hkey = key->keydata.hmacsha256;
1008 bytes = (key->key_size + 7) / 8;
1011 isc_buffer_putmem(data, hkey->key, bytes);
1017 hmacsha256_fromdns(dst_key_t *key, isc_buffer_t *data) {
1027 hkey = isc_mem_get(key->mctx, sizeof(dst_hmacsha256_key_t));
1031 memset(hkey->key, 0, sizeof(hkey->key));
1036 isc_sha256_final(hkey->key, &sha256ctx);
1039 memmove(hkey->key, r.base, r.length);
1043 key->key_size = keylen * 8;
1044 key->keydata.hmacsha256 = hkey;
1050 hmacsha256_tofile(const dst_key_t *key, const char *directory) {
1054 int bytes = (key->key_size + 7) / 8;
1057 if (key->keydata.hmacsha256 == NULL)
1060 hkey = key->keydata.hmacsha256;
1064 priv.elements[cnt++].data = hkey->key;
1066 buf[0] = (key->key_bits >> 8) & 0xffU;
1067 buf[1] = key->key_bits & 0xffU;
1073 return (dst__privstruct_writefile(key, &priv, directory));
1077 hmacsha256_parse(dst_key_t *key, isc_lex_t *lexer) {
1081 isc_mem_t *mctx = key->mctx;
1084 /* read private key file */
1085 result = dst__privstruct_parse(key, DST_ALG_HMACSHA256, lexer, mctx,
1090 key->key_bits = 0;
1097 tresult = hmacsha256_fromdns(key, &b);
1102 tresult = getkeybits(key, &priv.elements[i]);
1144 static isc_result_t hmacsha384_fromdns(dst_key_t *key, isc_buffer_t *data);
1147 unsigned char key[ISC_SHA384_DIGESTLENGTH];
1151 hmacsha384_createctx(dst_key_t *key, dst_context_t *dctx) {
1153 dst_hmacsha384_key_t *hkey = key->keydata.hmacsha384;
1158 isc_hmacsha384_init(hmacsha384ctx, hkey->key, ISC_SHA384_DIGESTLENGTH);
1221 if (isc_safe_memcmp(hkey1->key, hkey2->key, ISC_SHA384_DIGESTLENGTH))
1228 hmacsha384_generate(dst_key_t *key, int pseudorandom_ok) {
1234 bytes = (key->key_size + 7) / 8;
1237 key->key_size = HMAC_LEN * 8;
1248 ret = hmacsha384_fromdns(key, &b);
1255 hmacsha384_isprivate(const dst_key_t *key) {
1256 UNUSED(key);
1261 hmacsha384_destroy(dst_key_t *key) {
1262 dst_hmacsha384_key_t *hkey = key->keydata.hmacsha384;
1264 isc_mem_put(key->mctx, hkey, sizeof(dst_hmacsha384_key_t));
1265 key->keydata.hmacsha384 = NULL;
1269 hmacsha384_todns(const dst_key_t *key, isc_buffer_t *data) {
1273 REQUIRE(key->keydata.hmacsha384 != NULL);
1275 hkey = key->keydata.hmacsha384;
1277 bytes = (key->key_size + 7) / 8;
1280 isc_buffer_putmem(data, hkey->key, bytes);
1286 hmacsha384_fromdns(dst_key_t *key, isc_buffer_t *data) {
1296 hkey = isc_mem_get(key->mctx, sizeof(dst_hmacsha384_key_t));
1300 memset(hkey->key, 0, sizeof(hkey->key));
1305 isc_sha384_final(hkey->key, &sha384ctx);
1308 memmove(hkey->key, r.base, r.length);
1312 key->key_size = keylen * 8;
1313 key->keydata.hmacsha384 = hkey;
1319 hmacsha384_tofile(const dst_key_t *key, const char *directory) {
1323 int bytes = (key->key_size + 7) / 8;
1326 if (key->keydata.hmacsha384 == NULL)
1329 hkey = key->keydata.hmacsha384;
1333 priv.elements[cnt++].data = hkey->key;
1335 buf[0] = (key->key_bits >> 8) & 0xffU;
1336 buf[1] = key->key_bits & 0xffU;
1342 return (dst__privstruct_writefile(key, &priv, directory));
1346 hmacsha384_parse(dst_key_t *key, isc_lex_t *lexer) {
1350 isc_mem_t *mctx = key->mctx;
1353 /* read private key file */
1354 result = dst__privstruct_parse(key, DST_ALG_HMACSHA384, lexer, mctx,
1359 key->key_bits = 0;
1366 tresult = hmacsha384_fromdns(key, &b);
1371 tresult = getkeybits(key, &priv.elements[i]);
1413 static isc_result_t hmacsha512_fromdns(dst_key_t *key, isc_buffer_t *data);
1416 unsigned char key[ISC_SHA512_DIGESTLENGTH];
1420 hmacsha512_createctx(dst_key_t *key, dst_context_t *dctx) {
1422 dst_hmacsha512_key_t *hkey = key->keydata.hmacsha512;
1427 isc_hmacsha512_init(hmacsha512ctx, hkey->key, ISC_SHA512_DIGESTLENGTH);
1490 if (isc_safe_memcmp(hkey1->key, hkey2->key, ISC_SHA512_DIGESTLENGTH))
1497 hmacsha512_generate(dst_key_t *key, int pseudorandom_ok) {
1503 bytes = (key->key_size + 7) / 8;
1506 key->key_size = HMAC_LEN * 8;
1517 ret = hmacsha512_fromdns(key, &b);
1524 hmacsha512_isprivate(const dst_key_t *key) {
1525 UNUSED(key);
1530 hmacsha512_destroy(dst_key_t *key) {
1531 dst_hmacsha512_key_t *hkey = key->keydata.hmacsha512;
1533 isc_mem_put(key->mctx, hkey, sizeof(dst_hmacsha512_key_t));
1534 key->keydata.hmacsha512 = NULL;
1538 hmacsha512_todns(const dst_key_t *key, isc_buffer_t *data) {
1542 REQUIRE(key->keydata.hmacsha512 != NULL);
1544 hkey = key->keydata.hmacsha512;
1546 bytes = (key->key_size + 7) / 8;
1549 isc_buffer_putmem(data, hkey->key, bytes);
1555 hmacsha512_fromdns(dst_key_t *key, isc_buffer_t *data) {
1565 hkey = isc_mem_get(key->mctx, sizeof(dst_hmacsha512_key_t));
1569 memset(hkey->key, 0, sizeof(hkey->key));
1574 isc_sha512_final(hkey->key, &sha512ctx);
1577 memmove(hkey->key, r.base, r.length);
1581 key->key_size = keylen * 8;
1582 key->keydata.hmacsha512 = hkey;
1588 hmacsha512_tofile(const dst_key_t *key, const char *directory) {
1592 int bytes = (key->key_size + 7) / 8;
1595 if (key->keydata.hmacsha512 == NULL)
1598 hkey = key->keydata.hmacsha512;
1602 priv.elements[cnt++].data = hkey->key;
1604 buf[0] = (key->key_bits >> 8) & 0xffU;
1605 buf[1] = key->key_bits & 0xffU;
1611 return (dst__privstruct_writefile(key, &priv, directory));
1615 hmacsha512_parse(dst_key_t *key, isc_lex_t *lexer) {
1619 isc_mem_t *mctx = key->mctx;
1622 /* read private key file */
1623 result = dst__privstruct_parse(key, DST_ALG_HMACSHA512, lexer, mctx,
1628 key->key_bits = 0;
1635 tresult = hmacsha512_fromdns(key, &b);
1640 tresult = getkeybits(key, &priv.elements[i]);