e55890
diff --git a/bin/Makefile.in b/bin/Makefile.in
eb7207
index a18b222..26a7e4e 100644
e55890
--- a/bin/Makefile.in
e55890
+++ b/bin/Makefile.in
e55890
@@ -11,8 +11,8 @@ srcdir =	@srcdir@
e55890
 VPATH =		@srcdir@
e55890
 top_srcdir =	@top_srcdir@
e55890
 
e55890
-SUBDIRS =	named rndc dig delv dnssec tools nsupdate check confgen \
e55890
-		@NZD_TOOLS@ @PYTHON_TOOLS@ @PKCS11_TOOLS@ tests
e55890
+SUBDIRS =	named named-pkcs11 rndc dig delv dnssec dnssec-pkcs11 tools nsupdate \
e55890
+		check confgen @NZD_TOOLS@ @PYTHON_TOOLS@ @PKCS11_TOOLS@ tests
e55890
 TARGETS =
e55890
 
e55890
 @BIND9_MAKE_RULES@
e55890
diff --git a/bin/dnssec-pkcs11/Makefile.in b/bin/dnssec-pkcs11/Makefile.in
eb7207
index 390aa0c..e59a118 100644
e55890
--- a/bin/dnssec-pkcs11/Makefile.in
e55890
+++ b/bin/dnssec-pkcs11/Makefile.in
27025e
@@ -15,18 +15,18 @@ VERSION=@BIND9_VERSION@
e55890
 
e55890
 @BIND9_MAKE_INCLUDES@
e55890
 
e55890
-CINCLUDES =	${DNS_INCLUDES} ${ISC_INCLUDES} @DST_OPENSSL_INC@
e55890
+CINCLUDES =	${DNS_PKCS11_INCLUDES} ${ISC_PKCS11_INCLUDES}
e55890
 
27025e
-CDEFINES =	-DVERSION=\"${VERSION}\" @USE_PKCS11@ @PKCS11_ENGINE@ \
e55890
-		@CRYPTO@ -DPK11_LIB_LOCATION=\"@PKCS11_PROVIDER@\"
27025e
+CDEFINES =	-DVERSION=\"${VERSION}\" @PKCS11_ENGINE@ \
e55890
+		@CRYPTO_PK11@ -DPK11_LIB_LOCATION=\"@PKCS11_PROVIDER@\"
e55890
 CWARNINGS =
e55890
 
27025e
-DNSLIBS =	../../lib/dns/libdns.@A@ ${MAXMINDDB_LIBS} @DNS_CRYPTO_LIBS@
e55890
-ISCLIBS =	../../lib/isc/libisc.@A@
e55890
-ISCNOSYMLIBS =	../../lib/isc/libisc-nosymtbl.@A@
27025e
+DNSLIBS =	../../lib/dns-pkcs11/libdns-pkcs11.@A@ ${MAXMINDDB_LIBS} @DNS_CRYPTO_LIBS@
e55890
+ISCLIBS =	../../lib/isc-pkcs11/libisc-pkcs11.@A@
e55890
+ISCNOSYMLIBS =	../../lib/isc-pkcs11/libisc-pkcs11-nosymtbl.@A@
e55890
 
e55890
-DNSDEPLIBS =	../../lib/dns/libdns.@A@
e55890
-ISCDEPLIBS =	../../lib/isc/libisc.@A@
e55890
+DNSDEPLIBS =	../../lib/dns-pkcs11/libdns-pkcs11.@A@
e55890
+ISCDEPLIBS =	../../lib/isc-pkcs11/libisc-pkcs11.@A@
e55890
 
e55890
 DEPLIBS =	${DNSDEPLIBS} ${ISCDEPLIBS}
e55890
 
27025e
@@ -35,10 +35,10 @@ LIBS =		${DNSLIBS} ${ISCLIBS} @LIBS@
e55890
 NOSYMLIBS =	${DNSLIBS} ${ISCNOSYMLIBS} @LIBS@
e55890
 
e55890
 # Alphabetically
e55890
-TARGETS =	dnssec-keygen@EXEEXT@ dnssec-signzone@EXEEXT@ \
e55890
-		dnssec-keyfromlabel@EXEEXT@ dnssec-dsfromkey@EXEEXT@ \
e55890
-		dnssec-revoke@EXEEXT@ dnssec-settime@EXEEXT@ \
e55890
-		dnssec-verify@EXEEXT@ dnssec-importkey@EXEEXT@
e55890
+TARGETS =	dnssec-keygen-pkcs11@EXEEXT@ dnssec-signzone-pkcs11@EXEEXT@ \
e55890
+		dnssec-keyfromlabel-pkcs11@EXEEXT@ dnssec-dsfromkey-pkcs11@EXEEXT@ \
e55890
+		dnssec-revoke-pkcs11@EXEEXT@ dnssec-settime-pkcs11@EXEEXT@ \
e55890
+		dnssec-verify-pkcs11@EXEEXT@ dnssec-importkey-pkcs11@EXEEXT@
e55890
 
e55890
 OBJS =		dnssectool.@O@
e55890
 
27025e
@@ -59,15 +59,15 @@ MANOBJS =	${MANPAGES} ${HTMLPAGES}
e55890
 
e55890
 @BIND9_MAKE_RULES@
e55890
 
