#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.
*/
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));
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));
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");
+ }
+}
* '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