diff options
author | Florian Obser <florian@cvs.openbsd.org> | 2020-02-23 08:52:51 +0000 |
---|---|---|
committer | Florian Obser <florian@cvs.openbsd.org> | 2020-02-23 08:52:51 +0000 |
commit | 67be56c2eb5348710ab4b63f9ce2cda25089ea91 (patch) | |
tree | da2782dbdcfac7b3b69147d75c06cb70606a3bb2 | |
parent | c0a7286e9727f05654fbd1fcfecf4ac3a60e12e0 (diff) |
All key funcs are populated, skip NULL check.
While here remove *_isprivate since it is always true.
OK millert, jung
-rw-r--r-- | usr.bin/dig/lib/dns/dst_api.c | 26 | ||||
-rw-r--r-- | usr.bin/dig/lib/dns/dst_internal.h | 3 | ||||
-rw-r--r-- | usr.bin/dig/lib/dns/hmac_link.c | 37 |
3 files changed, 4 insertions, 62 deletions
diff --git a/usr.bin/dig/lib/dns/dst_api.c b/usr.bin/dig/lib/dns/dst_api.c index 9ddcefc662d..0fc5bba7c37 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.8 2020/02/23 08:51:53 florian Exp $ + * $Id: dst_api.c,v 1.9 2020/02/23 08:52:50 florian Exp $ */ /*! \file */ @@ -150,8 +150,6 @@ dst_context_create3(dst_key_t *key, REQUIRE(dst_initialized == ISC_TRUE); REQUIRE(dctxp != NULL && *dctxp == NULL); - if (key->func->createctx == NULL) - return (DST_R_UNSUPPORTEDALG); if (key->keydata.generic == NULL) return (DST_R_NULLKEY); @@ -183,7 +181,6 @@ dst_context_destroy(dst_context_t **dctxp) { REQUIRE(dctxp != NULL); dctx = *dctxp; - INSIST(dctx->key->func->destroyctx != NULL); dctx->key->func->destroyctx(dctx); if (dctx->key != NULL) dst_key_free(&dctx->key); @@ -194,8 +191,6 @@ dst_context_destroy(dst_context_t **dctxp) { isc_result_t dst_context_adddata(dst_context_t *dctx, const isc_region_t *data) { REQUIRE(data != NULL); - INSIST(dctx->key->func->adddata != NULL); - return (dctx->key->func->adddata(dctx, data)); } @@ -210,12 +205,6 @@ dst_context_sign(dst_context_t *dctx, isc_buffer_t *sig) { if (key->keydata.generic == NULL) return (DST_R_NULLKEY); - if (key->func->sign == NULL) - return (DST_R_NOTPRIVATEKEY); - if (key->func->isprivate == NULL || - key->func->isprivate(key) == ISC_FALSE) - return (DST_R_NOTPRIVATEKEY); - return (key->func->sign(dctx, sig)); } @@ -226,8 +215,6 @@ dst_context_verify(dst_context_t *dctx, isc_region_t *sig) { CHECKALG(dctx->key->key_alg); if (dctx->key->keydata.generic == NULL) return (DST_R_NULLKEY); - if (dctx->key->func->verify == NULL) - return (DST_R_NOTPUBLICKEY); return (dctx->key->func->verify(dctx, sig)); } @@ -239,9 +226,6 @@ dst_key_todns(const dst_key_t *key, isc_buffer_t *target) { CHECKALG(key->key_alg); - if (key->func->todns == NULL) - return (DST_R_UNSUPPORTEDALG); - if (isc_buffer_availablelength(target) < 4) return (ISC_R_NOSPACE); isc_buffer_putuint16(target, (uint16_t)(key->key_flags & 0xffff)); @@ -313,10 +297,8 @@ dst_key_free(dst_key_t **keyp) { return; isc_refcount_destroy(&key->refs); - if (key->keydata.generic != NULL) { - INSIST(key->func->destroy != NULL); + if (key->keydata.generic != NULL) key->func->destroy(key); - } if (key->engine != NULL) free(key->engine); if (key->label != NULL) @@ -461,10 +443,6 @@ frombuffer(dns_name_t *name, unsigned int alg, unsigned int flags, dst_key_free(&key); return (ret); } - if (key->func->fromdns == NULL) { - dst_key_free(&key); - return (DST_R_UNSUPPORTEDALG); - } ret = key->func->fromdns(key, source); if (ret != ISC_R_SUCCESS) { diff --git a/usr.bin/dig/lib/dns/dst_internal.h b/usr.bin/dig/lib/dns/dst_internal.h index 7799e9951e0..d76ebd8d6de 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.8 2020/02/23 08:51:53 florian Exp $ */ +/* $Id: dst_internal.h,v 1.9 2020/02/23 08:52:50 florian Exp $ */ #ifndef DST_DST_INTERNAL_H #define DST_DST_INTERNAL_H 1 @@ -143,7 +143,6 @@ struct dst_func { */ isc_result_t (*sign)(dst_context_t *dctx, isc_buffer_t *sig); isc_result_t (*verify)(dst_context_t *dctx, const isc_region_t *sig); - isc_boolean_t (*isprivate)(const dst_key_t *key); void (*destroy)(dst_key_t *key); /* conversion functions */ diff --git a/usr.bin/dig/lib/dns/hmac_link.c b/usr.bin/dig/lib/dns/hmac_link.c index 40c911001f6..53d259ef883 100644 --- a/usr.bin/dig/lib/dns/hmac_link.c +++ b/usr.bin/dig/lib/dns/hmac_link.c @@ -33,7 +33,7 @@ /* * Principal Author: Brian Wellington - * $Id: hmac_link.c,v 1.5 2020/02/23 08:51:53 florian Exp $ + * $Id: hmac_link.c,v 1.6 2020/02/23 08:52:50 florian Exp $ */ #include <string.h> @@ -113,12 +113,6 @@ hmacsha1_verify(dst_context_t *dctx, const isc_region_t *sig) { return (DST_R_VERIFYFAILURE); } -static isc_boolean_t -hmacsha1_isprivate(const dst_key_t *key) { - UNUSED(key); - return (ISC_TRUE); -} - static void hmacsha1_destroy(dst_key_t *key) { dst_hmacsha1_key_t *hkey = key->keydata.hmacsha1; @@ -186,7 +180,6 @@ static dst_func_t hmacsha1_functions = { hmacsha1_adddata, hmacsha1_sign, hmacsha1_verify, - hmacsha1_isprivate, hmacsha1_destroy, hmacsha1_todns, hmacsha1_fromdns, @@ -265,12 +258,6 @@ hmacsha224_verify(dst_context_t *dctx, const isc_region_t *sig) { return (DST_R_VERIFYFAILURE); } -static isc_boolean_t -hmacsha224_isprivate(const dst_key_t *key) { - UNUSED(key); - return (ISC_TRUE); -} - static void hmacsha224_destroy(dst_key_t *key) { dst_hmacsha224_key_t *hkey = key->keydata.hmacsha224; @@ -338,7 +325,6 @@ static dst_func_t hmacsha224_functions = { hmacsha224_adddata, hmacsha224_sign, hmacsha224_verify, - hmacsha224_isprivate, hmacsha224_destroy, hmacsha224_todns, hmacsha224_fromdns, @@ -417,12 +403,6 @@ hmacsha256_verify(dst_context_t *dctx, const isc_region_t *sig) { return (DST_R_VERIFYFAILURE); } -static isc_boolean_t -hmacsha256_isprivate(const dst_key_t *key) { - UNUSED(key); - return (ISC_TRUE); -} - static void hmacsha256_destroy(dst_key_t *key) { dst_hmacsha256_key_t *hkey = key->keydata.hmacsha256; @@ -490,7 +470,6 @@ static dst_func_t hmacsha256_functions = { hmacsha256_adddata, hmacsha256_sign, hmacsha256_verify, - hmacsha256_isprivate, hmacsha256_destroy, hmacsha256_todns, hmacsha256_fromdns, @@ -569,12 +548,6 @@ hmacsha384_verify(dst_context_t *dctx, const isc_region_t *sig) { return (DST_R_VERIFYFAILURE); } -static isc_boolean_t -hmacsha384_isprivate(const dst_key_t *key) { - UNUSED(key); - return (ISC_TRUE); -} - static void hmacsha384_destroy(dst_key_t *key) { dst_hmacsha384_key_t *hkey = key->keydata.hmacsha384; @@ -642,7 +615,6 @@ static dst_func_t hmacsha384_functions = { hmacsha384_adddata, hmacsha384_sign, hmacsha384_verify, - hmacsha384_isprivate, hmacsha384_destroy, hmacsha384_todns, hmacsha384_fromdns, @@ -721,12 +693,6 @@ hmacsha512_verify(dst_context_t *dctx, const isc_region_t *sig) { return (DST_R_VERIFYFAILURE); } -static isc_boolean_t -hmacsha512_isprivate(const dst_key_t *key) { - UNUSED(key); - return (ISC_TRUE); -} - static void hmacsha512_destroy(dst_key_t *key) { dst_hmacsha512_key_t *hkey = key->keydata.hmacsha512; @@ -794,7 +760,6 @@ static dst_func_t hmacsha512_functions = { hmacsha512_adddata, hmacsha512_sign, hmacsha512_verify, - hmacsha512_isprivate, hmacsha512_destroy, hmacsha512_todns, hmacsha512_fromdns, |