Tomas Hozza dce2d1
diff --git a/bin/Makefile.in b/bin/Makefile.in
df81e8
index 9ad7f62..094775a 100644
Tomas Hozza dce2d1
--- a/bin/Makefile.in
Tomas Hozza dce2d1
+++ b/bin/Makefile.in
df81e8
@@ -11,7 +11,7 @@ srcdir =	@srcdir@
Tomas Hozza dce2d1
 VPATH =		@srcdir@
Tomas Hozza dce2d1
 top_srcdir =	@top_srcdir@
Tomas Hozza dce2d1
 
a38c25
-SUBDIRS =	named rndc dig delv dnssec tools nsupdate check confgen \
df81e8
+SUBDIRS =	named named-pkcs11 rndc dig delv dnssec dnssec-pkcs11 tools nsupdate check confgen \
df81e8
 		@NZD_TOOLS@ @PYTHON_TOOLS@ @PKCS11_TOOLS@ plugins tests
Tomas Hozza dce2d1
 TARGETS =
Tomas Hozza dce2d1
 
05dbc8
diff --git a/bin/confgen/Makefile.in b/bin/confgen/Makefile.in
b8ccda
index c126bf3..1b7512d 100644
05dbc8
--- a/bin/confgen/Makefile.in
05dbc8
+++ b/bin/confgen/Makefile.in
05dbc8
@@ -22,7 +22,7 @@ VERSION=@BIND9_VERSION@
05dbc8
 CINCLUDES = -I${srcdir}/include ${ISC_INCLUDES} ${ISCCC_INCLUDES} \
05dbc8
 	${ISCCFG_INCLUDES} ${DNS_INCLUDES} ${BIND9_INCLUDES}
05dbc8
 
05dbc8
-CDEFINES = @USE_PKCS11@
05dbc8
+CDEFINES =
05dbc8
 CWARNINGS =
05dbc8
 
05dbc8
 ISCCFGLIBS =	../../lib/isccfg/libisccfg.@A@
Tomas Hozza dce2d1
diff --git a/bin/dnssec-pkcs11/Makefile.in b/bin/dnssec-pkcs11/Makefile.in
b8ccda
index ace0e5a..e0f6a00 100644
Tomas Hozza dce2d1
--- a/bin/dnssec-pkcs11/Makefile.in
Tomas Hozza dce2d1
+++ b/bin/dnssec-pkcs11/Makefile.in
afbbd0
@@ -15,18 +15,18 @@ VERSION=@BIND9_VERSION@
Tomas Hozza dce2d1
 
Tomas Hozza dce2d1
 @BIND9_MAKE_INCLUDES@
Tomas Hozza dce2d1
 
afbbd0
-CINCLUDES =	${DNS_INCLUDES} ${ISC_INCLUDES} ${ISCCFG_INCLUDES} \
afbbd0
+CINCLUDES =	${DNS_PKCS11_INCLUDES} ${ISC_INCLUDES} ${ISCCFG_INCLUDES} \
afbbd0
 		${OPENSSL_CFLAGS}
Tomas Hozza dce2d1
 
afbbd0
-CDEFINES =	-DVERSION=\"${VERSION}\" -DNAMED_CONFFILE=\"${sysconfdir}/named.conf\"
afbbd0
+CDEFINES =	-DVERSION=\"${VERSION}\" -DNAMED_CONFFILE=\"${sysconfdir}/named.conf\" -DUSE_PKCS11=1
Tomas Hozza dce2d1
 CWARNINGS =
Tomas Hozza dce2d1
 
b8ccda
-DNSLIBS =	../../lib/dns/libdns.@A@ @NO_LIBTOOL_DNSLIBS@
b8ccda
+DNSLIBS =	../../lib/dns-pkcs11/libdns-pkcs11.@A@ @NO_LIBTOOL_DNSLIBS@
afbbd0
 ISCCFGLIBS =	../../lib/isccfg/libisccfg.@A@
b8ccda
 ISCLIBS =	../../lib/isc/libisc.@A@ @NO_LIBTOOL_ISCLIBS@
b8ccda
 ISCNOSYMLIBS =	../../lib/isc/libisc-nosymtbl.@A@ @NO_LIBTOOL_ISCLIBS@
Tomas Hozza dce2d1
 
Tomas Hozza dce2d1
-DNSDEPLIBS =	../../lib/dns/libdns.@A@
Tomas Hozza dce2d1
+DNSDEPLIBS =	../../lib/dns-pkcs11/libdns-pkcs11.@A@
05dbc8
 ISCDEPLIBS =	../../lib/isc/libisc.@A@
afbbd0
 ISCCFGDEPLIBS =	../../lib/isccfg/libisccfg.@A@
Tomas Hozza dce2d1
 
afbbd0
@@ -36,12 +36,15 @@ LIBS =		${DNSLIBS} ${ISCCFGLIBS} ${ISCLIBS} @LIBS@
Tomas Hozza dce2d1
 
afbbd0
 NOSYMLIBS =	${DNSLIBS} ${ISCCFGLIBS} ${ISCNOSYMLIBS} @LIBS@
afbbd0
 
afbbd0
+# Add suffix to all targets
afbbd0
+EXEEXT =	-pkcs11@EXEEXT@
afbbd0
+
Tomas Hozza dce2d1
 # Alphabetically