e55890
-dnssec-dsfromkey@EXEEXT@: dnssec-dsfromkey.@O@ ${OBJS} ${DEPLIBS}
e55890
+dnssec-dsfromkey-pkcs11@EXEEXT@: dnssec-dsfromkey.@O@ ${OBJS} ${DEPLIBS}
e55890
 	export BASEOBJS="dnssec-dsfromkey.@O@ ${OBJS}"; \
e55890
 	${FINALBUILDCMD}
e55890
 
e55890
-dnssec-keyfromlabel@EXEEXT@: dnssec-keyfromlabel.@O@ ${OBJS} ${DEPLIBS}
e55890
+dnssec-keyfromlabel-pkcs11@EXEEXT@: dnssec-keyfromlabel.@O@ ${OBJS} ${DEPLIBS}
e55890
 	export BASEOBJS="dnssec-keyfromlabel.@O@ ${OBJS}"; \
e55890
 	${FINALBUILDCMD}
e55890
 
e55890
-dnssec-keygen@EXEEXT@: dnssec-keygen.@O@ ${OBJS} ${DEPLIBS}
e55890
+dnssec-keygen-pkcs11@EXEEXT@: dnssec-keygen.@O@ ${OBJS} ${DEPLIBS}
e55890
 	export BASEOBJS="dnssec-keygen.@O@ ${OBJS}"; \
e55890
 	${FINALBUILDCMD}
e55890
 
27025e
@@ -75,7 +75,7 @@ dnssec-signzone.@O@: dnssec-signzone.c
e55890
 	${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} -DVERSION=\"${VERSION}\" \
e55890
 		-c ${srcdir}/dnssec-signzone.c
e55890
 
e55890
-dnssec-signzone@EXEEXT@: dnssec-signzone.@O@ ${OBJS} ${DEPLIBS}
e55890
+dnssec-signzone-pkcs11@EXEEXT@: dnssec-signzone.@O@ ${OBJS} ${DEPLIBS}
e55890
 	export BASEOBJS="dnssec-signzone.@O@ ${OBJS}"; \
e55890
 	${FINALBUILDCMD}
e55890
 
27025e
@@ -83,19 +83,19 @@ dnssec-verify.@O@: dnssec-verify.c
e55890
 	${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} -DVERSION=\"${VERSION}\" \
e55890
 		-c ${srcdir}/dnssec-verify.c
e55890
 
e55890
-dnssec-verify@EXEEXT@: dnssec-verify.@O@ ${OBJS} ${DEPLIBS}
e55890
+dnssec-verify-pkcs11@EXEEXT@: dnssec-verify.@O@ ${OBJS} ${DEPLIBS}
e55890
 	export BASEOBJS="dnssec-verify.@O@ ${OBJS}"; \
e55890
 	${FINALBUILDCMD}
e55890
 
