mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 22:15:20 +00:00
Replace alg_totext with dst_hmac_algorithm_totext
The new library function will be reused by subsequent commits.
This commit is contained in:
committed by
Petr Špaček
parent
09f7e0607a
commit
151cc2fff9
@@ -34,29 +34,6 @@
|
||||
|
||||
#include "util.h"
|
||||
|
||||
/*%
|
||||
* Convert algorithm type to string.
|
||||
*/
|
||||
const char *
|
||||
alg_totext(dns_secalg_t alg) {
|
||||
switch (alg) {
|
||||
case DST_ALG_HMACMD5:
|
||||
return ("hmac-md5");
|
||||
case DST_ALG_HMACSHA1:
|
||||
return ("hmac-sha1");
|
||||
case DST_ALG_HMACSHA224:
|
||||
return ("hmac-sha224");
|
||||
case DST_ALG_HMACSHA256:
|
||||
return ("hmac-sha256");
|
||||
case DST_ALG_HMACSHA384:
|
||||
return ("hmac-sha384");
|
||||
case DST_ALG_HMACSHA512:
|
||||
return ("hmac-sha512");
|
||||
default:
|
||||
return ("(unknown)");
|
||||
}
|
||||
}
|
||||
|
||||
/*%
|
||||
* Convert string to algorithm type.
|
||||
*/
|
||||
@@ -175,7 +152,7 @@ void
|
||||
write_key_file(const char *keyfile, const char *user, const char *keyname,
|
||||
isc_buffer_t *secret, dns_secalg_t alg) {
|
||||
isc_result_t result;
|
||||
const char *algname = alg_totext(alg);
|
||||
const char *algname = dst_hmac_algorithm_totext(alg);
|
||||
FILE *fd = NULL;
|
||||
|
||||
DO("create keyfile", isc_file_safecreate(keyfile, &fd));
|
||||
|
@@ -222,7 +222,7 @@ main(int argc, char **argv) {
|
||||
if (keysize < 0) {
|
||||
keysize = alg_bits(alg);
|
||||
}
|
||||
algname = alg_totext(alg);
|
||||
algname = dst_hmac_algorithm_totext(alg);
|
||||
|
||||
isc_mem_create(&mctx);
|
||||
isc_buffer_init(&key_txtbuffer, &key_txtsecret, sizeof(key_txtsecret));
|
||||
|
@@ -208,7 +208,7 @@ main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
/* Use canonical algorithm name */
|
||||
algname = alg_totext(alg);
|
||||
algname = dst_hmac_algorithm_totext(alg);
|
||||
|
||||
isc_mem_create(&mctx);
|
||||
|
||||
|
@@ -2747,3 +2747,23 @@ dst_key_copy_metadata(dst_key_t *to, dst_key_t *from) {
|
||||
|
||||
dst_key_setmodified(to, dst_key_ismodified(from));
|
||||
}
|
||||
|
||||
const char *
|
||||
dst_hmac_algorithm_totext(dst_algorithm_t alg) {
|
||||
switch (alg) {
|
||||
case DST_ALG_HMACMD5:
|
||||
return ("hmac-md5");
|
||||
case DST_ALG_HMACSHA1:
|
||||
return ("hmac-sha1");
|
||||
case DST_ALG_HMACSHA224:
|
||||
return ("hmac-sha224");
|
||||
case DST_ALG_HMACSHA256:
|
||||
return ("hmac-sha256");
|
||||
case DST_ALG_HMACSHA384:
|
||||
return ("hmac-sha384");
|
||||
case DST_ALG_HMACSHA512:
|
||||
return ("hmac-sha512");
|
||||
default:
|
||||
return ("unknown");
|
||||
}
|
||||
}
|
||||
|
@@ -1225,4 +1225,11 @@ dst_key_copy_metadata(dst_key_t *to, dst_key_t *from);
|
||||
* 'to' and 'from' to be valid.
|
||||
*/
|
||||
|
||||
const char *
|
||||
dst_hmac_algorithm_totext(dst_algorithm_t alg);
|
||||
/*$<
|
||||
* Return the name associtated with the HMAC algorithm 'alg'
|
||||
* or return "unknown".
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
Reference in New Issue
Block a user