]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
cleanup: use dns_secalg_t and dns_dsdigest_t where appropriate
authorTony Finch <dot@dotat.at>
Fri, 8 Feb 2019 17:54:56 +0000 (17:54 +0000)
committerMark Andrews <marka@isc.org>
Fri, 8 Mar 2019 11:25:27 +0000 (22:25 +1100)
Use them in structs for various rdata types where they are missing.
This doesn't change the structs since we are replacing explicit
uint8_t field types with aliases for uint8_t.

Use dns_dsdigest_t in library function arguments.

(cherry picked from commit 0f219714e1f19c4cb9434e0c52e9de873a97942b)

CHANGES
bin/dnssec/dnssec-dsfromkey.c
lib/dns/ds.c
lib/dns/include/dns/ds.h
lib/dns/rdata/generic/ds_43.h
lib/dns/rdata/generic/key_25.h
lib/dns/rdata/generic/keydata_65533.h
lib/dns/validator.c

diff --git a/CHANGES b/CHANGES
index 5d6759b103f34fa9d807382de85b95f8c8650b0f..50166454b608ffe21605e096fcc1fe42e3ae064f 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+5179.  [cleanup]       Replace some vague type declarations with the more
+                       specific dns_secalg_t and dns_dsdigest_t.
+                       Thanks to Tony Finch. [GL !1498]
+
 5178.  [bug]           Handle EDQUOT (disk quota) and ENOSPC (disk full)
                        errors when writing files. [GL #902]
 
index 931d5deb2f41911f70812e0b159b1fd49501b4cb..060892b5a3605caef6cb24fcf55431781938cbb4 100644 (file)
@@ -236,7 +236,7 @@ logkey(dns_rdata_t *rdata)
 }
 
 static void
-emit(unsigned int dtype, bool showall, char *lookaside,
+emit(dns_dsdigest_t dtype, bool showall, char *lookaside,
      bool cds, dns_rdata_t *rdata)
 {
        isc_result_t result;
@@ -351,7 +351,7 @@ main(int argc, char **argv) {
        char            *lookaside = NULL;
        char            *endp;
        int             ch;
-       unsigned int    dtype = DNS_DSDIGEST_SHA1;
+       dns_dsdigest_t  dtype = DNS_DSDIGEST_SHA1;
        bool    cds = false;
        bool    both = true;
        bool    usekeyset = false;
index d1a507bcc2f8cfff253eecfc2650ad501316555b..d0b75cdbd1f4fdfe6cc72d66d7e443629c32318e 100644 (file)
@@ -37,7 +37,7 @@
 
 isc_result_t
 dns_ds_buildrdata(dns_name_t *owner, dns_rdata_t *key,
-                 unsigned int digest_type, unsigned char *buffer,
+                 dns_dsdigest_t digest_type, unsigned char *buffer,
                  dns_rdata_t *rdata)
 {
        dns_fixedname_t fname;
@@ -107,7 +107,6 @@ dns_ds_buildrdata(dns_name_t *owner, dns_rdata_t *key,
                break;
 
        case DNS_DSDIGEST_SHA256:
-       default:
                isc_sha256_init(&sha256);
                dns_name_toregion(name, &r);
                isc_sha256_update(&sha256, r.base, r.length);
@@ -116,6 +115,10 @@ dns_ds_buildrdata(dns_name_t *owner, dns_rdata_t *key,
                isc_sha256_update(&sha256, r.base, r.length);
                isc_sha256_final(digest, &sha256);
                break;
+
+       default:
+               INSIST(0);
+               ISC_UNREACHABLE();
        }
 
        ds.mctx = NULL;
index 4ea5a0d24df22fa248034ae0db6c9baa9ac1dedb..51f13b2eccbb97d45318799662fdc8a34a990bf9 100644 (file)
@@ -31,7 +31,7 @@ ISC_LANG_BEGINDECLS
 
 isc_result_t
 dns_ds_buildrdata(dns_name_t *owner, dns_rdata_t *key,
-                 unsigned int digest_type, unsigned char *buffer,
+                 dns_dsdigest_t digest_type, unsigned char *buffer,
                  dns_rdata_t *rdata);
 /*%<
  * Build the rdata of a DS record.
index 0d373ecea87f22bb8b74850ba113472cedc6ef65..9d477388be21e73594fff414f5ae0df4de12b829 100644 (file)
@@ -19,8 +19,8 @@ typedef struct dns_rdata_ds {
        dns_rdatacommon_t       common;
        isc_mem_t               *mctx;
        uint16_t                key_tag;
-       uint8_t         algorithm;
-       uint8_t         digest_type;
+       dns_secalg_t            algorithm;
+       dns_dsdigest_t          digest_type;
        uint16_t                length;
        unsigned char           *digest;
 } dns_rdata_ds_t;
index 330363b46503c36a72450364c1db079de4165e61..4bcad50b118c17bf16d3b3da5ed94cef7bdac533 100644 (file)
@@ -20,8 +20,8 @@ typedef struct dns_rdata_key {
        dns_rdatacommon_t       common;
        isc_mem_t *             mctx;
        uint16_t                flags;
-       uint8_t         protocol;
-       uint8_t         algorithm;
+       dns_secproto_t          protocol;
+       dns_secalg_t            algorithm;
        uint16_t                datalen;
        unsigned char *         data;
 } dns_rdata_key_t;
index 40061e1fde1be3602f783fa705f744d176c41d40..45a8fa9ee21771fb009e2a759bc2b92cb779a8f5 100644 (file)
@@ -20,8 +20,8 @@ typedef struct dns_rdata_keydata {
        uint32_t                addhd;        /* Hold-down timer for adding */
        uint32_t                removehd;     /* Hold-down timer for removing */
        uint16_t                flags;        /* Copy of DNSKEY_48 */
-       uint8_t         protocol;
-       uint8_t         algorithm;
+       dns_secproto_t          protocol;
+       dns_secalg_t            algorithm;
        uint16_t                datalen;
        unsigned char *         data;
 } dns_rdata_keydata_t;
index f603e742e06b832fd951c1be6cd7ce04d40ecea1..31ec897bf6b1afe326fae4498e560027bb6f7c0a 100644 (file)
@@ -1757,7 +1757,7 @@ checkkey(dns_validator_t *val, dns_rdata_t *keyrdata, uint16_t keyid,
  */
 static isc_result_t
 keyfromds(dns_validator_t *val, dns_rdataset_t *rdataset, dns_rdata_t *dsrdata,
-         uint8_t digest, uint16_t keyid, dns_secalg_t algorithm,
+         dns_dsdigest_t digest, uint16_t keyid, dns_secalg_t algorithm,
          dns_rdata_t *keyrdata)
 {
        dns_keytag_t keytag;