e55890
-dnssec-revoke@EXEEXT@: dnssec-revoke.@O@ ${OBJS} ${DEPLIBS}
e55890
+dnssec-revoke-pkcs11@EXEEXT@: dnssec-revoke.@O@ ${OBJS} ${DEPLIBS}
e55890
 	${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
e55890
 	dnssec-revoke.@O@ ${OBJS} ${LIBS}
e55890
 
e55890
-dnssec-settime@EXEEXT@: dnssec-settime.@O@ ${OBJS} ${DEPLIBS}
e55890
+dnssec-settime-pkcs11@EXEEXT@: dnssec-settime.@O@ ${OBJS} ${DEPLIBS}
e55890
 	${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
e55890
 	dnssec-settime.@O@ ${OBJS} ${LIBS}
e55890
 
e55890
-dnssec-importkey@EXEEXT@: dnssec-importkey.@O@ ${OBJS} ${DEPLIBS}
e55890
+dnssec-importkey-pkcs11@EXEEXT@: dnssec-importkey.@O@ ${OBJS} ${DEPLIBS}
e55890
 	${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
e55890
 	dnssec-importkey.@O@ ${OBJS} ${LIBS}
e55890
 
27025e
@@ -106,16 +106,14 @@ docclean manclean maintainer-clean::
e55890
 
e55890
 installdirs:
e55890
 	$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${sbindir}
e55890
-	$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${mandir}/man8
e55890
 
e55890
 install-man8: ${MANPAGES}
e55890
 	${INSTALL_DATA} $^ ${DESTDIR}${mandir}/man8
e55890
 
e55890
-install:: ${TARGETS} installdirs install-man8
e55890
+install:: ${TARGETS} installdirs
27025e
 	for t in ${TARGETS}; do ${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} $$t ${DESTDIR}${sbindir} || exit 1; done
e55890
 
e55890
 uninstall::
27025e
-	for m in ${MANPAGES}; do rm -f ${DESTDIR}${mandir}/man8/$$m || exit 1; done
27025e
 	for t in ${TARGETS}; do ${LIBTOOL_MODE_UNINSTALL} rm -f ${DESTDIR}${sbindir}/$$t || exit 1; done
e55890
 
e55890
 clean distclean::
e55890
diff --git a/bin/dnssec/Makefile.in b/bin/dnssec/Makefile.in
eb7207
index 390aa0c..851a008 100644
e55890
--- a/bin/dnssec/Makefile.in
e55890
+++ b/bin/dnssec/Makefile.in
27025e
@@ -17,7 +17,7 @@ VERSION=@BIND9_VERSION@
e55890
 
e55890
 CINCLUDES =	${DNS_INCLUDES} ${ISC_INCLUDES} @DST_OPENSSL_INC@
e55890
 
e55890
-CDEFINES =	-DVERSION=\"${VERSION}\" @USE_PKCS11@ @PKCS11_ENGINE@ \
e55890
+CDEFINES =	-DVERSION=\"${VERSION}\" \
e55890
 		@CRYPTO@ -DPK11_LIB_LOCATION=\"@PKCS11_PROVIDER@\"
e55890
 CWARNINGS =
e55890
 
e55890
diff --git a/bin/named-pkcs11/Makefile.in b/bin/named-pkcs11/Makefile.in
99b754
index 277a0f5..52a6375 100644
e55890
--- a/bin/named-pkcs11/Makefile.in
e55890
+++ b/bin/named-pkcs11/Makefile.in
27025e
@@ -43,27 +43,27 @@ DLZDRIVER_INCLUDES =	@DLZ_DRIVER_INCLUDES@
e55890
 DLZDRIVER_LIBS =	@DLZ_DRIVER_LIBS@
e55890
 
e55890
 CINCLUDES =	-I${srcdir}/include -I${srcdir}/unix/include -I. \
e55890
-		${LWRES_INCLUDES} ${DNS_INCLUDES} ${BIND9_INCLUDES} \
e55890
-		${ISCCFG_INCLUDES} ${ISCCC_INCLUDES} ${ISC_INCLUDES} \
27025e
+		${LWRES_INCLUDES} ${DNS_PKCS11_INCLUDES} ${BIND9_INCLUDES} \
27025e
+		${ISCCFG_INCLUDES} ${ISCCC_INCLUDES} ${ISC_PKCS11_INCLUDES} \
27025e
 		${DLZDRIVER_INCLUDES} ${DBDRIVER_INCLUDES} ${MAXMINDDB_CFLAGS} \
27025e
 		@DST_OPENSSL_INC@
e55890
 
e55890
-CDEFINES =      @CONTRIB_DLZ@ @USE_PKCS11@ @PKCS11_ENGINE@ @CRYPTO@
27025e
+CDEFINES =      @USE_PKCS11@ @PKCS11_ENGINE@ @CRYPTO_PK11@ @USE_GSSAPI@
e55890
 
e55890
 CWARNINGS =
e55890
 
27025e
-DNSLIBS =	../../lib/dns/libdns.@A@ ${MAXMINDDB_LIBS} @DNS_CRYPTO_LIBS@
27025e
+DNSLIBS =	../../lib/dns-pkcs11/libdns-pkcs11.@A@ ${MAXMINDDB_LIBS} @DNS_CRYPTO_LIBS@
e55890
 ISCCFGLIBS =	../../lib/isccfg/libisccfg.@A@
e55890
 ISCCCLIBS =	../../lib/isccc/libisccc.@A@
e55890
-ISCLIBS =	../../lib/isc/libisc.@A@
27025e
-ISCNOSYMLIBS =	../../lib/isc/libisc-nosymtbl.@A@
27025e
+ISCLIBS =	../../lib/isc-pkcs11/libisc-pkcs11.@A@
27025e
+ISCNOSYMLIBS =	../../lib/isc-pkcs11/libisc-pkcs11-nosymtbl.@A@
e55890
 LWRESLIBS =	../../lib/lwres/liblwres.@A@
e55890
 BIND9LIBS =	../../lib/bind9/libbind9.@A@
e55890
 
e55890
-DNSDEPLIBS =	../../lib/dns/libdns.@A@
27025e
+DNSDEPLIBS =	../../lib/dns-pkcs11/libdns-pkcs11.@A@
e55890
 ISCCFGDEPLIBS =	../../lib/isccfg/libisccfg.@A@
e55890
 ISCCCDEPLIBS =	../../lib/isccc/libisccc.@A@
e55890
-ISCDEPLIBS =	../../lib/isc/libisc.@A@
27025e
+ISCDEPLIBS =	../../lib/isc-pkcs11/libisc-pkcs11.@A@
e55890
 LWRESDEPLIBS =	../../lib/lwres/liblwres.@A@
e55890
 BIND9DEPLIBS =	../../lib/bind9/libbind9.@A@
e55890
 
27025e
@@ -72,15 +72,15 @@ DEPLIBS =	${LWRESDEPLIBS} ${DNSDEPLIBS} ${BIND9DEPLIBS} \
e55890
 
e55890
 LIBS =		${LWRESLIBS} ${DNSLIBS} ${BIND9LIBS} \
e55890
 		${ISCCFGLIBS} ${ISCCCLIBS} ${ISCLIBS} \
e55890
-		${DLZDRIVER_LIBS} ${DBDRIVER_LIBS} @LIBS@
e55890
+		@LIBS@
e55890
 
e55890
 NOSYMLIBS =	${LWRESLIBS} ${DNSLIBS} ${BIND9LIBS} \
e55890
 		${ISCCFGLIBS} ${ISCCCLIBS} ${ISCNOSYMLIBS} \
e55890
-		${DLZDRIVER_LIBS} ${DBDRIVER_LIBS} @LIBS@
27025e
+		@LIBS@
e55890
 
e55890
 SUBDIRS =	unix
e55890
 
e55890
-TARGETS =	named@EXEEXT@ lwresd@EXEEXT@
27025e
+TARGETS =	named-pkcs11@EXEEXT@
e55890
 
e55890
 GEOIPLINKOBJS = geoip.@O@
27025e
 GEOIP2LINKOBJS = geoip.@O@
27025e
@@ -94,8 +94,7 @@ OBJS =		builtin.@O@ client.@O@ config.@O@ control.@O@ \
e55890
 		tkeyconf.@O@ tsigconf.@O@ update.@O@ xfrout.@O@ \
e55890
 		zoneconf.@O@ \
e55890
 		lwaddr.@O@ lwresd.@O@ lwdclient.@O@ lwderror.@O@ lwdgabn.@O@ \
e55890
-		lwdgnba.@O@ lwdgrbn.@O@ lwdnoop.@O@ lwsearch.@O@ \
e55890
-		${DLZDRIVER_OBJS} ${DBDRIVER_OBJS}
e55890
+        lwdgnba.@O@ lwdgrbn.@O@ lwdnoop.@O@ lwsearch.@O@
e55890
 
e55890
 UOBJS =		unix/os.@O@ unix/dlz_dlopen_driver.@O@
e55890
 
27025e
@@ -113,8 +112,7 @@ SRCS =		builtin.c client.c config.c control.c \
e55890
 		tkeyconf.c tsigconf.c update.c xfrout.c \
e55890
 		zoneconf.c \
e55890
 		lwaddr.c lwresd.c lwdclient.c lwderror.c lwdgabn.c \
e55890
-		lwdgnba.c lwdgrbn.c lwdnoop.c lwsearch.c \
e55890
-		${DLZDRIVER_SRCS} ${DBDRIVER_SRCS}
e55890
+        lwdgnba.c lwdgrbn.c lwdnoop.c lwsearch.c
e55890
 
e55890
 MANPAGES =	named.8 lwresd.8 named.conf.5
e55890
 
27025e
@@ -154,14 +152,14 @@ server.@O@: server.c
e55890
 		-DPRODUCT=\"${PRODUCT}\" \
e55890
 		-DVERSION=\"${VERSION}\" -c ${srcdir}/server.c
e55890
 
e55890
-named@EXEEXT@: ${OBJS} ${DEPLIBS}
e55890
+named-pkcs11@EXEEXT@: ${OBJS} ${DEPLIBS}
e55890
 	export MAKE_SYMTABLE="yes"; \
e55890
 	export BASEOBJS="${OBJS} ${UOBJS}"; \
e55890
 	${FINALBUILDCMD}
e55890
 
e55890
-lwresd@EXEEXT@: named@EXEEXT@
e55890
+lwresd@EXEEXT@: named-pkcs11@EXEEXT@
e55890
 	rm -f lwresd@EXEEXT@
e55890
-	@LN@ named@EXEEXT@ lwresd@EXEEXT@
e55890
+	@LN@ named-pkcs11@EXEEXT@ lwresd@EXEEXT@
e55890
 
e55890
 doc man:: ${MANOBJS}
e55890
 
27025e
@@ -192,16 +190,11 @@ install-man8: named.8 lwresd.8
e55890
 
e55890
 install-man: install-man5 install-man8
e55890
 
e55890
-install:: named@EXEEXT@ lwresd@EXEEXT@ installdirs install-man
e55890
-	${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} named@EXEEXT@ ${DESTDIR}${sbindir}
e55890
-	(cd ${DESTDIR}${sbindir}; rm -f lwresd@EXEEXT@; @LN@ named@EXEEXT@ lwresd@EXEEXT@)
e55890
+install:: named-pkcs11@EXEEXT@ installdirs
e55890
+	${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} named-pkcs11@EXEEXT@ ${DESTDIR}${sbindir}
e55890
 
e55890
 uninstall::
e55890
-	rm -f ${DESTDIR}${mandir}/man5/named.conf.5
e55890
-	rm -f ${DESTDIR}${mandir}/man8/lwresd.8
e55890
-	rm -f ${DESTDIR}${mandir}/man8/named.8
e55890
-	rm -f ${DESTDIR}${sbindir}/lwresd@EXEEXT@
e55890
-	${LIBTOOL_MODE_UNINSTALL} rm -f ${DESTDIR}${sbindir}/named@EXEEXT@
e55890
+	${LIBTOOL_MODE_UNINSTALL} rm -f ${DESTDIR}${sbindir}/named-pkcs11@EXEEXT@
e55890
 
e55890
 @DLZ_DRIVER_RULES@
e55890
 
e55890
diff --git a/bin/named/Makefile.in b/bin/named/Makefile.in
99b754
index 277a0f5..0e00885 100644
e55890
--- a/bin/named/Makefile.in
e55890
+++ b/bin/named/Makefile.in
27025e
@@ -48,7 +48,7 @@ CINCLUDES =	-I${srcdir}/include -I${srcdir}/unix/include -I. \
27025e
 		${DLZDRIVER_INCLUDES} ${DBDRIVER_INCLUDES} ${MAXMINDDB_CFLAGS} \
27025e
 		@DST_OPENSSL_INC@
e55890
 
e55890
-CDEFINES =      @CONTRIB_DLZ@ @USE_PKCS11@ @PKCS11_ENGINE@ @CRYPTO@
27025e
+CDEFINES =      @CONTRIB_DLZ@ @USE_GSSAPI@ @CRYPTO@
e55890
 
e55890
 CWARNINGS =
e55890
 
e55890
diff --git a/bin/pkcs11/Makefile.in b/bin/pkcs11/Makefile.in
eb7207
index 2c19e7e..8223d5e 100644
e55890
--- a/bin/pkcs11/Makefile.in
e55890
+++ b/bin/pkcs11/Makefile.in
eb7207
@@ -13,13 +13,13 @@ top_srcdir =	@top_srcdir@
e55890
 
e55890
 @BIND9_MAKE_INCLUDES@
e55890
 
e55890
-CINCLUDES =	${ISC_INCLUDES}
e55890
+CINCLUDES =	${ISC_PKCS11_INCLUDES}
e55890
 
e55890
 CDEFINES =
e55890
 
e55890
-ISCLIBS =	../../lib/isc/libisc.@A@ @ISC_OPENSSL_LIBS@
e55890
+ISCLIBS =	../../lib/isc-pkcs11/libisc-pkcs11.@A@ @ISC_OPENSSL_LIBS@
e55890
 
e55890
-ISCDEPLIBS =	../../lib/isc/libisc.@A@
e55890
+ISCDEPLIBS =	../../lib/isc-pkcs11/libisc-pkcs11.@A@
e55890
 
e55890
 DEPLIBS =	${ISCDEPLIBS}
e55890
 
27025e
diff --git a/configure.ac b/configure.ac
99b754
index 83cad4a..e1e1a32 100644
27025e
--- a/configure.ac
27025e
+++ b/configure.ac
99b754
@@ -1178,12 +1178,14 @@ AC_SUBST(USE_GSSAPI)
e55890
 AC_SUBST(DST_GSSAPI_INC)
e55890
 AC_SUBST(DNS_GSSAPI_LIBS)
e55890
 DNS_CRYPTO_LIBS="$DNS_GSSAPI_LIBS $DNS_CRYPTO_LIBS"
e55890
+DNS_CRYPTO_PK11_LIBS="$DNS_GSSAPI_LIBS $DNS_CRYPTO_PK11_LIBS"
e55890
 
e55890
 #
e55890
 # Applications linking with libdns also need to link with these libraries.
e55890
 #
e55890
 
e55890
 AC_SUBST(DNS_CRYPTO_LIBS)
e55890
+AC_SUBST(DNS_CRYPTO_PK11_LIBS)
e55890
 
e55890
 #
e55890
 # was --with-randomdev specified?
99b754
@@ -1556,12 +1558,12 @@ AC_ARG_ENABLE(openssl-hash,
e55890
 AC_MSG_CHECKING(for OpenSSL library)
e55890
 OPENSSL_WARNING=
27025e
 openssldirs="/usr /usr/local /usr/local/ssl /opt/local /usr/pkg /usr/sfw"
e55890
-if test "yes" = "$want_native_pkcs11"
e55890
-then
e55890
-	use_openssl="native_pkcs11"
eb7207
-	want_openssl_hash="no"
e55890
-	AC_MSG_RESULT(use of native PKCS11 instead)
e55890
-fi
eb7207
+#if test "yes" = "$want_native_pkcs11"
eb7207
+#then
eb7207
+#	use_openssl="native_pkcs11"
eb7207
+#	want_openssl_hash="no"
eb7207
+#	AC_MSG_RESULT(use of native PKCS11 instead)
eb7207
+#fi
e55890
 
e55890
 if test "auto" = "$use_openssl"
e55890
 then
99b754
@@ -1574,6 +1576,7 @@ then
e55890
 		fi
e55890
 	done
e55890
 fi
e55890
+CRYPTO_PK11=""
e55890
 OPENSSL_ECDSA=""
e55890
 OPENSSL_GOST=""
e55890
 OPENSSL_ED25519=""
99b754
@@ -1595,11 +1598,10 @@ case "$with_gost" in
e55890
 		;;
e55890
 esac
e55890
 
e55890
-case "$use_openssl" in
e55890
-	native_pkcs11)
e55890
-		AC_MSG_RESULT(disabled because of native PKCS11)
e55890
+if test "$want_native_pkcs11" = "yes"
e55890
+then
e55890
 		DST_OPENSSL_INC=""
e55890
-		CRYPTO="-DPKCS11CRYPTO"
e55890
+		CRYPTO_PK11="-DPKCS11CRYPTO"
e55890
 		CRYPTOLIB="pkcs11"
e55890
 		OPENSSLECDSALINKOBJS=""
e55890
 		OPENSSLECDSALINKSRCS=""
99b754
@@ -1609,7 +1611,9 @@ case "$use_openssl" in
e55890
 		OPENSSLGOSTLINKSRCS=""
e55890
 		OPENSSLLINKOBJS=""
e55890
 		OPENSSLLINKSRCS=""
e55890
-		;;
e55890
+fi
e55890
+
e55890
+case "$use_openssl" in
e55890
 	no)
e55890
 		AC_MSG_RESULT(no)
e55890
 		DST_OPENSSL_INC=""
99b754
@@ -1641,7 +1645,7 @@ case "$use_openssl" in
e55890
 If you do not want OpenSSL, use --without-openssl])
