|
|
ce773a |
From 346683631ae0f83ad4f09a69cfa5e5c6ea49e5d9 Mon Sep 17 00:00:00 2001
|
|
|
57726f |
From: Evan Hunt <each@isc.org>
|
|
|
57726f |
Date: Tue, 12 Sep 2017 19:05:46 -0700
|
|
|
57726f |
Subject: [PATCH] rebased rt31459c
|
|
|
57726f |
|
|
|
57726f |
[rt31459d] update the newer tools
|
|
|
57726f |
|
|
|
57726f |
[rt31459d] setup entropy in dns_lib_init()
|
|
|
57726f |
|
|
|
57726f |
[rt31459d] silence compiler warning
|
|
|
57726f |
|
|
|
57726f |
DNS_OPENSSL_LIBS -> DST_OPENSSL_LIBS
|
|
|
57726f |
|
|
|
57726f |
Include new unit test
|
|
|
57726f |
---
|
|
|
57726f |
bin/confgen/keygen.c | 7 +
|
|
|
57726f |
bin/dnssec/dnssec-dsfromkey.c | 8 +-
|
|
|
57726f |
bin/dnssec/dnssec-importkey.c | 8 +-
|
|
|
57726f |
bin/dnssec/dnssec-revoke.c | 8 +-
|
|
|
57726f |
bin/dnssec/dnssec-settime.c | 8 +-
|
|
|
57726f |
bin/dnssec/dnssec-signzone.c | 11 +-
|
|
|
57726f |
bin/dnssec/dnssec-verify.c | 8 +-
|
|
|
57726f |
bin/dnssec/dnssectool.c | 11 +-
|
|
|
57726f |
bin/named/server.c | 6 +
|
|
|
57726f |
bin/nsupdate/nsupdate.c | 14 +-
|
|
|
57726f |
bin/tests/makejournal.c | 6 +-
|
|
|
57726f |
bin/tests/system/pipelined/pipequeries.c | 20 +-
|
|
|
57726f |
bin/tests/system/pipelined/tests.sh | 4 +-
|
|
|
57726f |
bin/tests/system/rsabigexponent/bigkey.c | 4 +
|
|
|
57726f |
bin/tests/system/tkey/keycreate.c | 26 ++-
|
|
|
57726f |
bin/tests/system/tkey/keydelete.c | 26 ++-
|
|
|
57726f |
bin/tests/system/tkey/tests.sh | 8 +-
|
|
|
57726f |
bin/tools/mdig.c | 3 +-
|
|
|
57726f |
configure | 250 +++++++++++++----------
|
|
|
57726f |
configure.ac | 77 ++++++-
|
|
|
57726f |
lib/dns/dst_api.c | 21 +-
|
|
|
57726f |
lib/dns/include/dst/dst.h | 8 +
|
|
|
57726f |
lib/dns/lib.c | 15 +-
|
|
|
57726f |
lib/dns/openssl_link.c | 72 ++++++-
|
|
|
57726f |
lib/dns/pkcs11.c | 29 ++-
|
|
|
57726f |
lib/dns/tests/Kyuafile | 1 +
|
|
|
57726f |
lib/dns/tests/Makefile.in | 7 +
|
|
|
57726f |
lib/dns/tests/dstrandom_test.c | 115 +++++++++++
|
|
|
57726f |
lib/dns/win32/libdns.def.in | 7 +
|
|
|
57726f |
lib/isc/entropy.c | 24 +++
|
|
|
57726f |
lib/isc/include/isc/entropy.h | 12 ++
|
|
|
57726f |
lib/isc/include/isc/platform.h.in | 5 +
|
|
|
57726f |
lib/isc/include/isc/types.h | 2 +
|
|
|
57726f |
lib/isc/pk11.c | 12 +-
|
|
|
57726f |
lib/isc/win32/include/isc/platform.h.in | 5 +
|
|
|
57726f |
win32utils/Configure | 28 ++-
|
|
|
57726f |
36 files changed, 701 insertions(+), 175 deletions(-)
|
|
|
57726f |
create mode 100644 lib/dns/tests/dstrandom_test.c
|
|
|
57726f |
|
|
|
57726f |
diff --git a/bin/confgen/keygen.c b/bin/confgen/keygen.c
|
|
|
e48f32 |
index 40cf74c..bd269e7 100644
|
|
|
57726f |
--- a/bin/confgen/keygen.c
|
|
|
57726f |
+++ b/bin/confgen/keygen.c
|
|
|
57726f |
@@ -165,6 +165,13 @@ generate_key(isc_mem_t *mctx, const char *randomfile, dns_secalg_t alg,
|
|
|
57726f |
randomfile = NULL;
|
|
|
57726f |
open_keyboard = ISC_ENTROPY_KEYBOARDYES;
|
|
|
57726f |
}
|
|
|
57726f |
+#ifdef ISC_PLATFORM_CRYPTORANDOM
|
|
|
57726f |
+ if (randomfile != NULL &&
|
|
|
57726f |
+ strcmp(randomfile, ISC_PLATFORM_CRYPTORANDOM) == 0) {
|
|
|
57726f |
+ randomfile = NULL;
|
|
|
57726f |
+ isc_entropy_usehook(ectx, true);
|
|
|
57726f |
+ }
|
|
|
57726f |
+#endif
|
|
|
57726f |
DO("start entropy source", isc_entropy_usebestsource(ectx,
|
|
|
57726f |
&entropy_source,
|
|
|
57726f |
randomfile,
|
|
|
57726f |
diff --git a/bin/dnssec/dnssec-dsfromkey.c b/bin/dnssec/dnssec-dsfromkey.c
|
|
|
e48f32 |
index 4420f2d..9cb63a8 100644
|
|
|
57726f |
--- a/bin/dnssec/dnssec-dsfromkey.c
|
|
|
57726f |
+++ b/bin/dnssec/dnssec-dsfromkey.c
|
|
|
f79ca9 |
@@ -498,14 +498,14 @@ main(int argc, char **argv) {
|
|
|
57726f |
|
|
|
57726f |
if (ectx == NULL)
|
|
|
57726f |
setup_entropy(mctx, NULL, &ectx);
|
|
|
57726f |
- result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE);
|
|
|
57726f |
- if (result != ISC_R_SUCCESS)
|
|
|
57726f |
- fatal("could not initialize hash");
|
|
|
57726f |
result = dst_lib_init(mctx, ectx,
|
|
|
57726f |
ISC_ENTROPY_BLOCKING | ISC_ENTROPY_GOODONLY);
|
|
|
57726f |
if (result != ISC_R_SUCCESS)
|
|
|
57726f |
fatal("could not initialize dst: %s",
|
|
|
57726f |
isc_result_totext(result));
|
|
|
57726f |
+ result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE);
|
|
|
57726f |
+ if (result != ISC_R_SUCCESS)
|
|
|
57726f |
+ fatal("could not initialize hash");
|
|
|
57726f |
isc_entropy_stopcallbacksources(ectx);
|
|
|
57726f |
|
|
|
57726f |
setup_logging(mctx, &log;;
|
|
|
f79ca9 |
@@ -574,8 +574,8 @@ main(int argc, char **argv) {
|
|
|
57726f |
if (dns_rdataset_isassociated(&rdataset))
|
|
|
57726f |
dns_rdataset_disassociate(&rdataset);
|
|
|
57726f |
cleanup_logging(&log;;
|
|
|
57726f |
- dst_lib_destroy();
|
|
|
57726f |
isc_hash_destroy();
|
|
|
57726f |
+ dst_lib_destroy();
|
|
|
57726f |
cleanup_entropy(&ectx);
|
|
|
57726f |
dns_name_destroy();
|
|
|
57726f |
if (verbose > 10)
|
|
|
57726f |
diff --git a/bin/dnssec/dnssec-importkey.c b/bin/dnssec/dnssec-importkey.c
|
|
|
e48f32 |
index dc9a293..52863a1 100644
|
|
|
57726f |
--- a/bin/dnssec/dnssec-importkey.c
|
|
|
57726f |
+++ b/bin/dnssec/dnssec-importkey.c
|
|
|
f79ca9 |
@@ -404,14 +404,14 @@ main(int argc, char **argv) {
|
|
|
57726f |
|
|
|
57726f |
if (ectx == NULL)
|
|
|
57726f |
setup_entropy(mctx, NULL, &ectx);
|
|
|
57726f |
- result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE);
|
|
|
57726f |
- if (result != ISC_R_SUCCESS)
|
|
|
57726f |
- fatal("could not initialize hash");
|
|
|
57726f |
result = dst_lib_init(mctx, ectx,
|
|
|
57726f |
ISC_ENTROPY_BLOCKING | ISC_ENTROPY_GOODONLY);
|
|
|
57726f |
if (result != ISC_R_SUCCESS)
|
|
|
57726f |
fatal("could not initialize dst: %s",
|
|
|
57726f |
isc_result_totext(result));
|
|
|
57726f |
+ result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE);
|
|
|
57726f |
+ if (result != ISC_R_SUCCESS)
|
|
|
57726f |
+ fatal("could not initialize hash");
|
|
|
57726f |
isc_entropy_stopcallbacksources(ectx);
|
|
|
57726f |
|
|
|
57726f |
setup_logging(mctx, &log;;
|
|
|
f79ca9 |
@@ -455,8 +455,8 @@ main(int argc, char **argv) {
|
|
|
57726f |
if (dns_rdataset_isassociated(&rdataset))
|
|
|
57726f |
dns_rdataset_disassociate(&rdataset);
|
|
|
57726f |
cleanup_logging(&log;;
|
|
|
57726f |
- dst_lib_destroy();
|
|
|
57726f |
isc_hash_destroy();
|
|
|
57726f |
+ dst_lib_destroy();
|
|
|
57726f |
cleanup_entropy(&ectx);
|
|
|
57726f |
dns_name_destroy();
|
|
|
57726f |
if (verbose > 10)
|
|
|
57726f |
diff --git a/bin/dnssec/dnssec-revoke.c b/bin/dnssec/dnssec-revoke.c
|
|
|
e48f32 |
index 0121a34..74a99b0 100644
|
|
|
57726f |
--- a/bin/dnssec/dnssec-revoke.c
|
|
|
57726f |
+++ b/bin/dnssec/dnssec-revoke.c
|
|
|
57726f |
@@ -184,14 +184,14 @@ main(int argc, char **argv) {
|
|
|
57726f |
|
|
|
57726f |
if (ectx == NULL)
|
|
|
57726f |
setup_entropy(mctx, NULL, &ectx);
|
|
|
57726f |
- result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE);
|
|
|
57726f |
- if (result != ISC_R_SUCCESS)
|
|
|
57726f |
- fatal("Could not initialize hash");
|
|
|
57726f |
result = dst_lib_init2(mctx, ectx, engine,
|
|
|
57726f |
ISC_ENTROPY_BLOCKING | ISC_ENTROPY_GOODONLY);
|
|
|
57726f |
if (result != ISC_R_SUCCESS)
|
|
|
57726f |
fatal("Could not initialize dst: %s",
|
|
|
57726f |
isc_result_totext(result));
|
|
|
57726f |
+ result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE);
|
|
|
57726f |
+ if (result != ISC_R_SUCCESS)
|
|
|
57726f |
+ fatal("Could not initialize hash");
|
|
|
57726f |
isc_entropy_stopcallbacksources(ectx);
|
|
|
57726f |
|
|
|
57726f |
result = dst_key_fromnamedfile(filename, dir,
|
|
|
57726f |
@@ -273,8 +273,8 @@ main(int argc, char **argv) {
|
|
|
57726f |
|
|
|
57726f |
cleanup:
|
|
|
57726f |
dst_key_free(&key);
|
|
|
57726f |
- dst_lib_destroy();
|
|
|
57726f |
isc_hash_destroy();
|
|
|
57726f |
+ dst_lib_destroy();
|
|
|
57726f |
cleanup_entropy(&ectx);
|
|
|
57726f |
if (verbose > 10)
|
|
|
57726f |
isc_mem_stats(mctx, stdout);
|
|
|
57726f |
diff --git a/bin/dnssec/dnssec-settime.c b/bin/dnssec/dnssec-settime.c
|
|
|
e48f32 |
index f017895..2c568fc 100644
|
|
|
57726f |
--- a/bin/dnssec/dnssec-settime.c
|
|
|
57726f |
+++ b/bin/dnssec/dnssec-settime.c
|
|
|
e48f32 |
@@ -391,14 +391,14 @@ main(int argc, char **argv) {
|
|
|
57726f |
|
|
|
57726f |
if (ectx == NULL)
|
|
|
57726f |
setup_entropy(mctx, NULL, &ectx);
|
|
|
57726f |
- result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE);
|
|
|
57726f |
- if (result != ISC_R_SUCCESS)
|
|
|
57726f |
- fatal("Could not initialize hash");
|
|
|
57726f |
result = dst_lib_init2(mctx, ectx, engine,
|
|
|
57726f |
ISC_ENTROPY_BLOCKING | ISC_ENTROPY_GOODONLY);
|
|
|
57726f |
if (result != ISC_R_SUCCESS)
|
|
|
57726f |
fatal("Could not initialize dst: %s",
|
|
|
57726f |
isc_result_totext(result));
|
|
|
57726f |
+ result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE);
|
|
|
57726f |
+ if (result != ISC_R_SUCCESS)
|
|
|
57726f |
+ fatal("Could not initialize hash");
|
|
|
57726f |
isc_entropy_stopcallbacksources(ectx);
|
|
|
57726f |
|
|
|
57726f |
if (predecessor != NULL) {
|
|
|
e48f32 |
@@ -683,8 +683,8 @@ main(int argc, char **argv) {
|
|
|
57726f |
if (prevkey != NULL)
|
|
|
57726f |
dst_key_free(&prevkey);
|
|
|
57726f |
dst_key_free(&key);
|
|
|
57726f |
- dst_lib_destroy();
|
|
|
57726f |
isc_hash_destroy();
|
|
|
57726f |
+ dst_lib_destroy();
|
|
|
57726f |
cleanup_entropy(&ectx);
|
|
|
57726f |
if (verbose > 10)
|
|
|
57726f |
isc_mem_stats(mctx, stdout);
|
|
|
57726f |
diff --git a/bin/dnssec/dnssec-signzone.c b/bin/dnssec/dnssec-signzone.c
|
|
|
ce773a |
index a097ac8..6567421 100644
|
|
|
57726f |
--- a/bin/dnssec/dnssec-signzone.c
|
|
|
57726f |
+++ b/bin/dnssec/dnssec-signzone.c
|
|
|
ce773a |
@@ -3472,14 +3472,15 @@ main(int argc, char *argv[]) {
|
|
|
57726f |
if (!pseudorandom)
|
|
|
57726f |
eflags |= ISC_ENTROPY_GOODONLY;
|
|
|
57726f |
|
|
|
57726f |
- result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE);
|
|
|
57726f |
- if (result != ISC_R_SUCCESS)
|
|
|
57726f |
- fatal("could not create hash context");
|
|
|
57726f |
-
|
|
|
57726f |
result = dst_lib_init2(mctx, ectx, engine, eflags);
|
|
|
57726f |
if (result != ISC_R_SUCCESS)
|
|
|
57726f |
fatal("could not initialize dst: %s",
|
|
|
57726f |
isc_result_totext(result));
|
|
|
57726f |
+
|
|
|
57726f |
+ result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE);
|
|
|
57726f |
+ if (result != ISC_R_SUCCESS)
|
|
|
57726f |
+ fatal("could not create hash context");
|
|
|
57726f |
+
|
|
|
57726f |
isc_stdtime_get(&now;;
|
|
|
57726f |
|
|
|
57726f |
if (startstr != NULL) {
|
|
|
ce773a |
@@ -3896,8 +3897,8 @@ main(int argc, char *argv[]) {
|
|
|
57726f |
dns_master_styledestroy(&dsstyle, mctx);
|
|
|
57726f |
|
|
|
57726f |
cleanup_logging(&log;;
|
|
|
57726f |
- dst_lib_destroy();
|
|
|
57726f |
isc_hash_destroy();
|
|
|
57726f |
+ dst_lib_destroy();
|
|
|
57726f |
cleanup_entropy(&ectx);
|
|
|
57726f |
dns_name_destroy();
|
|
|
57726f |
if (verbose > 10)
|
|
|
57726f |
diff --git a/bin/dnssec/dnssec-verify.c b/bin/dnssec/dnssec-verify.c
|
|
|
e48f32 |
index 087cd5d..07c7294 100644
|
|
|
57726f |
--- a/bin/dnssec/dnssec-verify.c
|
|
|
57726f |
+++ b/bin/dnssec/dnssec-verify.c
|
|
|
57726f |
@@ -281,15 +281,15 @@ main(int argc, char *argv[]) {
|
|
|
57726f |
if (ectx == NULL)
|
|
|
57726f |
setup_entropy(mctx, NULL, &ectx);
|
|
|
57726f |
|
|
|
57726f |
- result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE);
|
|
|
57726f |
- if (result != ISC_R_SUCCESS)
|
|
|
57726f |
- fatal("could not create hash context");
|
|
|
57726f |
-
|
|
|
57726f |
result = dst_lib_init2(mctx, ectx, engine, ISC_ENTROPY_BLOCKING);
|
|
|
57726f |
if (result != ISC_R_SUCCESS)
|
|
|
57726f |
fatal("could not initialize dst: %s",
|
|
|
57726f |
isc_result_totext(result));
|
|
|
57726f |
|
|
|
57726f |
+ result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE);
|
|
|
57726f |
+ if (result != ISC_R_SUCCESS)
|
|
|
57726f |
+ fatal("could not create hash context");
|
|
|
57726f |
+
|
|
|
57726f |
isc_stdtime_get(&now;;
|
|
|
57726f |
|
|
|
57726f |
rdclass = strtoclass(classname);
|
|
|
57726f |
diff --git a/bin/dnssec/dnssectool.c b/bin/dnssec/dnssectool.c
|
|
|
e48f32 |
index 7f045e8..2a0f9c6 100644
|
|
|
57726f |
--- a/bin/dnssec/dnssectool.c
|
|
|
57726f |
+++ b/bin/dnssec/dnssectool.c
|
|
|
57726f |
@@ -34,6 +34,7 @@
|
|
|
57726f |
#include <isc/heap.h>
|
|
|
57726f |
#include <isc/list.h>
|
|
|
57726f |
#include <isc/mem.h>
|
|
|
57726f |
+#include <isc/platform.h>
|
|
|
57726f |
#include <isc/print.h>
|
|
|
57726f |
#include <isc/string.h>
|
|
|
57726f |
#include <isc/time.h>
|
|
|
57726f |
@@ -235,7 +236,8 @@ setup_entropy(isc_mem_t *mctx, const char *randomfile, isc_entropy_t **ectx) {
|
|
|
57726f |
if (*ectx == NULL) {
|
|
|
57726f |
result = isc_entropy_create(mctx, ectx);
|
|
|
57726f |
if (result != ISC_R_SUCCESS)
|
|
|
57726f |
- fatal("could not create entropy object");
|
|
|
57726f |
+ fatal("could not create entropy object: %s",
|
|
|
57726f |
+ isc_result_totext(result));
|
|
|
57726f |
ISC_LIST_INIT(sources);
|
|
|
57726f |
}
|
|
|
57726f |
|
|
|
57726f |
@@ -244,6 +246,13 @@ setup_entropy(isc_mem_t *mctx, const char *randomfile, isc_entropy_t **ectx) {
|
|
|
57726f |
randomfile = NULL;
|
|
|
57726f |
}
|
|
|
57726f |
|
|
|
57726f |
+#ifdef ISC_PLATFORM_CRYPTORANDOM
|
|
|
57726f |
+ if (randomfile != NULL &&
|
|
|
57726f |
+ strcmp(randomfile, ISC_PLATFORM_CRYPTORANDOM) == 0) {
|
|
|
57726f |
+ randomfile = NULL;
|
|
|
57726f |
+ isc_entropy_usehook(*ectx, true);
|
|
|
57726f |
+ }
|
|
|
57726f |
+#endif
|
|
|
57726f |
result = isc_entropy_usebestsource(*ectx, &source, randomfile,
|
|
|
57726f |
usekeyboard);
|
|
|
57726f |
|
|
|
57726f |
diff --git a/bin/named/server.c b/bin/named/server.c
|
|
|
ce773a |
index 9826588..b3e3fc3 100644
|
|
|
57726f |
--- a/bin/named/server.c
|
|
|
57726f |
+++ b/bin/named/server.c
|
|
|
57726f |
@@ -36,6 +36,7 @@
|
|
|
57726f |
#include <isc/lex.h>
|
|
|
57726f |
#include <isc/meminfo.h>
|
|
|
57726f |
#include <isc/parseint.h>
|
|
|
57726f |
+#include <isc/platform.h>
|
|
|
57726f |
#include <isc/portset.h>
|
|
|
57726f |
#include <isc/print.h>
|
|
|
57726f |
#include <isc/random.h>
|
|
|
ce773a |
@@ -8291,6 +8292,10 @@ load_configuration(const char *filename, ns_server_t *server,
|
|
|
57726f |
"no source of entropy found");
|
|
|
57726f |
} else {
|
|
|
57726f |
const char *randomdev = cfg_obj_asstring(obj);
|
|
|
57726f |
+#ifdef ISC_PLATFORM_CRYPTORANDOM
|
|
|
57726f |
+ if (strcmp(randomdev, ISC_PLATFORM_CRYPTORANDOM) == 0)
|
|
|
57726f |
+ isc_entropy_usehook(ns_g_entropy, true);
|
|
|
57726f |
+#else
|
|
|
57726f |
int level = ISC_LOG_ERROR;
|
|
|
57726f |
result = isc_entropy_createfilesource(ns_g_entropy,
|
|
|
57726f |
randomdev);
|
|
|
ce773a |
@@ -8325,6 +8330,7 @@ load_configuration(const char *filename, ns_server_t *server,
|
|
|
57726f |
}
|
|
|
57726f |
isc_entropy_detach(&ns_g_fallbackentropy);
|
|
|
57726f |
}
|
|
|
57726f |
+#endif
|
|
|
57726f |
#endif
|
|
|
57726f |
}
|
|
|
57726f |
|
|
|
57726f |
diff --git a/bin/nsupdate/nsupdate.c b/bin/nsupdate/nsupdate.c
|
|
|
ce773a |
index 52b0274..23b69c9 100644
|
|
|
57726f |
--- a/bin/nsupdate/nsupdate.c
|
|
|
57726f |
+++ b/bin/nsupdate/nsupdate.c
|
|
|
ce773a |
@@ -279,7 +279,8 @@ setup_entropy(isc_mem_t *mctx, const char *randomfile, isc_entropy_t **ectx) {
|
|
|
57726f |
if (*ectx == NULL) {
|
|
|
57726f |
result = isc_entropy_create(mctx, ectx);
|
|
|
57726f |
if (result != ISC_R_SUCCESS)
|
|
|
57726f |
- fatal("could not create entropy object");
|
|
|
57726f |
+ fatal("could not create entropy object: %s",
|
|
|
57726f |
+ isc_result_totext(result));
|
|
|
57726f |
ISC_LIST_INIT(sources);
|
|
|
57726f |
}
|
|
|
57726f |
|
|
|
ce773a |
@@ -288,6 +289,13 @@ setup_entropy(isc_mem_t *mctx, const char *randomfile, isc_entropy_t **ectx) {
|
|
|
57726f |
randomfile = NULL;
|
|
|
57726f |
}
|
|
|
57726f |
|
|
|
57726f |
+#ifdef ISC_PLATFORM_CRYPTORANDOM
|
|
|
57726f |
+ if (randomfile != NULL &&
|
|
|
57726f |
+ strcmp(randomfile, ISC_PLATFORM_CRYPTORANDOM) == 0) {
|
|
|
57726f |
+ randomfile = NULL;
|
|
|
57726f |
+ isc_entropy_usehook(*ectx, true);
|
|
|
57726f |
+ }
|
|
|
57726f |
+#endif
|
|
|
57726f |
result = isc_entropy_usebestsource(*ectx, &source, randomfile,
|
|
|
57726f |
usekeyboard);
|
|
|
57726f |
|
|
|
ce773a |
@@ -990,11 +998,11 @@ setup_system(void) {
|
|
|
57726f |
}
|
|
|
57726f |
}
|
|
|
57726f |
|
|
|
57726f |
- setup_entropy(gmctx, NULL, &entropy);
|
|
|
57726f |
+ if (entropy == NULL)
|
|
|
57726f |
+ setup_entropy(gmctx, NULL, &entropy);
|
|
|
57726f |
|
|
|
57726f |
result = isc_hash_create(gmctx, entropy, DNS_NAME_MAXWIRE);
|
|
|
57726f |
check_result(result, "isc_hash_create");
|
|
|
57726f |
- isc_hash_init();
|
|
|
57726f |
|
|
|
57726f |
result = dns_dispatchmgr_create(gmctx, entropy, &dispatchmgr);
|
|
|
57726f |
check_result(result, "dns_dispatchmgr_create");
|
|
|
57726f |
diff --git a/bin/tests/makejournal.c b/bin/tests/makejournal.c
|
|
|
e48f32 |
index 68b5e5a..cd54c8d 100644
|
|
|
57726f |
--- a/bin/tests/makejournal.c
|
|
|
57726f |
+++ b/bin/tests/makejournal.c
|
|
|
57726f |
@@ -102,12 +102,12 @@ main(int argc, char **argv) {
|
|
|
57726f |
CHECK(isc_mem_create(0, 0, &mctx));
|
|
|
57726f |
CHECK(isc_entropy_create(mctx, &ectx));
|
|
|
57726f |
|
|
|
57726f |
- CHECK(isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE));
|
|
|
57726f |
- hash_active = true;
|
|
|
57726f |
-
|
|
|
57726f |
CHECK(dst_lib_init(mctx, ectx, ISC_ENTROPY_BLOCKING));
|
|
|
57726f |
dst_active = true;
|
|
|
57726f |
|
|
|
57726f |
+ CHECK(isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE));
|
|
|
57726f |
+ hash_active = true;
|
|
|
57726f |
+
|
|
|
57726f |
CHECK(isc_log_create(mctx, &lctx, &logconfig));
|
|
|
57726f |
isc_log_registercategories(lctx, categories);
|
|
|
57726f |
isc_log_setcontext(lctx);
|
|
|
57726f |
diff --git a/bin/tests/system/pipelined/pipequeries.c b/bin/tests/system/pipelined/pipequeries.c
|
|
|
e48f32 |
index e16ec11..95b65bf 100644
|
|
|
57726f |
--- a/bin/tests/system/pipelined/pipequeries.c
|
|
|
57726f |
+++ b/bin/tests/system/pipelined/pipequeries.c
|
|
|
57726f |
@@ -204,6 +204,7 @@ sendqueries(isc_task_t *task, isc_event_t *event) {
|
|
|
57726f |
|
|
|
57726f |
int
|
|
|
57726f |
main(int argc, char *argv[]) {
|
|
|
57726f |
+ char *randomfile = NULL;
|
|
|
57726f |
isc_sockaddr_t bind_any;
|
|
|
57726f |
struct in_addr inaddr;
|
|
|
57726f |
isc_result_t result;
|
|
|
57726f |
@@ -222,7 +223,7 @@ main(int argc, char *argv[]) {
|
|
|
57726f |
int c;
|
|
|
57726f |
|
|
|
57726f |
isc_commandline_errprint = false;
|
|
|
57726f |
- while ((c = isc_commandline_parse(argc, argv, "p:")) != -1) {
|
|
|
57726f |
+ while ((c = isc_commandline_parse(argc, argv, "p:r:")) != -1) {
|
|
|
57726f |
switch (c) {
|
|
|
57726f |
case 'p':
|
|
|
57726f |
result = isc_parse_uint16(&port,
|
|
|
57726f |
@@ -233,6 +234,9 @@ main(int argc, char *argv[]) {
|
|
|
57726f |
exit(1);
|
|
|
57726f |
}
|
|
|
57726f |
break;
|
|
|
57726f |
+ case 'r':
|
|
|
57726f |
+ randomfile = isc_commandline_argument;
|
|
|
57726f |
+ break;
|
|
|
57726f |
case '?':
|
|
|
57726f |
fprintf(stderr, "%s: invalid argument '%c'",
|
|
|
57726f |
argv[0], c);
|
|
|
57726f |
@@ -275,10 +279,18 @@ main(int argc, char *argv[]) {
|
|
|
57726f |
|
|
|
57726f |
ectx = NULL;
|
|
|
57726f |
RUNCHECK(isc_entropy_create(mctx, &ectx));
|
|
|
57726f |
- RUNCHECK(isc_entropy_createfilesource(ectx, "../random.data"));
|
|
|
57726f |
- RUNCHECK(isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE));
|
|
|
57726f |
+#ifdef ISC_PLATFORM_CRYPTORANDOM
|
|
|
57726f |
+ if (randomfile != NULL &&
|
|
|
57726f |
+ strcmp(randomfile, ISC_PLATFORM_CRYPTORANDOM) == 0) {
|
|
|
57726f |
+ randomfile = NULL;
|
|
|
57726f |
+ isc_entropy_usehook(ectx, true);
|
|
|
57726f |
+ }
|
|
|
57726f |
+#endif
|
|
|
57726f |
+ if (randomfile != NULL)
|
|
|
57726f |
+ RUNCHECK(isc_entropy_createfilesource(ectx, randomfile));
|
|
|
57726f |
|
|
|
57726f |
RUNCHECK(dst_lib_init(mctx, ectx, ISC_ENTROPY_GOODONLY));
|
|
|
57726f |
+ RUNCHECK(isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE));
|
|
|
57726f |
|
|
|
57726f |
taskmgr = NULL;
|
|
|
57726f |
RUNCHECK(isc_taskmgr_create(mctx, 1, 0, &taskmgr));
|
|
|
57726f |
@@ -331,8 +343,8 @@ main(int argc, char *argv[]) {
|
|
|
57726f |
isc_task_detach(&task);
|
|
|
57726f |
isc_taskmgr_destroy(&taskmgr);
|
|
|
57726f |
|
|
|
57726f |
- dst_lib_destroy();
|
|
|
57726f |
isc_hash_destroy();
|
|
|
57726f |
+ dst_lib_destroy();
|
|
|
57726f |
isc_entropy_detach(&ectx);
|
|
|
57726f |
|
|
|
57726f |
isc_log_destroy(&lctx);
|
|
|
57726f |
diff --git a/bin/tests/system/pipelined/tests.sh b/bin/tests/system/pipelined/tests.sh
|
|
|
e48f32 |
index c0a99a2..0245527 100644
|
|
|
57726f |
--- a/bin/tests/system/pipelined/tests.sh
|
|
|
57726f |
+++ b/bin/tests/system/pipelined/tests.sh
|
|
|
57726f |
@@ -19,7 +19,7 @@ status=0
|
|
|
57726f |
|
|
|
57726f |
echo_i "check pipelined TCP queries"
|
|
|
57726f |
ret=0
|
|
|
57726f |
-$PIPEQUERIES -p ${PORT} < input > raw || ret=1
|
|
|
57726f |
+$PIPEQUERIES -p ${PORT} -r $RANDFILE < input > raw || ret=1
|
|
|
57726f |
awk '{ print $1 " " $5 }' < raw > output
|
|
|
57726f |
sort < output > output-sorted
|
|
|
57726f |
$DIFF ref output-sorted || { ret=1 ; echo_i "diff sorted failed"; }
|
|
|
57726f |
@@ -43,7 +43,7 @@ status=`expr $status + $ret`
|
|
|
57726f |
|
|
|
57726f |
echo_i "check keep-response-order"
|
|
|
57726f |
ret=0
|
|
|
57726f |
-$PIPEQUERIES -p ${PORT} ++ < inputb > rawb || ret=1
|
|
|
57726f |
+$PIPEQUERIES -p ${PORT} -r $RANDFILE ++ < inputb > rawb || ret=1
|
|
|
57726f |
awk '{ print $1 " " $5 }' < rawb > outputb
|
|
|
57726f |
$DIFF refb outputb || ret=1
|
|
|
57726f |
if [ $ret != 0 ]; then echo_i "failed"; fi
|
|
|
57726f |
diff --git a/bin/tests/system/rsabigexponent/bigkey.c b/bin/tests/system/rsabigexponent/bigkey.c
|
|
|
e48f32 |
index abf12ed..fa5182c 100644
|
|
|
57726f |
--- a/bin/tests/system/rsabigexponent/bigkey.c
|
|
|
57726f |
+++ b/bin/tests/system/rsabigexponent/bigkey.c
|
|
|
57726f |
@@ -20,6 +20,7 @@
|
|
|
57726f |
#include <isc/buffer.h>
|
|
|
57726f |
#include <isc/entropy.h>
|
|
|
57726f |
#include <isc/mem.h>
|
|
|
57726f |
+#include <isc/platform.h>
|
|
|
57726f |
#include <isc/print.h>
|
|
|
57726f |
#include <isc/region.h>
|
|
|
57726f |
#include <isc/stdio.h>
|
|
|
57726f |
@@ -183,6 +184,9 @@ main(int argc, char **argv) {
|
|
|
57726f |
|
|
|
57726f |
CHECK(isc_mem_create(0, 0, &mctx), "isc_mem_create()");
|
|
|
57726f |
CHECK(isc_entropy_create(mctx, &ectx), "isc_entropy_create()");
|
|
|
57726f |
+#ifdef ISC_PLATFORM_CRYPTORANDOM
|
|
|
57726f |
+ isc_entropy_usehook(ectx, true);
|
|
|
57726f |
+#endif
|
|
|
57726f |
CHECK(isc_entropy_usebestsource(ectx, &source,
|
|
|
57726f |
"../random.data",
|
|
|
57726f |
ISC_ENTROPY_KEYBOARDNO),
|
|
|
57726f |
diff --git a/bin/tests/system/tkey/keycreate.c b/bin/tests/system/tkey/keycreate.c
|
|
|
e48f32 |
index 34360aa..3236968 100644
|
|
|
57726f |
--- a/bin/tests/system/tkey/keycreate.c
|
|
|
57726f |
+++ b/bin/tests/system/tkey/keycreate.c
|
|
|
57726f |
@@ -206,6 +206,7 @@ sendquery(isc_task_t *task, isc_event_t *event) {
|
|
|
57726f |
int
|
|
|
57726f |
main(int argc, char *argv[]) {
|
|
|
57726f |
char *ourkeyname;
|
|
|
57726f |
+ char *randomfile;
|
|
|
57726f |
isc_taskmgr_t *taskmgr;
|
|
|
57726f |
isc_timermgr_t *timermgr;
|
|
|
57726f |
isc_socketmgr_t *socketmgr;
|
|
|
57726f |
@@ -225,10 +226,21 @@ main(int argc, char *argv[]) {
|
|
|
57726f |
|
|
|
57726f |
RUNCHECK(isc_app_start());
|
|
|
57726f |
|
|
|
57726f |
+ randomfile = NULL;
|
|
|
57726f |
+
|
|
|
57726f |
if (argc < 2) {
|
|
|
57726f |
fprintf(stderr, "I:no DH key provided\n");
|
|
|
57726f |
exit(-1);
|
|
|
57726f |
}
|
|
|
57726f |
+ if (strcmp(argv[1], "-r") == 0) {
|
|
|
57726f |
+ if (argc < 4) {
|
|
|
57726f |
+ fprintf(stderr, "I:no DH key provided\n");
|
|
|
57726f |
+ exit(-1);
|
|
|
57726f |
+ }
|
|
|
57726f |
+ randomfile = argv[2];
|
|
|
57726f |
+ argv += 2;
|
|
|
57726f |
+ argc -= 2;
|
|
|
57726f |
+ }
|
|
|
57726f |
ourkeyname = argv[1];
|
|
|
57726f |
|
|
|
57726f |
if (argc >= 3)
|
|
|
57726f |
@@ -242,14 +254,22 @@ main(int argc, char *argv[]) {
|
|
|
57726f |
|
|
|
57726f |
ectx = NULL;
|
|
|
57726f |
RUNCHECK(isc_entropy_create(mctx, &ectx));
|
|
|
57726f |
- RUNCHECK(isc_entropy_createfilesource(ectx, "../random.data"));
|
|
|
57726f |
- RUNCHECK(isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE));
|
|
|
57726f |
+#ifdef ISC_PLATFORM_CRYPTORANDOM
|
|
|
57726f |
+ if (randomfile != NULL &&
|
|
|
57726f |
+ strcmp(randomfile, ISC_PLATFORM_CRYPTORANDOM) == 0) {
|
|
|
57726f |
+ randomfile = NULL;
|
|
|
57726f |
+ isc_entropy_usehook(ectx, true);
|
|
|
57726f |
+ }
|
|
|
57726f |
+#endif
|
|
|
57726f |
+ if (randomfile != NULL)
|
|
|
57726f |
+ RUNCHECK(isc_entropy_createfilesource(ectx, randomfile));
|
|
|
57726f |
|
|
|
57726f |
log = NULL;
|
|
|
57726f |
logconfig = NULL;
|
|
|
57726f |
RUNCHECK(isc_log_create(mctx, &log, &logconfig));
|
|
|
57726f |
|
|
|
57726f |
RUNCHECK(dst_lib_init(mctx, ectx, ISC_ENTROPY_GOODONLY));
|
|
|
57726f |
+ RUNCHECK(isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE));
|
|
|
57726f |
|
|
|
57726f |
taskmgr = NULL;
|
|
|
57726f |
RUNCHECK(isc_taskmgr_create(mctx, 1, 0, &taskmgr));
|
|
|
57726f |
@@ -328,8 +348,8 @@ main(int argc, char *argv[]) {
|
|
|
57726f |
|
|
|
57726f |
isc_log_destroy(&log;;
|
|
|
57726f |
|
|
|
57726f |
- dst_lib_destroy();
|
|
|
57726f |
isc_hash_destroy();
|
|
|
57726f |
+ dst_lib_destroy();
|
|
|
57726f |
isc_entropy_detach(&ectx);
|
|
|
57726f |
|
|
|
57726f |
isc_mem_destroy(&mctx);
|
|
|
57726f |
diff --git a/bin/tests/system/tkey/keydelete.c b/bin/tests/system/tkey/keydelete.c
|
|
|
ce773a |
index a3dd450..350723f 100644
|
|
|
57726f |
--- a/bin/tests/system/tkey/keydelete.c
|
|
|
57726f |
+++ b/bin/tests/system/tkey/keydelete.c
|
|
|
ce773a |
@@ -137,6 +137,7 @@ sendquery(isc_task_t *task, isc_event_t *event) {
|
|
|
57726f |
int
|
|
|
57726f |
main(int argc, char **argv) {
|
|
|
57726f |
char *keyname;
|
|
|
57726f |
+ char *randomfile;
|
|
|
57726f |
isc_taskmgr_t *taskmgr;
|
|
|
57726f |
isc_timermgr_t *timermgr;
|
|
|
57726f |
isc_socketmgr_t *socketmgr;
|
|
|
ce773a |
@@ -157,10 +158,21 @@ main(int argc, char **argv) {
|
|
|
57726f |
|
|
|
57726f |
RUNCHECK(isc_app_start());
|
|
|
57726f |
|
|
|
57726f |
+ randomfile = NULL;
|
|
|
57726f |
+
|
|
|
57726f |
if (argc < 2) {
|
|
|
57726f |
fprintf(stderr, "I:no key to delete\n");
|
|
|
57726f |
exit(-1);
|
|
|
57726f |
}
|
|
|
57726f |
+ if (strcmp(argv[1], "-r") == 0) {
|
|
|
57726f |
+ if (argc < 4) {
|
|
|
57726f |
+ fprintf(stderr, "I:no DH key provided\n");
|
|
|
57726f |
+ exit(-1);
|
|
|
57726f |
+ }
|
|
|
57726f |
+ randomfile = argv[2];
|
|
|
57726f |
+ argv += 2;
|
|
|
57726f |
+ argc -= 2;
|
|
|
57726f |
+ }
|
|
|
57726f |
keyname = argv[1];
|
|
|
57726f |
|
|
|
57726f |
dns_result_register();
|
|
|
ce773a |
@@ -170,14 +182,22 @@ main(int argc, char **argv) {
|
|
|
57726f |
|
|
|
57726f |
ectx = NULL;
|
|
|
57726f |
RUNCHECK(isc_entropy_create(mctx, &ectx));
|
|
|
57726f |
- RUNCHECK(isc_entropy_createfilesource(ectx, "../random.data"));
|
|
|
57726f |
- RUNCHECK(isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE));
|
|
|
57726f |
+#ifdef ISC_PLATFORM_CRYPTORANDOM
|
|
|
57726f |
+ if (randomfile != NULL &&
|
|
|
57726f |
+ strcmp(randomfile, ISC_PLATFORM_CRYPTORANDOM) == 0) {
|
|
|
57726f |
+ randomfile = NULL;
|
|
|
57726f |
+ isc_entropy_usehook(ectx, true);
|
|
|
57726f |
+ }
|
|
|
57726f |
+#endif
|
|
|
57726f |
+ if (randomfile != NULL)
|
|
|
57726f |
+ RUNCHECK(isc_entropy_createfilesource(ectx, randomfile));
|
|
|
57726f |
|
|
|
57726f |
log = NULL;
|
|
|
57726f |
logconfig = NULL;
|
|
|
57726f |
RUNCHECK(isc_log_create(mctx, &log, &logconfig));
|
|
|
57726f |
|
|
|
57726f |
RUNCHECK(dst_lib_init(mctx, ectx, ISC_ENTROPY_GOODONLY));
|
|
|
57726f |
+ RUNCHECK(isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE));
|
|
|
57726f |
|
|
|
57726f |
taskmgr = NULL;
|
|
|
57726f |
RUNCHECK(isc_taskmgr_create(mctx, 1, 0, &taskmgr));
|
|
|
ce773a |
@@ -265,8 +285,8 @@ main(int argc, char **argv) {
|
|
|
57726f |
|
|
|
57726f |
isc_log_destroy(&log;;
|
|
|
57726f |
|
|
|
57726f |
- dst_lib_destroy();
|
|
|
57726f |
isc_hash_destroy();
|
|
|
57726f |
+ dst_lib_destroy();
|
|
|
57726f |
isc_entropy_detach(&ectx);
|
|
|
57726f |
|
|
|
57726f |
isc_mem_destroy(&mctx);
|
|
|
57726f |
diff --git a/bin/tests/system/tkey/tests.sh b/bin/tests/system/tkey/tests.sh
|
|
|
e48f32 |
index b265156..bcd60a6 100644
|
|
|
57726f |
--- a/bin/tests/system/tkey/tests.sh
|
|
|
57726f |
+++ b/bin/tests/system/tkey/tests.sh
|
|
|
57726f |
@@ -33,7 +33,7 @@ for owner in . foo.example.
|
|
|
57726f |
do
|
|
|
e48f32 |
echo_i "creating new key using owner name \"$owner\" ($n)"
|
|
|
57726f |
ret=0
|
|
|
57726f |
- keyname=`$KEYCREATE $dhkeyname $owner` || ret=1
|
|
|
57726f |
+ keyname=`$KEYCREATE -r $RANDFILE $dhkeyname $owner` || ret=1
|
|
|
57726f |
if [ $ret != 0 ]; then
|
|
|
e48f32 |
echo_i "failed"
|
|
|
e48f32 |
status=$((status+ret))
|
|
|
e48f32 |
@@ -57,7 +57,7 @@ do
|
|
|
57726f |
|
|
|
e48f32 |
echo_i "deleting new key ($n)"
|
|
|
57726f |
ret=0
|
|
|
57726f |
- $KEYDELETE $keyname || ret=1
|
|
|
57726f |
+ $KEYDELETE -r $RANDFILE $keyname || ret=1
|
|
|
57726f |
if [ $ret != 0 ]; then
|
|
|
e48f32 |
echo_i "failed"
|
|
|
57726f |
fi
|
|
|
e48f32 |
@@ -79,7 +79,7 @@ done
|
|
|
57726f |
|
|
|
e48f32 |
echo_i "creating new key using owner name bar.example. ($n)"
|
|
|
57726f |
ret=0
|
|
|
57726f |
-keyname=`$KEYCREATE $dhkeyname bar.example.` || ret=1
|
|
|
57726f |
+keyname=`$KEYCREATE -r $RANDFILE $dhkeyname bar.example.` || ret=1
|
|
|
57726f |
if [ $ret != 0 ]; then
|
|
|
e48f32 |
echo_i "failed"
|
|
|
e48f32 |
status=$((status+ret))
|
|
|
e48f32 |
@@ -124,7 +124,7 @@ n=$((n+1))
|
|
|
57726f |
|
|
|
e48f32 |
echo_i "recreating the bar.example. key ($n)"
|
|
|
57726f |
ret=0
|
|
|
57726f |
-keyname=`$KEYCREATE $dhkeyname bar.example.` || ret=1
|
|
|
57726f |
+keyname=`$KEYCREATE -r $RANDFILE $dhkeyname bar.example.` || ret=1
|
|
|
57726f |
if [ $ret != 0 ]; then
|
|
|
e48f32 |
echo_i "failed"
|
|
|
e48f32 |
status=$((status+ret))
|
|
|
57726f |
diff --git a/bin/tools/mdig.c b/bin/tools/mdig.c
|
|
|
e48f32 |
index 26fa609..fb34aa0 100644
|
|
|
57726f |
--- a/bin/tools/mdig.c
|
|
|
57726f |
+++ b/bin/tools/mdig.c
|
|
|
e48f32 |
@@ -2005,12 +2005,11 @@ main(int argc, char *argv[]) {
|
|
|
57726f |
|
|
|
57726f |
ectx = NULL;
|
|
|
57726f |
RUNCHECK(isc_entropy_create(mctx, &ectx));
|
|
|
57726f |
+ RUNCHECK(dst_lib_init(mctx, ectx, ISC_ENTROPY_GOODONLY));
|
|
|
57726f |
RUNCHECK(isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE));
|
|
|
57726f |
RUNCHECK(isc_entropy_getdata(ectx, cookie_secret,
|
|
|
57726f |
sizeof(cookie_secret), NULL, 0));
|
|
|
57726f |
|
|
|
57726f |
- RUNCHECK(dst_lib_init(mctx, ectx, ISC_ENTROPY_GOODONLY));
|
|
|
57726f |
-
|
|
|
57726f |
ISC_LIST_INIT(queries);
|
|
|
57726f |
parse_args(false, argc, argv);
|
|
|
57726f |
if (server == NULL)
|
|
|
57726f |
diff --git a/configure b/configure
|
|
|
ce773a |
index 368112f..e060e9d 100755
|
|
|
57726f |
--- a/configure
|
|
|
57726f |
+++ b/configure
|
|
|
57726f |
@@ -640,6 +640,7 @@ ac_includes_default="\
|
|
|
57726f |
|
|
|
57726f |
ac_subst_vars='LTLIBOBJS
|
|
|
57726f |
LIBOBJS
|
|
|
57726f |
+LIBDIR_SUFFIX
|
|
|
57726f |
BUILD_LIBS
|
|
|
57726f |
BUILD_LDFLAGS
|
|
|
57726f |
BUILD_CPPFLAGS
|
|
|
ce773a |
@@ -822,6 +823,7 @@ LIBXML2_CFLAGS
|
|
|
57726f |
NZDTARGETS
|
|
|
57726f |
NZDSRCS
|
|
|
57726f |
NZD_TOOLS
|
|
|
57726f |
+ISC_PLATFORM_CRYPTORANDOM
|
|
|
57726f |
PKCS11_TEST
|
|
|
57726f |
PKCS11_ED25519
|
|
|
57726f |
PKCS11_GOST
|
|
|
ce773a |
@@ -1046,6 +1048,7 @@ with_eddsa
|
|
|
57726f |
with_aes
|
|
|
57726f |
enable_openssl_hash
|
|
|
57726f |
with_cc_alg
|
|
|
57726f |
+enable_crypto_rand
|
|
|
57726f |
with_lmdb
|
|
|
57726f |
with_libxml2
|
|
|
57726f |
with_libjson
|
|
|
ce773a |
@@ -1747,6 +1750,7 @@ Optional Features:
|
|
|
57726f |
--enable-threads enable multithreading
|
|
|
57726f |
--enable-native-pkcs11 use native PKCS11 for all crypto [default=no]
|
|
|
57726f |
--enable-openssl-hash use OpenSSL for hash functions [default=no]
|
|
|
57726f |
+ --enable-crypto-rand use the crypto provider for random [default=yes]
|
|
|
57726f |
--enable-largefile 64-bit file support
|
|
|
57726f |
--enable-backtrace log stack backtrace on abort [default=yes]
|
|
|
57726f |
--enable-symtable use internal symbol table for backtrace
|
|
|
ce773a |
@@ -17204,6 +17208,7 @@ case "$use_openssl" in
|
|
|
57726f |
$as_echo "disabled because of native PKCS11" >&6; }
|
|
|
57726f |
DST_OPENSSL_INC=""
|
|
|
57726f |
CRYPTO="-DPKCS11CRYPTO"
|
|
|
57726f |
+ CRYPTOLIB="pkcs11"
|
|
|
57726f |
OPENSSLECDSALINKOBJS=""
|
|
|
57726f |
OPENSSLECDSALINKSRCS=""
|
|
|
57726f |
OPENSSLEDDSALINKOBJS=""
|
|
|
ce773a |
@@ -17218,6 +17223,7 @@ $as_echo "disabled because of native PKCS11" >&6; }
|
|
|
57726f |
$as_echo "no" >&6; }
|
|
|
57726f |
DST_OPENSSL_INC=""
|
|
|
57726f |
CRYPTO=""
|
|
|
57726f |
+ CRYPTOLIB=""
|
|
|
57726f |
OPENSSLECDSALINKOBJS=""
|
|
|
57726f |
OPENSSLECDSALINKSRCS=""
|
|
|
57726f |
OPENSSLEDDSALINKOBJS=""
|
|
|
ce773a |
@@ -17230,6 +17236,7 @@ $as_echo "no" >&6; }
|
|
|
57726f |
auto)
|
|
|
57726f |
DST_OPENSSL_INC=""
|
|
|
57726f |
CRYPTO=""
|
|
|
57726f |
+ CRYPTOLIB=""
|
|
|
57726f |
OPENSSLECDSALINKOBJS=""
|
|
|
57726f |
OPENSSLECDSALINKSRCS=""
|
|
|
57726f |
OPENSSLEDDSALINKOBJS=""
|
|
|
ce773a |
@@ -17239,7 +17246,7 @@ $as_echo "no" >&6; }
|
|
|
57726f |
OPENSSLLINKOBJS=""
|
|
|
57726f |
OPENSSLLINKSRCS=""
|
|
|
57726f |
as_fn_error $? "OpenSSL was not found in any of $openssldirs; use --with-openssl=/path
|
|
|
57726f |
-If you don't want OpenSSL, use --without-openssl" "$LINENO" 5
|
|
|
57726f |
+If you do not want OpenSSL, use --without-openssl" "$LINENO" 5
|
|
|
57726f |
;;
|
|
|
57726f |
*)
|
|
|
57726f |
if test "yes" = "$want_native_pkcs11"
|
|
|
ce773a |
@@ -17270,6 +17277,7 @@ $as_echo "not found" >&6; }
|
|
|
57726f |
as_fn_error $? "\"$use_openssl/include/openssl/opensslv.h\" not found" "$LINENO" 5
|
|
|
57726f |
fi
|
|
|
57726f |
CRYPTO='-DOPENSSL'
|
|
|
57726f |
+ CRYPTOLIB="openssl"
|
|
|
57726f |
if test "/usr" = "$use_openssl"
|
|
|
57726f |
then
|
|
|
57726f |
DST_OPENSSL_INC=""
|
|
|
ce773a |
@@ -17904,8 +17912,6 @@ fi
|
|
|
57726f |
# Use OpenSSL for hash functions
|
|
|
57726f |
#
|
|
|
57726f |
|
|
|
57726f |
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for using OpenSSL for hash functions" >&5
|
|
|
57726f |
-$as_echo_n "checking for using OpenSSL for hash functions... " >&6; }
|
|
|
57726f |
ISC_PLATFORM_OPENSSLHASH="#undef ISC_PLATFORM_OPENSSLHASH"
|
|
|
57726f |
case $want_openssl_hash in
|
|
|
57726f |
yes)
|
|
|
ce773a |
@@ -18280,6 +18286,86 @@ if test "rt" = "$have_clock_gt"; then
|
|
|
57726f |
LIBS="-lrt $LIBS"
|
|
|
57726f |
fi
|
|
|
57726f |
|
|
|
57726f |
+#
|
|
|
57726f |
+# Use the crypto provider (OpenSSL/PKCS#11) for random functions
|
|
|
57726f |
+#
|
|
|
57726f |
+
|
|
|
57726f |
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for using the crypto library (vs. builtin) for random functions" >&5
|
|
|
57726f |
+$as_echo_n "checking for using the crypto library (vs. builtin) for random functions... " >&6; }
|
|
|
57726f |
+# Check whether --enable-crypto-rand was given.
|
|
|
57726f |
+if test "${enable_crypto_rand+set}" = set; then :
|
|
|
57726f |
+ enableval=$enable_crypto_rand; want_crypto_rand="$enableval"
|
|
|
57726f |
+else
|
|
|
57726f |
+ want_crypto_rand="auto"
|
|
|
57726f |
+fi
|
|
|
57726f |
+
|
|
|
57726f |
+if test "$want_crypto_rand" = "auto"
|
|
|
57726f |
+then
|
|
|
57726f |
+ case "$CRYPTOLIB" in
|
|
|
57726f |
+ "")
|
|
|
57726f |
+ want_crypto_rand="no"
|
|
|
57726f |
+ ;;
|
|
|
57726f |
+ pkcs11)
|
|
|
57726f |
+ want_crypto_rand="yes"
|
|
|
57726f |
+ ;;
|
|
|
57726f |
+ openssl)
|
|
|
57726f |
+ saved_cflags="$CFLAGS"
|
|
|
57726f |
+ saved_libs="$LIBS"
|
|
|
57726f |
+ CFLAGS="$CFLAGS $DST_OPENSSL_INC"
|
|
|
57726f |
+ LIBS="$LIBS $DST_OPENSSL_LIBS"
|
|
|
57726f |
+ if test "$cross_compiling" = yes; then :
|
|
|
57726f |
+ want_crypto_rand="yes"
|
|
|
57726f |
+else
|
|
|
57726f |
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
|
|
57726f |
+/* end confdefs.h. */
|
|
|
57726f |
+
|
|
|
57726f |
+#include <openssl/rand.h>
|
|
|
57726f |
+
|
|
|
57726f |
+unsigned char buf[128];
|
|
|
57726f |
+
|
|
|
57726f |
+int main()
|
|
|
57726f |
+{
|
|
|
57726f |
+ if (RAND_bytes(buf, 128) != 1)
|
|
|
57726f |
+ return (1);
|
|
|
57726f |
+ return (0);
|
|
|
57726f |
+}
|
|
|
57726f |
+
|
|
|
57726f |
+_ACEOF
|
|
|
57726f |
+if ac_fn_c_try_run "$LINENO"; then :
|
|
|
57726f |
+ want_crypto_rand="yes"
|
|
|
57726f |
+else
|
|
|
57726f |
+ want_crypto_rand="no"
|
|
|
57726f |
+fi
|
|
|
57726f |
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
|
|
|
57726f |
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
|
|
|
57726f |
+fi
|
|
|
57726f |
+
|
|
|
57726f |
+ CFLAGS="$saved_cflags"
|
|
|
57726f |
+ LIBS="$saved_libs"
|
|
|
57726f |
+ ;;
|
|
|
57726f |
+ *)
|
|
|
57726f |
+ as_fn_error $? "Unknown crypto library define $CRYPTOLIB" "$LINENO" 5
|
|
|
57726f |
+ ;;
|
|
|
57726f |
+ esac
|
|
|
57726f |
+fi
|
|
|
57726f |
+case $want_crypto_rand in
|
|
|
57726f |
+ yes)
|
|
|
57726f |
+ if test "$CRYPTOLIB" = ""
|
|
|
57726f |
+ then
|
|
|
57726f |
+ as_fn_error $? "No crypto library for random functions" "$LINENO" 5
|
|
|
57726f |
+ fi
|
|
|
57726f |
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: \"$CRYPTOLIB\"" >&5
|
|
|
57726f |
+$as_echo "\"$CRYPTOLIB\"" >&6; }
|
|
|
57726f |
+ ISC_PLATFORM_CRYPTORANDOM="#define ISC_PLATFORM_CRYPTORANDOM \"$CRYPTOLIB\""
|
|
|
57726f |
+ ;;
|
|
|
57726f |
+ no)
|
|
|
57726f |
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
|
|
57726f |
+$as_echo "no" >&6; }
|
|
|
57726f |
+ ISC_PLATFORM_CRYPTORANDOM="#undef ISC_PLATFORM_CRYPTORANDOM"
|
|
|
57726f |
+ ;;
|
|
|
57726f |
+esac
|
|
|
57726f |
+
|
|
|
57726f |
+
|
|
|
57726f |
#
|
|
|
57726f |
# was --with-lmdb specified?
|
|
|
57726f |
#
|
|
|
ce773a |
@@ -20556,9 +20642,12 @@ _ACEOF
|
|
|
57726f |
if ac_fn_c_try_compile "$LINENO"; then :
|
|
|
57726f |
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: size_t for buflen; int for flags" >&5
|
|
|
57726f |
$as_echo "size_t for buflen; int for flags" >&6; }
|
|
|
57726f |
- $as_echo "#define IRS_GETNAMEINFO_SOCKLEN_T size_t" >>confdefs.h
|
|
|
57726f |
+ # Changed to solve multilib conflict on Fedora
|
|
|
57726f |
+ # AC_DEFINE(IRS_GETNAMEINFO_SOCKLEN_T, size_t)
|
|
|
57726f |
+ # AC_DEFINE(IRS_GETNAMEINFO_BUFLEN_T, size_t)
|
|
|
57726f |
+ $as_echo "#define IRS_GETNAMEINFO_SOCKLEN_T socklen_t" >>confdefs.h
|
|
|
57726f |
|
|
|
57726f |
- $as_echo "#define IRS_GETNAMEINFO_BUFLEN_T size_t" >>confdefs.h
|
|
|
57726f |
+ $as_echo "#define IRS_GETNAMEINFO_BUFLEN_T socklen_t" >>confdefs.h
|
|
|
57726f |
|
|
|
57726f |
$as_echo "#define IRS_GETNAMEINFO_FLAGS_T int" >>confdefs.h
|
|
|
57726f |
|
|
|
ce773a |
@@ -21856,12 +21945,7 @@ ISC_PLATFORM_USEGCCASM="#undef ISC_PLATFORM_USEGCCASM"
|
|
|
57726f |
ISC_PLATFORM_USESTDASM="#undef ISC_PLATFORM_USESTDASM"
|
|
|
57726f |
ISC_PLATFORM_USEMACASM="#undef ISC_PLATFORM_USEMACASM"
|
|
|
57726f |
if test "yes" = "$use_atomic"; then
|
|
|
57726f |
- have_atomic=yes # set default
|
|
|
57726f |
- case "$host" in
|
|
|
57726f |
- i[3456]86-*)
|
|
|
57726f |
- # XXX: some old x86 architectures actually do not support
|
|
|
57726f |
- # (some of) these operations. Do we need stricter checks?
|
|
|
57726f |
- # The cast to long int works around a bug in the HP C Compiler
|
|
|
57726f |
+ # The cast to long int works around a bug in the HP C Compiler
|
|
|
57726f |
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
|
|
|
57726f |
# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
|
|
|
57726f |
# This bug is HP SR number 8606223364.
|
|
|
ce773a |
@@ -21894,6 +21978,11 @@ cat >>confdefs.h <<_ACEOF
|
|
|
57726f |
_ACEOF
|
|
|
57726f |
|
|
|
57726f |
|
|
|
57726f |
+ have_atomic=yes # set default
|
|
|
57726f |
+ case "$host" in
|
|
|
57726f |
+ i[3456]86-*)
|
|
|
57726f |
+ # XXX: some old x86 architectures actually do not support
|
|
|
57726f |
+ # (some of) these operations. Do we need stricter checks?
|
|
|
57726f |
if test $ac_cv_sizeof_void_p = 8; then
|
|
|
57726f |
arch=x86_64
|
|
|
57726f |
have_xaddq=yes
|
|
|
ce773a |
@@ -21902,39 +21991,6 @@ _ACEOF
|
|
|
57726f |
fi
|
|
|
57726f |
;;
|
|
|
57726f |
x86_64-*|amd64-*)
|
|
|
57726f |
- # The cast to long int works around a bug in the HP C Compiler
|
|
|
57726f |
-# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
|
|
|
57726f |
-# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
|
|
|
57726f |
-# This bug is HP SR number 8606223364.
|
|
|
57726f |
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of void *" >&5
|
|
|
57726f |
-$as_echo_n "checking size of void *... " >&6; }
|
|
|
57726f |
-if ${ac_cv_sizeof_void_p+:} false; then :
|
|
|
57726f |
- $as_echo_n "(cached) " >&6
|
|
|
57726f |
-else
|
|
|
57726f |
- if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (void *))" "ac_cv_sizeof_void_p" "$ac_includes_default"; then :
|
|
|
57726f |
-
|
|
|
57726f |
-else
|
|
|
57726f |
- if test "$ac_cv_type_void_p" = yes; then
|
|
|
57726f |
- { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
|
|
|
57726f |
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
|
|
|
57726f |
-as_fn_error 77 "cannot compute sizeof (void *)
|
|
|
57726f |
-See \`config.log' for more details" "$LINENO" 5; }
|
|
|
57726f |
- else
|
|
|
57726f |
- ac_cv_sizeof_void_p=0
|
|
|
57726f |
- fi
|
|
|
57726f |
-fi
|
|
|
57726f |
-
|
|
|
57726f |
-fi
|
|
|
57726f |
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_void_p" >&5
|
|
|
57726f |
-$as_echo "$ac_cv_sizeof_void_p" >&6; }
|
|
|
57726f |
-
|
|
|
57726f |
-
|
|
|
57726f |
-
|
|
|
57726f |
-cat >>confdefs.h <<_ACEOF
|
|
|
57726f |
-#define SIZEOF_VOID_P $ac_cv_sizeof_void_p
|
|
|
57726f |
-_ACEOF
|
|
|
57726f |
-
|
|
|
57726f |
-
|
|
|
57726f |
if test $ac_cv_sizeof_void_p = 8; then
|
|
|
57726f |
arch=x86_64
|
|
|
57726f |
have_xaddq=yes
|
|
|
ce773a |
@@ -21965,6 +22021,10 @@ $as_echo_n "checking architecture type for atomic operations... " >&6; }
|
|
|
57726f |
$as_echo "$arch" >&6; }
|
|
|
57726f |
fi
|
|
|
57726f |
|
|
|
57726f |
+if test ! "$arch" = "x86_64" -a "$have_xaddq" = "yes"; then
|
|
|
57726f |
+ as_fn_error $? "XADDQ present but disabled by Fedora patch!" "$LINENO" 5
|
|
|
57726f |
+fi
|
|
|
57726f |
+
|
|
|
57726f |
if test "yes" = "$have_atomic"; then
|
|
|
57726f |
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking compiler support for inline assembly code" >&5
|
|
|
57726f |
$as_echo_n "checking compiler support for inline assembly code... " >&6; }
|
|
|
ce773a |
@@ -24547,6 +24607,30 @@ CFLAGS="$CFLAGS $SO_CFLAGS"
|
|
|
57726f |
#
|
|
|
57726f |
dlzdir='${DLZ_DRIVER_DIR}'
|
|
|
57726f |
|
|
|
57726f |
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for target libdir" >&5
|
|
|
57726f |
+$as_echo_n "checking for target libdir... " >&6; }
|
|
|
57726f |
+if test "$cross_compiling" = yes; then :
|
|
|
57726f |
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
|
|
|
57726f |
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
|
|
|
57726f |
+as_fn_error $? "cannot run test program while cross compiling
|
|
|
57726f |
+See \`config.log' for more details" "$LINENO" 5; }
|
|
|
57726f |
+else
|
|
|
57726f |
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
|
|
57726f |
+/* end confdefs.h. */
|
|
|
57726f |
+int main(void) {exit((sizeof(void *) == 8) ? 0 : 1);}
|
|
|
57726f |
+_ACEOF
|
|
|
57726f |
+if ac_fn_c_try_run "$LINENO"; then :
|
|
|
57726f |
+ target_lib=lib64
|
|
|
57726f |
+else
|
|
|
57726f |
+ target_lib=lib
|
|
|
57726f |
+fi
|
|
|
57726f |
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
|
|
|
57726f |
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
|
|
|
57726f |
+fi
|
|
|
57726f |
+
|
|
|
57726f |
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: \"$target_lib\"" >&5
|
|
|
57726f |
+$as_echo "\"$target_lib\"" >&6; }
|
|
|
57726f |
+
|
|
|
57726f |
#
|
|
|
57726f |
# Private autoconf macro to simplify configuring drivers:
|
|
|
57726f |
#
|
|
|
ce773a |
@@ -24877,11 +24961,11 @@ $as_echo "no" >&6; }
|
|
|
57726f |
$as_echo "using mysql with libs ${mysql_lib} and includes ${mysql_include}" >&6; }
|
|
|
57726f |
;;
|
|
|
57726f |
*)
|
|
|
57726f |
- if test -d "$use_dlz_mysql/lib/mysql"
|
|
|
57726f |
+ if test -d $use_dlz_mysql/${target_lib}/mysql
|
|
|
57726f |
then
|
|
|
57726f |
- mysql_lib="$use_dlz_mysql/lib/mysql"
|
|
|
57726f |
+ mysql_lib=$use_dlz_mysql/${target_lib}/mysql
|
|
|
57726f |
else
|
|
|
57726f |
- mysql_lib="$use_dlz_mysql/lib"
|
|
|
57726f |
+ mysql_lib=$use_dlz_mysql/${target_lib}
|
|
|
57726f |
fi
|
|
|
57726f |
|
|
|
57726f |
CONTRIB_DLZ="$CONTRIB_DLZ -DDLZ_MYSQL"
|
|
|
ce773a |
@@ -24966,7 +25050,7 @@ $as_echo "" >&6; }
|
|
|
57726f |
# Check other locations for includes.
|
|
|
57726f |
# Order is important (sigh).
|
|
|
57726f |
|
|
|
57726f |
- bdb_incdirs="/db53 /db51 /db48 /db47 /db46 /db45 /db44 /db43 /db42 /db41 /db4 /db"
|
|
|
57726f |
+ bdb_incdirs="/db53 /db51 /db48 /db47 /db46 /db45 /db44 /db43 /db42 /db41 /db4 /libdb /db"
|
|
|
57726f |
# include a blank element first
|
|
|
57726f |
for d in "" $bdb_incdirs
|
|
|
57726f |
do
|
|
|
ce773a |
@@ -24991,57 +25075,9 @@ $as_echo "" >&6; }
|
|
|
57726f |
bdb_libnames="db53 db-5.3 db51 db-5.1 db48 db-4.8 db47 db-4.7 db46 db-4.6 db45 db-4.5 db44 db-4.4 db43 db-4.3 db42 db-4.2 db41 db-4.1 db"
|
|
|
57726f |
for d in $bdb_libnames
|
|
|
57726f |
do
|
|
|
57726f |
- if test "$dd" = "/usr"
|
|
|
57726f |
- then
|
|
|
57726f |
- as_ac_Lib=`$as_echo "ac_cv_lib_$d''_db_create" | $as_tr_sh`
|
|
|
57726f |
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for db_create in -l$d" >&5
|
|
|
57726f |
-$as_echo_n "checking for db_create in -l$d... " >&6; }
|
|
|
57726f |
-if eval \${$as_ac_Lib+:} false; then :
|
|
|
57726f |
- $as_echo_n "(cached) " >&6
|
|
|
57726f |
-else
|
|
|
57726f |
- ac_check_lib_save_LIBS=$LIBS
|
|
|
57726f |
-LIBS="-l$d $LIBS"
|
|
|
57726f |
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
|
|
57726f |
-/* end confdefs.h. */
|
|
|
57726f |
-
|
|
|
57726f |
-/* Override any GCC internal prototype to avoid an error.
|
|
|
57726f |
- Use char because int might match the return type of a GCC
|
|
|
57726f |
- builtin and then its argument prototype would still apply. */
|
|
|
57726f |
-#ifdef __cplusplus
|
|
|
57726f |
-extern "C"
|
|
|
57726f |
-#endif
|
|
|
57726f |
-char db_create ();
|
|
|
57726f |
-int
|
|
|
57726f |
-main ()
|
|
|
57726f |
-{
|
|
|
57726f |
-return db_create ();
|
|
|
57726f |
- ;
|
|
|
57726f |
- return 0;
|
|
|
57726f |
-}
|
|
|
57726f |
-_ACEOF
|
|
|
57726f |
-if ac_fn_c_try_link "$LINENO"; then :
|
|
|
57726f |
- eval "$as_ac_Lib=yes"
|
|
|
57726f |
-else
|
|
|
57726f |
- eval "$as_ac_Lib=no"
|
|
|
57726f |
-fi
|
|
|
57726f |
-rm -f core conftest.err conftest.$ac_objext \
|
|
|
57726f |
- conftest$ac_exeext conftest.$ac_ext
|
|
|
57726f |
-LIBS=$ac_check_lib_save_LIBS
|
|
|
57726f |
-fi
|
|
|
57726f |
-eval ac_res=\$$as_ac_Lib
|
|
|
57726f |
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
|
|
|
57726f |
-$as_echo "$ac_res" >&6; }
|
|
|
57726f |
-if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then :
|
|
|
57726f |
- dlz_bdb_libs="-l${d}"
|
|
|
57726f |
-fi
|
|
|
57726f |
-
|
|
|
57726f |
- if test $dlz_bdb_libs != "yes"
|
|
|
57726f |
- then
|
|
|
57726f |
- break
|
|
|
57726f |
- fi
|
|
|
57726f |
- elif test -f "$dd/lib/lib${d}.so"
|
|
|
57726f |
+ if test -f "$dd/${target_lib}/lib${d}.so"
|
|
|
57726f |
then
|
|
|
57726f |
- dlz_bdb_libs="-L${dd}/lib -l${d}"
|
|
|
57726f |
+ dlz_bdb_libs="-L${dd}/${target_lib}/libdb -l${d}"
|
|
|
57726f |
break
|
|
|
57726f |
fi
|
|
|
57726f |
done
|
|
|
ce773a |
@@ -25200,10 +25236,10 @@ $as_echo "no" >&6; }
|
|
|
57726f |
DLZ_DRIVER_INCLUDES="$DLZ_DRIVER_INCLUDES -I$use_dlz_ldap/include"
|
|
|
57726f |
DLZ_DRIVER_LDAP_INCLUDES="-I$use_dlz_ldap/include"
|
|
|
57726f |
fi
|
|
|
57726f |
- if test -n "-L$use_dlz_ldap/lib -lldap -llber"
|
|
|
57726f |
+ if test -n "-L$use_dlz_ldap/${target_lib} -lldap -llber"
|
|
|
57726f |
then
|
|
|
57726f |
- DLZ_DRIVER_LIBS="$DLZ_DRIVER_LIBS -L$use_dlz_ldap/lib -lldap -llber"
|
|
|
57726f |
- DLZ_DRIVER_LDAP_LIBS="-L$use_dlz_ldap/lib -lldap -llber"
|
|
|
57726f |
+ DLZ_DRIVER_LIBS="$DLZ_DRIVER_LIBS -L$use_dlz_ldap/${target_lib} -lldap -llber"
|
|
|
57726f |
+ DLZ_DRIVER_LDAP_LIBS="-L$use_dlz_ldap/${target_lib} -lldap -llber"
|
|
|
57726f |
fi
|
|
|
57726f |
|
|
|
57726f |
|
|
|
ce773a |
@@ -25289,11 +25325,11 @@ fi
|
|
|
57726f |
odbcdirs="/usr /usr/local /usr/pkg"
|
|
|
57726f |
for d in $odbcdirs
|
|
|
57726f |
do
|
|
|
57726f |
- if test -f $d/include/sql.h -a -f $d/lib/libodbc.a
|
|
|
57726f |
+ if test -f $d/include/sql.h -a -f $d/${target_lib}/libodbc.a
|
|
|
57726f |
then
|
|
|
57726f |
use_dlz_odbc=$d
|
|
|
57726f |
dlz_odbc_include="-I$use_dlz_odbc/include"
|
|
|
57726f |
- dlz_odbc_libs="-L$use_dlz_odbc/lib -lodbc"
|
|
|
57726f |
+ dlz_odbc_libs="-L$use_dlz_odbc/${target_lib} -lodbc"
|
|
|
57726f |
break
|
|
|
57726f |
fi
|
|
|
57726f |
done
|
|
|
ce773a |
@@ -25568,6 +25604,8 @@ DNS_CRYPTO_LIBS="$NEWFLAGS"
|
|
|
57726f |
|
|
|
57726f |
|
|
|
57726f |
|
|
|
57726f |
+
|
|
|
57726f |
+
|
|
|
57726f |
#
|
|
|
57726f |
# Commands to run at the end of config.status.
|
|
|
57726f |
# Don't just put these into configure, it won't work right if somebody
|
|
|
ce773a |
@@ -27946,6 +27984,8 @@ report() {
|
|
|
57726f |
echo " IPv6 support (--enable-ipv6)"
|
|
|
57726f |
test "X$CRYPTO" = "X" -o "yes" = "$want_native_pkcs11" || \
|
|
|
57726f |
echo " OpenSSL cryptography/DNSSEC (--with-openssl)"
|
|
|
57726f |
+ test "no" = "$want_crypto_rand" || \
|
|
|
57726f |
+ echo " Crypto provider entropy source (--enable-crypto-rand)"
|
|
|
57726f |
test "X$PYTHON" = "X" || echo " Python tools (--with-python)"
|
|
|
57726f |
test "X$XMLSTATS" = "X" || echo " XML statistics (--with-libxml2)"
|
|
|
57726f |
test "X$JSONSTATS" = "X" || echo " JSON statistics (--with-libjson)"
|
|
|
ce773a |
@@ -27986,6 +28026,8 @@ report() {
|
|
|
57726f |
echo " Very verbose query trace logging (--enable-querytrace)"
|
|
|
57726f |
test "no" = "$with_cmocka" || echo " CMocka Unit Testing Framework (--with-cmocka)"
|
|
|
57726f |
|
|
|
57726f |
+ echo " Cryptographic library for DNSSEC: $CRYPTOLIB"
|
|
|
57726f |
+
|
|
|
57726f |
echo " Dynamically loadable zone (DLZ) drivers:"
|
|
|
57726f |
test "no" = "$use_dlz_bdb" || \
|
|
|
57726f |
echo " Berkeley DB (--with-dlz-bdb)"
|
|
|
ce773a |
@@ -28033,6 +28075,8 @@ report() {
|
|
|
57726f |
echo " ECDSA algorithm support (--with-ecdsa)"
|
|
|
57726f |
test "X$CRYPTO" = "X" -o "yes" = "$OPENSSL_ED25519" -o "yes" = "$PKCS11_ED25519" || \
|
|
|
57726f |
echo " EDDSA algorithm support (--with-eddsa)"
|
|
|
57726f |
+ test "yes" = "$want_crypto_rand" || \
|
|
|
57726f |
+ echo " Crypto provider entropy source (--enable-crypto-rand)"
|
|
|
57726f |
|
|
|
57726f |
test "yes" = "$enable_seccomp" || \
|
|
|
57726f |
echo " Use libseccomp system call filtering (--enable-seccomp)"
|
|
|
57726f |
diff --git a/configure.ac b/configure.ac
|
|
|
ce773a |
index 11f41e8..fdcfc62 100644
|
|
|
57726f |
--- a/configure.ac
|
|
|
57726f |
+++ b/configure.ac
|
|
|
ce773a |
@@ -1600,6 +1600,7 @@ case "$use_openssl" in
|
|
|
57726f |
AC_MSG_RESULT(disabled because of native PKCS11)
|
|
|
57726f |
DST_OPENSSL_INC=""
|
|
|
57726f |
CRYPTO="-DPKCS11CRYPTO"
|
|
|
57726f |
+ CRYPTOLIB="pkcs11"
|
|
|
57726f |
OPENSSLECDSALINKOBJS=""
|
|
|
57726f |
OPENSSLECDSALINKSRCS=""
|
|
|
57726f |
OPENSSLEDDSALINKOBJS=""
|
|
|
ce773a |
@@ -1613,6 +1614,7 @@ case "$use_openssl" in
|
|
|
57726f |
AC_MSG_RESULT(no)
|
|
|
57726f |
DST_OPENSSL_INC=""
|
|
|
57726f |
CRYPTO=""
|
|
|
57726f |
+ CRYPTOLIB=""
|
|
|
57726f |
OPENSSLECDSALINKOBJS=""
|
|
|
57726f |
OPENSSLECDSALINKSRCS=""
|
|
|
57726f |
OPENSSLEDDSALINKOBJS=""
|
|
|
ce773a |
@@ -1625,6 +1627,7 @@ case "$use_openssl" in
|
|
|
57726f |
auto)
|
|
|
57726f |
DST_OPENSSL_INC=""
|
|
|
57726f |
CRYPTO=""
|
|
|
57726f |
+ CRYPTOLIB=""
|
|
|
57726f |
OPENSSLECDSALINKOBJS=""
|
|
|
57726f |
OPENSSLECDSALINKSRCS=""
|
|
|
57726f |
OPENSSLEDDSALINKOBJS=""
|
|
|
ce773a |
@@ -1635,7 +1638,7 @@ case "$use_openssl" in
|
|
|
57726f |
OPENSSLLINKSRCS=""
|
|
|
57726f |
AC_MSG_ERROR(
|
|
|
57726f |
[OpenSSL was not found in any of $openssldirs; use --with-openssl=/path
|
|
|
57726f |
-If you don't want OpenSSL, use --without-openssl])
|
|
|
57726f |
+If you do not want OpenSSL, use --without-openssl])
|
|
|
57726f |
;;
|
|
|
57726f |
*)
|
|
|
57726f |
if test "yes" = "$want_native_pkcs11"
|
|
|
ce773a |
@@ -1665,6 +1668,7 @@ If you don't want OpenSSL, use --without-openssl])
|
|
|
57726f |
AC_MSG_ERROR(["$use_openssl/include/openssl/opensslv.h" not found])
|
|
|
57726f |
fi
|
|
|
57726f |
CRYPTO='-DOPENSSL'
|
|
|
57726f |
+ CRYPTOLIB="openssl"
|
|
|
57726f |
if test "/usr" = "$use_openssl"
|
|
|
57726f |
then
|
|
|
57726f |
DST_OPENSSL_INC=""
|
|
|
ce773a |
@@ -2109,7 +2113,6 @@ fi
|
|
|
57726f |
# Use OpenSSL for hash functions
|
|
|
57726f |
#
|
|
|
57726f |
|
|
|
57726f |
-AC_MSG_CHECKING(for using OpenSSL for hash functions)
|
|
|
57726f |
ISC_PLATFORM_OPENSSLHASH="#undef ISC_PLATFORM_OPENSSLHASH"
|
|
|
57726f |
case $want_openssl_hash in
|
|
|
57726f |
yes)
|
|
|
ce773a |
@@ -2381,6 +2384,67 @@ if test "rt" = "$have_clock_gt"; then
|
|
|
57726f |
LIBS="-lrt $LIBS"
|
|
|
57726f |
fi
|
|
|
57726f |
|
|
|
57726f |
+#
|
|
|
57726f |
+# Use the crypto provider (OpenSSL/PKCS#11) for random functions
|
|
|
57726f |
+#
|
|
|
57726f |
+
|
|
|
57726f |
+AC_MSG_CHECKING(for using the crypto library (vs. builtin) for random functions)
|
|
|
57726f |
+AC_ARG_ENABLE(crypto-rand,
|
|
|
57726f |
+ [ --enable-crypto-rand use the crypto provider for random [[default=yes]]],
|
|
|
57726f |
+ want_crypto_rand="$enableval", want_crypto_rand="auto")
|
|
|
57726f |
+if test "$want_crypto_rand" = "auto"
|
|
|
57726f |
+then
|
|
|
57726f |
+ case "$CRYPTOLIB" in
|
|
|
57726f |
+ "")
|
|
|
57726f |
+ want_crypto_rand="no"
|
|
|
57726f |
+ ;;
|
|
|
57726f |
+ pkcs11)
|
|
|
57726f |
+ want_crypto_rand="yes"
|
|
|
57726f |
+ ;;
|
|
|
57726f |
+ openssl)
|
|
|
57726f |
+ saved_cflags="$CFLAGS"
|
|
|
57726f |
+ saved_libs="$LIBS"
|
|
|
57726f |
+ CFLAGS="$CFLAGS $DST_OPENSSL_INC"
|
|
|
57726f |
+ LIBS="$LIBS $DST_OPENSSL_LIBS"
|
|
|
57726f |
+ AC_TRY_RUN([
|
|
|
57726f |
+#include <openssl/rand.h>
|
|
|
57726f |
+
|
|
|
57726f |
+unsigned char buf[128];
|
|
|
57726f |
+
|
|
|
57726f |
+int main()
|
|
|
57726f |
+{
|
|
|
57726f |
+ if (RAND_bytes(buf, 128) != 1)
|
|
|
57726f |
+ return (1);
|
|
|
57726f |
+ return (0);
|
|
|
57726f |
+}
|
|
|
57726f |
+],
|
|
|
57726f |
+ [want_crypto_rand="yes"],
|
|
|
57726f |
+ [want_crypto_rand="no"],
|
|
|
57726f |
+ [want_crypto_rand="yes"])
|
|
|
57726f |
+ CFLAGS="$saved_cflags"
|
|
|
57726f |
+ LIBS="$saved_libs"
|
|
|
57726f |
+ ;;
|
|
|
57726f |
+ *)
|
|
|
57726f |
+ AC_MSG_ERROR([Unknown crypto library define $CRYPTOLIB])
|
|
|
57726f |
+ ;;
|
|
|
57726f |
+ esac
|
|
|
57726f |
+fi
|
|
|
57726f |
+case $want_crypto_rand in
|
|
|
57726f |
+ yes)
|
|
|
57726f |
+ if test "$CRYPTOLIB" = ""
|
|
|
57726f |
+ then
|
|
|
57726f |
+ AC_MSG_ERROR([No crypto library for random functions])
|
|
|
57726f |
+ fi
|
|
|
57726f |
+ AC_MSG_RESULT(["$CRYPTOLIB"])
|
|
|
57726f |
+ ISC_PLATFORM_CRYPTORANDOM="#define ISC_PLATFORM_CRYPTORANDOM \"$CRYPTOLIB\""
|
|
|
57726f |
+ ;;
|
|
|
57726f |
+ no)
|
|
|
57726f |
+ AC_MSG_RESULT(no)
|
|
|
57726f |
+ ISC_PLATFORM_CRYPTORANDOM="#undef ISC_PLATFORM_CRYPTORANDOM"
|
|
|
57726f |
+ ;;
|
|
|
57726f |
+esac
|
|
|
57726f |
+AC_SUBST(ISC_PLATFORM_CRYPTORANDOM)
|
|
|
57726f |
+
|
|
|
57726f |
#
|
|
|
57726f |
# was --with-lmdb specified?
|
|
|
57726f |
#
|
|
|
ce773a |
@@ -4174,12 +4238,12 @@ ISC_PLATFORM_USEGCCASM="#undef ISC_PLATFORM_USEGCCASM"
|
|
|
57726f |
ISC_PLATFORM_USESTDASM="#undef ISC_PLATFORM_USESTDASM"
|
|
|
57726f |
ISC_PLATFORM_USEMACASM="#undef ISC_PLATFORM_USEMACASM"
|
|
|
57726f |
if test "yes" = "$use_atomic"; then
|
|
|
57726f |
+ AC_CHECK_SIZEOF([void *])
|
|
|
57726f |
have_atomic=yes # set default
|
|
|
57726f |
case "$host" in
|
|
|
57726f |
[i[3456]86-*])
|
|
|
57726f |
# XXX: some old x86 architectures actually do not support
|
|
|
57726f |
# (some of) these operations. Do we need stricter checks?
|
|
|
57726f |
- AC_CHECK_SIZEOF([void *])
|
|
|
57726f |
if test $ac_cv_sizeof_void_p = 8; then
|
|
|
57726f |
arch=x86_64
|
|
|
57726f |
have_xaddq=yes
|
|
|
ce773a |
@@ -4188,7 +4252,6 @@ if test "yes" = "$use_atomic"; then
|
|
|
57726f |
fi
|
|
|
57726f |
;;
|
|
|
57726f |
x86_64-*|amd64-*)
|
|
|
57726f |
- AC_CHECK_SIZEOF([void *])
|
|
|
57726f |
if test $ac_cv_sizeof_void_p = 8; then
|
|
|
57726f |
arch=x86_64
|
|
|
57726f |
have_xaddq=yes
|
|
|
ce773a |
@@ -5622,6 +5685,8 @@ report() {
|
|
|
57726f |
echo " IPv6 support (--enable-ipv6)"
|
|
|
57726f |
test "X$CRYPTO" = "X" -o "yes" = "$want_native_pkcs11" || \
|
|
|
57726f |
echo " OpenSSL cryptography/DNSSEC (--with-openssl)"
|
|
|
57726f |
+ test "no" = "$want_crypto_rand" || \
|
|
|
57726f |
+ echo " Crypto provider entropy source (--enable-crypto-rand)"
|
|
|
57726f |
test "X$PYTHON" = "X" || echo " Python tools (--with-python)"
|
|
|
57726f |
test "X$XMLSTATS" = "X" || echo " XML statistics (--with-libxml2)"
|
|
|
57726f |
test "X$JSONSTATS" = "X" || echo " JSON statistics (--with-libjson)"
|
|
|
ce773a |
@@ -5662,6 +5727,8 @@ report() {
|
|
|
57726f |
echo " Very verbose query trace logging (--enable-querytrace)"
|
|
|
57726f |
test "no" = "$with_cmocka" || echo " CMocka Unit Testing Framework (--with-cmocka)"
|
|
|
57726f |
|
|
|
57726f |
+ echo " Cryptographic library for DNSSEC: $CRYPTOLIB"
|
|
|
57726f |
+
|
|
|
57726f |
echo " Dynamically loadable zone (DLZ) drivers:"
|
|
|
57726f |
test "no" = "$use_dlz_bdb" || \
|
|
|
57726f |
echo " Berkeley DB (--with-dlz-bdb)"
|
|
|
ce773a |
@@ -5709,6 +5776,8 @@ report() {
|
|
|
57726f |
echo " ECDSA algorithm support (--with-ecdsa)"
|
|
|
57726f |
test "X$CRYPTO" = "X" -o "yes" = "$OPENSSL_ED25519" -o "yes" = "$PKCS11_ED25519" || \
|
|
|
57726f |
echo " EDDSA algorithm support (--with-eddsa)"
|
|
|
57726f |
+ test "yes" = "$want_crypto_rand" || \
|
|
|
57726f |
+ echo " Crypto provider entropy source (--enable-crypto-rand)"
|
|
|
57726f |
|
|
|
57726f |
test "yes" = "$enable_seccomp" || \
|
|
|
57726f |
echo " Use libseccomp system call filtering (--enable-seccomp)"
|
|
|
57726f |
diff --git a/lib/dns/dst_api.c b/lib/dns/dst_api.c
|
|
|
e48f32 |
index 7a86506..aa54afc 100644
|
|
|
57726f |
--- a/lib/dns/dst_api.c
|
|
|
57726f |
+++ b/lib/dns/dst_api.c
|
|
|
57726f |
@@ -277,6 +277,12 @@ dst_lib_init2(isc_mem_t *mctx, isc_entropy_t *ectx,
|
|
|
57726f |
#ifdef GSSAPI
|
|
|
57726f |
RETERR(dst__gssapi_init(&dst_t_func[DST_ALG_GSSAPI]));
|
|
|
57726f |
#endif
|
|
|
57726f |
+#if defined(OPENSSL) || defined(PKCS11CRYPTO)
|
|
|
57726f |
+#ifdef ISC_PLATFORM_CRYPTORANDOM
|
|
|
57726f |
+ if (dst_entropy_pool != NULL)
|
|
|
57726f |
+ isc_entropy_sethook(dst_random_getdata);
|
|
|
57726f |
+#endif
|
|
|
57726f |
+#endif /* defined(OPENSSL) || defined(PKCS11CRYPTO) */
|
|
|
57726f |
dst_initialized = true;
|
|
|
57726f |
return (ISC_R_SUCCESS);
|
|
|
57726f |
|
|
|
57726f |
@@ -296,11 +302,19 @@ dst_lib_destroy(void) {
|
|
|
57726f |
for (i = 0; i < DST_MAX_ALGS; i++)
|
|
|
57726f |
if (dst_t_func[i] != NULL && dst_t_func[i]->cleanup != NULL)
|
|
|
57726f |
dst_t_func[i]->cleanup();
|
|
|
57726f |
+#if defined(OPENSSL) || defined(PKCS11CRYPTO)
|
|
|
57726f |
+#ifdef ISC_PLATFORM_CRYPTORANDOM
|
|
|
57726f |
+ if (dst_entropy_pool != NULL) {
|
|
|
57726f |
+ isc_entropy_usehook(dst_entropy_pool, false);
|
|
|
57726f |
+ isc_entropy_sethook(NULL);
|
|
|
57726f |
+ }
|
|
|
57726f |
+#endif
|
|
|
57726f |
#ifdef OPENSSL
|
|
|
57726f |
dst__openssl_destroy();
|
|
|
57726f |
#elif PKCS11CRYPTO
|
|
|
57726f |
(void) dst__pkcs11_destroy();
|
|
|
57726f |
#endif /* if OPENSSL, elif PKCS11CRYPTO */
|
|
|
57726f |
+#endif /* defined(OPENSSL) || defined(PKCS11CRYPTO) */
|
|
|
57726f |
if (dst__memory_pool != NULL)
|
|
|
57726f |
isc_mem_detach(&dst__memory_pool);
|
|
|
57726f |
if (dst_entropy_pool != NULL)
|
|
|
57726f |
@@ -2002,13 +2016,17 @@ dst__entropy_getdata(void *buf, unsigned int len, bool pseudo) {
|
|
|
57726f |
flags &= ~ISC_ENTROPY_GOODONLY;
|
|
|
57726f |
else
|
|
|
57726f |
flags |= ISC_ENTROPY_BLOCKING;
|
|
|
57726f |
+#ifdef ISC_PLATFORM_CRYPTORANDOM
|
|
|
57726f |
+ return (dst_random_getdata(buf, len, NULL, flags));
|
|
|
57726f |
+#else
|
|
|
57726f |
return (isc_entropy_getdata(dst_entropy_pool, buf, len, NULL, flags));
|
|
|
57726f |
+#endif
|
|
|
57726f |
#endif /* PKCS11CRYPTO */
|
|
|
57726f |
}
|
|
|
57726f |
|
|
|
57726f |
unsigned int
|
|
|
57726f |
dst__entropy_status(void) {
|
|
|
57726f |
-#ifndef PKCS11CRYPTO
|
|
|
57726f |
+#if !defined(PKCS11CRYPTO) && !defined(ISC_PLATFORM_CRYPTORANDOM)
|
|
|
57726f |
#ifdef GSSAPI
|
|
|
57726f |
unsigned int flags = dst_entropy_flags;
|
|
|
57726f |
isc_result_t ret;
|
|
|
57726f |
@@ -2031,6 +2049,7 @@ dst__entropy_status(void) {
|
|
|
57726f |
#endif
|
|
|
57726f |
return (isc_entropy_status(dst_entropy_pool));
|
|
|
57726f |
#else
|
|
|
57726f |
+ /* Doesn't matter as it is not used in this case. */
|
|
|
57726f |
return (0);
|
|
|
57726f |
#endif
|
|
|
57726f |
}
|
|
|
57726f |
diff --git a/lib/dns/include/dst/dst.h b/lib/dns/include/dst/dst.h
|
|
|
e48f32 |
index 5b42ab4..3aba028 100644
|
|
|
57726f |
--- a/lib/dns/include/dst/dst.h
|
|
|
57726f |
+++ b/lib/dns/include/dst/dst.h
|
|
|
57726f |
@@ -159,6 +159,14 @@ dst_lib_destroy(void);
|
|
|
57726f |
* Releases all resources allocated by DST.
|
|
|
57726f |
*/
|
|
|
57726f |
|
|
|
57726f |
+isc_result_t
|
|
|
57726f |
+dst_random_getdata(void *data, unsigned int length,
|
|
|
57726f |
+ unsigned int *returned, unsigned int flags);
|
|
|
57726f |
+/*%<
|
|
|
57726f |
+ * \brief Return data from the crypto random generator.
|
|
|
57726f |
+ * Specialization of isc_entropy_getdata().
|
|
|
57726f |
+ */
|
|
|
57726f |
+
|
|
|
57726f |
bool
|
|
|
57726f |
dst_algorithm_supported(unsigned int alg);
|
|
|
57726f |
/*%<
|
|
|
57726f |
diff --git a/lib/dns/lib.c b/lib/dns/lib.c
|
|
|
e48f32 |
index d9417de..0dc935d 100644
|
|
|
57726f |
--- a/lib/dns/lib.c
|
|
|
57726f |
+++ b/lib/dns/lib.c
|
|
|
e48f32 |
@@ -16,6 +16,7 @@
|
|
|
57726f |
#include <stdbool.h>
|
|
|
57726f |
#include <stddef.h>
|
|
|
57726f |
|
|
|
57726f |
+#include <isc/entropy.h>
|
|
|
57726f |
#include <isc/hash.h>
|
|
|
57726f |
#include <isc/mem.h>
|
|
|
57726f |
#include <isc/msgcat.h>
|
|
|
e48f32 |
@@ -76,6 +77,7 @@ static unsigned int references = 0;
|
|
|
57726f |
static void
|
|
|
57726f |
initialize(void) {
|
|
|
57726f |
isc_result_t result;
|
|
|
57726f |
+ isc_entropy_t *ectx = NULL;
|
|
|
57726f |
|
|
|
57726f |
REQUIRE(initialize_done == false);
|
|
|
57726f |
|
|
|
e48f32 |
@@ -86,11 +88,14 @@ initialize(void) {
|
|
|
57726f |
result = dns_ecdb_register(dns_g_mctx, &dbimp);
|
|
|
57726f |
if (result != ISC_R_SUCCESS)
|
|
|
57726f |
goto cleanup_mctx;
|
|
|
57726f |
- result = isc_hash_create(dns_g_mctx, NULL, DNS_NAME_MAXWIRE);
|
|
|
57726f |
+ result = isc_entropy_create(dns_g_mctx, &ectx);
|
|
|
57726f |
if (result != ISC_R_SUCCESS)
|
|
|
57726f |
goto cleanup_db;
|
|
|
57726f |
+ result = isc_hash_create(dns_g_mctx, NULL, DNS_NAME_MAXWIRE);
|
|
|
57726f |
+ if (result != ISC_R_SUCCESS)
|
|
|
57726f |
+ goto cleanup_ectx;
|
|
|
57726f |
|
|
|
57726f |
- result = dst_lib_init(dns_g_mctx, NULL, 0);
|
|
|
57726f |
+ result = dst_lib_init(dns_g_mctx, ectx, 0);
|
|
|
57726f |
if (result != ISC_R_SUCCESS)
|
|
|
57726f |
goto cleanup_hash;
|
|
|
57726f |
|
|
|
e48f32 |
@@ -98,11 +103,17 @@ initialize(void) {
|
|
|
57726f |
if (result != ISC_R_SUCCESS)
|
|
|
57726f |
goto cleanup_dst;
|
|
|
57726f |
|
|
|
57726f |
+ isc_hash_init();
|
|
|
57726f |
+ isc_entropy_detach(&ectx);
|
|
|
57726f |
+
|
|
|
57726f |
initialize_done = true;
|
|
|
57726f |
return;
|
|
|
57726f |
|
|
|
57726f |
cleanup_dst:
|
|
|
57726f |
dst_lib_destroy();
|
|
|
57726f |
+ cleanup_ectx:
|
|
|
57726f |
+ if (ectx != NULL)
|
|
|
57726f |
+ isc_entropy_detach(&ectx);
|
|
|
57726f |
cleanup_hash:
|
|
|
57726f |
isc_hash_destroy();
|
|
|
57726f |
cleanup_db:
|
|
|
57726f |
diff --git a/lib/dns/openssl_link.c b/lib/dns/openssl_link.c
|
|
|
e48f32 |
index 1e57c71..3f4f822 100644
|
|
|
57726f |
--- a/lib/dns/openssl_link.c
|
|
|
57726f |
+++ b/lib/dns/openssl_link.c
|
|
|
57726f |
@@ -31,6 +31,7 @@
|
|
|
57726f |
#include <isc/mem.h>
|
|
|
57726f |
#include <isc/mutex.h>
|
|
|
57726f |
#include <isc/mutexblock.h>
|
|
|
57726f |
+#include <isc/platform.h>
|
|
|
57726f |
#include <isc/string.h>
|
|
|
57726f |
#include <isc/thread.h>
|
|
|
57726f |
#include <isc/util.h>
|
|
|
57726f |
@@ -46,8 +47,6 @@
|
|
|
57726f |
#include <openssl/engine.h>
|
|
|
57726f |
#endif
|
|
|
57726f |
|
|
|
57726f |
-static RAND_METHOD *rm = NULL;
|
|
|
57726f |
-
|
|
|
57726f |
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
|
|
|
57726f |
static isc_mutex_t *locks = NULL;
|
|
|
57726f |
static int nlocks;
|
|
|
57726f |
@@ -57,6 +56,9 @@ static int nlocks;
|
|
|
57726f |
static ENGINE *e = NULL;
|
|
|
57726f |
#endif
|
|
|
57726f |
|
|
|
57726f |
+#ifndef ISC_PLATFORM_CRYPTORANDOM
|
|
|
57726f |
+static RAND_METHOD *rm = NULL;
|
|
|
57726f |
+
|
|
|
57726f |
static int
|
|
|
57726f |
entropy_get(unsigned char *buf, int num) {
|
|
|
57726f |
isc_result_t result;
|
|
|
57726f |
@@ -102,6 +104,7 @@ entropy_add(const void *buf, int num, double entropy) {
|
|
|
57726f |
return (1);
|
|
|
57726f |
}
|
|
|
57726f |
#endif
|
|
|
57726f |
+#endif /* !ISC_PLATFORM_CRYPTORANDOM */
|
|
|
57726f |
|
|
|
f79ca9 |
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
|
|
|
57726f |
static void
|
|
|
57726f |
@@ -192,7 +195,7 @@ _set_thread_id(CRYPTO_THREADID *id)
|
|
|
57726f |
isc_result_t
|
|
|
57726f |
dst__openssl_init(const char *engine) {
|
|
|
57726f |
isc_result_t result;
|
|
|
57726f |
-#if !defined(OPENSSL_NO_ENGINE)
|
|
|
57726f |
+#if !defined(OPENSSL_NO_ENGINE) && !defined(ISC_PLATFORM_CRYPTORANDOM)
|
|
|
57726f |
ENGINE *re;
|
|
|
57726f |
#else
|
|
|
57726f |
UNUSED(engine);
|
|
|
57726f |
@@ -222,6 +225,7 @@ dst__openssl_init(const char *engine) {
|
|
|
57726f |
ERR_load_crypto_strings();
|
|
|
57726f |
#endif
|
|
|
57726f |
|
|
|
57726f |
+#ifndef ISC_PLATFORM_CRYPTORANDOM
|
|
|
57726f |
rm = mem_alloc(sizeof(RAND_METHOD) FILELINE);
|
|
|
57726f |
if (rm == NULL) {
|
|
|
57726f |
result = ISC_R_NOMEMORY;
|
|
|
57726f |
@@ -233,6 +237,7 @@ dst__openssl_init(const char *engine) {
|
|
|
57726f |
rm->add = entropy_add;
|
|
|
57726f |
rm->pseudorand = entropy_getpseudo;
|
|
|
57726f |
rm->status = entropy_status;
|
|
|
57726f |
+#endif
|
|
|
57726f |
|
|
|
57726f |
#if !defined(OPENSSL_NO_ENGINE)
|
|
|
57726f |
#if !defined(CONF_MFLAGS_DEFAULT_SECTION)
|
|
|
57726f |
@@ -266,6 +271,7 @@ dst__openssl_init(const char *engine) {
|
|
|
57726f |
}
|
|
|
57726f |
}
|
|
|
57726f |
|
|
|
57726f |
+#ifndef ISC_PLATFORM_CRYPTORANDOM
|
|
|
57726f |
re = ENGINE_get_default_RAND();
|
|
|
57726f |
if (re == NULL) {
|
|
|
57726f |
re = ENGINE_new();
|
|
|
57726f |
@@ -278,9 +284,21 @@ dst__openssl_init(const char *engine) {
|
|
|
57726f |
ENGINE_free(re);
|
|
|
57726f |
} else
|
|
|
57726f |
ENGINE_finish(re);
|
|
|
57726f |
+#endif
|
|
|
57726f |
#else
|
|
|
57726f |
+#ifndef ISC_PLATFORM_CRYPTORANDOM
|
|
|
57726f |
RAND_set_rand_method(rm);
|
|
|
57726f |
+#endif
|
|
|
57726f |
#endif /* !defined(OPENSSL_NO_ENGINE) */
|
|
|
57726f |
+
|
|
|
57726f |
+ /* Protect ourselves against unseeded PRNG */
|
|
|
57726f |
+ if (RAND_status() != 1) {
|
|
|
57726f |
+ FATAL_ERROR(__FILE__, __LINE__,
|
|
|
57726f |
+ "OpenSSL pseudorandom number generator "
|
|
|
57726f |
+ "cannot be initialized (see the `PRNG not "
|
|
|
57726f |
+ "seeded' message in the OpenSSL FAQ)");
|
|
|
57726f |
+ }
|
|
|
57726f |
+
|
|
|
57726f |
return (ISC_R_SUCCESS);
|
|
|
57726f |
|
|
|
57726f |
#if !defined(OPENSSL_NO_ENGINE)
|
|
|
57726f |
@@ -288,10 +306,14 @@ dst__openssl_init(const char *engine) {
|
|
|
57726f |
if (e != NULL)
|
|
|
57726f |
ENGINE_free(e);
|
|
|
57726f |
e = NULL;
|
|
|
57726f |
+#ifndef ISC_PLATFORM_CRYPTORANDOM
|
|
|
57726f |
mem_free(rm FILELINE);
|
|
|
57726f |
rm = NULL;
|
|
|
57726f |
#endif
|
|
|
57726f |
+#endif
|
|
|
57726f |
+#ifndef ISC_PLATFORM_CRYPTORANDOM
|
|
|
57726f |
cleanup_mutexinit:
|
|
|
57726f |
+#endif
|
|
|
57726f |
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
|
|
|
57726f |
CRYPTO_set_locking_callback(NULL);
|
|
|
57726f |
DESTROYMUTEXBLOCK(locks, nlocks);
|
|
|
57726f |
@@ -306,14 +328,17 @@ void
|
|
|
57726f |
dst__openssl_destroy(void) {
|
|
|
57726f |
#if !defined(LIBRESSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER >= 0x10100000L)
|
|
|
57726f |
OPENSSL_cleanup();
|
|
|
57726f |
+#ifndef ISC_PLATFORM_CRYPTORANDOM
|
|
|
57726f |
if (rm != NULL) {
|
|
|
57726f |
mem_free(rm FILELINE);
|
|
|
57726f |
rm = NULL;
|
|
|
57726f |
}
|
|
|
57726f |
+#endif
|
|
|
57726f |
#else
|
|
|
57726f |
/*
|
|
|
57726f |
* Sequence taken from apps_shutdown() in <apps/apps.h>.
|
|
|
57726f |
*/
|
|
|
57726f |
+#ifndef ISC_PLATFORM_CRYPTORANDOM
|
|
|
57726f |
if (rm != NULL) {
|
|
|
57726f |
#if OPENSSL_VERSION_NUMBER >= 0x00907000L
|
|
|
57726f |
RAND_cleanup();
|
|
|
57726f |
@@ -321,6 +346,7 @@ dst__openssl_destroy(void) {
|
|
|
57726f |
mem_free(rm FILELINE);
|
|
|
57726f |
rm = NULL;
|
|
|
57726f |
}
|
|
|
57726f |
+#endif
|
|
|
57726f |
#if (OPENSSL_VERSION_NUMBER >= 0x00907000L)
|
|
|
57726f |
CONF_modules_free();
|
|
|
57726f |
#endif
|
|
|
57726f |
@@ -456,11 +482,45 @@ dst__openssl_getengine(const char *engine) {
|
|
|
57726f |
}
|
|
|
57726f |
#endif
|
|
|
57726f |
|
|
|
57726f |
-#else /* OPENSSL */
|
|
|
57726f |
+isc_result_t
|
|
|
57726f |
+dst_random_getdata(void *data, unsigned int length,
|
|
|
57726f |
+ unsigned int *returned, unsigned int flags) {
|
|
|
57726f |
+#ifdef ISC_PLATFORM_CRYPTORANDOM
|
|
|
57726f |
+#ifndef DONT_REQUIRE_DST_LIB_INIT
|
|
|
57726f |
+ INSIST(dst__memory_pool != NULL);
|
|
|
57726f |
+#endif
|
|
|
57726f |
+ REQUIRE(data != NULL);
|
|
|
57726f |
+ REQUIRE(length > 0);
|
|
|
57726f |
|
|
|
57726f |
-#include <isc/util.h>
|
|
|
57726f |
+#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
|
|
|
57726f |
+ if ((flags & ISC_ENTROPY_GOODONLY) == 0) {
|
|
|
57726f |
+ if (RAND_pseudo_bytes((unsigned char *)data, (int)length) < 0)
|
|
|
57726f |
+ return (dst__openssl_toresult2("RAND_pseudo_bytes",
|
|
|
57726f |
+ DST_R_OPENSSLFAILURE));
|
|
|
57726f |
+ } else {
|
|
|
57726f |
+ if (RAND_bytes((unsigned char *)data, (int)length) != 1)
|
|
|
57726f |
+ return (dst__openssl_toresult2("RAND_bytes",
|
|
|
57726f |
+ DST_R_OPENSSLFAILURE));
|
|
|
57726f |
+ }
|
|
|
57726f |
+#else
|
|
|
57726f |
+ UNUSED(flags);
|
|
|
57726f |
|
|
|
57726f |
-EMPTY_TRANSLATION_UNIT
|
|
|
57726f |
+ if (RAND_bytes((unsigned char *)data, (int)length) != 1)
|
|
|
57726f |
+ return (dst__openssl_toresult2("RAND_bytes",
|
|
|
57726f |
+ DST_R_OPENSSLFAILURE));
|
|
|
57726f |
+#endif
|
|
|
57726f |
+ if (returned != NULL)
|
|
|
57726f |
+ *returned = length;
|
|
|
57726f |
+ return (ISC_R_SUCCESS);
|
|
|
57726f |
+#else
|
|
|
57726f |
+ UNUSED(data);
|
|
|
57726f |
+ UNUSED(length);
|
|
|
57726f |
+ UNUSED(returned);
|
|
|
57726f |
+ UNUSED(flags);
|
|
|
57726f |
+
|
|
|
57726f |
+ return (ISC_R_NOTIMPLEMENTED);
|
|
|
57726f |
+#endif
|
|
|
57726f |
+}
|
|
|
57726f |
|
|
|
57726f |
#endif /* OPENSSL */
|
|
|
57726f |
/*! \file */
|
|
|
57726f |
diff --git a/lib/dns/pkcs11.c b/lib/dns/pkcs11.c
|
|
|
e48f32 |
index 6b30309..20552fa 100644
|
|
|
57726f |
--- a/lib/dns/pkcs11.c
|
|
|
57726f |
+++ b/lib/dns/pkcs11.c
|
|
|
57726f |
@@ -13,12 +13,15 @@
|
|
|
57726f |
|
|
|
57726f |
#include <config.h>
|
|
|
57726f |
|
|
|
57726f |
+#include <isc/util.h>
|
|
|
57726f |
+
|
|
|
57726f |
#include <dns/log.h>
|
|
|
57726f |
#include <dns/result.h>
|
|
|
57726f |
|
|
|
57726f |
#include <pk11/pk11.h>
|
|
|
57726f |
#include <pk11/internal.h>
|
|
|
57726f |
|
|
|
57726f |
+#include "dst_internal.h"
|
|
|
57726f |
#include "dst_pkcs11.h"
|
|
|
57726f |
|
|
|
57726f |
isc_result_t
|
|
|
57726f |
@@ -34,12 +37,32 @@ dst__pkcs11_toresult(const char *funcname, const char *file, int line,
|
|
|
57726f |
return (fallback);
|
|
|
57726f |
}
|
|
|
57726f |
|
|
|
57726f |
+isc_result_t
|
|
|
57726f |
+dst_random_getdata(void *data, unsigned int length,
|
|
|
57726f |
+ unsigned int *returned, unsigned int flags) {
|
|
|
57726f |
+#ifdef ISC_PLATFORM_CRYPTORANDOM
|
|
|
57726f |
+ isc_result_t ret;
|
|
|
57726f |
|
|
|
57726f |
-#else /* PKCS11CRYPTO */
|
|
|
57726f |
+#ifndef DONT_REQUIRE_DST_LIB_INIT
|
|
|
57726f |
+ INSIST(dst__memory_pool != NULL);
|
|
|
57726f |
+#endif
|
|
|
57726f |
+ REQUIRE(data != NULL);
|
|
|
57726f |
+ REQUIRE(length > 0);
|
|
|
57726f |
+ UNUSED(flags);
|
|
|
57726f |
|
|
|
57726f |
-#include <isc/util.h>
|
|
|
57726f |
+ ret = pk11_rand_bytes(data, (int) length);
|
|
|
57726f |
+ if ((ret == ISC_R_SUCCESS) && (returned != NULL))
|
|
|
57726f |
+ *returned = length;
|
|
|
57726f |
+ return (ret);
|
|
|
57726f |
+#else
|
|
|
57726f |
+ UNUSED(data);
|
|
|
57726f |
+ UNUSED(length);
|
|
|
57726f |
+ UNUSED(returned);
|
|
|
57726f |
+ UNUSED(flags);
|
|
|
57726f |
|
|
|
57726f |
-EMPTY_TRANSLATION_UNIT
|
|
|
57726f |
+ return (ISC_R_NOTIMPLEMENTED);
|
|
|
57726f |
+#endif
|
|
|
57726f |
+}
|
|
|
57726f |
|
|
|
57726f |
#endif /* PKCS11CRYPTO */
|
|
|
57726f |
/*! \file */
|
|
|
57726f |
diff --git a/lib/dns/tests/Kyuafile b/lib/dns/tests/Kyuafile
|
|
|
57726f |
index 937b548..f3c0e38 100644
|
|
|
57726f |
--- a/lib/dns/tests/Kyuafile
|
|
|
57726f |
+++ b/lib/dns/tests/Kyuafile
|
|
|
57726f |
@@ -10,6 +10,7 @@ tap_test_program{name='dh_test'}
|
|
|
57726f |
tap_test_program{name='dispatch_test'}
|
|
|
57726f |
tap_test_program{name='dnstap_test'}
|
|
|
57726f |
tap_test_program{name='dst_test'}
|
|
|
57726f |
+tap_test_program{name='dstrandom_test'}
|
|
|
57726f |
tap_test_program{name='geoip_test'}
|
|
|
57726f |
tap_test_program{name='gost_test'}
|
|
|
57726f |
tap_test_program{name='keytable_test'}
|
|
|
57726f |
diff --git a/lib/dns/tests/Makefile.in b/lib/dns/tests/Makefile.in
|
|
|
e48f32 |
index 4126372..30cab17 100644
|
|
|
57726f |
--- a/lib/dns/tests/Makefile.in
|
|
|
57726f |
+++ b/lib/dns/tests/Makefile.in
|
|
|
57726f |
@@ -37,6 +37,7 @@ SRCS = acl_test.c \
|
|
|
57726f |
dnstap_test.c \
|
|
|
57726f |
dst_test.c \
|
|
|
57726f |
dnstest.c \
|
|
|
57726f |
+ dstrandom_test.c \
|
|
|
57726f |
geoip_test.c \
|
|
|
57726f |
gost_test.c \
|
|
|
57726f |
keytable_test.c \
|
|
|
57726f |
@@ -69,6 +70,7 @@ TARGETS = acl_test@EXEEXT@ \
|
|
|
57726f |
dh_test@EXEEXT@ \
|
|
|
57726f |
dispatch_test@EXEEXT@ \
|
|
|
57726f |
dnstap_test@EXEEXT@ \
|
|
|
57726f |
+ dstrandom_test@EXEEXT@ \
|
|
|
57726f |
dst_test@EXEEXT@ \
|
|
|
57726f |
geoip_test@EXEEXT@ \
|
|
|
57726f |
gost_test@EXEEXT@ \
|
|
|
57726f |
@@ -258,6 +260,11 @@ zt_test@EXEEXT@: zt_test.@O@ dnstest.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS}
|
|
|
57726f |
${LDFLAGS} -o $@ zt_test.@O@ dnstest.@O@ \
|
|
|
57726f |
${DNSLIBS} ${ISCLIBS} ${LIBS}
|
|
|
57726f |
|
|
|
57726f |
+dstrandom_test@EXEEXT@: dstrandom_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS}
|
|
|
57726f |
+ ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
|
|
|
57726f |
+ dstrandom_test.@O@ ${DNSLIBS} \
|
|
|
57726f |
+ ${ISCLIBS} ${ISCPK11LIBS} ${LIBS}
|
|
|
57726f |
+
|
|
|
57726f |
unit::
|
|
|
57726f |
sh ${top_builddir}/unit/unittest.sh
|
|
|
57726f |
|
|
|
57726f |
diff --git a/lib/dns/tests/dstrandom_test.c b/lib/dns/tests/dstrandom_test.c
|
|
|
57726f |
new file mode 100644
|
|
|
57726f |
index 0000000..bd3d164
|
|
|
57726f |
--- /dev/null
|
|
|
57726f |
+++ b/lib/dns/tests/dstrandom_test.c
|
|
|
57726f |
@@ -0,0 +1,115 @@
|
|
|
57726f |
+/*
|
|
|
57726f |
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
|
|
57726f |
+ *
|
|
|
57726f |
+ * This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
57726f |
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
57726f |
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
57726f |
+ *
|
|
|
57726f |
+ * See the COPYRIGHT file distributed with this work for additional
|
|
|
57726f |
+ * information regarding copyright ownership.
|
|
|
57726f |
+ */
|
|
|
57726f |
+
|
|
|
57726f |
+#include <config.h>
|
|
|
57726f |
+
|
|
|
57726f |
+#if HAVE_CMOCKA
|
|
|
57726f |
+
|
|
|
57726f |
+#include <stdarg.h>
|
|
|
57726f |
+#include <stddef.h>
|
|
|
57726f |
+#include <setjmp.h>
|
|
|
57726f |
+
|
|
|
57726f |
+#include <stdlib.h>
|
|
|
57726f |
+#include <stdio.h>
|
|
|
57726f |
+#include <string.h>
|
|
|
57726f |
+#include <unistd.h>
|
|
|
57726f |
+
|
|
|
57726f |
+#define UNIT_TESTING
|
|
|
57726f |
+#include <cmocka.h>
|
|
|
57726f |
+
|
|
|
57726f |
+#include <isc/entropy.h>
|
|
|
57726f |
+#include <isc/mem.h>
|
|
|
57726f |
+#include <isc/print.h>
|
|
|
57726f |
+#include <isc/platform.h>
|
|
|
57726f |
+#include <isc/util.h>
|
|
|
57726f |
+
|
|
|
57726f |
+#include <dst/dst.h>
|
|
|
57726f |
+
|
|
|
57726f |
+isc_mem_t *mctx = NULL;
|
|
|
57726f |
+isc_entropy_t *ectx = NULL;
|
|
|
57726f |
+unsigned char buffer[128];
|
|
|
57726f |
+
|
|
|
57726f |
+/* isc_entropy_getdata() examples */
|
|
|
57726f |
+static void
|
|
|
57726f |
+isc_entropy_getdata_test(void **state) {
|
|
|
57726f |
+ isc_result_t result;
|
|
|
57726f |
+ unsigned int returned, status;
|
|
|
57726f |
+ const char *randomfile = "testdata/dstrandom/random.data";
|
|
|
57726f |
+ int ret;
|
|
|
57726f |
+
|
|
|
57726f |
+ UNUSED(state);
|
|
|
57726f |
+
|
|
|
57726f |
+ isc_mem_debugging |= ISC_MEM_DEBUGRECORD;
|
|
|
57726f |
+ result = isc_mem_create(0, 0, &mctx);
|
|
|
57726f |
+ assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
57726f |
+ result = isc_entropy_create(mctx, &ectx);
|
|
|
57726f |
+ assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
57726f |
+ result = dst_lib_init(mctx, ectx, 0);
|
|
|
57726f |
+ assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
57726f |
+
|
|
|
57726f |
+#ifdef ISC_PLATFORM_CRYPTORANDOM
|
|
|
57726f |
+ isc_entropy_usehook(ectx, true);
|
|
|
57726f |
+
|
|
|
57726f |
+ returned = 0;
|
|
|
57726f |
+ result = isc_entropy_getdata(ectx, buffer, sizeof(buffer),
|
|
|
57726f |
+ &returned, 0);
|
|
|
57726f |
+ assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
57726f |
+ assert_int_equal(returned, sizeof(buffer));
|
|
|
57726f |
+
|
|
|
57726f |
+ status = isc_entropy_status(ectx);
|
|
|
57726f |
+ assert_int_equal(status, 0);
|
|
|
57726f |
+
|
|
|
57726f |
+ isc_entropy_usehook(ectx, false);
|
|
|
57726f |
+#endif
|
|
|
57726f |
+
|
|
|
57726f |
+ ret = chdir(TESTS);
|
|
|
57726f |
+ assert_int_equal(ret, 0);
|
|
|
57726f |
+
|
|
|
57726f |
+ result = isc_entropy_createfilesource(ectx, randomfile);
|
|
|
57726f |
+ assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
57726f |
+
|
|
|
57726f |
+ returned = 0;
|
|
|
57726f |
+ result = isc_entropy_getdata(ectx, buffer, sizeof(buffer),
|
|
|
57726f |
+ &returned, 0);
|
|
|
57726f |
+ assert_int_equal(result, ISC_R_SUCCESS);
|
|
|
57726f |
+ assert_int_equal(returned, sizeof(buffer));
|
|
|
57726f |
+
|
|
|
57726f |
+ status = isc_entropy_status(ectx);
|
|
|
57726f |
+ assert_true(status > 0);
|
|
|
57726f |
+
|
|
|
57726f |
+ dst_lib_destroy();
|
|
|
57726f |
+ isc_entropy_detach(&ectx);
|
|
|
57726f |
+ assert_null(ectx);
|
|
|
57726f |
+
|
|
|
57726f |
+ isc_mem_destroy(&mctx);
|
|
|
57726f |
+ assert_null(mctx);
|
|
|
57726f |
+}
|
|
|
57726f |
+
|
|
|
57726f |
+int
|
|
|
57726f |
+main(void) {
|
|
|
57726f |
+ const struct CMUnitTest tests[] = {
|
|
|
57726f |
+ cmocka_unit_test(isc_entropy_getdata_test),
|
|
|
57726f |
+ };
|
|
|
57726f |
+
|
|
|
57726f |
+ return (cmocka_run_group_tests(tests, NULL, NULL));
|
|
|
57726f |
+}
|
|
|
57726f |
+
|
|
|
57726f |
+#else /* HAVE_CMOCKA */
|
|
|
57726f |
+
|
|
|
57726f |
+#include <stdio.h>
|
|
|
57726f |
+
|
|
|
57726f |
+int
|
|
|
57726f |
+main(void) {
|
|
|
57726f |
+ printf("1..0 # Skipped: cmocka not available\n");
|
|
|
57726f |
+ return (0);
|
|
|
57726f |
+}
|
|
|
57726f |
+
|
|
|
57726f |
+#endif
|
|
|
57726f |
diff --git a/lib/dns/win32/libdns.def.in b/lib/dns/win32/libdns.def.in
|
|
|
e48f32 |
index 9c2ef79..f597049 100644
|
|
|
57726f |
--- a/lib/dns/win32/libdns.def.in
|
|
|
57726f |
+++ b/lib/dns/win32/libdns.def.in
|
|
|
e48f32 |
@@ -1487,6 +1487,13 @@ dst_lib_destroy
|
|
|
57726f |
dst_lib_init
|
|
|
57726f |
dst_lib_init2
|
|
|
57726f |
dst_lib_initmsgcat
|
|
|
57726f |
+@IF PKCS11
|
|
|
57726f |
+dst_random_getdata
|
|
|
57726f |
+@ELSE PKCS11
|
|
|
57726f |
+@IF OPENSSL
|
|
|
57726f |
+dst_random_getdata
|
|
|
57726f |
+@END OPENSSL
|
|
|
57726f |
+@END PKCS11
|
|
|
57726f |
dst_region_computeid
|
|
|
57726f |
dst_region_computerid
|
|
|
57726f |
dst_result_register
|
|
|
57726f |
diff --git a/lib/isc/entropy.c b/lib/isc/entropy.c
|
|
|
e48f32 |
index 0c1f3ed..fdd17d7 100644
|
|
|
57726f |
--- a/lib/isc/entropy.c
|
|
|
57726f |
+++ b/lib/isc/entropy.c
|
|
|
57726f |
@@ -104,11 +104,15 @@ struct isc_entropy {
|
|
|
57726f |
uint32_t initialized;
|
|
|
57726f |
uint32_t initcount;
|
|
|
57726f |
isc_entropypool_t pool;
|
|
|
57726f |
+ bool usehook;
|
|
|
57726f |
unsigned int nsources;
|
|
|
57726f |
isc_entropysource_t *nextsource;
|
|
|
57726f |
ISC_LIST(isc_entropysource_t) sources;
|
|
|
57726f |
};
|
|
|
57726f |
|
|
|
57726f |
+/*% Global Hook */
|
|
|
57726f |
+static isc_entropy_getdata_t hook;
|
|
|
57726f |
+
|
|
|
57726f |
/*% Sample Queue */
|
|
|
57726f |
typedef struct {
|
|
|
57726f |
uint32_t last_time; /*%< last time recorded */
|
|
|
57726f |
@@ -557,6 +561,11 @@ isc_entropy_getdata(isc_entropy_t *ent, void *data, unsigned int length,
|
|
|
57726f |
|
|
|
57726f |
LOCK(&ent->lock);
|
|
|
57726f |
|
|
|
57726f |
+ if (ent->usehook && (hook != NULL)) {
|
|
|
57726f |
+ UNLOCK(&ent->lock);
|
|
|
57726f |
+ return (hook(data, length, returned, flags));
|
|
|
57726f |
+ }
|
|
|
57726f |
+
|
|
|
57726f |
remain = length;
|
|
|
57726f |
buf = data;
|
|
|
57726f |
total = 0;
|
|
|
57726f |
@@ -708,6 +717,7 @@ isc_entropy_create(isc_mem_t *mctx, isc_entropy_t **entp) {
|
|
|
57726f |
ent->refcnt = 1;
|
|
|
57726f |
ent->initialized = 0;
|
|
|
57726f |
ent->initcount = 0;
|
|
|
57726f |
+ ent->usehook = false;
|
|
|
57726f |
ent->magic = ENTROPY_MAGIC;
|
|
|
57726f |
|
|
|
57726f |
isc_entropypool_init(&ent->pool);
|
|
|
57726f |
@@ -1286,3 +1296,17 @@ isc_entropy_usebestsource(isc_entropy_t *ectx, isc_entropysource_t **source,
|
|
|
57726f |
*/
|
|
|
57726f |
return (final_result);
|
|
|
57726f |
}
|
|
|
57726f |
+
|
|
|
57726f |
+void
|
|
|
57726f |
+isc_entropy_usehook(isc_entropy_t *ectx, bool onoff) {
|
|
|
57726f |
+ REQUIRE(VALID_ENTROPY(ectx));
|
|
|
57726f |
+
|
|
|
57726f |
+ LOCK(&ectx->lock);
|
|
|
57726f |
+ ectx->usehook = onoff;
|
|
|
57726f |
+ UNLOCK(&ectx->lock);
|
|
|
57726f |
+}
|
|
|
57726f |
+
|
|
|
57726f |
+void
|
|
|
57726f |
+isc_entropy_sethook(isc_entropy_getdata_t myhook) {
|
|
|
57726f |
+ hook = myhook;
|
|
|
57726f |
+}
|
|
|
57726f |
diff --git a/lib/isc/include/isc/entropy.h b/lib/isc/include/isc/entropy.h
|
|
|
e48f32 |
index b5bc956..f32c9dc 100644
|
|
|
57726f |
--- a/lib/isc/include/isc/entropy.h
|
|
|
57726f |
+++ b/lib/isc/include/isc/entropy.h
|
|
|
f79ca9 |
@@ -302,6 +302,18 @@ isc_entropy_usebestsource(isc_entropy_t *ectx, isc_entropysource_t **source,
|
|
|
57726f |
* isc_entropy_createcallbacksource().
|
|
|
57726f |
*/
|
|
|
57726f |
|
|
|
57726f |
+void
|
|
|
57726f |
+isc_entropy_usehook(isc_entropy_t *ectx, bool onoff);
|
|
|
57726f |
+/*!<
|
|
|
57726f |
+ * \brief Mark/unmark the given entropy structure as being hooked.
|
|
|
57726f |
+ */
|
|
|
57726f |
+
|
|
|
57726f |
+void
|
|
|
57726f |
+isc_entropy_sethook(isc_entropy_getdata_t myhook);
|
|
|
57726f |
+/*!<
|
|
|
57726f |
+ * \brief Set the getdata hook (e.g., for a crypto random generator).
|
|
|
57726f |
+ */
|
|
|
57726f |
+
|
|
|
57726f |
ISC_LANG_ENDDECLS
|
|
|
57726f |
|
|
|
57726f |
#endif /* ISC_ENTROPY_H */
|
|
|
57726f |
diff --git a/lib/isc/include/isc/platform.h.in b/lib/isc/include/isc/platform.h.in
|
|
|
e48f32 |
index 2bf8758..f4c684e 100644
|
|
|
57726f |
--- a/lib/isc/include/isc/platform.h.in
|
|
|
57726f |
+++ b/lib/isc/include/isc/platform.h.in
|
|
|
f79ca9 |
@@ -359,6 +359,11 @@
|
|
|
57726f |
*/
|
|
|
57726f |
@ISC_PLATFORM_HAVESTRINGSH@
|
|
|
57726f |
|
|
|
57726f |
+/*
|
|
|
57726f |
+ * Define if the random functions are provided by crypto.
|
|
|
57726f |
+ */
|
|
|
57726f |
+@ISC_PLATFORM_CRYPTORANDOM@
|
|
|
57726f |
+
|
|
|
57726f |
/*
|
|
|
57726f |
* Define if the hash functions must be provided by OpenSSL.
|
|
|
57726f |
*/
|
|
|
57726f |
diff --git a/lib/isc/include/isc/types.h b/lib/isc/include/isc/types.h
|
|
|
e48f32 |
index 3bdd54f..d5acd39 100644
|
|
|
57726f |
--- a/lib/isc/include/isc/types.h
|
|
|
57726f |
+++ b/lib/isc/include/isc/types.h
|
|
|
e48f32 |
@@ -95,6 +95,8 @@ typedef struct isc_time isc_time_t; /*%< Time */
|
|
|
57726f |
typedef struct isc_timer isc_timer_t; /*%< Timer */
|
|
|
57726f |
typedef struct isc_timermgr isc_timermgr_t; /*%< Timer Manager */
|
|
|
57726f |
|
|
|
57726f |
+typedef isc_result_t (*isc_entropy_getdata_t)(void *, unsigned int,
|
|
|
57726f |
+ unsigned int *, unsigned int);
|
|
|
57726f |
typedef void (*isc_taskaction_t)(isc_task_t *, isc_event_t *);
|
|
|
57726f |
typedef int (*isc_sockfdwatch_t)(isc_task_t *, isc_socket_t *, void *, int);
|
|
|
57726f |
|
|
|
57726f |
diff --git a/lib/isc/pk11.c b/lib/isc/pk11.c
|
|
|
e48f32 |
index 227f807..4a63fdf 100644
|
|
|
57726f |
--- a/lib/isc/pk11.c
|
|
|
57726f |
+++ b/lib/isc/pk11.c
|
|
|
57726f |
@@ -321,14 +321,16 @@ pk11_rand_seed_fromfile(const char *randomfile) {
|
|
|
57726f |
ret = isc_stdio_open(randomfile, "r", &stream);
|
|
|
57726f |
if (ret != ISC_R_SUCCESS)
|
|
|
57726f |
goto cleanup;
|
|
|
57726f |
- ret = isc_stdio_read(seed, 1, SEEDSIZE, stream, &cc);
|
|
|
57726f |
- if (ret!= ISC_R_SUCCESS)
|
|
|
57726f |
- goto cleanup;
|
|
|
57726f |
+ while (ret == ISC_R_SUCCESS) {
|
|
|
57726f |
+ ret = isc_stdio_read(seed, 1, SEEDSIZE, stream, &cc);
|
|
|
57726f |
+ if ((ret != ISC_R_SUCCESS) && (ret != ISC_R_EOF))
|
|
|
57726f |
+ goto cleanup;
|
|
|
57726f |
+ (void) pkcs_C_SeedRandom(ctx.session, seed, (CK_ULONG) cc);
|
|
|
57726f |
+ }
|
|
|
57726f |
ret = isc_stdio_close(stream);
|
|
|
57726f |
stream = NULL;
|
|
|
57726f |
- if (ret!= ISC_R_SUCCESS)
|
|
|
57726f |
+ if (ret != ISC_R_SUCCESS)
|
|
|
57726f |
goto cleanup;
|
|
|
57726f |
- (void) pkcs_C_SeedRandom(ctx.session, seed, (CK_ULONG) cc);
|
|
|
57726f |
|
|
|
57726f |
cleanup:
|
|
|
57726f |
if (stream != NULL)
|
|
|
57726f |
diff --git a/lib/isc/win32/include/isc/platform.h.in b/lib/isc/win32/include/isc/platform.h.in
|
|
|
e48f32 |
index 1f785e0..f9051c3 100644
|
|
|
57726f |
--- a/lib/isc/win32/include/isc/platform.h.in
|
|
|
57726f |
+++ b/lib/isc/win32/include/isc/platform.h.in
|
|
|
f79ca9 |
@@ -73,6 +73,11 @@
|
|
|
57726f |
#define ISC_PLATFORM_NORETURN_PRE __declspec(noreturn)
|
|
|
57726f |
#define ISC_PLATFORM_NORETURN_POST
|
|
|
57726f |
|
|
|
57726f |
+/*
|
|
|
57726f |
+ * Define if the random functions are provided by crypto.
|
|
|
57726f |
+ */
|
|
|
57726f |
+@ISC_PLATFORM_CRYPTORANDOM@
|
|
|
57726f |
+
|
|
|
57726f |
/*
|
|
|
57726f |
* Define if the hash functions must be provided by OpenSSL.
|
|
|
57726f |
*/
|
|
|
57726f |
diff --git a/win32utils/Configure b/win32utils/Configure
|
|
|
ce773a |
index 7ac30fb..55b6c23 100644
|
|
|
57726f |
--- a/win32utils/Configure
|
|
|
57726f |
+++ b/win32utils/Configure
|
|
|
57726f |
@@ -382,6 +382,7 @@ my @substdefh = ("ALLOW_FILTER_AAAA",
|
|
|
57726f |
my %configdefp;
|
|
|
57726f |
|
|
|
57726f |
my @substdefp = ("ISC_PLATFORM_BUSYWAITNOP",
|
|
|
57726f |
+ "ISC_PLATFORM_CRYPTORANDOM",
|
|
|
57726f |
"ISC_PLATFORM_HAVEATOMICSTORE",
|
|
|
57726f |
"ISC_PLATFORM_HAVEATOMICSTOREQ",
|
|
|
57726f |
"ISC_PLATFORM_HAVECMPXCHG",
|
|
|
ce773a |
@@ -516,7 +517,8 @@ my @allcond = (@substcond, "NOTYET", "NOLONGER");
|
|
|
57726f |
|
|
|
57726f |
# enable-xxx/disable-xxx
|
|
|
57726f |
|
|
|
57726f |
-my @enablelist = ("developer",
|
|
|
57726f |
+my @enablelist = ("crypto-rand",
|
|
|
57726f |
+ "developer",
|
|
|
57726f |
"fixed-rrset",
|
|
|
57726f |
"intrinsics",
|
|
|
ce773a |
"native-pkcs11",
|
|
|
ce773a |
@@ -578,6 +580,7 @@ my @help = (
|
|
|
57726f |
"\nOptional Features:\n",
|
|
|
f79ca9 |
" enable-intrinsics enable intrinsic/atomic functions [default=yes]\n",
|
|
|
57726f |
" enable-native-pkcs11 use native PKCS#11 for all crypto [default=no]\n",
|
|
|
57726f |
+" enable-crypto-rand use crypto provider for random [default=yes]\n",
|
|
|
57726f |
" enable-openssl-hash use OpenSSL for hash functions [default=yes]\n",
|
|
|
57726f |
" enable-filter-aaaa enable filtering of AAAA records [default=yes]\n",
|
|
|
ce773a |
" enable-fixed-rrset enable fixed rrset ordering [default=no]\n",
|
|
|
ce773a |
@@ -625,7 +628,9 @@ my $want_clean = "no";
|
|
|
57726f |
my $want_unknown = "no";
|
|
|
57726f |
my $unknown_value;
|
|
|
57726f |
my $enable_intrinsics = "yes";
|
|
|
57726f |
+my $cryptolib = "";
|
|
|
57726f |
my $enable_native_pkcs11 = "no";
|
|
|
57726f |
+my $enable_crypto_rand = "yes";
|
|
|
57726f |
my $enable_openssl_hash = "auto";
|
|
|
57726f |
my $enable_filter_aaaa = "yes";
|
|
|
ce773a |
my $enable_fixed_rrset = "no";
|
|
|
ce773a |
@@ -844,6 +849,10 @@ sub myenable {
|
|
|
57726f |
if ($val =~ /^yes$/i) {
|
|
|
57726f |
$enable_native_pkcs11 = "yes";
|
|
|
57726f |
}
|
|
|
57726f |
+ } elsif ($key =~ /^crypto-rand$/i) {
|
|
|
57726f |
+ if ($val =~ /^no$/i) {
|
|
|
57726f |
+ $enable_crypto_rand = "no";
|
|
|
57726f |
+ }
|
|
|
57726f |
} elsif ($key =~ /^openssl-hash$/i) {
|
|
|
57726f |
if ($val =~ /^yes$/i) {
|
|
|
57726f |
$enable_openssl_hash = "yes";
|
|
|
ce773a |
@@ -1146,6 +1155,11 @@ if ($verbose) {
|
|
|
57726f |
} else {
|
|
|
57726f |
print "native-pkcs11: disabled\n";
|
|
|
57726f |
}
|
|
|
57726f |
+ if ($enable_crypto_rand eq "yes") {
|
|
|
57726f |
+ print "crypto-rand: enabled\n";
|
|
|
57726f |
+ } else {
|
|
|
57726f |
+ print "crypto-rand: disabled\n";
|
|
|
57726f |
+ }
|
|
|
57726f |
if ($enable_openssl_hash eq "yes") {
|
|
|
57726f |
print "openssl-hash: enabled\n";
|
|
|
57726f |
} else {
|
|
|
ce773a |
@@ -1498,6 +1512,7 @@ if ($enable_intrinsics eq "yes") {
|
|
|
57726f |
|
|
|
57726f |
# enable-native-pkcs11
|
|
|
57726f |
if ($enable_native_pkcs11 eq "yes") {
|
|
|
57726f |
+ $cryptolib = "pkcs11";
|
|
|
57726f |
if ($use_openssl eq "auto") {
|
|
|
57726f |
$use_openssl = "no";
|
|
|
57726f |
}
|
|
|
ce773a |
@@ -1707,6 +1722,7 @@ if ($use_openssl eq "yes") {
|
|
|
57726f |
$openssl_dll = File::Spec->catdir($openssl_path, "@dirlist[0]");
|
|
|
ce773a |
}
|
|
|
57726f |
|
|
|
57726f |
+ $cryptolib = "openssl";
|
|
|
57726f |
$configcond{"OPENSSL"} = 1;
|
|
|
57726f |
$configdefd{"CRYPTO"} = "OPENSSL";
|
|
|
57726f |
$configvar{"OPENSSL_PATH"} = "$openssl_path";
|
|
|
ce773a |
@@ -2278,6 +2294,15 @@ if ($use_aes eq "yes") {
|
|
|
57726f |
}
|
|
|
57726f |
|
|
|
57726f |
|
|
|
57726f |
+# enable-crypto-rand
|
|
|
57726f |
+if ($enable_crypto_rand eq "yes") {
|
|
|
57726f |
+ if (($use_openssl eq "no") && ($enable_native_pkcs11 eq "no")) {
|
|
|
57726f |
+ die "No crypto provider for random functions\n";
|
|
|
57726f |
+ }
|
|
|
57726f |
+ $configdefp{"ISC_PLATFORM_CRYPTORANDOM"} = "\"$cryptolib\"";
|
|
|
57726f |
+}
|
|
|
57726f |
+print "Cryptographic library for DNSSEC: $cryptolib";
|
|
|
57726f |
+
|
|
|
57726f |
# enable-openssl-hash
|
|
|
57726f |
if ($enable_openssl_hash eq "yes") {
|
|
|
57726f |
if ($use_openssl eq "no") {
|
|
|
ce773a |
@@ -3650,6 +3675,7 @@ exit 0;
|
|
|
57726f |
# --enable-developer partially supported
|
|
|
57726f |
# --enable-newstats (9.9/9.9sub only)
|
|
|
57726f |
# --enable-native-pkcs11 supported
|
|
|
57726f |
+# --enable-crypto-rand supported
|
|
|
57726f |
# --enable-openssl-version-check included without a way to disable it
|
|
|
57726f |
# --enable-openssl-hash supported
|
|
|
57726f |
# --enable-threads included without a way to disable it
|
|
|
57726f |
--
|
|
|
ce773a |
2.31.1
|
|
|
57726f |
|