From 09f7e0607a34d90eae53f862954e98c31b5ae532 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Thu, 15 Sep 2022 19:18:53 +1000 Subject: [PATCH] Convert DST_ALG defines to enum and group HMAC algorithms 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 | 2 +- lib/dns/include/dst/dst.h | 56 +++++++++++++++++--------------- lib/isccc/Makefile.am | 1 + lib/isccc/include/isccc/cc.h | 19 ++++++----- 4 files changed, 43 insertions(+), 35 deletions(-) diff --git a/bin/tests/system/dnssec/tests.sh b/bin/tests/system/dnssec/tests.sh index 9f36160c8a..10e5fa224d 100644 --- a/bin/tests/system/dnssec/tests.sh +++ b/bin/tests/system/dnssec/tests.sh @@ -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 diff --git a/lib/dns/include/dst/dst.h b/lib/dns/include/dst/dst.h index fdd2122b20..4e2437e11e 100644 --- a/lib/dns/include/dst/dst.h +++ b/lib/dns/include/dst/dst.h @@ -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 diff --git a/lib/isccc/Makefile.am b/lib/isccc/Makefile.am index 10a0ec1c98..7877bfbb18 100644 --- a/lib/isccc/Makefile.am +++ b/lib/isccc/Makefile.am @@ -27,6 +27,7 @@ libisccc_la_SOURCES = \ libisccc_la_CPPFLAGS = \ $(AM_CPPFLAGS) \ $(LIBISC_CFLAGS) \ + $(LIBDNS_CFLAGS) \ $(LIBISCCC_CFLAGS) libisccc_la_LIBADD = \ diff --git a/lib/isccc/include/isccc/cc.h b/lib/isccc/include/isccc/cc.h index a50b1dea20..f597276756 100644 --- a/lib/isccc/include/isccc/cc.h +++ b/lib/isccc/include/isccc/cc.h @@ -37,19 +37,22 @@ #include #include +#include #include 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