]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Replace alg_totext with dst_hmac_algorithm_totext
authorMark Andrews <marka@isc.org>
Thu, 15 Sep 2022 14:42:15 +0000 (00:42 +1000)
committerPetr Špaček <pspacek@isc.org>
Tue, 27 Sep 2022 14:55:33 +0000 (16:55 +0200)
The new library function will be reused by subsequent commits.

(cherry picked from commit 151cc2fff99efe11e284ce3ae0796523ce1975e5)

bin/confgen/keygen.c
bin/confgen/rndc-confgen.c
bin/confgen/tsig-keygen.c
lib/dns/dst_api.c
lib/dns/include/dst/dst.h

index 345933d37435786a904d9d9377aefe7f2fb9405a..97dfa34667b54d3ac92f49e30f52977223f892c8 100644 (file)
 
 #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));
index e0786be7824d09b9f3220975bf87d4def498f5f6..817929544e6c98dd24984e6af49032d305b35b47 100644 (file)
@@ -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));
index dd39ad8726407434394e61d885f887ba9484f732..f6c5b2e2722445f78b8a79e75d0ab6d9fb338a09 100644 (file)
@@ -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);
 
index 39fcbf1fa67066935fa4015cc51d19bc1f161658..c13463ffd1b560a46efbd5c8e6c53016c9c07ad8 100644 (file)
@@ -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");
+       }
+}
index 4e2437e11ed94e18222dde1fdc9e44b76002d1fc..62192a9be798483233b26d533ffe247acbda86d1 100644 (file)
@@ -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