e55890
 		;;
e55890
 	*)
e55890
-		if test "yes" = "$want_native_pkcs11"
e55890
+		if false # test "yes" = "$want_native_pkcs11"
e55890
 		then
e55890
 			AC_MSG_RESULT()
e55890
 			AC_MSG_ERROR([OpenSSL and native PKCS11 cannot be used together.])
99b754
@@ -2077,6 +2081,7 @@ AC_SUBST(OPENSSL_ED25519)
e55890
 AC_SUBST(OPENSSL_GOST)
e55890
 
e55890
 DNS_CRYPTO_LIBS="$DNS_CRYPTO_LIBS $DST_OPENSSL_LIBS"
e55890
+DNS_CRYPTO_PK11_LIBS="$DNS_CRYPTO_LIBS"
e55890
 
e55890
 ISC_PLATFORM_WANTAES="#undef ISC_PLATFORM_WANTAES"
e55890
 if test "yes" = "$with_aes"
99b754
@@ -2363,6 +2368,7 @@ esac
e55890
 AC_SUBST(PKCS11LINKOBJS)
e55890
 AC_SUBST(PKCS11LINKSRCS)
e55890
 AC_SUBST(CRYPTO)
e55890
+AC_SUBST(CRYPTO_PK11)
e55890
 AC_SUBST(PKCS11_ECDSA)
