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.

(cherry picked from commit 09f7e0607a)
This commit is contained in:
Mark Andrews
2022-09-15 19:18:53 +10:00
committed by Petr Špaček
parent 57a773fa81
commit 0bbc0c61e3
4 changed files with 43 additions and 35 deletions

View File

@@ -3373,7 +3373,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

View 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

View File

@@ -27,6 +27,7 @@ libisccc_la_SOURCES = \
libisccc_la_CPPFLAGS = \
$(AM_CPPFLAGS) \
$(LIBISC_CFLAGS) \
$(LIBDNS_CFLAGS) \
$(LIBISCCC_CFLAGS)
libisccc_la_LIBADD = \

View File

@@ -37,19 +37,22 @@
#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