1baafe
From e6ab9c67f0a14adc23c1067e03a106da1b1651b7 Mon Sep 17 00:00:00 2001
1baafe
From: Petr Mensik <pemensik@redhat.com>
1baafe
Date: Fri, 18 Oct 2019 21:30:52 +0200
1baafe
Subject: [PATCH] Move USE_PKCS11 and USE_OPENSSL out of config.h
1baafe
1baafe
Building two variants with the same common code requires to unset
1baafe
USE_PKCS11 on part of build. That is not possible with config.h value.
1baafe
Move it as normal define to CDEFINES.
1baafe
---
1baafe
 bin/confgen/Makefile.in |  2 +-
1baafe
 configure.ac            |  8 ++++++--
1baafe
 lib/dns/dst_internal.h  | 12 +++++++++---
1baafe
 3 files changed, 16 insertions(+), 6 deletions(-)
1baafe
1baafe
diff --git a/bin/confgen/Makefile.in b/bin/confgen/Makefile.in
1baafe
index 1b7512d..c126bf3 100644
1baafe
--- a/bin/confgen/Makefile.in
1baafe
+++ b/bin/confgen/Makefile.in
1baafe
@@ -22,7 +22,7 @@ VERSION=@BIND9_VERSION@
1baafe
 CINCLUDES = -I${srcdir}/include ${ISC_INCLUDES} ${ISCCC_INCLUDES} \
1baafe
 	${ISCCFG_INCLUDES} ${DNS_INCLUDES} ${BIND9_INCLUDES}
1baafe
 
1baafe
-CDEFINES =
1baafe
+CDEFINES = @USE_PKCS11@
1baafe
 CWARNINGS =
1baafe
 
1baafe
 ISCCFGLIBS =	../../lib/isccfg/libisccfg.@A@
1baafe
diff --git a/configure.ac b/configure.ac
1baafe
index f5483fe..08a7d8a 100644
1baafe
--- a/configure.ac
1baafe
+++ b/configure.ac
1baafe
@@ -935,10 +935,14 @@ AC_SUBST([PKCS11_TEST])
1baafe
 AC_SUBST([PKCS11_TOOLS])
1baafe
 AC_SUBST([PKCS11_MANS])
1baafe
 
1baafe
+USE_PKCS11='-DUSE_PKCS11=0'
1baafe
+USE_OPENSSL='-DUSE_OPENSSL=0'
1baafe
 AC_SUBST([CRYPTO])
1baafe
 AS_CASE([$CRYPTO],
1baafe
-	[pkcs11],[AC_DEFINE([USE_PKCS11], [1], [define if PKCS11 is used for Public-Key Cryptography])],
1baafe
-	[AC_DEFINE([USE_OPENSSL], [1], [define if OpenSSL is used for Public-Key Cryptography])])
1baafe
+	[pkcs11],[USE_PKCS11='-DUSE_PKCS11=1'],
1baafe
+	[USE_OPENSSL='-DUSE_OPENSSL=1'])
1baafe
+AC_SUBST(USE_PKCS11)
1baafe
+AC_SUBST(USE_OPENSSL)
1baafe
 
1baafe
 # preparation for automake
1baafe
 # AM_CONDITIONAL([PKCS11_TOOLS], [test "$with_native_pkcs11" = "yes"])
1baafe
diff --git a/lib/dns/dst_internal.h b/lib/dns/dst_internal.h
1baafe
index 2c3b4a3..55e9dc4 100644
1baafe
--- a/lib/dns/dst_internal.h
1baafe
+++ b/lib/dns/dst_internal.h
1baafe
@@ -38,6 +38,13 @@
1baafe
 #include <isc/stdtime.h>
1baafe
 #include <isc/types.h>
1baafe
 
1baafe
+#ifndef USE_PKCS11
1baafe
+#define USE_PKCS11 0
1baafe
+#endif
1baafe
+#ifndef USE_OPENSSL
1baafe
+#define USE_OPENSSL (! USE_PKCS11)
1baafe
+#endif
1baafe
+
1baafe
 #if USE_PKCS11
1baafe
 #include <pk11/pk11.h>
1baafe
 #include <pk11/site.h>
1baafe
@@ -116,11 +123,10 @@ struct dst_key {
1baafe
 		void *generic;
1baafe
 		dns_gss_ctx_id_t gssctx;
1baafe
 		DH *dh;
1baafe
-#if USE_OPENSSL
1baafe
-		EVP_PKEY *pkey;
1baafe
-#endif /* if USE_OPENSSL */
1baafe
 #if USE_PKCS11
1baafe
 		pk11_object_t *pkey;
1baafe
+#else
1baafe
+		EVP_PKEY *pkey;
1baafe
 #endif /* if USE_PKCS11 */
1baafe
 		dst_hmac_key_t *hmac_key;
1baafe
 	} keydata; /*%< pointer to key in crypto pkg fmt */
1baafe
-- 
1baafe
2.26.2
1baafe