df81e8
-TARGETS =	dnssec-cds@EXEEXT@ dnssec-dsfromkey@EXEEXT@ \
df81e8
-		dnssec-importkey@EXEEXT@ dnssec-keyfromlabel@EXEEXT@ \
df81e8
-		dnssec-keygen@EXEEXT@ dnssec-revoke@EXEEXT@ \
df81e8
-		dnssec-settime@EXEEXT@ dnssec-signzone@EXEEXT@ \
df81e8
-		dnssec-verify@EXEEXT@
afbbd0
+TARGETS =	dnssec-cds${EXEEXT} dnssec-dsfromkey${EXEEXT} \
afbbd0
+		dnssec-importkey${EXEEXT} dnssec-keyfromlabel${EXEEXT} \
afbbd0
+		dnssec-keygen${EXEEXT} dnssec-revoke${EXEEXT} \
afbbd0
+		dnssec-settime${EXEEXT} dnssec-signzone${EXEEXT} \
afbbd0
+		dnssec-verify${EXEEXT}
Tomas Hozza dce2d1
 
Tomas Hozza dce2d1
 OBJS =		dnssectool.@O@
Tomas Hozza dce2d1
 
b8ccda
@@ -52,19 +55,19 @@ SRCS =		dnssec-cds.c dnssec-dsfromkey.c dnssec-importkey.c \
Tomas Hozza dce2d1
 
Tomas Hozza dce2d1
 @BIND9_MAKE_RULES@
Tomas Hozza dce2d1
 
df81e8
-dnssec-cds@EXEEXT@: dnssec-cds.@O@ ${OBJS} ${DEPLIBS}
df81e8
+dnssec-cds-pkcs11@EXEEXT@: dnssec-cds.@O@ ${OBJS} ${DEPLIBS}
df81e8
 	export BASEOBJS="dnssec-cds.@O@ ${OBJS}"; \
df81e8
 	${FINALBUILDCMD}
df81e8
 
Tomas Hozza dce2d1
-dnssec-dsfromkey@EXEEXT@: dnssec-dsfromkey.@O@ ${OBJS} ${DEPLIBS}
Tomas Hozza dce2d1
+dnssec-dsfromkey-pkcs11@EXEEXT@: dnssec-dsfromkey.@O@ ${OBJS} ${DEPLIBS}
Tomas Hozza dce2d1
 	export BASEOBJS="dnssec-dsfromkey.@O@ ${OBJS}"; \
Tomas Hozza dce2d1
 	${FINALBUILDCMD}
Tomas Hozza dce2d1
 
Tomas Hozza dce2d1
-dnssec-keyfromlabel@EXEEXT@: dnssec-keyfromlabel.@O@ ${OBJS} ${DEPLIBS}
Tomas Hozza dce2d1
+dnssec-keyfromlabel-pkcs11@EXEEXT@: dnssec-keyfromlabel.@O@ ${OBJS} ${DEPLIBS}
Tomas Hozza dce2d1
 	export BASEOBJS="dnssec-keyfromlabel.@O@ ${OBJS}"; \
Tomas Hozza dce2d1
 	${FINALBUILDCMD}
Tomas Hozza dce2d1
 
Tomas Hozza dce2d1
-dnssec-keygen@EXEEXT@: dnssec-keygen.@O@ ${OBJS} ${DEPLIBS}
Tomas Hozza dce2d1
+dnssec-keygen-pkcs11@EXEEXT@: dnssec-keygen.@O@ ${OBJS} ${DEPLIBS}
Tomas Hozza dce2d1
 	export BASEOBJS="dnssec-keygen.@O@ ${OBJS}"; \
Tomas Hozza dce2d1
 	${FINALBUILDCMD}
Tomas Hozza dce2d1
 
b8ccda
@@ -72,7 +75,7 @@ dnssec-signzone.@O@: dnssec-signzone.c
Tomas Hozza dce2d1
 	${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} -DVERSION=\"${VERSION}\" \
Tomas Hozza dce2d1
 		-c ${srcdir}/dnssec-signzone.c
Tomas Hozza dce2d1
 
Tomas Hozza dce2d1
-dnssec-signzone@EXEEXT@: dnssec-signzone.@O@ ${OBJS} ${DEPLIBS}
Tomas Hozza dce2d1
+dnssec-signzone-pkcs11@EXEEXT@: dnssec-signzone.@O@ ${OBJS} ${DEPLIBS}
Tomas Hozza dce2d1
 	export BASEOBJS="dnssec-signzone.@O@ ${OBJS}"; \
Tomas Hozza dce2d1
 	${FINALBUILDCMD}
Tomas Hozza dce2d1
 
b8ccda
@@ -80,19 +83,19 @@ dnssec-verify.@O@: dnssec-verify.c
Tomas Hozza dce2d1
 	${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} -DVERSION=\"${VERSION}\" \
Tomas Hozza dce2d1
 		-c ${srcdir}/dnssec-verify.c
Tomas Hozza dce2d1
 
Tomas Hozza dce2d1
-dnssec-verify@EXEEXT@: dnssec-verify.@O@ ${OBJS} ${DEPLIBS}
Tomas Hozza dce2d1
+dnssec-verify-pkcs11@EXEEXT@: dnssec-verify.@O@ ${OBJS} ${DEPLIBS}
Tomas Hozza dce2d1
 	export BASEOBJS="dnssec-verify.@O@ ${OBJS}"; \
Tomas Hozza dce2d1
 	${FINALBUILDCMD}
Tomas Hozza dce2d1
 
