diff options
author | Florian Obser <florian@cvs.openbsd.org> | 2020-02-23 08:54:02 +0000 |
---|---|---|
committer | Florian Obser <florian@cvs.openbsd.org> | 2020-02-23 08:54:02 +0000 |
commit | 9df1776374c441890ed555034ac9240845b0a1b2 (patch) | |
tree | 0850218bf482b99ed64cc3580b314cdf8e0f7f18 /usr.bin/dig | |
parent | 7213f54139cecf5e85f0df8b8f4ede86ece85dd1 (diff) |
Remove unused fields from struct dst_key and stop passing name and
rdclass around.
OK millert, jung
Diffstat (limited to 'usr.bin/dig')
-rw-r--r-- | usr.bin/dig/lib/dns/dst_api.c | 70 | ||||
-rw-r--r-- | usr.bin/dig/lib/dns/dst_internal.h | 22 | ||||
-rw-r--r-- | usr.bin/dig/lib/dns/include/dst/dst.h | 6 | ||||
-rw-r--r-- | usr.bin/dig/lib/dns/tsig.c | 17 |
4 files changed, 20 insertions, 95 deletions
diff --git a/usr.bin/dig/lib/dns/dst_api.c b/usr.bin/dig/lib/dns/dst_api.c index c5917579c94..1a10c0cef75 100644 --- a/usr.bin/dig/lib/dns/dst_api.c +++ b/usr.bin/dig/lib/dns/dst_api.c @@ -33,7 +33,7 @@ /* * Principal Author: Brian Wellington - * $Id: dst_api.c,v 1.10 2020/02/23 08:53:19 florian Exp $ + * $Id: dst_api.c,v 1.11 2020/02/23 08:54:01 florian Exp $ */ /*! \file */ @@ -64,19 +64,14 @@ static isc_boolean_t dst_initialized = ISC_FALSE; /* * Static functions. */ -static dst_key_t * get_key_struct(dns_name_t *name, - unsigned int alg, +static dst_key_t * get_key_struct(unsigned int alg, unsigned int flags, unsigned int protocol, - unsigned int bits, - dns_rdataclass_t rdclass, - dns_ttl_t ttl); + unsigned int bits); static isc_result_t computeid(dst_key_t *key); -static isc_result_t frombuffer(dns_name_t *name, - unsigned int alg, +static isc_result_t frombuffer(unsigned int alg, unsigned int flags, unsigned int protocol, - dns_rdataclass_t rdclass, isc_buffer_t *source, dst_key_t **keyp); @@ -237,9 +232,7 @@ dst_key_todns(const dst_key_t *key, isc_buffer_t *target) { } isc_result_t -dst_key_frombuffer(dns_name_t *name, unsigned int alg, - unsigned int flags, unsigned int protocol, - dns_rdataclass_t rdclass, +dst_key_frombuffer(unsigned int alg, unsigned int flags, unsigned int protocol, isc_buffer_t *source, dst_key_t **keyp) { dst_key_t *key = NULL; @@ -247,8 +240,7 @@ dst_key_frombuffer(dns_name_t *name, unsigned int alg, REQUIRE(dst_initialized); - result = frombuffer(name, alg, flags, protocol, rdclass, source, - &key); + result = frombuffer(alg, flags, protocol, source, &key); if (result != ISC_R_SUCCESS) return (result); @@ -288,15 +280,6 @@ dst_key_free(dst_key_t **keyp) { isc_refcount_destroy(&key->refs); key->func->destroy(key); - if (key->engine != NULL) - free(key->engine); - if (key->label != NULL) - free(key->label); - dns_name_free(key->key_name); - free(key->key_name); - if (key->key_tkeytoken) { - isc_buffer_free(&key->key_tkeytoken); - } isc_safe_memwipe(key, sizeof(*key)); free(key); *keyp = NULL; @@ -338,14 +321,12 @@ dst_key_sigsize(const dst_key_t *key, unsigned int *n) { * Allocates a key structure and fills in some of the fields. */ static dst_key_t * -get_key_struct(dns_name_t *name, unsigned int alg, +get_key_struct(unsigned int alg, unsigned int flags, unsigned int protocol, - unsigned int bits, dns_rdataclass_t rdclass, - dns_ttl_t ttl) + unsigned int bits) { dst_key_t *key; isc_result_t result; - int i; key = (dst_key_t *) malloc(sizeof(dst_key_t)); if (key == NULL) @@ -353,24 +334,8 @@ get_key_struct(dns_name_t *name, unsigned int alg, memset(key, 0, sizeof(dst_key_t)); - key->key_name = malloc(sizeof(dns_name_t)); - if (key->key_name == NULL) { - free(key); - return (NULL); - } - - dns_name_init(key->key_name, NULL); - result = dns_name_dup(name, key->key_name); - if (result != ISC_R_SUCCESS) { - free(key->key_name); - free(key); - return (NULL); - } - result = isc_refcount_init(&key->refs, 1); if (result != ISC_R_SUCCESS) { - dns_name_free(key->key_name); - free(key->key_name); free(key); return (NULL); } @@ -378,16 +343,7 @@ get_key_struct(dns_name_t *name, unsigned int alg, key->key_flags = flags; key->key_proto = protocol; key->key_size = bits; - key->key_class = rdclass; - key->key_ttl = ttl; key->func = dst_t_func[alg]; - key->fmt_major = 0; - key->fmt_minor = 0; - for (i = 0; i < (DST_MAX_TIMES + 1); i++) { - key->times[i] = 0; - key->timeset[i] = ISC_FALSE; - } - key->inactive = ISC_FALSE; return (key); } @@ -404,24 +360,20 @@ computeid(dst_key_t *key) { return (ret); isc_buffer_usedregion(&dnsbuf, &r); - key->key_id = dst_region_computeid(&r, key->key_alg); - key->key_rid = dst_region_computerid(&r, key->key_alg); return (ISC_R_SUCCESS); } static isc_result_t -frombuffer(dns_name_t *name, unsigned int alg, unsigned int flags, - unsigned int protocol, dns_rdataclass_t rdclass, - isc_buffer_t *source, dst_key_t **keyp) +frombuffer(unsigned int alg, unsigned int flags, + unsigned int protocol, isc_buffer_t *source, dst_key_t **keyp) { dst_key_t *key; isc_result_t ret; - REQUIRE(dns_name_isabsolute(name)); REQUIRE(source != NULL); REQUIRE(keyp != NULL && *keyp == NULL); - key = get_key_struct(name, alg, flags, protocol, 0, rdclass, 0); + key = get_key_struct(alg, flags, protocol, 0); if (key == NULL) return (ISC_R_NOMEMORY); diff --git a/usr.bin/dig/lib/dns/dst_internal.h b/usr.bin/dig/lib/dns/dst_internal.h index 35a7f746c6c..a8b8f342d80 100644 --- a/usr.bin/dig/lib/dns/dst_internal.h +++ b/usr.bin/dig/lib/dns/dst_internal.h @@ -31,7 +31,7 @@ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: dst_internal.h,v 1.10 2020/02/23 08:53:19 florian Exp $ */ +/* $Id: dst_internal.h,v 1.11 2020/02/23 08:54:01 florian Exp $ */ #ifndef DST_DST_INTERNAL_H #define DST_DST_INTERNAL_H 1 @@ -71,19 +71,11 @@ typedef enum { DO_SIGN, DO_VERIFY } dst_use_t; /*% DST Key Structure */ struct dst_key { isc_refcount_t refs; - dns_name_t * key_name; /*%< name of the key */ unsigned int key_size; /*%< size of the key in bits */ unsigned int key_proto; /*%< protocols this key is used for */ unsigned int key_alg; /*%< algorithm of the key */ uint32_t key_flags; /*%< flags of the public key */ - uint16_t key_id; /*%< identifier of the key */ - uint16_t key_rid; /*%< identifier of the key when - revoked */ uint16_t key_bits; /*%< hmac digest bits */ - dns_rdataclass_t key_class; /*%< class of the key record */ - dns_ttl_t key_ttl; /*%< default/initial dnskey ttl */ - char *engine; /*%< engine name (HSM) */ - char *label; /*%< engine label (HSM) */ union { dst_hmacsha1_key_t *hmacsha1; dst_hmacsha224_key_t *hmacsha224; @@ -93,19 +85,7 @@ struct dst_key { } keydata; /*%< pointer to key in crypto pkg fmt */ - time_t times[DST_MAX_TIMES + 1]; /*%< timing metadata */ - isc_boolean_t timeset[DST_MAX_TIMES + 1]; /*%< data set? */ - time_t nums[DST_MAX_NUMERIC + 1]; /*%< numeric metadata */ - isc_boolean_t numset[DST_MAX_NUMERIC + 1]; /*%< data set? */ - isc_boolean_t inactive; /*%< private key not present as it is - inactive */ - isc_boolean_t external; /*%< external key */ - - int fmt_major; /*%< private key format, major version */ - int fmt_minor; /*%< private key format, minor version */ - dst_func_t * func; /*%< crypto package specific functions */ - isc_buffer_t *key_tkeytoken; /*%< TKEY token data */ }; struct dst_context { diff --git a/usr.bin/dig/lib/dns/include/dst/dst.h b/usr.bin/dig/lib/dns/include/dst/dst.h index fedae45c621..a9ba221dbe5 100644 --- a/usr.bin/dig/lib/dns/include/dst/dst.h +++ b/usr.bin/dig/lib/dns/include/dst/dst.h @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: dst.h,v 1.8 2020/02/23 08:51:53 florian Exp $ */ +/* $Id: dst.h,v 1.9 2020/02/23 08:54:01 florian Exp $ */ #ifndef DST_DST_H #define DST_DST_H 1 @@ -227,9 +227,7 @@ dst_key_todns(const dst_key_t *key, isc_buffer_t *target); */ isc_result_t -dst_key_frombuffer(dns_name_t *name, unsigned int alg, - unsigned int flags, unsigned int protocol, - dns_rdataclass_t rdclass, +dst_key_frombuffer(unsigned int alg, unsigned int flags, unsigned int protocol, isc_buffer_t *source, dst_key_t **keyp); /*%< * Converts a buffer containing DNS KEY RDATA into a DST key. diff --git a/usr.bin/dig/lib/dns/tsig.c b/usr.bin/dig/lib/dns/tsig.c index 525b245d05a..da0b76ef828 100644 --- a/usr.bin/dig/lib/dns/tsig.c +++ b/usr.bin/dig/lib/dns/tsig.c @@ -15,7 +15,7 @@ */ /* - * $Id: tsig.c,v 1.8 2020/02/18 18:11:27 florian Exp $ + * $Id: tsig.c,v 1.9 2020/02/23 08:54:01 florian Exp $ */ /*! \file */ @@ -292,10 +292,9 @@ dns_tsigkey_create(dns_name_t *name, dns_name_t *algorithm, isc_buffer_init(&b, secret, length); isc_buffer_add(&b, length); - result = dst_key_frombuffer(name, DST_ALG_HMACSHA1, + result = dst_key_frombuffer(DST_ALG_HMACSHA1, DNS_KEYOWNER_ENTITY, DNS_KEYPROTO_DNSSEC, - dns_rdataclass_in, &b, &dstkey); if (result != ISC_R_SUCCESS) return (result); @@ -306,10 +305,9 @@ dns_tsigkey_create(dns_name_t *name, dns_name_t *algorithm, isc_buffer_init(&b, secret, length); isc_buffer_add(&b, length); - result = dst_key_frombuffer(name, DST_ALG_HMACSHA224, + result = dst_key_frombuffer(DST_ALG_HMACSHA224, DNS_KEYOWNER_ENTITY, DNS_KEYPROTO_DNSSEC, - dns_rdataclass_in, &b, &dstkey); if (result != ISC_R_SUCCESS) return (result); @@ -320,10 +318,9 @@ dns_tsigkey_create(dns_name_t *name, dns_name_t *algorithm, isc_buffer_init(&b, secret, length); isc_buffer_add(&b, length); - result = dst_key_frombuffer(name, DST_ALG_HMACSHA256, + result = dst_key_frombuffer(DST_ALG_HMACSHA256, DNS_KEYOWNER_ENTITY, DNS_KEYPROTO_DNSSEC, - dns_rdataclass_in, &b, &dstkey); if (result != ISC_R_SUCCESS) return (result); @@ -334,10 +331,9 @@ dns_tsigkey_create(dns_name_t *name, dns_name_t *algorithm, isc_buffer_init(&b, secret, length); isc_buffer_add(&b, length); - result = dst_key_frombuffer(name, DST_ALG_HMACSHA384, + result = dst_key_frombuffer(DST_ALG_HMACSHA384, DNS_KEYOWNER_ENTITY, DNS_KEYPROTO_DNSSEC, - dns_rdataclass_in, &b, &dstkey); if (result != ISC_R_SUCCESS) return (result); @@ -348,10 +344,9 @@ dns_tsigkey_create(dns_name_t *name, dns_name_t *algorithm, isc_buffer_init(&b, secret, length); isc_buffer_add(&b, length); - result = dst_key_frombuffer(name, DST_ALG_HMACSHA512, + result = dst_key_frombuffer(DST_ALG_HMACSHA512, DNS_KEYOWNER_ENTITY, DNS_KEYPROTO_DNSSEC, - dns_rdataclass_in, &b, &dstkey); if (result != ISC_R_SUCCESS) return (result); |