]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Convert DST_ALG defines to enum and group HMAC algorithms
authorMark Andrews <marka@isc.org>
Thu, 15 Sep 2022 09:18:53 +0000 (19:18 +1000)
committerPetr Špaček <pspacek@isc.org>
Tue, 27 Sep 2022 14:54:36 +0000 (16:54 +0200)
The HMACs and GSSAPI are just using unallocated values.
Moving them around shouldn't cause issues.
Only the dnssec system test knew the internal number in use for hmacmd5.

bin/tests/system/dnssec/tests.sh
lib/dns/include/dst/dst.h
lib/isccc/Makefile.am
lib/isccc/include/isccc/cc.h

index 9f36160c8a08bb981f1c95857d4db3e1b77da771..10e5fa224d05ca099f45fb179078da4adac7b5a7 100644 (file)
@@ -3387,7 +3387,7 @@ do
        2) # Diffie Helman
            alg=$((alg+1))
            continue;;
-       157|160|161|162|163|164|165) # private - non standard
+       159|160|161|162|163|164|165) # private - non standard
            alg=$((alg+1))
            continue;;
        1|5|7|8|10) # RSA algorithms
index fdd2122b20465f3a37a600072ca9f90b0aef2062..4e2437e11ed94e18222dde1fdc9e44b76002d1fc 100644 (file)
@@ -78,32 +78,36 @@ typedef enum dst_key_state {
 } dst_key_state_t;
 
 /* DST algorithm codes */
-#define DST_ALG_UNKNOWN             0
-#define DST_ALG_RSA         1 /* Used for parsing RSASHA1, RSASHA256 and RSASHA512 */
-#define DST_ALG_RSAMD5      1
-#define DST_ALG_DH          2
-#define DST_ALG_DSA         3
-#define DST_ALG_ECC         4
-#define DST_ALG_RSASHA1             5
-#define DST_ALG_NSEC3DSA     6
-#define DST_ALG_NSEC3RSASHA1 7
-#define DST_ALG_RSASHA256    8
-#define DST_ALG_RSASHA512    10
-#define DST_ALG_ECCGOST             12
-#define DST_ALG_ECDSA256     13
-#define DST_ALG_ECDSA384     14
-#define DST_ALG_ED25519             15
-#define DST_ALG_ED448       16
-#define DST_ALG_HMACMD5             157
-#define DST_ALG_GSSAPI      160
-#define DST_ALG_HMACSHA1     161 /* XXXMPA */
-#define DST_ALG_HMACSHA224   162 /* XXXMPA */
-#define DST_ALG_HMACSHA256   163 /* XXXMPA */
-#define DST_ALG_HMACSHA384   164 /* XXXMPA */
-#define DST_ALG_HMACSHA512   165 /* XXXMPA */
-#define DST_ALG_INDIRECT     252
-#define DST_ALG_PRIVATE             254
-#define DST_MAX_ALGS        256
+typedef enum dst_algorithm {
+       DST_ALG_UNKNOWN = 0,
+       DST_ALG_RSA = 1, /* Used for parsing RSASHA1, RSASHA256 and RSASHA512 */
+       DST_ALG_RSAMD5 = 1,
+       DST_ALG_DH = 2,
+       DST_ALG_DSA = 3,
+       DST_ALG_ECC = 4,
+       DST_ALG_RSASHA1 = 5,
+       DST_ALG_NSEC3DSA = 6,
+       DST_ALG_NSEC3RSASHA1 = 7,
+       DST_ALG_RSASHA256 = 8,
+       DST_ALG_RSASHA512 = 10,
+       DST_ALG_ECCGOST = 12,
+       DST_ALG_ECDSA256 = 13,
+       DST_ALG_ECDSA384 = 14,
+       DST_ALG_ED25519 = 15,
+       DST_ALG_ED448 = 16,
+       DST_ALG_GSSAPI = 159,
+       DST_ALG_HMACMD5 = 160,
+       DST_ALG_HMAC_FIRST = DST_ALG_HMACMD5,
+       DST_ALG_HMACSHA1 = 161,   /* XXXMPA */
+       DST_ALG_HMACSHA224 = 162, /* XXXMPA */
+       DST_ALG_HMACSHA256 = 163, /* XXXMPA */
+       DST_ALG_HMACSHA384 = 164, /* XXXMPA */
+       DST_ALG_HMACSHA512 = 165, /* XXXMPA */
+       DST_ALG_HMAC_LAST = DST_ALG_HMACSHA512,
+       DST_ALG_INDIRECT = 252,
+       DST_ALG_PRIVATE = 254,
+       DST_MAX_ALGS = 256,
+} dst_algorithm_t;
 
 /*% A buffer of this size is large enough to hold any key */
 #define DST_KEY_MAXSIZE 1280
index 10a0ec1c98c24ea102f0e3ba2b57a522c363e6e9..7877bfbb180dcad745d62739d44ce3b4aa76fe06 100644 (file)
@@ -27,6 +27,7 @@ libisccc_la_SOURCES =         \
 libisccc_la_CPPFLAGS =         \
        $(AM_CPPFLAGS)          \
        $(LIBISC_CFLAGS)        \
+       $(LIBDNS_CFLAGS)        \
        $(LIBISCCC_CFLAGS)
 
 libisccc_la_LIBADD =   \
index a50b1dea20ac8e0da258e3f5b91821c1145eac41..f597276756d68eb253715d18ff7e75b941d0e695 100644 (file)
 #include <isc/buffer.h>
 #include <isc/lang.h>
 
+#include <dst/dst.h>
 #include <isccc/types.h>
 
 ISC_LANG_BEGINDECLS
 
-/*% from lib/dns/include/dst/dst.h */
-
+/*%
+ * The HMAC algorithms supported by isccc_cc_fromwire and
+ * isccc_cc_towire as implemented in DST.
+ */
 #define ISCCC_ALG_UNKNOWN    0
-#define ISCCC_ALG_HMACMD5    157
-#define ISCCC_ALG_HMACSHA1   161
-#define ISCCC_ALG_HMACSHA224 162
-#define ISCCC_ALG_HMACSHA256 163
-#define ISCCC_ALG_HMACSHA384 164
-#define ISCCC_ALG_HMACSHA512 165
+#define ISCCC_ALG_HMACMD5    DST_ALG_HMACMD5
+#define ISCCC_ALG_HMACSHA1   DST_ALG_HMACSHA1
+#define ISCCC_ALG_HMACSHA224 DST_ALG_HMACSHA224
+#define ISCCC_ALG_HMACSHA256 DST_ALG_HMACSHA256
+#define ISCCC_ALG_HMACSHA384 DST_ALG_HMACSHA384
+#define ISCCC_ALG_HMACSHA512 DST_ALG_HMACSHA512
 
 /*% Maximum Datagram Package */
 #define ISCCC_CC_MAXDGRAMPACKET 4096