summaryrefslogtreecommitdiff
path: root/usr.sbin/bind/lib/dns/dst_api.c
diff options
context:
space:
mode:
authorFlorian Obser <florian@cvs.openbsd.org>2020-01-09 13:52:24 +0000
committerFlorian Obser <florian@cvs.openbsd.org>2020-01-09 13:52:24 +0000
commit2d988f85868515551cf46b4bd15f6635e9222e0e (patch)
treee851496bd35c602f2ca7d6a52611a37a15d62adb /usr.sbin/bind/lib/dns/dst_api.c
parent05c7b08c9257c2409507b7bd6cbae23a97361827 (diff)
unifdef pkcs11:
#undef USE_PKCS11 #undef PKCS11_TOOLS #undef PKCS11CRYPTO #undef HAVE_PKCS11_GOST #undef HAVE_PKCS11_ECDSA #undef HAVE_PKCS11_ED25519 #undef HAVE_PKCS11_ED448 #define PK11_DH_DISABLE #define PK11_DSA_DISABLE #define PK11_FLAVOR #define PK11_MD5_DISABLE #undef PK11_SOFTHSMV2_FLAVOR prodding deraadt@
Diffstat (limited to 'usr.sbin/bind/lib/dns/dst_api.c')
-rw-r--r--usr.sbin/bind/lib/dns/dst_api.c111
1 files changed, 7 insertions, 104 deletions
diff --git a/usr.sbin/bind/lib/dns/dst_api.c b/usr.sbin/bind/lib/dns/dst_api.c
index 286f25d3752..90407cbb70b 100644
--- a/usr.sbin/bind/lib/dns/dst_api.c
+++ b/usr.sbin/bind/lib/dns/dst_api.c
@@ -33,7 +33,7 @@
/*
* Principal Author: Brian Wellington
- * $Id: dst_api.c,v 1.10 2020/01/09 13:47:12 florian Exp $
+ * $Id: dst_api.c,v 1.11 2020/01/09 13:52:23 florian Exp $
*/
/*! \file */
@@ -61,7 +61,7 @@
#include <isc/util.h>
#include <isc/file.h>
-#include <pk11/site.h>
+
#define DST_KEY_INTERNAL
@@ -167,7 +167,7 @@ dst_lib_init2(isc_mem_t *mctx, isc_entropy_t *ectx,
REQUIRE(mctx != NULL);
REQUIRE(dst_initialized == ISC_FALSE);
-#if !defined(OPENSSL) && !defined(PKCS11CRYPTO)
+#if !defined(OPENSSL)
UNUSED(engine);
#endif
@@ -202,9 +202,6 @@ dst_lib_init2(isc_mem_t *mctx, isc_entropy_t *ectx,
dst_result_register();
memset(dst_t_func, 0, sizeof(dst_t_func));
-#ifndef PK11_MD5_DISABLE
- RETERR(dst__hmacmd5_init(&dst_t_func[DST_ALG_HMACMD5]));
-#endif
RETERR(dst__hmacsha1_init(&dst_t_func[DST_ALG_HMACSHA1]));
RETERR(dst__hmacsha224_init(&dst_t_func[DST_ALG_HMACSHA224]));
RETERR(dst__hmacsha256_init(&dst_t_func[DST_ALG_HMACSHA256]));
@@ -212,10 +209,6 @@ dst_lib_init2(isc_mem_t *mctx, isc_entropy_t *ectx,
RETERR(dst__hmacsha512_init(&dst_t_func[DST_ALG_HMACSHA512]));
#ifdef OPENSSL
RETERR(dst__openssl_init(engine));
-#ifndef PK11_MD5_DISABLE
- RETERR(dst__opensslrsa_init(&dst_t_func[DST_ALG_RSAMD5],
- DST_ALG_RSAMD5));
-#endif
RETERR(dst__opensslrsa_init(&dst_t_func[DST_ALG_RSASHA1],
DST_ALG_RSASHA1));
RETERR(dst__opensslrsa_init(&dst_t_func[DST_ALG_NSEC3RSASHA1],
@@ -224,13 +217,6 @@ dst_lib_init2(isc_mem_t *mctx, isc_entropy_t *ectx,
DST_ALG_RSASHA256));
RETERR(dst__opensslrsa_init(&dst_t_func[DST_ALG_RSASHA512],
DST_ALG_RSASHA512));
-#if defined(HAVE_OPENSSL_DSA) && !defined(PK11_DSA_DISABLE)
- RETERR(dst__openssldsa_init(&dst_t_func[DST_ALG_DSA]));
- RETERR(dst__openssldsa_init(&dst_t_func[DST_ALG_NSEC3DSA]));
-#endif
-#ifndef PK11_DH_DISABLE
- RETERR(dst__openssldh_init(&dst_t_func[DST_ALG_DH]));
-#endif
#ifdef HAVE_OPENSSL_GOST
RETERR(dst__opensslgost_init(&dst_t_func[DST_ALG_ECCGOST]));
#endif
@@ -244,36 +230,7 @@ dst_lib_init2(isc_mem_t *mctx, isc_entropy_t *ectx,
#ifdef HAVE_OPENSSL_ED448
RETERR(dst__openssleddsa_init(&dst_t_func[DST_ALG_ED448]));
#endif
-#elif PKCS11CRYPTO
- RETERR(dst__pkcs11_init(mctx, engine));
-#ifndef PK11_MD5_DISABLE
- RETERR(dst__pkcs11rsa_init(&dst_t_func[DST_ALG_RSAMD5]));
-#endif
- RETERR(dst__pkcs11rsa_init(&dst_t_func[DST_ALG_RSASHA1]));
- RETERR(dst__pkcs11rsa_init(&dst_t_func[DST_ALG_NSEC3RSASHA1]));
- RETERR(dst__pkcs11rsa_init(&dst_t_func[DST_ALG_RSASHA256]));
- RETERR(dst__pkcs11rsa_init(&dst_t_func[DST_ALG_RSASHA512]));
-#ifndef PK11_DSA_DISABLE
- RETERR(dst__pkcs11dsa_init(&dst_t_func[DST_ALG_DSA]));
- RETERR(dst__pkcs11dsa_init(&dst_t_func[DST_ALG_NSEC3DSA]));
-#endif
-#ifndef PK11_DH_DISABLE
- RETERR(dst__pkcs11dh_init(&dst_t_func[DST_ALG_DH]));
-#endif
-#ifdef HAVE_PKCS11_ECDSA
- RETERR(dst__pkcs11ecdsa_init(&dst_t_func[DST_ALG_ECDSA256]));
- RETERR(dst__pkcs11ecdsa_init(&dst_t_func[DST_ALG_ECDSA384]));
-#endif
-#ifdef HAVE_PKCS11_ED25519
- RETERR(dst__pkcs11eddsa_init(&dst_t_func[DST_ALG_ED25519]));
-#endif
-#ifdef HAVE_PKCS11_ED448
- RETERR(dst__pkcs11eddsa_init(&dst_t_func[DST_ALG_ED448]));
-#endif
-#ifdef HAVE_PKCS11_GOST
- RETERR(dst__pkcs11gost_init(&dst_t_func[DST_ALG_ECCGOST]));
-#endif
-#endif /* if OPENSSL, elif PKCS11CRYPTO */
+#endif /* if OPENSSL */
#ifdef GSSAPI
RETERR(dst__gssapi_init(&dst_t_func[DST_ALG_GSSAPI]));
#endif
@@ -298,9 +255,7 @@ dst_lib_destroy(void) {
dst_t_func[i]->cleanup();
#ifdef OPENSSL
dst__openssl_destroy();
-#elif PKCS11CRYPTO
- (void) dst__pkcs11_destroy();
-#endif /* if OPENSSL, elif PKCS11CRYPTO */
+#endif /* if OPENSSL */
if (dst__memory_pool != NULL)
isc_mem_detach(&dst__memory_pool);
if (dst_entropy_pool != NULL)
@@ -318,7 +273,7 @@ dst_algorithm_supported(unsigned int alg) {
isc_boolean_t
dst_ds_digest_supported(unsigned int digest_type) {
-#if defined(HAVE_OPENSSL_GOST) || defined(HAVE_PKCS11_GOST)
+#if defined(HAVE_OPENSSL_GOST)
return (ISC_TF(digest_type == DNS_DSDIGEST_SHA1 ||
digest_type == DNS_DSDIGEST_SHA256 ||
digest_type == DNS_DSDIGEST_GOST ||
@@ -1086,10 +1041,6 @@ comparekeys(const dst_key_t *key1, const dst_key_t *key2,
if (key1->key_id != key2->key_id) {
if (!match_revoked_key)
return (ISC_FALSE);
-#ifndef PK11_MD5_DISABLE
- if (key1->key_alg == DST_ALG_RSAMD5)
- return (ISC_FALSE);
-#endif
if ((key1->key_flags & DNS_KEYFLAG_REVOKE) ==
(key2->key_flags & DNS_KEYFLAG_REVOKE))
return (ISC_FALSE);
@@ -1252,21 +1203,12 @@ dst_key_sigsize(const dst_key_t *key, unsigned int *n) {
/* XXXVIX this switch statement is too sparse to gen a jump table. */
switch (key->key_alg) {
-#ifndef PK11_MD5_DISABLE
- case DST_ALG_RSAMD5:
-#endif
case DST_ALG_RSASHA1:
case DST_ALG_NSEC3RSASHA1:
case DST_ALG_RSASHA256:
case DST_ALG_RSASHA512:
*n = (key->key_size + 7) / 8;
break;
-#ifndef PK11_DSA_DISABLE
- case DST_ALG_DSA:
- case DST_ALG_NSEC3DSA:
- *n = DNS_SIG_DSASIGSIZE;
- break;
-#endif
case DST_ALG_ECCGOST:
*n = DNS_SIG_GOSTSIGSIZE;
break;
@@ -1282,11 +1224,6 @@ dst_key_sigsize(const dst_key_t *key, unsigned int *n) {
case DST_ALG_ED448:
*n = DNS_SIG_ED448SIZE;
break;
-#ifndef PK11_MD5_DISABLE
- case DST_ALG_HMACMD5:
- *n = 16;
- break;
-#endif
case DST_ALG_HMACSHA1:
*n = ISC_SHA1_DIGESTLENGTH;
break;
@@ -1305,9 +1242,6 @@ dst_key_sigsize(const dst_key_t *key, unsigned int *n) {
case DST_ALG_GSSAPI:
*n = 128; /*%< XXX */
break;
-#ifndef PK11_DH_DISABLE
- case DST_ALG_DH:
-#endif
default:
return (DST_R_UNSUPPORTEDALG);
}
@@ -1320,15 +1254,7 @@ dst_key_secretsize(const dst_key_t *key, unsigned int *n) {
REQUIRE(VALID_KEY(key));
REQUIRE(n != NULL);
-#ifndef PK11_DH_DISABLE
- if (key->key_alg == DST_ALG_DH)
- *n = (key->key_size + 7) / 8;
- else
-#endif
return (DST_R_UNSUPPORTEDALG);
-#ifndef PK11_DH_DISABLE
- return (ISC_R_SUCCESS);
-#endif
}
/*%
@@ -1607,29 +1533,16 @@ issymmetric(const dst_key_t *key) {
/* XXXVIX this switch statement is too sparse to gen a jump table. */
switch (key->key_alg) {
-#ifndef PK11_MD5_DISABLE
- case DST_ALG_RSAMD5:
-#endif
case DST_ALG_RSASHA1:
case DST_ALG_NSEC3RSASHA1:
case DST_ALG_RSASHA256:
case DST_ALG_RSASHA512:
-#ifndef PK11_DSA_DISABLE
- case DST_ALG_DSA:
- case DST_ALG_NSEC3DSA:
-#endif
-#ifndef PK11_DH_DISABLE
- case DST_ALG_DH:
-#endif
case DST_ALG_ECCGOST:
case DST_ALG_ECDSA256:
case DST_ALG_ECDSA384:
case DST_ALG_ED25519:
case DST_ALG_ED448:
return (ISC_FALSE);
-#ifndef PK11_MD5_DISABLE
- case DST_ALG_HMACMD5:
-#endif
case DST_ALG_HMACSHA1:
case DST_ALG_HMACSHA224:
case DST_ALG_HMACSHA256:
@@ -1892,7 +1805,7 @@ algorithm_status(unsigned int alg) {
if (dst_algorithm_supported(alg))
return (ISC_R_SUCCESS);
-#if !defined(OPENSSL) && !defined(PKCS11CRYPTO)
+#if !defined(OPENSSL)
if (alg == DST_ALG_RSAMD5 || alg == DST_ALG_RSASHA1 ||
alg == DST_ALG_DSA || alg == DST_ALG_DH ||
alg == DST_ALG_HMACMD5 || alg == DST_ALG_NSEC3DSA ||
@@ -1942,22 +1855,15 @@ dst__entropy_getdata(void *buf, unsigned int len, isc_boolean_t pseudo) {
if (len == 0)
return (ISC_R_SUCCESS);
-#ifdef PKCS11CRYPTO
- UNUSED(pseudo);
- UNUSED(flags);
- return (pk11_rand_bytes(buf, len));
-#else /* PKCS11CRYPTO */
if (pseudo)
flags &= ~ISC_ENTROPY_GOODONLY;
else
flags |= ISC_ENTROPY_BLOCKING;
return (isc_entropy_getdata(dst_entropy_pool, buf, len, NULL, flags));
-#endif /* PKCS11CRYPTO */
}
unsigned int
dst__entropy_status(void) {
-#ifndef PKCS11CRYPTO
#ifdef GSSAPI
unsigned int flags = dst_entropy_flags;
isc_result_t ret;
@@ -1979,9 +1885,6 @@ dst__entropy_status(void) {
}
#endif
return (isc_entropy_status(dst_entropy_pool));
-#else
- return (0);
-#endif
}
isc_buffer_t *