e55890
 AC_SUBST(PKCS11_GOST)
e55890
 AC_SUBST(PKCS11_ED25519)
99b754
@@ -5491,8 +5497,11 @@ AC_CONFIG_FILES([
e55890
 	bin/delv/Makefile
e55890
 	bin/dig/Makefile
e55890
 	bin/dnssec/Makefile
e55890
+	bin/dnssec-pkcs11/Makefile	
e55890
 	bin/named/Makefile
e55890
 	bin/named/unix/Makefile
e55890
+	bin/named-pkcs11/Makefile
e55890
+	bin/named-pkcs11/unix/Makefile
e55890
 	bin/nsupdate/Makefile
e55890
 	bin/pkcs11/Makefile
e55890
 	bin/python/Makefile
99b754
@@ -5565,6 +5574,10 @@ AC_CONFIG_FILES([
e55890
 	lib/dns/include/dns/Makefile
e55890
 	lib/dns/include/dst/Makefile
e55890
 	lib/dns/tests/Makefile
e55890
+	lib/dns-pkcs11/Makefile
e55890
+	lib/dns-pkcs11/include/Makefile
e55890
+	lib/dns-pkcs11/include/dns/Makefile
e55890
+	lib/dns-pkcs11/include/dst/Makefile
e55890
 	lib/irs/Makefile
e55890
 	lib/irs/include/Makefile
e55890
 	lib/irs/include/irs/Makefile
99b754
@@ -5589,6 +5602,24 @@ AC_CONFIG_FILES([
e55890
 	lib/isc/unix/include/Makefile
e55890
 	lib/isc/unix/include/isc/Makefile
e55890
 	lib/isc/unix/include/pkcs11/Makefile
e55890
+	lib/isc-pkcs11/$arch/Makefile
e55890
+	lib/isc-pkcs11/$arch/include/Makefile
e55890
+	lib/isc-pkcs11/$arch/include/isc/Makefile
e55890
+	lib/isc-pkcs11/$thread_dir/Makefile
e55890
+	lib/isc-pkcs11/$thread_dir/include/Makefile
e55890
+	lib/isc-pkcs11/$thread_dir/include/isc/Makefile
e55890
+	lib/isc-pkcs11/Makefile
e55890
+	lib/isc-pkcs11/include/Makefile
e55890
+	lib/isc-pkcs11/include/isc/Makefile
e55890
+	lib/isc-pkcs11/include/isc/platform.h
e55890
+	lib/isc-pkcs11/include/pk11/Makefile
e55890
+	lib/isc-pkcs11/include/pkcs11/Makefile
e55890
+	lib/isc-pkcs11/tests/Makefile
e55890
+	lib/isc-pkcs11/nls/Makefile
e55890
+	lib/isc-pkcs11/unix/Makefile
e55890
+	lib/isc-pkcs11/unix/include/Makefile
e55890
+	lib/isc-pkcs11/unix/include/isc/Makefile
e55890
+	lib/isc-pkcs11/unix/include/pkcs11/Makefile
e55890
 	lib/isccc/Makefile
e55890
 	lib/isccc/include/Makefile
e55890
 	lib/isccc/include/isccc/Makefile
e55890
diff --git a/lib/Makefile.in b/lib/Makefile.in
eb7207
index f089bea..3ed939b 100644
e55890
--- a/lib/Makefile.in
e55890
+++ b/lib/Makefile.in
e55890
@@ -15,7 +15,7 @@ top_srcdir =	@top_srcdir@
e55890
 # Attempt to disable parallel processing.
e55890
 .NOTPARALLEL:
e55890
 .NO_PARALLEL:
e55890
-SUBDIRS =	isc isccc dns isccfg bind9 lwres irs samples
e55890
+SUBDIRS =	isc isc-pkcs11 isccc dns dns-pkcs11 isccfg bind9 lwres irs samples
e55890
 TARGETS =
e55890
 
e55890
 @BIND9_MAKE_RULES@
e55890
diff --git a/lib/dns-pkcs11/Makefile.in b/lib/dns-pkcs11/Makefile.in
99b754
index 1d0f5df..98c9ba0 100644
e55890
--- a/lib/dns-pkcs11/Makefile.in
e55890
+++ b/lib/dns-pkcs11/Makefile.in
99b754
@@ -24,17 +24,17 @@ VERSION=@BIND9_VERSION@
e55890
 
99b754
 @BIND9_MAKE_INCLUDES@
e55890
 
e55890
-CINCLUDES =	-I. -I${top_srcdir}/lib/dns -Iinclude ${DNS_INCLUDES} \
27025e
-		${ISC_INCLUDES} ${MAXMINDDB_CFLAGS} \
e55890
+CINCLUDES =	-I. -I${top_srcdir}/lib/dns-pkcs11 -Iinclude ${DNS_PKCS11_INCLUDES} \
99b754
+		${ISC_PKCS11_INCLUDES} ${MAXMINDDB_CFLAGS} \
99b754
 		@DST_OPENSSL_INC@ @DST_GSSAPI_INC@
e55890
 
99b754
-CDEFINES =	-DUSE_MD5 @CRYPTO@ @USE_GSSAPI@
99b754
+CDEFINES =	-DUSE_MD5 @CRYPTO_PK11@ @USE_GSSAPI@
e55890
 
e55890
 CWARNINGS =
e55890
 
e55890
-ISCLIBS =	../../lib/isc/libisc.@A@
e55890
+ISCLIBS =	../../lib/isc-pkcs11/libisc-pkcs11.@A@
e55890
 
e55890
-ISCDEPLIBS =	../../lib/isc/libisc.@A@
e55890
+ISCDEPLIBS =	../../lib/isc-pkcs11/libisc-pkcs11.@A@
e55890
 
27025e
 LIBS =		${MAXMINDDB_LIBS} @LIBS@
e55890
 
99b754
@@ -148,15 +148,15 @@ version.@O@: version.c
e55890
 		-DLIBAGE=${LIBAGE} \
e55890
 		-c ${srcdir}/version.c
e55890
 
e55890
-libdns.@SA@: ${OBJS}
e55890
+libdns-pkcs11.@SA@: ${OBJS}
e55890
 	${AR} ${ARFLAGS} $@ ${OBJS}
e55890
 	${RANLIB} $@
e55890
 
e55890
-libdns.la: ${OBJS}
e55890
+libdns-pkcs11.la: ${OBJS}
e55890
 	${LIBTOOL_MODE_LINK} \
e55890
-		${CC} ${ALL_CFLAGS} ${LDFLAGS} -o libdns.la -rpath ${libdir} \
e55890
+		${CC} ${ALL_CFLAGS} ${LDFLAGS} -o libdns-pkcs11.la -rpath ${libdir} \
e55890
 		-version-info ${LIBINTERFACE}:${LIBREVISION}:${LIBAGE} \
e55890
-		${OBJS} ${ISCLIBS} @DNS_CRYPTO_LIBS@ ${LIBS}
e55890
+		${OBJS} ${ISCLIBS} @DNS_CRYPTO_PK11_LIBS@ ${LIBS}
e55890
 
e55890
 include: gen
e55890
 	${MAKE} include/dns/enumtype.h
99b754
@@ -187,22 +187,22 @@ gen: gen.c
27025e
 	${BUILD_CPPFLAGS} ${BUILD_LDFLAGS} -o $@ ${srcdir}/gen.c \
27025e
 	${BUILD_LIBS} ${LFS_LIBS}
e55890
 
e55890
-timestamp: include libdns.@A@
e55890
+timestamp: include libdns-pkcs11.@A@
e55890
 	touch timestamp
e55890
 
e55890
-testdirs: libdns.@A@
e55890
+testdirs: libdns-pkcs11.@A@
e55890
 
e55890
 installdirs:
e55890
 	$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${libdir}
e55890
 
e55890
 install:: timestamp installdirs
e55890
-	${LIBTOOL_MODE_INSTALL} ${INSTALL_LIBRARY} libdns.@A@ ${DESTDIR}${libdir}
e55890
+	${LIBTOOL_MODE_INSTALL} ${INSTALL_LIBRARY} libdns-pkcs11.@A@ ${DESTDIR}${libdir}
e55890
 
e55890
 uninstall::
e55890
-	${LIBTOOL_MODE_UNINSTALL} rm -f ${DESTDIR}${libdir}/libdns.@A@
e55890
+	${LIBTOOL_MODE_UNINSTALL} rm -f ${DESTDIR}${libdir}/libdns-pkcs11.@A@
e55890
 
e55890
 clean distclean::
e55890
-	rm -f libdns.@A@ timestamp
e55890
+	rm -f libdns-pkcs11.@A@ timestamp
e55890
 	rm -f gen code.h include/dns/enumtype.h include/dns/enumclass.h
e55890
 	rm -f include/dns/rdatastruct.h
27025e
 	rm -f dnstap.pb-c.c dnstap.pb-c.h
e55890
diff --git a/lib/isc-pkcs11/Makefile.in b/lib/isc-pkcs11/Makefile.in
eb7207
index 7e3e9ce..58d7466 100644
e55890
--- a/lib/isc-pkcs11/Makefile.in
e55890
+++ b/lib/isc-pkcs11/Makefile.in
e55890
@@ -23,8 +23,8 @@ CINCLUDES =	-I${srcdir}/unix/include \
e55890
 		-I${srcdir}/@ISC_THREAD_DIR@/include \
e55890
 		-I${srcdir}/@ISC_ARCH_DIR@/include \
e55890
 		-I./include \
e55890
-		-I${srcdir}/include ${DNS_INCLUDES} @ISC_OPENSSL_INC@
e55890
-CDEFINES =	@CRYPTO@ -DPK11_LIB_LOCATION=\"${PROVIDER}\"
e55890
+		-I${srcdir}/include ${DNS_PKCS11_INCLUDES}
e55890
+CDEFINES =	@CRYPTO_PK11@ -DPK11_LIB_LOCATION=\"${PROVIDER}\"
e55890
 CWARNINGS =
e55890
 
e55890
 # Alphabetically
eb7207
@@ -107,40 +107,40 @@ version.@O@: version.c
e55890
 		-DLIBAGE=${LIBAGE} \
e55890
 		-c ${srcdir}/version.c
e55890
 
e55890
-libisc.@SA@: ${OBJS} ${SYMTBLOBJS}
e55890
+libisc-pkcs11.@SA@: ${OBJS} ${SYMTBLOBJS}
e55890
 	${AR} ${ARFLAGS} $@ ${OBJS} ${SYMTBLOBJS}
e55890
 	${RANLIB} $@
e55890
 
e55890
-libisc-nosymtbl.@SA@: ${OBJS}
e55890
+libisc-pkcs11-nosymtbl.@SA@: ${OBJS}
e55890
 	${AR} ${ARFLAGS} $@ ${OBJS}
e55890
 	${RANLIB} $@
e55890
 
e55890
-libisc.la: ${OBJS} ${SYMTBLOBJS}
e55890
+libisc-pkcs11.la: ${OBJS} ${SYMTBLOBJS}
e55890
 	${LIBTOOL_MODE_LINK} \
e55890
-		${CC} ${ALL_CFLAGS} ${LDFLAGS} -o libisc.la -rpath ${libdir} \
e55890
+		${CC} ${ALL_CFLAGS} ${LDFLAGS} -o libisc-pkcs11.la -rpath ${libdir} \
e55890
 		-version-info ${LIBINTERFACE}:${LIBREVISION}:${LIBAGE} \
e55890
 		${OBJS} ${SYMTBLOBJS} ${LIBS}
e55890
 
e55890
-libisc-nosymtbl.la: ${OBJS}
e55890
+libisc-pkcs11-nosymtbl.la: ${OBJS}
e55890
 	${LIBTOOL_MODE_LINK} \
e55890
-		${CC} ${ALL_CFLAGS} ${LDFLAGS} -o libisc-nosymtbl.la -rpath ${libdir} \
e55890
+		${CC} ${ALL_CFLAGS} ${LDFLAGS} -o libisc-pkcs11-nosymtbl.la -rpath ${libdir} \
e55890
 		-version-info ${LIBINTERFACE}:${LIBREVISION}:${LIBAGE} \
e55890
 		${OBJS} ${LIBS}
e55890
 
e55890
-timestamp: libisc.@A@ libisc-nosymtbl.@A@
e55890
+timestamp: libisc-pkcs11.@A@ libisc-pkcs11-nosymtbl.@A@
e55890
 	touch timestamp
e55890
 
e55890
-testdirs: libisc.@A@ libisc-nosymtbl.@A@
e55890
+testdirs: libisc-pkcs11.@A@ libisc-pkcs11-nosymtbl.@A@
e55890
 
e55890
 installdirs:
e55890
 	$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${libdir}
e55890
 
e55890
 install:: timestamp installdirs
e55890
-	${LIBTOOL_MODE_INSTALL} ${INSTALL_LIBRARY} libisc.@A@ ${DESTDIR}${libdir}
e55890
+	${LIBTOOL_MODE_INSTALL} ${INSTALL_LIBRARY} libisc-pkcs11.@A@ ${DESTDIR}${libdir}
e55890
 
e55890
 uninstall::
e55890
-	${LIBTOOL_MODE_UNINSTALL} rm -f ${DESTDIR}${libdir}/libisc.@A@
e55890
+	${LIBTOOL_MODE_UNINSTALL} rm -f ${DESTDIR}${libdir}/libisc-pkcs11.@A@
e55890
 
e55890
 clean distclean::
e55890
-	rm -f libisc.@A@ libisc-nosymtbl.@A@ libisc.la \
e55890
-	libisc-nosymtbl.la timestamp
e55890
+	rm -f libisc-pkcs11.@A@ libisc-pkcs11-nosymtbl.@A@ libisc-pkcs11.la \
e55890
+	libisc-pkcs11-nosymtbl.la timestamp
e55890
diff --git a/make/includes.in b/make/includes.in
eb7207
index 66efe68..966671f 100644
e55890
--- a/make/includes.in
e55890
+++ b/make/includes.in
eb7207
@@ -41,3 +41,13 @@ BIND9_INCLUDES = @BIND9_BIND9_BUILDINCLUDE@ \
e55890
 
e55890
 TEST_INCLUDES = \
e55890
 	-I${top_srcdir}/lib/tests/include
e55890
+
e55890
+ISC_PKCS11_INCLUDES = @BIND9_ISC_BUILDINCLUDE@ \
e55890
+	-I${top_srcdir}/lib/isc-pkcs11 \
e55890
+	-I${top_srcdir}/lib/isc-pkcs11/include \
e55890
+	-I${top_srcdir}/lib/isc-pkcs11/unix/include \
e55890
+	-I${top_srcdir}/lib/isc-pkcs11/@ISC_THREAD_DIR@/include \
e55890
+	-I${top_srcdir}/lib/isc-pkcs11/@ISC_ARCH_DIR@/include
e55890
+
e55890
+DNS_PKCS11_INCLUDES = @BIND9_DNS_BUILDINCLUDE@ \
e55890
+	-I${top_srcdir}/lib/dns-pkcs11/include