Tomas Hozza dce2d1
-dnssec-revoke@EXEEXT@: dnssec-revoke.@O@ ${OBJS} ${DEPLIBS}
Tomas Hozza dce2d1
+dnssec-revoke-pkcs11@EXEEXT@: dnssec-revoke.@O@ ${OBJS} ${DEPLIBS}
Tomas Hozza dce2d1
 	${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
Tomas Hozza dce2d1
 	dnssec-revoke.@O@ ${OBJS} ${LIBS}
Tomas Hozza dce2d1
 
Tomas Hozza dce2d1
-dnssec-settime@EXEEXT@: dnssec-settime.@O@ ${OBJS} ${DEPLIBS}
Tomas Hozza dce2d1
+dnssec-settime-pkcs11@EXEEXT@: dnssec-settime.@O@ ${OBJS} ${DEPLIBS}
Tomas Hozza dce2d1
 	${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
Tomas Hozza dce2d1
 	dnssec-settime.@O@ ${OBJS} ${LIBS}
Tomas Hozza dce2d1
 
Tomas Hozza dce2d1
-dnssec-importkey@EXEEXT@: dnssec-importkey.@O@ ${OBJS} ${DEPLIBS}
Tomas Hozza dce2d1
+dnssec-importkey-pkcs11@EXEEXT@: dnssec-importkey.@O@ ${OBJS} ${DEPLIBS}
Tomas Hozza dce2d1
 	${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
Tomas Hozza dce2d1
 	dnssec-importkey.@O@ ${OBJS} ${LIBS}
Tomas Hozza dce2d1
 
Tomas Hozza dce2d1
diff --git a/bin/named-pkcs11/Makefile.in b/bin/named-pkcs11/Makefile.in
b47115
index 525f505..d517ec6 100644
Tomas Hozza dce2d1
--- a/bin/named-pkcs11/Makefile.in
Tomas Hozza dce2d1
+++ b/bin/named-pkcs11/Makefile.in
afbbd0
@@ -37,13 +37,14 @@ DBDRIVER_LIBS =
afbbd0
 
afbbd0
 DLZ_DRIVER_DIR =	${top_srcdir}/contrib/dlz/drivers
afbbd0
 
afbbd0
-DLZDRIVER_OBJS =	@DLZ_DRIVER_OBJS@
afbbd0
-DLZDRIVER_SRCS =	@DLZ_DRIVER_SRCS@
afbbd0
-DLZDRIVER_INCLUDES =	@DLZ_DRIVER_INCLUDES@
afbbd0
-DLZDRIVER_LIBS =	@DLZ_DRIVER_LIBS@
afbbd0
+# Skip building on PKCS11 variant
afbbd0
+DLZDRIVER_OBJS =
afbbd0
+DLZDRIVER_SRCS =
afbbd0
+DLZDRIVER_INCLUDES =
afbbd0
+DLZDRIVER_LIBS =
Tomas Hozza dce2d1
 
Tomas Hozza dce2d1
 CINCLUDES =	-I${srcdir}/include -I${srcdir}/unix/include -I. \
df81e8
-		${NS_INCLUDES} ${DNS_INCLUDES} \
05dbc8
+		${NS_PKCS11_INCLUDES} ${DNS_PKCS11_INCLUDES} \
df81e8
 		${BIND9_INCLUDES} ${ISCCFG_INCLUDES} ${ISCCC_INCLUDES} \
05dbc8
 		${ISC_INCLUDES} ${DLZDRIVER_INCLUDES} \
afbbd0
 		${DBDRIVER_INCLUDES} \
b47115
@@ -55,24 +56,24 @@ CINCLUDES =	-I${srcdir}/include -I${srcdir}/unix/include -I. \
b8ccda
 		${LIBXML2_CFLAGS} \
b8ccda
 		${MAXMINDDB_CFLAGS}
afbbd0
 
afbbd0
-CDEFINES =      @CONTRIB_DLZ@
afbbd0
+CDEFINES =
Tomas Hozza dce2d1
 
Tomas Hozza dce2d1
 CWARNINGS =
Tomas Hozza dce2d1
 
b8ccda
-DNSLIBS =	../../lib/dns/libdns.@A@ @NO_LIBTOOL_DNSLIBS@
b8ccda
+DNSLIBS =	../../lib/dns-pkcs11/libdns-pkcs11.@A@ @NO_LIBTOOL_DNSLIBS@
Tomas Hozza dce2d1
 ISCCFGLIBS =	../../lib/isccfg/libisccfg.@A@
Tomas Hozza dce2d1
 ISCCCLIBS =	../../lib/isccc/libisccc.@A@
b8ccda
 ISCLIBS =	../../lib/isc/libisc.@A@ @NO_LIBTOOL_ISCLIBS@
b8ccda
 ISCNOSYMLIBS =	../../lib/isc/libisc-nosymtbl.@A@ @NO_LIBTOOL_ISCLIBS@
Tomas Hozza dce2d1
 BIND9LIBS =	../../lib/bind9/libbind9.@A@
05dbc8
-NSLIBS =	../../lib/ns/libns.@A@
05dbc8
+NSLIBS =	../../lib/ns-pkcs11/libns-pkcs11.@A@
Tomas Hozza dce2d1
 
Tomas Hozza dce2d1
-DNSDEPLIBS =	../../lib/dns/libdns.@A@
371a1e
+DNSDEPLIBS =	../../lib/dns-pkcs11/libdns-pkcs11.@A@
Tomas Hozza dce2d1
 ISCCFGDEPLIBS =	../../lib/isccfg/libisccfg.@A@
Tomas Hozza dce2d1
 ISCCCDEPLIBS =	../../lib/isccc/libisccc.@A@
05dbc8
 ISCDEPLIBS =	../../lib/isc/libisc.@A@
Tomas Hozza dce2d1
 BIND9DEPLIBS =	../../lib/bind9/libbind9.@A@
05dbc8
-NSDEPLIBS =	../../lib/ns/libns.@A@
05dbc8
+NSDEPLIBS =	../../lib/ns-pkcs11/libns-pkcs11.@A@
Tomas Hozza dce2d1
 
05dbc8
 DEPLIBS =	${NSDEPLIBS} ${DNSDEPLIBS} ${BIND9DEPLIBS} \
05dbc8
 		${ISCCFGDEPLIBS} ${ISCCCDEPLIBS} ${ISCDEPLIBS}
b47115
@@ -92,7 +93,7 @@ NOSYMLIBS =	${NSLIBS} ${DNSLIBS} ${BIND9LIBS} \
Tomas Hozza dce2d1
 
Tomas Hozza dce2d1
 SUBDIRS =	unix
Tomas Hozza dce2d1
 
df81e8
-TARGETS =	named@EXEEXT@ feature-test@EXEEXT@
d0d728
+TARGETS =	named-pkcs11@EXEEXT@ feature-test-pkcs11@EXEEXT@
Tomas Hozza dce2d1
 
2dbb09
 GEOIP2LINKOBJS = geoip.@O@
afbbd0
 
b47115
@@ -150,7 +151,7 @@ server.@O@: server.c
Michal Ruprich d886cd
 		-DPRODUCT=\"${PRODUCT}\" \
Michal Ruprich d886cd
 		-DVERSION=\"${VERSION}\" -c ${srcdir}/server.c
Tomas Hozza dce2d1
 
cb2172
-named@EXEEXT@: ${OBJS} ${DEPLIBS}
cb2172
+named-pkcs11@EXEEXT@: ${OBJS} ${DEPLIBS}
Tomas Hozza dce2d1
 	export MAKE_SYMTABLE="yes"; \
Tomas Hozza dce2d1
 	export BASEOBJS="${OBJS} ${UOBJS}"; \
Tomas Hozza dce2d1
 	${FINALBUILDCMD}
b47115
@@ -160,7 +161,7 @@ feature-test.@O@: ${top_srcdir}/bin/tests/system/feature-test.c
d0d728
 	${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} \
d0d728
 		-c ${top_srcdir}/bin/tests/system/feature-test.c
d0d728
 
d0d728
-feature-test@EXEEXT@: feature-test.@O@
d0d728
+feature-test-pkcs11@EXEEXT@: feature-test.@O@
d0d728
 	${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} \
d0d728
 		-o $@ feature-test.@O@ ${ISCLIBS} ${LIBS}
cb2172
 
b47115
@@ -179,11 +180,11 @@ statschannel.@O@: bind9.xsl.h
b8ccda
 installdirs:
b8ccda
 	$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${sbindir}
Michal Ruprich d886cd
 
b8ccda
-install:: named@EXEEXT@ installdirs
Tomas Hozza dce2d1
-	${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} named@EXEEXT@ ${DESTDIR}${sbindir}
b8ccda
+install:: named-pkcs11@EXEEXT@ installdirs
Tomas Hozza dce2d1
+	${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} named-pkcs11@EXEEXT@ ${DESTDIR}${sbindir}
Tomas Hozza dce2d1
 
102df2
 uninstall::
102df2
-	${LIBTOOL_MODE_UNINSTALL} rm -f ${DESTDIR}${sbindir}/named@EXEEXT@
102df2
+	${LIBTOOL_MODE_UNINSTALL} rm -f ${DESTDIR}${sbindir}/named-pkcs11@EXEEXT@
102df2
 
Tomas Hozza dce2d1
 @DLZ_DRIVER_RULES@
Tomas Hozza dce2d1
 
1e4169
diff --git a/configure.ac b/configure.ac
b47115
index 1932000..cf15786 100644
1e4169
--- a/configure.ac
1e4169
+++ b/configure.ac
b47115
@@ -1244,12 +1244,14 @@ AC_SUBST(USE_GSSAPI)
Tomas Hozza 4fa997
 AC_SUBST(DST_GSSAPI_INC)
Tomas Hozza 4fa997
 AC_SUBST(DNS_GSSAPI_LIBS)
df81e8
 DNS_CRYPTO_LIBS="$DNS_GSSAPI_LIBS"
Tomas Hozza 4fa997
+DNS_CRYPTO_PK11_LIBS="$DNS_GSSAPI_LIBS $DNS_CRYPTO_PK11_LIBS"
Tomas Hozza 4fa997
 
Tomas Hozza 4fa997
 #
Tomas Hozza 4fa997
 # Applications linking with libdns also need to link with these libraries.
Tomas Hozza 4fa997
 #
Tomas Hozza 4fa997
 
Tomas Hozza 4fa997
 AC_SUBST(DNS_CRYPTO_LIBS)
Tomas Hozza 4fa997
+AC_SUBST(DNS_CRYPTO_PK11_LIBS)
Tomas Hozza 4fa997
 
Tomas Hozza 4fa997
 #
df81e8
 # was --with-lmdb specified?
b47115
@@ -2336,6 +2338,8 @@ AC_SUBST(BIND9_DNS_BUILDINCLUDE)
df81e8
 AC_SUBST(BIND9_NS_BUILDINCLUDE)
df81e8
 AC_SUBST(BIND9_BIND9_BUILDINCLUDE)
df81e8
 AC_SUBST(BIND9_IRS_BUILDINCLUDE)
df81e8
+AC_SUBST(BIND9_DNS_PKCS11_BUILDINCLUDE)
df81e8
+AC_SUBST(BIND9_NS_PKCS11_BUILDINCLUDE)
df81e8
 if test "X$srcdir" != "X"; then
df81e8
 	BIND9_ISC_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/isc/include"
df81e8
 	BIND9_ISCCC_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/isccc/include"
b47115
@@ -2344,6 +2348,8 @@ if test "X$srcdir" != "X"; then
df81e8
 	BIND9_NS_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/ns/include"
df81e8
 	BIND9_BIND9_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/bind9/include"
df81e8
 	BIND9_IRS_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/irs/include"
df81e8
+	BIND9_DNS_PKCS11_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/dns-pkcs11/include"
df81e8
+	BIND9_NS_PKCS11_BUILDINCLUDE="-I${BIND9_TOP_BUILDDIR}/lib/ns-pkcs11/include"
df81e8
 else
df81e8
 	BIND9_ISC_BUILDINCLUDE=""
df81e8
 	BIND9_ISCCC_BUILDINCLUDE=""
b47115
@@ -2352,6 +2358,8 @@ else
df81e8
 	BIND9_NS_BUILDINCLUDE=""
df81e8
 	BIND9_BIND9_BUILDINCLUDE=""
df81e8
 	BIND9_IRS_BUILDINCLUDE=""
df81e8
+	BIND9_DNS_PKCS11_BUILDINCLUDE=""
df81e8
+	BIND9_NS_PKCS11_BUILDINCLUDE=""
Tomas Hozza dce2d1
 fi
df81e8
 
df81e8
 AC_SUBST_FILE(BIND9_MAKE_INCLUDES)
b47115
@@ -2824,8 +2832,11 @@ AC_CONFIG_FILES([
Tomas Hozza 4fa997
 	bin/delv/Makefile
Tomas Hozza dce2d1
 	bin/dig/Makefile
Tomas Hozza dce2d1
 	bin/dnssec/Makefile
df81e8
+	bin/dnssec-pkcs11/Makefile
Tomas Hozza dce2d1
 	bin/named/Makefile
Tomas Hozza 4fa997
 	bin/named/unix/Makefile
Tomas Hozza dce2d1
+	bin/named-pkcs11/Makefile
Tomas Hozza dce2d1
+	bin/named-pkcs11/unix/Makefile
Tomas Hozza dce2d1
 	bin/nsupdate/Makefile
Tomas Hozza dce2d1
 	bin/pkcs11/Makefile
df81e8
 	bin/plugins/Makefile
b47115
@@ -2887,6 +2898,10 @@ AC_CONFIG_FILES([
Tomas Hozza dce2d1
 	lib/dns/include/dns/Makefile
Tomas Hozza dce2d1
 	lib/dns/include/dst/Makefile
Tomas Hozza dce2d1
 	lib/dns/tests/Makefile
Tomas Hozza dce2d1
+	lib/dns-pkcs11/Makefile
Tomas Hozza dce2d1
+	lib/dns-pkcs11/include/Makefile
Tomas Hozza dce2d1
+	lib/dns-pkcs11/include/dns/Makefile
Tomas Hozza dce2d1
+	lib/dns-pkcs11/include/dst/Makefile
Tomas Hozza 4fa997
 	lib/irs/Makefile
Tomas Hozza 4fa997
 	lib/irs/include/Makefile
Tomas Hozza 4fa997
 	lib/irs/include/irs/Makefile
b47115
@@ -2919,6 +2934,10 @@ AC_CONFIG_FILES([
05dbc8
 	lib/ns/include/Makefile
05dbc8
 	lib/ns/include/ns/Makefile
05dbc8
 	lib/ns/tests/Makefile
05dbc8
+	lib/ns-pkcs11/Makefile
05dbc8
+	lib/ns-pkcs11/include/Makefile
05dbc8
+	lib/ns-pkcs11/include/ns/Makefile
05dbc8
+	lib/ns-pkcs11/tests/Makefile
05dbc8
 	lib/samples/Makefile
05dbc8
 	lib/samples/Makefile-postinstall
afbbd0
 	make/Makefile
Tomas Hozza dce2d1
diff --git a/lib/Makefile.in b/lib/Makefile.in
05dbc8
index ffa2d5a..6fbc192 100644
Tomas Hozza dce2d1
--- a/lib/Makefile.in
Tomas Hozza dce2d1
+++ b/lib/Makefile.in
a38c25
@@ -15,7 +15,7 @@ top_srcdir =	@top_srcdir@
Tomas Hozza dce2d1
 # Attempt to disable parallel processing.
Tomas Hozza dce2d1
 .NOTPARALLEL:
Tomas Hozza dce2d1
 .NO_PARALLEL:
df81e8
-SUBDIRS =	isc isccc dns ns isccfg bind9 irs samples
05dbc8
+SUBDIRS =	isc isccc dns dns-pkcs11 ns ns-pkcs11 isccfg bind9 irs samples
Tomas Hozza dce2d1
 TARGETS =
Tomas Hozza dce2d1
 
Tomas Hozza dce2d1
 @BIND9_MAKE_RULES@
Tomas Hozza dce2d1
diff --git a/lib/dns-pkcs11/Makefile.in b/lib/dns-pkcs11/Makefile.in
b8ccda
index 8de85bf..d5c3c2b 100644
Tomas Hozza dce2d1
--- a/lib/dns-pkcs11/Makefile.in
Tomas Hozza dce2d1
+++ b/lib/dns-pkcs11/Makefile.in
b8ccda
@@ -26,7 +26,7 @@ VERSION=@BIND9_VERSION@
Tomas Hozza dce2d1
 
Tomas Hozza dce2d1
 USE_ISC_SPNEGO = @USE_ISC_SPNEGO@
Tomas Hozza dce2d1
 
Tomas Hozza 4fa997
-CINCLUDES =	-I. -I${top_srcdir}/lib/dns -Iinclude ${DNS_INCLUDES} \
Tomas Hozza 4fa997
+CINCLUDES =	-I. -I${top_srcdir}/lib/dns-pkcs11 -Iinclude ${DNS_PKCS11_INCLUDES} \
afbbd0
 		${ISC_INCLUDES} \
b8ccda
 		${FSTRM_CFLAGS} \
afbbd0
 		${OPENSSL_CFLAGS} @DST_GSSAPI_INC@ \
b8ccda
@@ -36,7 +36,7 @@ CINCLUDES =	-I. -I${top_srcdir}/lib/dns -Iinclude ${DNS_INCLUDES} \
b8ccda
 		${LMDB_CFLAGS} \
afbbd0
 		${MAXMINDDB_CFLAGS}
Tomas Hozza dce2d1
 
afbbd0
-CDEFINES =	@USE_GSSAPI@ ${USE_ISC_SPNEGO}
afbbd0
+CDEFINES =	@USE_GSSAPI@ ${USE_ISC_SPNEGO} @USE_PKCS11@
Tomas Hozza dce2d1
 
Tomas Hozza dce2d1
 CWARNINGS =
Tomas Hozza dce2d1
 
b8ccda
@@ -142,15 +142,15 @@ version.@O@: version.c
Tomas Hozza 4fa997
 		-DLIBAGE=${LIBAGE} \
Tomas Hozza 4fa997
 		-c ${srcdir}/version.c
Tomas Hozza dce2d1
 
Tomas Hozza dce2d1
-libdns.@SA@: ${OBJS}
Tomas Hozza dce2d1
+libdns-pkcs11.@SA@: ${OBJS}
Tomas Hozza dce2d1
 	${AR} ${ARFLAGS} $@ ${OBJS}
Tomas Hozza dce2d1
 	${RANLIB} $@
Tomas Hozza dce2d1
 
Tomas Hozza dce2d1
-libdns.la: ${OBJS}
Tomas Hozza dce2d1
+libdns-pkcs11.la: ${OBJS}
Tomas Hozza dce2d1
 	${LIBTOOL_MODE_LINK} \
Tomas Hozza dce2d1
-		${CC} ${ALL_CFLAGS} ${LDFLAGS} -o libdns.la -rpath ${libdir} \
Tomas Hozza dce2d1
+		${CC} ${ALL_CFLAGS} ${LDFLAGS} -o libdns-pkcs11.la -rpath ${libdir} \
Tomas Hozza dce2d1
 		-version-info ${LIBINTERFACE}:${LIBREVISION}:${LIBAGE} \
Tomas Hozza dce2d1
-		${OBJS} ${ISCLIBS} @DNS_CRYPTO_LIBS@ ${LIBS}
Tomas Hozza dce2d1
+		${OBJS} ${ISCLIBS} @DNS_CRYPTO_PK11_LIBS@ ${LIBS}
102df2
 
79d28e
 include: gen
79d28e
 	${MAKE} include/dns/enumtype.h
b8ccda
@@ -181,22 +181,22 @@ gen: gen.c
2dbb09
 	${BUILD_CPPFLAGS} ${BUILD_LDFLAGS} -o $@ ${srcdir}/gen.c \
2dbb09
 	${BUILD_LIBS} ${LFS_LIBS}
79d28e
 
79d28e
-timestamp: include libdns.@A@
79d28e
+timestamp: include libdns-pkcs11.@A@
Tomas Hozza dce2d1
 	touch timestamp
102df2
 
79d28e
-testdirs: libdns.@A@
79d28e
+testdirs: libdns-pkcs11.@A@
79d28e
 
Tomas Hozza dce2d1
 installdirs:
Tomas Hozza dce2d1
 	$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${libdir}
102df2
 
Tomas Hozza dce2d1
 install:: timestamp installdirs
Tomas Hozza dce2d1
-	${LIBTOOL_MODE_INSTALL} ${INSTALL_LIBRARY} libdns.@A@ ${DESTDIR}${libdir}
Tomas Hozza dce2d1
+	${LIBTOOL_MODE_INSTALL} ${INSTALL_LIBRARY} libdns-pkcs11.@A@ ${DESTDIR}${libdir}
102df2
 
102df2
 uninstall::
102df2
-	${LIBTOOL_MODE_UNINSTALL} rm -f ${DESTDIR}${libdir}/libdns.@A@
102df2
+	${LIBTOOL_MODE_UNINSTALL} rm -f ${DESTDIR}${libdir}/libdns-pkcs11.@A@
102df2
 
Tomas Hozza dce2d1
 clean distclean::
Tomas Hozza dce2d1
-	rm -f libdns.@A@ timestamp
Tomas Hozza dce2d1
+	rm -f libdns-pkcs11.@A@ timestamp
Tomas Hozza dce2d1
 	rm -f gen code.h include/dns/enumtype.h include/dns/enumclass.h
Tomas Hozza dce2d1
 	rm -f include/dns/rdatastruct.h
2dbb09
 	rm -f dnstap.pb-c.c dnstap.pb-c.h
05dbc8
diff --git a/lib/dns-pkcs11/tests/Makefile.in b/lib/dns-pkcs11/tests/Makefile.in
b8ccda
index 8aec0a8..3c2cc04 100644
05dbc8
--- a/lib/dns-pkcs11/tests/Makefile.in
05dbc8
+++ b/lib/dns-pkcs11/tests/Makefile.in
05dbc8
@@ -15,14 +15,14 @@ VERSION=@BIND9_VERSION@
05dbc8
 
05dbc8
 @BIND9_MAKE_INCLUDES@
05dbc8
 
05dbc8
-CINCLUDES =	-I. -Iinclude ${DNS_INCLUDES} ${ISC_INCLUDES} \
05dbc8
+CINCLUDES =	-I. -Iinclude ${DNS_PKCS11_INCLUDES} ${ISC_INCLUDES} \
afbbd0
 		${OPENSSL_CFLAGS} ${MAXMINDDB_CFLAGS} @CMOCKA_CFLAGS@
05dbc8
-CDEFINES =	-DTESTS="\"${top_builddir}/lib/dns/tests/\""
05dbc8
+CDEFINES =	@USE_PKCS11@ -DTESTS="\"${top_builddir}/lib/dns-pkcs11/tests/\""
05dbc8
 
b8ccda
 ISCLIBS =	../../isc/libisc.@A@ @NO_LIBTOOL_ISCLIBS@
05dbc8
 ISCDEPLIBS =	../../isc/libisc.@A@
b8ccda
-DNSLIBS =	../libdns.@A@ @NO_LIBTOOL_DNSLIBS@
05dbc8
-DNSDEPLIBS =	../libdns.@A@
b8ccda
+DNSLIBS =	../libdns-pkcs11.@A@ @NO_LIBTOOL_DNSLIBS@
05dbc8
+DNSDEPLIBS =	../libdns-pkcs11.@A@
05dbc8
 
05dbc8
 LIBS =		@LIBS@ @CMOCKA_LIBS@
05dbc8
 
05dbc8
diff --git a/lib/ns-pkcs11/Makefile.in b/lib/ns-pkcs11/Makefile.in
b8ccda
index d00ddaf..b867afe 100644
05dbc8
--- a/lib/ns-pkcs11/Makefile.in
05dbc8
+++ b/lib/ns-pkcs11/Makefile.in
b8ccda
@@ -20,12 +20,12 @@ VERSION=@BIND9_VERSION@
05dbc8
 
05dbc8
 USE_ISC_SPNEGO = @USE_ISC_SPNEGO@
05dbc8
 
05dbc8
-CINCLUDES =	-I. -I${top_srcdir}/lib/ns -Iinclude \
05dbc8
-		${NS_INCLUDES} ${DNS_INCLUDES} ${ISC_INCLUDES} \
05dbc8
+CINCLUDES =	-I. -I${top_srcdir}/lib/ns-pkcs11 -Iinclude \
05dbc8
+		${NS_PKCS11_INCLUDES} ${DNS_PKCS11_INCLUDES} ${ISC_INCLUDES} \
b8ccda
 		${OPENSSL_CFLAGS} @DST_GSSAPI_INC@ \
b8ccda
 		${FSTRM_CFLAGS}
05dbc8
 
afbbd0
-CDEFINES =	-DNAMED_PLUGINDIR=\"${plugindir}\"
afbbd0
+CDEFINES =	@USE_PKCS11@ -DNAMED_PLUGINDIR=\"${plugindir}\"
afbbd0
 
afbbd0
 CWARNINGS =
afbbd0
 
b8ccda
@@ -33,9 +33,9 @@ ISCLIBS =	../../lib/isc/libisc.@A@
05dbc8
 
05dbc8
 ISCDEPLIBS =	../../lib/isc/libisc.@A@
05dbc8
 
b8ccda
-DNSLIBS =	../../lib/dns/libdns.@A@ @NO_LIBTOOL_DNSLIBS@
b8ccda
+DNSLIBS =	../../lib/dns-pkcs11/libdns-pkcs11.@A@ @NO_LIBTOOL_DNSLIBS@
05dbc8
 
05dbc8
-DNSDEPLIBS =	../../lib/dns/libdns.@A@
05dbc8
+DNSDEPLIBS =	../../lib/dns-pkcs11/libdns-pkcs11.@A@
05dbc8
 
05dbc8
 LIBS =		@LIBS@
05dbc8
 
b8ccda
@@ -67,28 +67,28 @@ version.@O@: version.c
Tomas Hozza dce2d1
 		-DLIBAGE=${LIBAGE} \
Tomas Hozza dce2d1
 		-c ${srcdir}/version.c
Tomas Hozza dce2d1
 
05dbc8
-libns.@SA@: ${OBJS}
05dbc8
+libns-pkcs11.@SA@: ${OBJS}
Tomas Hozza dce2d1
 	${AR} ${ARFLAGS} $@ ${OBJS}
Tomas Hozza dce2d1
 	${RANLIB} $@
Tomas Hozza dce2d1
 
05dbc8
-libns.la: ${OBJS}
05dbc8
+libns-pkcs11.la: ${OBJS}
Tomas Hozza dce2d1
 	${LIBTOOL_MODE_LINK} \
05dbc8
-		${CC} ${ALL_CFLAGS} ${LDFLAGS} -o libns.la -rpath ${libdir} \
05dbc8
+		${CC} ${ALL_CFLAGS} ${LDFLAGS} -o libns-pkcs11.la -rpath ${libdir} \
Tomas Hozza dce2d1
 		-version-info ${LIBINTERFACE}:${LIBREVISION}:${LIBAGE} \
b8ccda
-		${OBJS} ${ISCLIBS} ${DNSLIBS} @DNS_CRYPTO_LIBS@ ${LIBS}
b8ccda
+		${OBJS} ${ISCLIBS} ${DNSLIBS} @DNS_CRYPTO_PK11_LIBS@ ${LIBS}
Tomas Hozza dce2d1
 
05dbc8
-timestamp: libns.@A@
05dbc8
+timestamp: libns-pkcs11.@A@
Tomas Hozza dce2d1
 	touch timestamp
Tomas Hozza dce2d1
 
Tomas Hozza dce2d1
 installdirs:
Tomas Hozza dce2d1
 	$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${libdir}
Tomas Hozza dce2d1
 
Tomas Hozza dce2d1
 install:: timestamp installdirs
05dbc8
-	${LIBTOOL_MODE_INSTALL} ${INSTALL_LIBRARY} libns.@A@ \
05dbc8
+	${LIBTOOL_MODE_INSTALL} ${INSTALL_LIBRARY} libns-pkcs11.@A@ \
05dbc8
 		${DESTDIR}${libdir}
Tomas Hozza dce2d1
 
102df2
 uninstall::
05dbc8
-	${LIBTOOL_MODE_UNINSTALL} rm -f ${DESTDIR}${libdir}/libns.@A@
05dbc8
+	${LIBTOOL_MODE_UNINSTALL} rm -f ${DESTDIR}${libdir}/libns-pkcs11.@A@
102df2
 
Tomas Hozza dce2d1
 clean distclean::
05dbc8
-	rm -f libns.@A@ timestamp
05dbc8
+	rm -f libns-pkcs11.@A@ timestamp
05dbc8
diff --git a/lib/ns-pkcs11/tests/Makefile.in b/lib/ns-pkcs11/tests/Makefile.in
b47115
index ef1c1a6..5bbf10d 100644
05dbc8
--- a/lib/ns-pkcs11/tests/Makefile.in
05dbc8
+++ b/lib/ns-pkcs11/tests/Makefile.in
b47115
@@ -17,17 +17,17 @@ VERSION=@BIND9_VERSION@
b47115
 
b47115
 WRAP_OPTIONS =	-Wl,--wrap=isc_nmhandle_detach -Wl,--wrap=isc_nmhandle_attach
05dbc8
 
05dbc8
-CINCLUDES =	-I. -Iinclude ${NS_INCLUDES} ${DNS_INCLUDES} ${ISC_INCLUDES} \
05dbc8
+CINCLUDES =	-I. -Iinclude ${NS_PKCS11_INCLUDES} ${DNS_PKCS11_INCLUDES} ${ISC_INCLUDES} \
afbbd0
 		${OPENSSL_CFLAGS} \
afbbd0
 		@CMOCKA_CFLAGS@
05dbc8
-CDEFINES =	-DTESTS="\"${top_builddir}/lib/ns/tests/\"" -DNAMED_PLUGINDIR=\"${plugindir}\"
b47115
+CDEFINES =	-DTESTS="\"${top_builddir}/lib/ns-pkcs11/tests/\"" -DNAMED_PLUGINDIR=\"${plugindir}\" @USE_PKCS11@
05dbc8
 
b8ccda
 ISCLIBS =	../../isc/libisc.@A@ @NO_LIBTOOL_ISCLIBS@
05dbc8
 ISCDEPLIBS =	../../isc/libisc.@A@
b8ccda
-DNSLIBS =	../../dns/libdns.@A@ @NO_LIBTOOL_DNSLIBS@
05dbc8
-DNSDEPLIBS =	../../dns/libdns.@A@
05dbc8
-NSLIBS =	../libns.@A@
05dbc8
-NSDEPLIBS =	../libns.@A@
b8ccda
+DNSLIBS =	../../dns-pkcs11/libdns-pkcs11.@A@ @NO_LIBTOOL_DNSLIBS@
05dbc8
+DNSDEPLIBS =	../../dns-pkcs11/libdns-pkcs11.@A@
05dbc8
+NSLIBS =	../libns-pkcs11.@A@
05dbc8
+NSDEPLIBS =	../libns-pkcs11.@A@
df81e8
 
df81e8
 LIBS =		@LIBS@ @CMOCKA_LIBS@
05dbc8
 
Tomas Hozza dce2d1
diff --git a/make/includes.in b/make/includes.in
b47115
index 5373a7e..f1901ee 100644
Tomas Hozza dce2d1
--- a/make/includes.in
Tomas Hozza dce2d1
+++ b/make/includes.in
b8ccda
@@ -41,3 +41,10 @@ BIND9_INCLUDES = @BIND9_BIND9_BUILDINCLUDE@ \
Tomas Hozza dce2d1
 
Tomas Hozza dce2d1
 TEST_INCLUDES = \
Tomas Hozza dce2d1
 	-I${top_srcdir}/lib/tests/include
Tomas Hozza dce2d1
+
df81e8
+DNS_PKCS11_INCLUDES = @BIND9_DNS_PKCS11_BUILDINCLUDE@ \
Tomas Hozza dce2d1
+	-I${top_srcdir}/lib/dns-pkcs11/include
df81e8
+
df81e8
+NS_PKCS11_INCLUDES = @BIND9_NS_PKCS11_BUILDINCLUDE@ \
df81e8
+	-I${top_srcdir}/lib/ns-pkcs11/include
df81e8
+