From a6f9fe005ec983b4c5a886833fdd82255c2844c4 Mon Sep 17 00:00:00 2001 From: Petr Menšík Date: Mar 27 2020 11:39:30 +0000 Subject: Remove unused 9.14 patches --- diff --git a/bind-9.11-fips-code.patch b/bind-9.11-fips-code.patch deleted file mode 100644 index cf00104..0000000 --- a/bind-9.11-fips-code.patch +++ /dev/null @@ -1,1459 +0,0 @@ -From eff6dcb62f3cea6df0a848c2220a49bc02cb4a0e Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= -Date: Thu, 2 Aug 2018 23:34:45 +0200 -Subject: [PATCH] FIPS code changes -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Squashed commit of the following: - -commit b49f70ce0575b6b52a71b90fe0376dbf16f92c6b -Author: Petr Menšík -Date: Mon Jan 22 14:12:37 2018 +0100 - - Update system tests to detect MD5 disabled at runtime - -commit 80ceffee4860c24baf70bc9a8653d92731eda2e4 -Author: Petr Menšík -Date: Thu Aug 2 14:53:54 2018 +0200 - - Avoid warning about undefined parameters - -commit e4ad4363e3d1acaac58456117579f02761f38fdc -Author: Petr Menšík -Date: Wed Jun 20 19:31:19 2018 +0200 - - Fix rndc-confgen default algorithm, report true algorithm in usage. - -commit 7e629a351010cb75e0589ec361f720085675998c -Author: Petr Menšík -Date: Fri Feb 23 21:21:30 2018 +0100 - - Cleanup only if initialization was successful - -commit 2101b948c77cbcbe07eb4a1e60f3e693b2245ec6 -Author: Petr Menšík -Date: Mon Feb 5 12:19:28 2018 +0100 - - Ensure dst backend is initialized first even before hmac algorithms. - -commit 7567c7edde7519115a9ae7e20818c835d3eb1ffe -Author: Petr Menšík -Date: Mon Feb 5 12:17:54 2018 +0100 - - Skip initialization of MD5 based algorithms if not available. - -commit 5782137df6b45a6d900d5a1c250c1257227e917a -Author: Petr Menšík -Date: Mon Feb 5 10:21:27 2018 +0100 - - Change secalgs skipping to be more safe - -commit f2d78729898182d2d19d5064de1bec9b66817159 -Author: Petr Menšík -Date: Wed Jan 31 18:26:11 2018 +0100 - - Skip MD5 algorithm also in case of NULL name - -commit 32a2ad4abc7aaca1c257730319ad3c27405d3407 -Author: Petr Menšík -Date: Wed Jan 31 11:38:12 2018 +0100 - - Make MD5 behave like unknown algorithm in TSIG. - -commit 13cd3f704dce568fdf24a567be5802b58ac6007b -Author: Petr Menšík -Date: Tue Nov 28 20:14:37 2017 +0100 - - Select token with most supported functions, instead of demanding it must support all functions - - Initialize PKCS#11 always until successfully initialized - -commit a71df74abdca4fe63bcdf542b81a109cf1f495b4 -Author: Petr Menšík -Date: Mon Jan 22 16:17:44 2018 +0100 - - Handle MD5 unavailability from DST - -commit dd82cb263efa2753d3ee772972726ea08bcc639b -Author: Petr Menšík -Date: Mon Jan 22 14:11:16 2018 +0100 - - Check runtime flag from library and applications, fail gracefully. - -commit c7b2f87f07ecae75b821a908e29f08a42371e32e -Author: Petr Menšík -Date: Mon Jan 22 08:39:08 2018 +0100 - - Modify libraries to use isc_md5_available() if PK11_MD5_DISABLE is not - defined. - TODO: pk11.c should accept slot without MD5 support. - -commit 0b8e470ec636b9e350b5ec3203eb2b4091415fde -Author: Petr Menšík -Date: Mon Jan 22 07:21:04 2018 +0100 - - Add runtime detection whether MD5 is useable. ---- - bin/confgen/keygen.c | 10 +++- - bin/confgen/rndc-confgen.c | 32 ++++--------- - bin/dig/dig.c | 7 +-- - bin/dig/dighost.c | 14 ++++-- - bin/dnssec/dnssec-keygen.c | 14 ++++++ - bin/named/config.c | 25 +++++++++- - bin/nsupdate/nsupdate.c | 24 ++++++---- - bin/rndc/rndc.c | 3 +- - bin/tests/optional/hash_test.c | 78 ++++++++++++++++--------------- - bin/tests/system/tkey/keycreate.c | 3 ++ - bin/tests/system/tkey/keydelete.c | 17 ++++--- - lib/bind9/check.c | 10 ++++ - lib/dns/dst_api.c | 23 ++++++--- - lib/dns/dst_internal.h | 3 +- - lib/dns/dst_parse.c | 18 +++++-- - lib/dns/hmac_link.c | 18 ++----- - lib/dns/opensslrsa_link.c | 6 +++ - lib/dns/pkcs11rsa_link.c | 33 +++++++++++-- - lib/dns/rcode.c | 21 ++++++++- - lib/dns/tests/rsa_test.c | 4 ++ - lib/dns/tests/tsig_test.c | 1 + - lib/dns/tkey.c | 9 ++++ - lib/dns/tsec.c | 8 +++- - lib/dns/tsig.c | 17 ++++--- - lib/isc/include/isc/md5.h | 3 ++ - lib/isc/md5.c | 59 +++++++++++++++++++++++ - lib/isc/pk11.c | 44 +++++++++++------ - lib/isc/tests/hash_test.c | 9 ++++ - lib/isccc/cc.c | 42 +++++++++++------ - 29 files changed, 400 insertions(+), 155 deletions(-) - -diff --git a/bin/confgen/keygen.c b/bin/confgen/keygen.c -index 8931ad5..5015abb 100644 ---- a/bin/confgen/keygen.c -+++ b/bin/confgen/keygen.c -@@ -22,6 +22,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -73,7 +74,7 @@ alg_fromtext(const char *name) { - p = &name[5]; - - #ifndef PK11_MD5_DISABLE -- if (strcasecmp(p, "md5") == 0) -+ if (strcasecmp(p, "md5") == 0 && isc_md5_available()) - return DST_ALG_HMACMD5; - #endif - if (strcasecmp(p, "sha1") == 0) -@@ -132,6 +133,13 @@ generate_key(isc_mem_t *mctx, const char *randomfile, dns_secalg_t alg, - switch (alg) { - #ifndef PK11_MD5_DISABLE - case DST_ALG_HMACMD5: -+ if (!isc_md5_available()) { -+ fatal("unsupported algorithm %d\n", alg); -+ } else if (keysize < 1 || keysize > 512) { -+ fatal("keysize %d out of range (must be 1-512)\n", -+ keysize); -+ } -+ break; - #endif - case DST_ALG_HMACSHA1: - case DST_ALG_HMACSHA224: -diff --git a/bin/confgen/rndc-confgen.c b/bin/confgen/rndc-confgen.c -index 5ca3d76..6b7790a 100644 ---- a/bin/confgen/rndc-confgen.c -+++ b/bin/confgen/rndc-confgen.c -@@ -36,6 +36,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -63,7 +64,7 @@ const char *progname; - - bool verbose = false; - --const char *keyfile, *keydef; -+const char *keyfile, *keydef, *algdef; - - ISC_PLATFORM_NORETURN_PRE static void - usage(int status) ISC_PLATFORM_NORETURN_POST; -@@ -71,13 +72,12 @@ usage(int status) ISC_PLATFORM_NORETURN_POST; - static void - usage(int status) { - --#ifndef PK11_MD5_DISABLE - fprintf(stderr, "\ - Usage:\n\ - %s [-a] [-b bits] [-c keyfile] [-k keyname] [-p port] [-r randomfile] \ - [-s addr] [-t chrootdir] [-u user]\n\ - -a: generate just the key clause and write it to keyfile (%s)\n\ -- -A alg: algorithm (default hmac-md5)\n\ -+ -A alg: algorithm (default %s)\n\ - -b bits: from 1 through 512, default 256; total length of the secret\n\ - -c keyfile: specify an alternate key file (requires -a)\n\ - -k keyname: the name as it will be used in named.conf and rndc.conf\n\ -@@ -86,24 +86,7 @@ Usage:\n\ - -s addr: the address to which rndc should connect\n\ - -t chrootdir: write a keyfile in chrootdir as well (requires -a)\n\ - -u user: set the keyfile owner to \"user\" (requires -a)\n", -- progname, keydef); --#else -- fprintf(stderr, "\ --Usage:\n\ -- %s [-a] [-b bits] [-c keyfile] [-k keyname] [-p port] [-r randomfile] \ --[-s addr] [-t chrootdir] [-u user]\n\ -- -a: generate just the key clause and write it to keyfile (%s)\n\ -- -A alg: algorithm (default hmac-sha256)\n\ -- -b bits: from 1 through 512, default 256; total length of the secret\n\ -- -c keyfile: specify an alternate key file (requires -a)\n\ -- -k keyname: the name as it will be used in named.conf and rndc.conf\n\ -- -p port: the port named will listen on and rndc will connect to\n\ -- -r randomfile: source of random data (use \"keyboard\" for key timing)\n\ -- -s addr: the address to which rndc should connect\n\ -- -t chrootdir: write a keyfile in chrootdir as well (requires -a)\n\ -- -u user: set the keyfile owner to \"user\" (requires -a)\n", -- progname, keydef); --#endif -+ progname, keydef, algdef); - - exit (status); - } -@@ -139,11 +122,12 @@ main(int argc, char **argv) { - progname = program; - - keyname = DEFAULT_KEYNAME; --#ifndef PK11_MD5_DISABLE -- alg = DST_ALG_HMACMD5; --#else - alg = DST_ALG_HMACSHA256; -+#ifndef PK11_MD5_DISABLE -+ if (isc_md5_available()) -+ alg = DST_ALG_HMACMD5; - #endif -+ algdef = alg_totext(alg); - serveraddr = DEFAULT_SERVER; - port = DEFAULT_PORT; - -diff --git a/bin/dig/dig.c b/bin/dig/dig.c -index 706299e..aaf22e7 100644 ---- a/bin/dig/dig.c -+++ b/bin/dig/dig.c -@@ -20,6 +20,7 @@ - #include - - #include -+#include - #include - #include - #include -@@ -1774,10 +1775,10 @@ dash_option(char *option, char *next, dig_lookup_t **lookup, - ptr = ptr2; - ptr2 = ptr3; - } else { --#ifndef PK11_MD5_DISABLE -- hmacname = DNS_TSIG_HMACMD5_NAME; --#else - hmacname = DNS_TSIG_HMACSHA256_NAME; -+#ifndef PK11_MD5_DISABLE -+ if (isc_md5_available()) -+ hmacname = DNS_TSIG_HMACMD5_NAME; - #endif - digestbits = 0; - } -diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c -index 93e5b40..afd2700 100644 ---- a/bin/dig/dighost.c -+++ b/bin/dig/dighost.c -@@ -80,6 +80,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -1246,9 +1247,10 @@ parse_hmac(const char *hmac) { - digestbits = 0; - - #ifndef PK11_MD5_DISABLE -- if (strcasecmp(buf, "hmac-md5") == 0) { -+ if (strcasecmp(buf, "hmac-md5") == 0 && isc_md5_available()) { - hmacname = DNS_TSIG_HMACMD5_NAME; -- } else if (strncasecmp(buf, "hmac-md5-", 9) == 0) { -+ } else if (strncasecmp(buf, "hmac-md5-", 9) == 0 && -+ isc_md5_available()) { - hmacname = DNS_TSIG_HMACMD5_NAME; - digestbits = parse_bits(&buf[9], "digest-bits [0..128]", 128); - } else -@@ -1368,7 +1370,13 @@ setup_file_key(void) { - switch (dst_key_alg(dstkey)) { - #ifndef PK11_MD5_DISABLE - case DST_ALG_HMACMD5: -- hmacname = DNS_TSIG_HMACMD5_NAME; -+ if (isc_md5_available()) { -+ hmacname = DNS_TSIG_HMACMD5_NAME; -+ } else { -+ printf(";; Couldn't create key %s: bad algorithm\n", -+ keynametext); -+ goto failure; -+ } - break; - #endif - case DST_ALG_HMACSHA1: -diff --git a/bin/dnssec/dnssec-keygen.c b/bin/dnssec/dnssec-keygen.c -index 1476d0d..f5c9316 100644 ---- a/bin/dnssec/dnssec-keygen.c -+++ b/bin/dnssec/dnssec-keygen.c -@@ -36,6 +36,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -562,6 +563,19 @@ main(int argc, char **argv) { - "\"-a RSAMD5\"\n"); - INSIST(freeit == NULL); - return (1); -+ } else if (strcasecmp(algname, "HMAC-MD5") == 0) { -+ if (isc_md5_available()) { -+ alg = DST_ALG_HMACMD5; -+ } else { -+ fprintf(stderr, -+ "The use of HMAC-MD5 was disabled\n"); -+ return (1); -+ } -+ } else if (strcasecmp(algname, "RSAMD5") == 0 && -+ !isc_md5_available()) { -+ fprintf(stderr, "The use of RSAMD5 was disabled\n"); -+ INSIST(freeit == NULL); -+ return (1); - } else if (strcasecmp(algname, "HMAC-MD5") == 0) { - alg = DST_ALG_HMACMD5; - #else -diff --git a/bin/named/config.c b/bin/named/config.c -index 32c454a..dff826b 100644 ---- a/bin/named/config.c -+++ b/bin/named/config.c -@@ -18,6 +18,7 @@ - - #include - #include -+#include - #include - #include - #include -@@ -974,6 +975,21 @@ ns_config_getkeyalgorithm(const char *str, dns_name_t **name, - return (ns_config_getkeyalgorithm2(str, name, NULL, digestbits)); - } - -+static inline int -+algorithms_start() { -+#ifndef PK11_MD5_DISABLE -+ if (!isc_md5_available()) { -+ int i = 0; -+ while (algorithms[i].str != NULL && -+ algorithms[i].hmac == hmacmd5) { -+ i++; -+ } -+ return i; -+ } -+#endif -+ return 0; -+} -+ - isc_result_t - ns_config_getkeyalgorithm2(const char *str, dns_name_t **name, - unsigned int *typep, uint16_t *digestbits) -@@ -983,7 +999,7 @@ ns_config_getkeyalgorithm2(const char *str, dns_name_t **name, - uint16_t bits; - isc_result_t result; - -- for (i = 0; algorithms[i].str != NULL; i++) { -+ for (i = algorithms_start(); algorithms[i].str != NULL; i++) { - len = strlen(algorithms[i].str); - if (strncasecmp(algorithms[i].str, str, len) == 0 && - (str[len] == '\0' || -@@ -1006,7 +1022,12 @@ ns_config_getkeyalgorithm2(const char *str, dns_name_t **name, - if (name != NULL) { - switch (algorithms[i].hmac) { - #ifndef PK11_MD5_DISABLE -- case hmacmd5: *name = dns_tsig_hmacmd5_name; break; -+ case hmacmd5: -+ if (isc_md5_available()) { -+ *name = dns_tsig_hmacmd5_name; break; -+ } else { -+ return (ISC_R_NOTFOUND); -+ } - #endif - case hmacsha1: *name = dns_tsig_hmacsha1_name; break; - case hmacsha224: *name = dns_tsig_hmacsha224_name; break; -diff --git a/bin/nsupdate/nsupdate.c b/bin/nsupdate/nsupdate.c -index de60313..bbb3936 100644 ---- a/bin/nsupdate/nsupdate.c -+++ b/bin/nsupdate/nsupdate.c -@@ -31,6 +31,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -477,9 +478,10 @@ parse_hmac(dns_name_t **hmac, const char *hmacstr, size_t len, - strlcpy(buf, hmacstr, ISC_MIN(len + 1, sizeof(buf))); - - #ifndef PK11_MD5_DISABLE -- if (strcasecmp(buf, "hmac-md5") == 0) { -+ if (strcasecmp(buf, "hmac-md5") == 0 && isc_md5_available()) { - *hmac = DNS_TSIG_HMACMD5_NAME; -- } else if (strncasecmp(buf, "hmac-md5-", 9) == 0) { -+ } else if (strncasecmp(buf, "hmac-md5-", 9) == 0 && -+ isc_md5_available()) { - *hmac = DNS_TSIG_HMACMD5_NAME; - result = isc_parse_uint16(&digestbits, &buf[9], 10); - if (result != ISC_R_SUCCESS || digestbits > 128) { -@@ -592,10 +594,10 @@ setup_keystr(void) { - exit(1); - } - } else { --#ifndef PK11_MD5_DISABLE -- hmacname = DNS_TSIG_HMACMD5_NAME; --#else - hmacname = DNS_TSIG_HMACSHA256_NAME; -+#ifndef PK11_MD5_DISABLE -+ if (isc_md5_available()) -+ hmacname = DNS_TSIG_HMACMD5_NAME; - #endif - name = keystr; - n = s; -@@ -732,7 +734,8 @@ setup_keyfile(isc_mem_t *mctx, isc_log_t *lctx) { - switch (dst_key_alg(dstkey)) { - #ifndef PK11_MD5_DISABLE - case DST_ALG_HMACMD5: -- hmacname = DNS_TSIG_HMACMD5_NAME; -+ if (isc_md5_available()) -+ hmacname = DNS_TSIG_HMACMD5_NAME; - break; - #endif - case DST_ALG_HMACSHA1: -@@ -1637,12 +1640,13 @@ evaluate_key(char *cmdline) { - return (STATUS_SYNTAX); - } - namestr = n + 1; -- } else --#ifndef PK11_MD5_DISABLE -- hmacname = DNS_TSIG_HMACMD5_NAME; --#else -+ } else { - hmacname = DNS_TSIG_HMACSHA256_NAME; -+#ifndef PK11_MD5_DISABLE -+ if (isc_md5_available()) -+ hmacname = DNS_TSIG_HMACMD5_NAME; - #endif -+ } - - isc_buffer_init(&b, namestr, strlen(namestr)); - isc_buffer_add(&b, strlen(namestr)); -diff --git a/bin/rndc/rndc.c b/bin/rndc/rndc.c -index 9eb0ce0..8083654 100644 ---- a/bin/rndc/rndc.c -+++ b/bin/rndc/rndc.c -@@ -23,6 +23,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -636,7 +637,7 @@ parse_config(isc_mem_t *mctx, isc_log_t *log, const char *keyname, - algorithmstr = cfg_obj_asstring(algorithmobj); - - #ifndef PK11_MD5_DISABLE -- if (strcasecmp(algorithmstr, "hmac-md5") == 0) -+ if (strcasecmp(algorithmstr, "hmac-md5") == 0 && isc_md5_available()) - algorithm = ISCCC_ALG_HMACMD5; - else - #endif -diff --git a/bin/tests/optional/hash_test.c b/bin/tests/optional/hash_test.c -index bf2891a..b5f0a1c 100644 ---- a/bin/tests/optional/hash_test.c -+++ b/bin/tests/optional/hash_test.c -@@ -90,43 +90,47 @@ main(int argc, char **argv) { - print_digest(s, "sha224", digest, ISC_SHA224_DIGESTLENGTH/4); - - #ifndef PK11_MD5_DISABLE -- s = "abc"; -- isc_md5_init(&md5); -- memmove(buffer, s, strlen(s)); -- isc_md5_update(&md5, buffer, strlen(s)); -- isc_md5_final(&md5, digest); -- print_digest(s, "md5", digest, 4); -- -- /* -- * The 3 HMAC-MD5 examples from RFC2104 -- */ -- s = "Hi There"; -- memset(key, 0x0b, 16); -- isc_hmacmd5_init(&hmacmd5, key, 16); -- memmove(buffer, s, strlen(s)); -- isc_hmacmd5_update(&hmacmd5, buffer, strlen(s)); -- isc_hmacmd5_sign(&hmacmd5, digest); -- print_digest(s, "hmacmd5", digest, 4); -- -- s = "what do ya want for nothing?"; -- strlcpy((char *)key, "Jefe", sizeof(key)); -- isc_hmacmd5_init(&hmacmd5, key, 4); -- memmove(buffer, s, strlen(s)); -- isc_hmacmd5_update(&hmacmd5, buffer, strlen(s)); -- isc_hmacmd5_sign(&hmacmd5, digest); -- print_digest(s, "hmacmd5", digest, 4); -- -- s = "\335\335\335\335\335\335\335\335\335\335" -- "\335\335\335\335\335\335\335\335\335\335" -- "\335\335\335\335\335\335\335\335\335\335" -- "\335\335\335\335\335\335\335\335\335\335" -- "\335\335\335\335\335\335\335\335\335\335"; -- memset(key, 0xaa, 16); -- isc_hmacmd5_init(&hmacmd5, key, 16); -- memmove(buffer, s, strlen(s)); -- isc_hmacmd5_update(&hmacmd5, buffer, strlen(s)); -- isc_hmacmd5_sign(&hmacmd5, digest); -- print_digest(s, "hmacmd5", digest, 4); -+ if (isc_md5_available()) { -+ s = "abc"; -+ isc_md5_init(&md5); -+ memmove(buffer, s, strlen(s)); -+ isc_md5_update(&md5, buffer, strlen(s)); -+ isc_md5_final(&md5, digest); -+ print_digest(s, "md5", digest, 4); -+ -+ /* -+ * The 3 HMAC-MD5 examples from RFC2104 -+ */ -+ s = "Hi There"; -+ memset(key, 0x0b, 16); -+ isc_hmacmd5_init(&hmacmd5, key, 16); -+ memmove(buffer, s, strlen(s)); -+ isc_hmacmd5_update(&hmacmd5, buffer, strlen(s)); -+ isc_hmacmd5_sign(&hmacmd5, digest); -+ print_digest(s, "hmacmd5", digest, 4); -+ -+ s = "what do ya want for nothing?"; -+ strlcpy((char *)key, "Jefe", sizeof(key)); -+ isc_hmacmd5_init(&hmacmd5, key, 4); -+ memmove(buffer, s, strlen(s)); -+ isc_hmacmd5_update(&hmacmd5, buffer, strlen(s)); -+ isc_hmacmd5_sign(&hmacmd5, digest); -+ print_digest(s, "hmacmd5", digest, 4); -+ -+ s = "\335\335\335\335\335\335\335\335\335\335" -+ "\335\335\335\335\335\335\335\335\335\335" -+ "\335\335\335\335\335\335\335\335\335\335" -+ "\335\335\335\335\335\335\335\335\335\335" -+ "\335\335\335\335\335\335\335\335\335\335"; -+ memset(key, 0xaa, 16); -+ isc_hmacmd5_init(&hmacmd5, key, 16); -+ memmove(buffer, s, strlen(s)); -+ isc_hmacmd5_update(&hmacmd5, buffer, strlen(s)); -+ isc_hmacmd5_sign(&hmacmd5, digest); -+ print_digest(s, "hmacmd5", digest, 4); -+ } else { -+ fprintf(stderr, "Skipping disabled MD5 algorithm\n"); -+ } - #endif - - /* -diff --git a/bin/tests/system/tkey/keycreate.c b/bin/tests/system/tkey/keycreate.c -index 5a00f86..653c951 100644 ---- a/bin/tests/system/tkey/keycreate.c -+++ b/bin/tests/system/tkey/keycreate.c -@@ -20,6 +20,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -142,6 +143,8 @@ sendquery(isc_task_t *task, isc_event_t *event) { - static char keystr[] = "0123456789ab"; - - isc_event_free(&event); -+ if (!isc_md5_available()) -+ CHECK("MD5 was disabled", ISC_R_NOTIMPLEMENTED); - - result = ISC_R_FAILURE; - if (inet_pton(AF_INET, "10.53.0.1", &inaddr) != 1) -diff --git a/bin/tests/system/tkey/keydelete.c b/bin/tests/system/tkey/keydelete.c -index bde66a4..70a40c3 100644 ---- a/bin/tests/system/tkey/keydelete.c -+++ b/bin/tests/system/tkey/keydelete.c -@@ -225,12 +225,17 @@ main(int argc, char **argv) { - result = dst_key_fromnamedfile(keyname, NULL, type, mctx, &dstkey); - CHECK("dst_key_fromnamedfile", result); - #ifndef PK11_MD5_DISABLE -- result = dns_tsigkey_createfromkey(dst_key_name(dstkey), -- DNS_TSIG_HMACMD5_NAME, -- dstkey, true, NULL, 0, 0, -- mctx, ring, &tsigkey); -- dst_key_free(&dstkey); -- CHECK("dns_tsigkey_createfromkey", result); -+ if (isc_md5_available()) { -+ result = dns_tsigkey_createfromkey(dst_key_name(dstkey), -+ DNS_TSIG_HMACMD5_NAME, -+ dstkey, true, NULL, 0, 0, -+ mctx, ring, &tsigkey); -+ dst_key_free(&dstkey); -+ CHECK("dns_tsigkey_createfromkey", result); -+ } else { -+ dst_key_free(&dstkey); -+ CHECK("MD5 was disabled", ISC_R_NOTIMPLEMENTED); -+ } - #else - dst_key_free(&dstkey); - CHECK("MD5 was disabled", ISC_R_NOTIMPLEMENTED); -diff --git a/lib/bind9/check.c b/lib/bind9/check.c -index ec0ab6d..e0803d4 100644 ---- a/lib/bind9/check.c -+++ b/lib/bind9/check.c -@@ -23,6 +23,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -2618,6 +2619,15 @@ bind9_check_key(const cfg_obj_t *key, isc_log_t *logctx) { - } - - algorithm = cfg_obj_asstring(algobj); -+#ifndef PK11_MD5_DISABLE -+ /* Skip hmac-md5* algorithms */ -+ if (!isc_md5_available() && -+ strncasecmp(algorithm, "hmac-md5", 8) == 0) { -+ cfg_obj_log(algobj, logctx, ISC_LOG_ERROR, -+ "disabled algorithm '%s'", algorithm); -+ return (ISC_R_DISABLED); -+ } -+#endif - for (i = 0; algorithms[i].name != NULL; i++) { - len = strlen(algorithms[i].name); - if (strncasecmp(algorithms[i].name, algorithm, len) == 0 && -diff --git a/lib/dns/dst_api.c b/lib/dns/dst_api.c -index e3c47a9..320c0f8 100644 ---- a/lib/dns/dst_api.c -+++ b/lib/dns/dst_api.c -@@ -192,6 +192,12 @@ dst_lib_init2(isc_mem_t *mctx, isc_entropy_t *ectx, - dst_result_register(); - - memset(dst_t_func, 0, sizeof(dst_t_func)); -+ -+#ifdef OPENSSL -+ RETERR(dst__openssl_init(engine)); -+#elif PKCS11CRYPTO -+ RETERR(dst__pkcs11_init(mctx, engine)); -+#endif - #ifndef PK11_MD5_DISABLE - RETERR(dst__hmacmd5_init(&dst_t_func[DST_ALG_HMACMD5])); - #endif -@@ -201,7 +207,6 @@ dst_lib_init2(isc_mem_t *mctx, isc_entropy_t *ectx, - RETERR(dst__hmacsha384_init(&dst_t_func[DST_ALG_HMACSHA384])); - RETERR(dst__hmacsha512_init(&dst_t_func[DST_ALG_HMACSHA512])); - #ifdef OPENSSL -- RETERR(dst__openssl_init(engine)); - #ifndef PK11_MD5_DISABLE - RETERR(dst__opensslrsa_init(&dst_t_func[DST_ALG_RSAMD5], - DST_ALG_RSAMD5)); -@@ -235,14 +240,18 @@ dst_lib_init2(isc_mem_t *mctx, isc_entropy_t *ectx, - RETERR(dst__openssleddsa_init(&dst_t_func[DST_ALG_ED448])); - #endif - #elif PKCS11CRYPTO -- RETERR(dst__pkcs11_init(mctx, engine)); - #ifndef PK11_MD5_DISABLE -- RETERR(dst__pkcs11rsa_init(&dst_t_func[DST_ALG_RSAMD5])); -+ RETERR(dst__pkcs11rsa_init(&dst_t_func[DST_ALG_RSAMD5], -+ DST_ALG_RSAMD5)); - #endif -- RETERR(dst__pkcs11rsa_init(&dst_t_func[DST_ALG_RSASHA1])); -- RETERR(dst__pkcs11rsa_init(&dst_t_func[DST_ALG_NSEC3RSASHA1])); -- RETERR(dst__pkcs11rsa_init(&dst_t_func[DST_ALG_RSASHA256])); -- RETERR(dst__pkcs11rsa_init(&dst_t_func[DST_ALG_RSASHA512])); -+ RETERR(dst__pkcs11rsa_init(&dst_t_func[DST_ALG_RSASHA1], -+ DST_ALG_RSASHA1)); -+ RETERR(dst__pkcs11rsa_init(&dst_t_func[DST_ALG_NSEC3RSASHA1], -+ DST_ALG_NSEC3RSASHA1)); -+ RETERR(dst__pkcs11rsa_init(&dst_t_func[DST_ALG_RSASHA256], -+ DST_ALG_RSASHA256)); -+ RETERR(dst__pkcs11rsa_init(&dst_t_func[DST_ALG_RSASHA512], -+ DST_ALG_RSASHA512)); - #ifndef PK11_DSA_DISABLE - RETERR(dst__pkcs11dsa_init(&dst_t_func[DST_ALG_DSA])); - RETERR(dst__pkcs11dsa_init(&dst_t_func[DST_ALG_NSEC3DSA])); -diff --git a/lib/dns/dst_internal.h b/lib/dns/dst_internal.h -index 6ee796c..3e55d44 100644 ---- a/lib/dns/dst_internal.h -+++ b/lib/dns/dst_internal.h -@@ -250,7 +250,8 @@ isc_result_t dst__hmacsha384_init(struct dst_func **funcp); - isc_result_t dst__hmacsha512_init(struct dst_func **funcp); - isc_result_t dst__opensslrsa_init(struct dst_func **funcp, - unsigned char algorithm); --isc_result_t dst__pkcs11rsa_init(struct dst_func **funcp); -+isc_result_t dst__pkcs11rsa_init(struct dst_func **funcp, -+ unsigned char algorithm); - #ifndef PK11_DSA_DISABLE - isc_result_t dst__openssldsa_init(struct dst_func **funcp); - isc_result_t dst__pkcs11dsa_init(struct dst_func **funcp); -diff --git a/lib/dns/dst_parse.c b/lib/dns/dst_parse.c -index f31c33d..87023a6 100644 ---- a/lib/dns/dst_parse.c -+++ b/lib/dns/dst_parse.c -@@ -33,6 +33,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -396,6 +397,10 @@ check_data(const dst_private_t *priv, const unsigned int alg, - switch (alg) { - #ifndef PK11_MD5_DISABLE - case DST_ALG_RSAMD5: -+ if (isc_md5_available()) -+ return (check_rsa(priv, external)); -+ else -+ return (DST_R_UNSUPPORTEDALG); - #endif - case DST_ALG_RSASHA1: - case DST_ALG_NSEC3RSASHA1: -@@ -421,7 +426,10 @@ check_data(const dst_private_t *priv, const unsigned int alg, - return (check_eddsa(priv, external)); - #ifndef PK11_MD5_DISABLE - case DST_ALG_HMACMD5: -- return (check_hmac_md5(priv, old)); -+ if (isc_md5_available()) -+ return (check_hmac_md5(priv, old)); -+ else -+ return (DST_R_UNSUPPORTEDALG); - #endif - case DST_ALG_HMACSHA1: - return (check_hmac_sha(priv, HMACSHA1_NTAGS, alg)); -@@ -640,11 +648,13 @@ dst__privstruct_parse(dst_key_t *key, unsigned int alg, isc_lex_t *lex, - } - - #ifdef PK11_MD5_DISABLE -- check = check_data(priv, alg == DST_ALG_RSA ? DST_ALG_RSASHA1 : alg, -- true, external); -+ if (alg == DST_ALG_RSA) -+ alg = DST_ALG_RSASHA1; - #else -- check = check_data(priv, alg, true, external); -+ if (!isc_md5_available() && alg == DST_ALG_RSA) -+ alg = DST_ALG_RSASHA1; - #endif -+ check = check_data(priv, alg, true, external); - if (check < 0) { - ret = DST_R_INVALIDPRIVATEKEY; - goto fail; -diff --git a/lib/dns/hmac_link.c b/lib/dns/hmac_link.c -index 3b6579b..4bdce2f 100644 ---- a/lib/dns/hmac_link.c -+++ b/lib/dns/hmac_link.c -@@ -340,20 +340,10 @@ static dst_func_t hmacmd5_functions = { - - isc_result_t - dst__hmacmd5_init(dst_func_t **funcp) { --#ifdef HAVE_FIPS_MODE -- /* -- * Problems from OpenSSL are likely from FIPS mode -- */ -- int fips_mode = FIPS_mode(); -- -- if (fips_mode != 0) { -- UNEXPECTED_ERROR(__FILE__, __LINE__, -- "FIPS mode is %d: MD5 is only supported " -- "if the value is 0.\n" -- "Please disable either FIPS mode or MD5.", -- fips_mode); -- } --#endif -+ -+ /* Intentionally skip initialization */ -+ if (!isc_md5_available()) -+ return (ISC_R_SUCCESS); - - #if PK11_FLAVOR != PK11_UTIMACO_FLAVOR - /* -diff --git a/lib/dns/opensslrsa_link.c b/lib/dns/opensslrsa_link.c -index ec35f50..c80fabe 100644 ---- a/lib/dns/opensslrsa_link.c -+++ b/lib/dns/opensslrsa_link.c -@@ -1812,6 +1812,12 @@ dst__opensslrsa_init(dst_func_t **funcp, unsigned char algorithm) { - - if (*funcp == NULL) { - switch (algorithm) { -+#ifndef PK11_MD5_DISABLE -+ case DST_ALG_RSAMD5: -+ if (isc_md5_available()) -+ *funcp = &opensslrsa_functions; -+ break; -+#endif - case DST_ALG_RSASHA256: - #if defined(HAVE_EVP_SHA256) || !USE_EVP - *funcp = &opensslrsa_functions; -diff --git a/lib/dns/pkcs11rsa_link.c b/lib/dns/pkcs11rsa_link.c -index 096c1a8..6c280bf 100644 ---- a/lib/dns/pkcs11rsa_link.c -+++ b/lib/dns/pkcs11rsa_link.c -@@ -96,10 +96,15 @@ pkcs11rsa_createctx_sign(dst_key_t *key, dst_context_t *dctx) { - #endif - - /* -- * Reject incorrect RSA key lengths. -+ * Reject incorrect RSA key lengths or disabled algorithms. - */ - switch (dctx->key->key_alg) { - case DST_ALG_RSAMD5: -+#ifndef PK11_MD5_DISABLE -+ if (!isc_md5_available()) -+ return (ISC_R_FAILURE); -+#endif -+ /* FALLTHROUGH */ - case DST_ALG_RSASHA1: - case DST_ALG_NSEC3RSASHA1: - /* From RFC 3110 */ -@@ -641,6 +646,9 @@ pkcs11rsa_createctx(dst_key_t *key, dst_context_t *dctx) { - switch (key->key_alg) { - #ifndef PK11_MD5_DISABLE - case DST_ALG_RSAMD5: -+ if (!isc_md5_available()) -+ return (ISC_R_FAILURE); -+ - mech.mechanism = CKM_MD5; - break; - #endif -@@ -799,6 +807,9 @@ pkcs11rsa_sign(dst_context_t *dctx, isc_buffer_t *sig) { - switch (key->key_alg) { - #ifndef PK11_MD5_DISABLE - case DST_ALG_RSAMD5: -+ if (!isc_md5_available()) -+ return (ISC_R_FAILURE); -+ - der = md5_der; - derlen = sizeof(md5_der); - hashlen = ISC_MD5_DIGESTLENGTH; -@@ -1024,6 +1035,9 @@ pkcs11rsa_verify(dst_context_t *dctx, const isc_region_t *sig) { - switch (key->key_alg) { - #ifndef PK11_MD5_DISABLE - case DST_ALG_RSAMD5: -+ if (!isc_md5_available()) -+ return (ISC_R_FAILURE); -+ - der = md5_der; - derlen = sizeof(md5_der); - hashlen = ISC_MD5_DIGESTLENGTH; -@@ -2231,11 +2245,22 @@ static dst_func_t pkcs11rsa_functions = { - }; - - isc_result_t --dst__pkcs11rsa_init(dst_func_t **funcp) { -+dst__pkcs11rsa_init(dst_func_t **funcp, unsigned char algorithm) { - REQUIRE(funcp != NULL); - -- if (*funcp == NULL) -- *funcp = &pkcs11rsa_functions; -+ if (*funcp == NULL) { -+ switch (algorithm) { -+#ifndef PK11_MD5_DISABLE -+ case DST_ALG_RSAMD5: -+ if (isc_md5_available()) -+ *funcp = &pkcs11rsa_functions; -+ break; -+#endif -+ default: -+ *funcp = &pkcs11rsa_functions; -+ break; -+ } -+ } - return (ISC_R_SUCCESS); - } - -diff --git a/lib/dns/rcode.c b/lib/dns/rcode.c -index 9c42c50..f51d548 100644 ---- a/lib/dns/rcode.c -+++ b/lib/dns/rcode.c -@@ -16,6 +16,7 @@ - #include - - #include -+#include - #include - #include - #include -@@ -357,17 +358,33 @@ dns_cert_totext(dns_cert_t cert, isc_buffer_t *target) { - return (dns_mnemonic_totext(cert, target, certs)); - } - -+static inline struct tbl * -+secalgs_tbl_start() { -+ struct tbl *algs = secalgs; -+ -+#ifndef PK11_MD5_DISABLE -+ if (!isc_md5_available()) { -+ while (algs->name != NULL && -+ algs->value == DNS_KEYALG_RSAMD5) -+ ++algs; -+ } -+#endif -+ return algs; -+} -+ - isc_result_t - dns_secalg_fromtext(dns_secalg_t *secalgp, isc_textregion_t *source) { - unsigned int value; -- RETERR(dns_mnemonic_fromtext(&value, source, secalgs, 0xff)); -+ -+ RETERR(dns_mnemonic_fromtext(&value, source, -+ secalgs_tbl_start(), 0xff)); - *secalgp = value; - return (ISC_R_SUCCESS); - } - - isc_result_t - dns_secalg_totext(dns_secalg_t secalg, isc_buffer_t *target) { -- return (dns_mnemonic_totext(secalg, target, secalgs)); -+ return (dns_mnemonic_totext(secalg, target, secalgs_tbl_start())); - } - - void -diff --git a/lib/dns/tests/rsa_test.c b/lib/dns/tests/rsa_test.c -index f9ac6d0..241e17e 100644 ---- a/lib/dns/tests/rsa_test.c -+++ b/lib/dns/tests/rsa_test.c -@@ -27,6 +27,7 @@ - #define UNIT_TESTING - #include - -+#include - #include - #include - -@@ -248,6 +249,8 @@ isc_rsa_verify_test(void **state) { - /* RSAMD5 */ - - #ifndef PK11_MD5_DISABLE -+ if (isc_md5_available()) { -+ /* wrong indentation is kept for diff minimization */ - key->key_alg = DST_ALG_RSAMD5; - - ret = dst_context_create3(key, mctx, DNS_LOGCATEGORY_DNSSEC, -@@ -265,6 +268,7 @@ isc_rsa_verify_test(void **state) { - assert_int_equal(ret, ISC_R_SUCCESS); - - dst_context_destroy(&ctx); -+ } - #endif - - /* RSASHA256 */ -diff --git a/lib/dns/tests/tsig_test.c b/lib/dns/tests/tsig_test.c -index 11d011a..feb2068 100644 ---- a/lib/dns/tests/tsig_test.c -+++ b/lib/dns/tests/tsig_test.c -@@ -25,6 +25,7 @@ - #define UNIT_TESTING - #include - -+#include - #include - #include - #include -diff --git a/lib/dns/tkey.c b/lib/dns/tkey.c -index 89cfc79..d07364a 100644 ---- a/lib/dns/tkey.c -+++ b/lib/dns/tkey.c -@@ -245,6 +245,9 @@ compute_secret(isc_buffer_t *shared, isc_region_t *queryrandomness, - unsigned char digests[32]; - unsigned int i; - -+ if (!isc_md5_available()) -+ return (ISC_R_NOTIMPLEMENTED); -+ - isc_buffer_usedregion(shared, &r); - - /* -@@ -321,6 +324,12 @@ process_dhtkey(dns_message_t *msg, dns_name_t *signer, dns_name_t *name, - } - - #ifndef PK11_MD5_DISABLE -+ if (!isc_md5_available()) { -+ tkey_log("process_dhtkey: MD5 was disabled"); -+ tkeyout->error = dns_tsigerror_badalg; -+ return (ISC_R_SUCCESS); -+ } -+ - if (!dns_name_equal(&tkeyin->algorithm, DNS_TSIG_HMACMD5_NAME)) { - tkey_log("process_dhtkey: algorithms other than " - "hmac-md5 are not supported"); -diff --git a/lib/dns/tsec.c b/lib/dns/tsec.c -index 9d8ead4..0c82f65 100644 ---- a/lib/dns/tsec.c -+++ b/lib/dns/tsec.c -@@ -11,6 +11,7 @@ - - #include - -+#include - #include - #include - -@@ -63,7 +64,12 @@ dns_tsec_create(isc_mem_t *mctx, dns_tsectype_t type, dst_key_t *key, - switch (dst_key_alg(key)) { - #ifndef PK11_MD5_DISABLE - case DST_ALG_HMACMD5: -- algname = dns_tsig_hmacmd5_name; -+ if (isc_md5_available()) { -+ algname = dns_tsig_hmacmd5_name; -+ } else { -+ isc_mem_put(mctx, tsec, sizeof(*tsec)); -+ return (DNS_R_BADALG); -+ } - break; - #endif - case DST_ALG_HMACSHA1: -diff --git a/lib/dns/tsig.c b/lib/dns/tsig.c -index 58c1104..00ee1e1 100644 ---- a/lib/dns/tsig.c -+++ b/lib/dns/tsig.c -@@ -273,7 +273,8 @@ dns_tsigkey_createfromkey(dns_name_t *name, dns_name_t *algorithm, - (void)dns_name_downcase(&tkey->name, &tkey->name, NULL); - - #ifndef PK11_MD5_DISABLE -- if (dns_name_equal(algorithm, DNS_TSIG_HMACMD5_NAME)) { -+ if (dns_name_equal(algorithm, DNS_TSIG_HMACMD5_NAME) && -+ isc_md5_available()) { - tkey->algorithm = DNS_TSIG_HMACMD5_NAME; - if (dstkey != NULL && dst_key_alg(dstkey) != DST_ALG_HMACMD5) { - ret = DNS_R_BADALG; -@@ -499,7 +500,8 @@ destroyring(dns_tsig_keyring_t *ring) { - static unsigned int - dst_alg_fromname(dns_name_t *algorithm) { - #ifndef PK11_MD5_DISABLE -- if (dns_name_equal(algorithm, DNS_TSIG_HMACMD5_NAME)) { -+ if (dns_name_equal(algorithm, DNS_TSIG_HMACMD5_NAME) && -+ isc_md5_available()) { - return (DST_ALG_HMACMD5); - } else - #endif -@@ -683,7 +685,8 @@ dns_tsigkey_create(dns_name_t *name, dns_name_t *algorithm, - REQUIRE(secret != NULL); - - #ifndef PK11_MD5_DISABLE -- if (dns_name_equal(algorithm, DNS_TSIG_HMACMD5_NAME)) { -+ if (dns_name_equal(algorithm, DNS_TSIG_HMACMD5_NAME) && -+ isc_md5_available()) { - if (secret != NULL) { - isc_buffer_t b; - -@@ -1291,7 +1294,7 @@ dns_tsig_verify(isc_buffer_t *source, dns_message_t *msg, - return (ret); - if ( - #ifndef PK11_MD5_DISABLE -- alg == DST_ALG_HMACMD5 || -+ (alg == DST_ALG_HMACMD5 && isc_md5_available()) || - #endif - alg == DST_ALG_HMACSHA1 || - alg == DST_ALG_HMACSHA224 || alg == DST_ALG_HMACSHA256 || -@@ -1460,7 +1463,7 @@ dns_tsig_verify(isc_buffer_t *source, dns_message_t *msg, - - if ( - #ifndef PK11_MD5_DISABLE -- alg == DST_ALG_HMACMD5 || -+ (alg == DST_ALG_HMACMD5 && isc_md5_available()) || - #endif - alg == DST_ALG_HMACSHA1 || - alg == DST_ALG_HMACSHA224 || alg == DST_ALG_HMACSHA256 || -@@ -1601,7 +1604,7 @@ tsig_verify_tcp(isc_buffer_t *source, dns_message_t *msg) { - goto cleanup_querystruct; - if ( - #ifndef PK11_MD5_DISABLE -- alg == DST_ALG_HMACMD5 || -+ (alg == DST_ALG_HMACMD5 && isc_md5_available()) || - #endif - alg == DST_ALG_HMACSHA1 || - alg == DST_ALG_HMACSHA224 || -@@ -1780,7 +1783,7 @@ tsig_verify_tcp(isc_buffer_t *source, dns_message_t *msg) { - goto cleanup_context; - if ( - #ifndef PK11_MD5_DISABLE -- alg == DST_ALG_HMACMD5 || -+ (alg == DST_ALG_HMACMD5 && isc_md5_available()) || - #endif - alg == DST_ALG_HMACSHA1 || - alg == DST_ALG_HMACSHA224 || -diff --git a/lib/isc/include/isc/md5.h b/lib/isc/include/isc/md5.h -index 4d29398..e3f5cec 100644 ---- a/lib/isc/include/isc/md5.h -+++ b/lib/isc/include/isc/md5.h -@@ -91,6 +91,9 @@ isc_md5_final(isc_md5_t *ctx, unsigned char *digest); - bool - isc_md5_check(bool testing); - -+bool -+isc_md5_available(void); -+ - ISC_LANG_ENDDECLS - - #endif /* !PK11_MD5_DISABLE */ -diff --git a/lib/isc/md5.c b/lib/isc/md5.c -index 249f3da..628a414 100644 ---- a/lib/isc/md5.c -+++ b/lib/isc/md5.c -@@ -37,6 +37,7 @@ - - #include - #include -+#include - #include - #include - #include -@@ -54,6 +55,9 @@ - #define EVP_MD_CTX_free(ptr) EVP_MD_CTX_cleanup(ptr) - #endif - -+static isc_once_t available_once = ISC_ONCE_INIT; -+static bool available = false; -+ - void - isc_md5_init(isc_md5_t *ctx) { - ctx->ctx = EVP_MD_CTX_new(); -@@ -85,8 +89,33 @@ isc_md5_final(isc_md5_t *ctx, unsigned char *digest) { - ctx->ctx = NULL; - } - -+static void -+do_detect_available() { -+ isc_md5_t local; -+ isc_md5_t *ctx = &local; -+ unsigned char digest[ISC_MD5_DIGESTLENGTH]; -+ -+ ctx->ctx = EVP_MD_CTX_new(); -+ RUNTIME_CHECK(ctx->ctx != NULL); -+ available = (EVP_DigestInit(ctx->ctx, EVP_md5()) == 1); -+ if (available) -+ (void)EVP_DigestFinal(ctx->ctx, digest, NULL); -+ EVP_MD_CTX_free(ctx->ctx); -+ ctx->ctx = NULL; -+} -+ -+bool -+isc_md5_available() { -+ RUNTIME_CHECK(isc_once_do(&available_once, do_detect_available) -+ == ISC_R_SUCCESS); -+ return available; -+} -+ - #elif PKCS11CRYPTO - -+static isc_once_t available_once = ISC_ONCE_INIT; -+static bool available = false; -+ - void - isc_md5_init(isc_md5_t *ctx) { - CK_RV rv; -@@ -129,6 +158,31 @@ isc_md5_final(isc_md5_t *ctx, unsigned char *digest) { - pk11_return_session(ctx); - } - -+static void -+do_detect_available() { -+ isc_md5_t local; -+ isc_md5_t *ctx = &local; -+ CK_RV rv; -+ CK_MECHANISM mech = { CKM_MD5, NULL, 0 }; -+ -+ if (pk11_get_session(ctx, OP_DIGEST, true, false, -+ false, NULL, 0) == ISC_R_SUCCESS) -+ { -+ rv = pkcs_C_DigestInit(ctx->session, &mech); -+ isc_md5_invalidate(ctx); -+ available = (rv == CKR_OK); -+ } else { -+ available = false; -+ } -+} -+ -+bool -+isc_md5_available() { -+ RUNTIME_CHECK(isc_once_do(&available_once, do_detect_available) -+ == ISC_R_SUCCESS); -+ return available; -+} -+ - #else - - static void -@@ -338,6 +392,11 @@ isc_md5_final(isc_md5_t *ctx, unsigned char *digest) { - memmove(digest, ctx->buf, 16); - isc_safe_memwipe(ctx, sizeof(*ctx)); /* In case it's sensitive */ - } -+ -+bool -+isc_md5_available() { -+ return true; -+} - #endif - - /* -diff --git a/lib/isc/pk11.c b/lib/isc/pk11.c -index 0d5b009..7809e7b 100644 ---- a/lib/isc/pk11.c -+++ b/lib/isc/pk11.c -@@ -197,8 +197,6 @@ pk11_initialize(isc_mem_t *mctx, const char *engine) { - UNLOCK(&alloclock); - if (initialized) { - goto unlock; -- } else { -- initialized = true; - } - - ISC_LIST_INIT(tokens); -@@ -238,6 +236,7 @@ pk11_initialize(isc_mem_t *mctx, const char *engine) { - } - #endif - #endif /* PKCS11CRYPTO */ -+ initialized = true; - unlock: - UNLOCK(&sessionlock); - return (result); -@@ -589,6 +588,8 @@ scan_slots(void) { - pk11_token_t *token; - unsigned int i; - bool bad; -+ unsigned int best_rsa_algorithms = 0; -+ unsigned int best_digest_algorithms = 0; - - slotCount = 0; - PK11_FATALCHECK(pkcs_C_GetSlotList, (CK_FALSE, NULL_PTR, &slotCount)); -@@ -601,6 +602,8 @@ scan_slots(void) { - PK11_FATALCHECK(pkcs_C_GetSlotList, (CK_FALSE, slotList, &slotCount)); - - for (i = 0; i < slotCount; i++) { -+ unsigned int rsa_algorithms = 0; -+ unsigned int digest_algorithms = 0; - slot = slotList[i]; - PK11_TRACE2("slot#%u=0x%lx\n", i, slot); - -@@ -640,11 +643,12 @@ scan_slots(void) { - if ((rv != CKR_OK) || - ((mechInfo.flags & CKF_SIGN) == 0) || - ((mechInfo.flags & CKF_VERIFY) == 0)) { --#if !defined(PK11_MD5_DISABLE) && !defined(PK11_RSA_PKCS_REPLACE) -- bad = true; --#endif - PK11_TRACEM(CKM_MD5_RSA_PKCS); - } -+#if !defined(PK11_MD5_DISABLE) && !defined(PK11_RSA_PKCS_REPLACE) -+ else -+ ++rsa_algorithms; -+#endif - rv = pkcs_C_GetMechanismInfo(slot, CKM_SHA1_RSA_PKCS, - &mechInfo); - if ((rv != CKR_OK) || -@@ -687,8 +691,14 @@ scan_slots(void) { - if (bad) - goto try_dsa; - token->operations |= 1 << OP_RSA; -- if (best_rsa_token == NULL) -+ if (best_rsa_token == NULL) { - best_rsa_token = token; -+ best_rsa_algorithms = rsa_algorithms; -+ } else if (rsa_algorithms > best_rsa_algorithms) { -+ pk11_mem_put(best_rsa_token, sizeof(*best_rsa_token)); -+ best_rsa_token = token; -+ best_rsa_algorithms = rsa_algorithms; -+ } - - try_dsa: - bad = false; -@@ -756,11 +766,12 @@ scan_slots(void) { - bad = false; - rv = pkcs_C_GetMechanismInfo(slot, CKM_MD5, &mechInfo); - if ((rv != CKR_OK) || ((mechInfo.flags & CKF_DIGEST) == 0)) { --#ifndef PK11_MD5_DISABLE -- bad = true; --#endif - PK11_TRACEM(CKM_MD5); - } -+#ifndef PK11_MD5_DISABLE -+ else -+ ++digest_algorithms; -+#endif - rv = pkcs_C_GetMechanismInfo(slot, CKM_SHA_1, &mechInfo); - if ((rv != CKR_OK) || ((mechInfo.flags & CKF_DIGEST) == 0)) { - bad = true; -@@ -788,11 +799,12 @@ scan_slots(void) { - } - rv = pkcs_C_GetMechanismInfo(slot, CKM_MD5_HMAC, &mechInfo); - if ((rv != CKR_OK) || ((mechInfo.flags & CKF_SIGN) == 0)) { --#if !defined(PK11_MD5_DISABLE) && !defined(PK11_MD5_HMAC_REPLACE) -- bad = true; --#endif - PK11_TRACEM(CKM_MD5_HMAC); - } -+#if !defined(PK11_MD5_DISABLE) && !defined(PK11_MD5_HMAC_REPLACE) -+ else -+ ++digest_algorithms; -+#endif - rv = pkcs_C_GetMechanismInfo(slot, CKM_SHA_1_HMAC, &mechInfo); - if ((rv != CKR_OK) || ((mechInfo.flags & CKF_SIGN) == 0)) { - #ifndef PK11_SHA_1_HMAC_REPLACE -@@ -830,8 +842,14 @@ scan_slots(void) { - } - if (!bad) { - token->operations |= 1 << OP_DIGEST; -- if (digest_token == NULL) -+ if (digest_token == NULL) { - digest_token = token; -+ best_digest_algorithms = digest_algorithms; -+ } else if (digest_algorithms > best_digest_algorithms) { -+ pk11_mem_put(digest_token, sizeof(*digest_token)); -+ digest_token = token; -+ best_digest_algorithms = digest_algorithms; -+ } - } - - /* ECDSA requires digest */ -diff --git a/lib/isc/tests/hash_test.c b/lib/isc/tests/hash_test.c -index 31ced94..421131e 100644 ---- a/lib/isc/tests/hash_test.c -+++ b/lib/isc/tests/hash_test.c -@@ -775,6 +775,9 @@ isc_md5_test(void **state) { - - UNUSED(state); - -+ if (!isc_md5_available()) -+ return; -+ - /* - * These are the various test vectors. All of these are passed - * through the hash function and the results are compared to the -@@ -1630,6 +1633,9 @@ isc_hmacmd5_test(void **state) { - - UNUSED(state); - -+ if (!isc_md5_available()) -+ return; -+ - /* - * These are the various test vectors. All of these are passed - * through the hash function and the results are compared to the -@@ -1940,6 +1946,9 @@ static void - md5_check_test(void **state) { - UNUSED(state); - -+ if (!isc_md5_available()) -+ return; -+ - assert_true(isc_md5_check(false)); - assert_false(isc_md5_check(true)); - -diff --git a/lib/isccc/cc.c b/lib/isccc/cc.c -index c2740cb..c314d76 100644 ---- a/lib/isccc/cc.c -+++ b/lib/isccc/cc.c -@@ -272,11 +272,15 @@ sign(unsigned char *data, unsigned int length, unsigned char *hmac, - switch (algorithm) { - #ifndef PK11_MD5_DISABLE - case ISCCC_ALG_HMACMD5: -- isc_hmacmd5_init(&ctx.hmd5, secret->rstart, -- REGION_SIZE(*secret)); -- isc_hmacmd5_update(&ctx.hmd5, data, length); -- isc_hmacmd5_sign(&ctx.hmd5, digest); -- source.rend = digest + ISC_MD5_DIGESTLENGTH; -+ if (isc_md5_available()) { -+ isc_hmacmd5_init(&ctx.hmd5, secret->rstart, -+ REGION_SIZE(*secret)); -+ isc_hmacmd5_update(&ctx.hmd5, data, length); -+ isc_hmacmd5_sign(&ctx.hmd5, digest); -+ source.rend = digest + ISC_MD5_DIGESTLENGTH; -+ } else { -+ return (ISC_R_FAILURE); -+ } - break; - #endif - -@@ -350,14 +354,18 @@ isccc_cc_towire(isccc_sexpr_t *alist, isc_buffer_t **buffer, - { - unsigned int hmac_base, signed_base; - isc_result_t result; -+ const bool md5 = (algorithm == ISCCC_ALG_HMACMD5); - - #ifndef PK11_MD5_DISABLE -+ if (md5 && !isc_md5_available()) -+ return (ISC_R_NOTIMPLEMENTED); -+ - result = isc_buffer_reserve(buffer, -- 4 + ((algorithm == ISCCC_ALG_HMACMD5) ? -+ 4 + ((md5) ? - sizeof(auth_hmd5) : - sizeof(auth_hsha))); - #else -- if (algorithm == ISCCC_ALG_HMACMD5) -+ if (md5) - return (ISC_R_NOTIMPLEMENTED); - result = isc_buffer_reserve(buffer, 4 + sizeof(auth_hsha)); - #endif -@@ -376,7 +384,7 @@ isccc_cc_towire(isccc_sexpr_t *alist, isc_buffer_t **buffer, - * we know what it is. - */ - #ifndef PK11_MD5_DISABLE -- if (algorithm == ISCCC_ALG_HMACMD5) { -+ if (md5) { - hmac_base = (*buffer)->used + HMD5_OFFSET; - isc_buffer_putmem(*buffer, - auth_hmd5, sizeof(auth_hmd5)); -@@ -442,7 +450,7 @@ verify(isccc_sexpr_t *alist, unsigned char *data, unsigned int length, - if (!isccc_alist_alistp(_auth)) - return (ISC_R_FAILURE); - #ifndef PK11_MD5_DISABLE -- if (algorithm == ISCCC_ALG_HMACMD5) -+ if (algorithm == ISCCC_ALG_HMACMD5 && isc_md5_available()) - hmac = isccc_alist_lookup(_auth, "hmd5"); - else - #endif -@@ -457,12 +465,16 @@ verify(isccc_sexpr_t *alist, unsigned char *data, unsigned int length, - switch (algorithm) { - #ifndef PK11_MD5_DISABLE - case ISCCC_ALG_HMACMD5: -- isc_hmacmd5_init(&ctx.hmd5, secret->rstart, -- REGION_SIZE(*secret)); -- isc_hmacmd5_update(&ctx.hmd5, data, length); -- isc_hmacmd5_sign(&ctx.hmd5, digest); -- source.rend = digest + ISC_MD5_DIGESTLENGTH; -- break; -+ if (isc_md5_available()) { -+ isc_hmacmd5_init(&ctx.hmd5, secret->rstart, -+ REGION_SIZE(*secret)); -+ isc_hmacmd5_update(&ctx.hmd5, data, length); -+ isc_hmacmd5_sign(&ctx.hmd5, digest); -+ source.rend = digest + ISC_MD5_DIGESTLENGTH; -+ break; -+ } else { -+ return (ISC_R_FAILURE); -+ } - #endif - - case ISCCC_ALG_HMACSHA1: --- -2.20.1 - diff --git a/bind-9.11-rt31459.patch b/bind-9.11-rt31459.patch deleted file mode 100644 index 587fc28..0000000 --- a/bind-9.11-rt31459.patch +++ /dev/null @@ -1,375 +0,0 @@ -From 31612e4f76eeb07d0fffa33814ce5edef04b286a Mon Sep 17 00:00:00 2001 -From: Evan Hunt -Date: Tue, 12 Sep 2017 19:05:46 -0700 -Subject: [PATCH] rebased rt31459c - -[rt31459d] update the newer tools - -[rt31459d] setup entropy in dns_lib_init() - -[rt31459d] silence compiler warning - -DNS_OPENSSL_LIBS -> DST_OPENSSL_LIBS - -Include new unit test ---- - bin/tests/system/pipelined/pipequeries.c | 1 + - bin/tests/system/pipelined/tests.sh | 4 +- - bin/tests/system/tkey/keycreate.c | 1 + - bin/tests/system/tkey/keydelete.c | 1 + - bin/tests/system/tkey/tests.sh | 8 +- - configure | 97 ++++++++++-------------- - lib/dns/include/dst/dst.h | 8 ++ - lib/dns/lib.c | 1 + - lib/dns/tests/Makefile.in | 5 ++ - lib/isc/include/isc/types.h | 2 + - win32utils/Configure | 4 +- - 11 files changed, 66 insertions(+), 66 deletions(-) - -diff --git a/bin/tests/system/pipelined/pipequeries.c b/bin/tests/system/pipelined/pipequeries.c -index 74de833..4fac3cb 100644 ---- a/bin/tests/system/pipelined/pipequeries.c -+++ b/bin/tests/system/pipelined/pipequeries.c -@@ -205,6 +205,7 @@ sendqueries(isc_task_t *task, isc_event_t *event) { - - int - main(int argc, char *argv[]) { -+ char *randomfile = NULL; - isc_sockaddr_t bind_any; - struct in_addr inaddr; - isc_result_t result; -diff --git a/bin/tests/system/pipelined/tests.sh b/bin/tests/system/pipelined/tests.sh -index 61f1ff7..ed1302a 100644 ---- a/bin/tests/system/pipelined/tests.sh -+++ b/bin/tests/system/pipelined/tests.sh -@@ -19,7 +19,7 @@ status=0 - - echo_i "check pipelined TCP queries" - ret=0 --$PIPEQUERIES -p ${PORT} < input > raw || ret=1 -+$PIPEQUERIES -p ${PORT} -r $RANDFILE < input > raw || ret=1 - awk '{ print $1 " " $5 }' < raw > output - sort < output > output-sorted - $DIFF ref output-sorted || { ret=1 ; echo_i "diff sorted failed"; } -@@ -43,7 +43,7 @@ status=`expr $status + $ret` - - echo_i "check keep-response-order" - ret=0 --$PIPEQUERIES -p ${PORT} ++ < inputb > rawb || ret=1 -+$PIPEQUERIES -p ${PORT} -r $RANDFILE ++ < inputb > rawb || ret=1 - awk '{ print $1 " " $5 }' < rawb > outputb - $DIFF refb outputb || ret=1 - if [ $ret != 0 ]; then echo_i "failed"; fi -diff --git a/bin/tests/system/tkey/keycreate.c b/bin/tests/system/tkey/keycreate.c -index c39f6a4..b29a3cb 100644 ---- a/bin/tests/system/tkey/keycreate.c -+++ b/bin/tests/system/tkey/keycreate.c -@@ -195,6 +195,7 @@ sendquery(isc_task_t *task, isc_event_t *event) { - int - main(int argc, char *argv[]) { - char *ourkeyname; -+ char *randomfile; - isc_taskmgr_t *taskmgr; - isc_timermgr_t *timermgr; - isc_socketmgr_t *socketmgr; -diff --git a/bin/tests/system/tkey/keydelete.c b/bin/tests/system/tkey/keydelete.c -index 547e8d0..efcea1d 100644 ---- a/bin/tests/system/tkey/keydelete.c -+++ b/bin/tests/system/tkey/keydelete.c -@@ -136,6 +136,7 @@ sendquery(isc_task_t *task, isc_event_t *event) { - int - main(int argc, char **argv) { - char *keyname; -+ char *randomfile; - isc_taskmgr_t *taskmgr; - isc_timermgr_t *timermgr; - isc_socketmgr_t *socketmgr; -diff --git a/bin/tests/system/tkey/tests.sh b/bin/tests/system/tkey/tests.sh -index a293d32..51ed2cb 100644 ---- a/bin/tests/system/tkey/tests.sh -+++ b/bin/tests/system/tkey/tests.sh -@@ -31,7 +31,7 @@ for owner in . foo.example. - do - echo "I:creating new key using owner name \"$owner\"" - ret=0 -- keyname=`$KEYCREATE $dhkeyname $owner` || ret=1 -+ keyname=`$KEYCREATE -r $RANDFILE $dhkeyname $owner` || ret=1 - if [ $ret != 0 ]; then - echo "I:failed" - status=`expr $status + $ret` -@@ -53,7 +53,7 @@ do - - echo "I:deleting new key" - ret=0 -- $KEYDELETE $keyname || ret=1 -+ $KEYDELETE -r $RANDFILE $keyname || ret=1 - if [ $ret != 0 ]; then - echo "I:failed" - fi -@@ -73,7 +73,7 @@ done - - echo "I:creating new key using owner name bar.example." - ret=0 --keyname=`$KEYCREATE $dhkeyname bar.example.` || ret=1 -+keyname=`$KEYCREATE -r $RANDFILE $dhkeyname bar.example.` || ret=1 - if [ $ret != 0 ]; then - echo "I:failed" - status=`expr $status + $ret` -@@ -114,7 +114,7 @@ status=`expr $status + $ret` - - echo "I:recreating the bar.example. key" - ret=0 --keyname=`$KEYCREATE $dhkeyname bar.example.` || ret=1 -+keyname=`$KEYCREATE -r $RANDFILE $dhkeyname bar.example.` || ret=1 - if [ $ret != 0 ]; then - echo "I:failed" - status=`expr $status + $ret` -diff --git a/configure b/configure -index 4c97c8c..1e047bd 100755 ---- a/configure -+++ b/configure -@@ -632,6 +632,7 @@ ac_includes_default="\ - - ac_subst_vars='LTLIBOBJS - LIBOBJS -+LIBDIR_SUFFIX - BUILD_LIBS - BUILD_LDFLAGS - BUILD_CPPFLAGS -@@ -20509,6 +20510,30 @@ fi - # - dlzdir='${DLZ_DRIVER_DIR}' - -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for target libdir" >&5 -+$as_echo_n "checking for target libdir... " >&6; } -+if test "$cross_compiling" = yes; then : -+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -+as_fn_error $? "cannot run test program while cross compiling -+See \`config.log' for more details" "$LINENO" 5; } -+else -+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext -+/* end confdefs.h. */ -+int main(void) {exit((sizeof(void *) == 8) ? 0 : 1);} -+_ACEOF -+if ac_fn_c_try_run "$LINENO"; then : -+ target_lib=lib64 -+else -+ target_lib=lib -+fi -+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ -+ conftest.$ac_objext conftest.beam conftest.$ac_ext -+fi -+ -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: \"$target_lib\"" >&5 -+$as_echo "\"$target_lib\"" >&6; } -+ - # - # Private autoconf macro to simplify configuring drivers: - # -@@ -20839,11 +20864,11 @@ $as_echo "no" >&6; } - $as_echo "using mysql with libs ${mysql_lib} and includes ${mysql_include}" >&6; } - ;; - *) -- if test -d "$use_dlz_mysql/lib/mysql" -+ if test -d $use_dlz_mysql/${target_lib}/mysql - then -- mysql_lib="$use_dlz_mysql/lib/mysql" -+ mysql_lib=$use_dlz_mysql/${target_lib}/mysql - else -- mysql_lib="$use_dlz_mysql/lib" -+ mysql_lib=$use_dlz_mysql/${target_lib} - fi - - CONTRIB_DLZ="$CONTRIB_DLZ -DDLZ_MYSQL" -@@ -20928,7 +20953,7 @@ $as_echo "" >&6; } - # Check other locations for includes. - # Order is important (sigh). - -- bdb_incdirs="/db53 /db51 /db48 /db47 /db46 /db45 /db44 /db43 /db42 /db41 /db4 /db" -+ bdb_incdirs="/db53 /db51 /db48 /db47 /db46 /db45 /db44 /db43 /db42 /db41 /db4 /libdb /db" - # include a blank element first - for d in "" $bdb_incdirs - do -@@ -20953,57 +20978,9 @@ $as_echo "" >&6; } - 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" - for d in $bdb_libnames - do -- if test "$dd" = "/usr" -- then -- as_ac_Lib=`$as_echo "ac_cv_lib_$d''_db_create" | $as_tr_sh` --{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for db_create in -l$d" >&5 --$as_echo_n "checking for db_create in -l$d... " >&6; } --if eval \${$as_ac_Lib+:} false; then : -- $as_echo_n "(cached) " >&6 --else -- ac_check_lib_save_LIBS=$LIBS --LIBS="-l$d $LIBS" --cat confdefs.h - <<_ACEOF >conftest.$ac_ext --/* end confdefs.h. */ -- --/* Override any GCC internal prototype to avoid an error. -- Use char because int might match the return type of a GCC -- builtin and then its argument prototype would still apply. */ --#ifdef __cplusplus --extern "C" --#endif --char db_create (); --int --main () --{ --return db_create (); -- ; -- return 0; --} --_ACEOF --if ac_fn_c_try_link "$LINENO"; then : -- eval "$as_ac_Lib=yes" --else -- eval "$as_ac_Lib=no" --fi --rm -f core conftest.err conftest.$ac_objext \ -- conftest$ac_exeext conftest.$ac_ext --LIBS=$ac_check_lib_save_LIBS --fi --eval ac_res=\$$as_ac_Lib -- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 --$as_echo "$ac_res" >&6; } --if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : -- dlz_bdb_libs="-l${d}" --fi -- -- if test $dlz_bdb_libs != "yes" -- then -- break -- fi -- elif test -f "$dd/lib/lib${d}.so" -+ if test -f "$dd/${target_lib}/lib${d}.so" - then -- dlz_bdb_libs="-L${dd}/lib -l${d}" -+ dlz_bdb_libs="-L${dd}/${target_lib}/libdb -l${d}" - break - fi - done -@@ -21162,10 +21139,10 @@ $as_echo "no" >&6; } - DLZ_DRIVER_INCLUDES="$DLZ_DRIVER_INCLUDES -I$use_dlz_ldap/include" - DLZ_DRIVER_LDAP_INCLUDES="-I$use_dlz_ldap/include" - fi -- if test -n "-L$use_dlz_ldap/lib -lldap -llber" -+ if test -n "-L$use_dlz_ldap/${target_lib} -lldap -llber" - then -- DLZ_DRIVER_LIBS="$DLZ_DRIVER_LIBS -L$use_dlz_ldap/lib -lldap -llber" -- DLZ_DRIVER_LDAP_LIBS="-L$use_dlz_ldap/lib -lldap -llber" -+ DLZ_DRIVER_LIBS="$DLZ_DRIVER_LIBS -L$use_dlz_ldap/${target_lib} -lldap -llber" -+ DLZ_DRIVER_LDAP_LIBS="-L$use_dlz_ldap/${target_lib} -lldap -llber" - fi - - -@@ -21251,11 +21228,11 @@ fi - odbcdirs="/usr /usr/local /usr/pkg" - for d in $odbcdirs - do -- if test -f $d/include/sql.h -a -f $d/lib/libodbc.a -+ if test -f $d/include/sql.h -a -f $d/${target_lib}/libodbc.a - then - use_dlz_odbc=$d - dlz_odbc_include="-I$use_dlz_odbc/include" -- dlz_odbc_libs="-L$use_dlz_odbc/lib -lodbc" -+ dlz_odbc_libs="-L$use_dlz_odbc/${target_lib} -lodbc" - break - fi - done -@@ -21530,6 +21507,8 @@ DNS_CRYPTO_LIBS="$NEWFLAGS" - - - -+ -+ - # - # Commands to run at the end of config.status. - # Don't just put these into configure, it won't work right if somebody -diff --git a/lib/dns/include/dst/dst.h b/lib/dns/include/dst/dst.h -index 3146d88..3f7ac4d 100644 ---- a/lib/dns/include/dst/dst.h -+++ b/lib/dns/include/dst/dst.h -@@ -153,6 +153,14 @@ dst_lib_destroy(void); - * Releases all resources allocated by DST. - */ - -+isc_result_t -+dst_random_getdata(void *data, unsigned int length, -+ unsigned int *returned, unsigned int flags); -+/*%< -+ * \brief Return data from the crypto random generator. -+ * Specialization of isc_entropy_getdata(). -+ */ -+ - bool - dst_algorithm_supported(unsigned int alg); - /*%< -diff --git a/lib/dns/lib.c b/lib/dns/lib.c -index 5fccb57..1f627c4 100644 ---- a/lib/dns/lib.c -+++ b/lib/dns/lib.c -@@ -51,6 +51,7 @@ static unsigned int references = 0; - static void - initialize(void) { - isc_result_t result; -+ isc_entropy_t *ectx = NULL; - - REQUIRE(initialize_done == false); - -diff --git a/lib/dns/tests/Makefile.in b/lib/dns/tests/Makefile.in -index 7b35b93..c5befff 100644 ---- a/lib/dns/tests/Makefile.in -+++ b/lib/dns/tests/Makefile.in -@@ -259,6 +259,11 @@ zt_test@EXEEXT@: zt_test.@O@ dnstest.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} - ${LDFLAGS} -o $@ zt_test.@O@ dnstest.@O@ \ - ${DNSLIBS} ${ISCLIBS} ${LIBS} - -+dstrandom_test@EXEEXT@: dstrandom_test.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS} -+ ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \ -+ dstrandom_test.@O@ ${DNSLIBS} \ -+ ${ISCLIBS} ${ISCPK11LIBS} ${LIBS} -+ - unit:: - sh ${top_builddir}/unit/unittest.sh - -diff --git a/lib/isc/include/isc/types.h b/lib/isc/include/isc/types.h -index f8e5ae6..d0dc9b5 100644 ---- a/lib/isc/include/isc/types.h -+++ b/lib/isc/include/isc/types.h -@@ -82,6 +82,8 @@ typedef struct isc_time isc_time_t; /*%< Time */ - typedef struct isc_timer isc_timer_t; /*%< Timer */ - typedef struct isc_timermgr isc_timermgr_t; /*%< Timer Manager */ - -+typedef isc_result_t (*isc_entropy_getdata_t)(void *, unsigned int, -+ unsigned int *, unsigned int); - typedef void (*isc_taskaction_t)(isc_task_t *, isc_event_t *); - typedef int (*isc_sockfdwatch_t)(isc_task_t *, isc_socket_t *, void *, int); - -diff --git a/win32utils/Configure b/win32utils/Configure -index 9731b0c..0b7bc6e 100644 ---- a/win32utils/Configure -+++ b/win32utils/Configure -@@ -353,7 +353,8 @@ my @allcond = (@substcond, "NOTYET", "NOLONGER"); - - # enable-xxx/disable-xxx - --my @enablelist = ("developer", -+my @enablelist = ("crypto-rand", -+ "developer", - "fixed-rrset", - "intrinsics", - "isc-spnego", -@@ -2929,6 +2930,7 @@ exit 0; - # --enable-developer partially supported - # --enable-newstats (9.9/9.9sub only) - # --enable-native-pkcs11 supported -+# --enable-crypto-rand supported - # --enable-openssl-version-check included without a way to disable it - # --enable-openssl-hash supported - # --enable-threads included without a way to disable it --- -2.20.1 - diff --git a/bind-9.11-rt46047.patch b/bind-9.11-rt46047.patch deleted file mode 100644 index 8f413f6..0000000 --- a/bind-9.11-rt46047.patch +++ /dev/null @@ -1,799 +0,0 @@ -From 5a465424f5249ceaf0547ab90361a16eb08f7a2b Mon Sep 17 00:00:00 2001 -From: Evan Hunt -Date: Thu, 28 Sep 2017 10:09:22 -0700 -Subject: [PATCH] completed and corrected the crypto-random change - -4724. [func] By default, BIND now uses the random number - functions provided by the crypto library (i.e., - OpenSSL or a PKCS#11 provider) as a source of - randomness rather than /dev/random. This is - suitable for virtual machine environments - which have limited entropy pools and lack - hardware random number generators. - - This can be overridden by specifying another - entropy source via the "random-device" option - in named.conf, or via the -r command line option; - however, for functions requiring full cryptographic - strength, such as DNSSEC key generation, this - cannot be overridden. In particular, the -r - command line option no longer has any effect on - dnssec-keygen. - - This can be disabled by building with - "configure --disable-crypto-rand". - [RT #31459] [RT #46047] ---- - bin/confgen/keygen.c | 12 +++--- - bin/dnssec/dnssec-keygen.docbook | 24 +++++++---- - bin/dnssec/dnssectool.c | 12 +++--- - bin/named/client.c | 3 +- - bin/named/config.c | 4 +- - bin/named/controlconf.c | 19 +++++--- - bin/named/include/named/server.h | 2 + - bin/named/interfacemgr.c | 1 + - bin/named/query.c | 1 + - bin/named/server.c | 52 ++++++++++++++-------- - bin/nsupdate/nsupdate.c | 4 +- - bin/tests/system/pipelined/pipequeries.c | 4 +- - bin/tests/system/tkey/keycreate.c | 4 +- - bin/tests/system/tkey/keydelete.c | 5 +-- - doc/arm/Bv9ARM-book.xml | 55 +++++++++++++++++------- - doc/arm/notes-rh-changes.xml | 43 ++++++++++++++++++ - doc/arm/notes.xml | 1 + - lib/dns/dst_api.c | 4 +- - lib/dns/include/dst/dst.h | 14 +++++- - lib/dns/openssl_link.c | 3 +- - lib/isc/include/isc/entropy.h | 50 +++++++++++++++------ - lib/isc/include/isc/random.h | 28 +++++++----- - lib/isccfg/namedconf.c | 2 +- - 23 files changed, 241 insertions(+), 106 deletions(-) - create mode 100644 doc/arm/notes-rh-changes.xml - -diff --git a/bin/confgen/keygen.c b/bin/confgen/keygen.c -index 295e16f..0f79aa8 100644 ---- a/bin/confgen/keygen.c -+++ b/bin/confgen/keygen.c -@@ -161,17 +161,15 @@ generate_key(isc_mem_t *mctx, const char *randomfile, dns_secalg_t alg, - - DO("create entropy context", isc_entropy_create(mctx, &ectx)); - -- if (randomfile != NULL && strcmp(randomfile, "keyboard") == 0) { -- randomfile = NULL; -- open_keyboard = ISC_ENTROPY_KEYBOARDYES; -- } - #ifdef ISC_PLATFORM_CRYPTORANDOM -- if (randomfile != NULL && -- strcmp(randomfile, ISC_PLATFORM_CRYPTORANDOM) == 0) { -- randomfile = NULL; -+ if (randomfile == NULL) { - isc_entropy_usehook(ectx, true); - } - #endif -+ if (randomfile != NULL && strcmp(randomfile, "keyboard") == 0) { -+ randomfile = NULL; -+ open_keyboard = ISC_ENTROPY_KEYBOARDYES; -+ } - DO("start entropy source", isc_entropy_usebestsource(ectx, - &entropy_source, - randomfile, -diff --git a/bin/dnssec/dnssec-keygen.docbook b/bin/dnssec/dnssec-keygen.docbook -index 0ae6b41..4562430 100644 ---- a/bin/dnssec/dnssec-keygen.docbook -+++ b/bin/dnssec/dnssec-keygen.docbook -@@ -348,15 +348,23 @@ - -r randomdev - - -- Specifies the source of randomness. If the operating -- system does not provide a /dev/random -- or equivalent device, the default source of randomness -- is keyboard input. randomdev -- specifies -+ Specifies a source of randomness. Normally, when generating -+ DNSSEC keys, this option has no effect; the random number -+ generation function provided by the cryptographic library will -+ be used. -+ -+ -+ If that behavior is disabled at compile time, however, -+ the specified file will be used as entropy source -+ for key generation. randomdev is - the name of a character device or file containing random -- data to be used instead of the default. The special value -- keyboard indicates that keyboard -- input should be used. -+ data to be used. The special value keyboard -+ indicates that keyboard input should be used. -+ -+ -+ The default is /dev/random if the -+ operating system provides it or an equivalent device; -+ if not, the default source of randomness is keyboard input. - - - -diff --git a/bin/dnssec/dnssectool.c b/bin/dnssec/dnssectool.c -index 31a99e7..38c83ed 100644 ---- a/bin/dnssec/dnssectool.c -+++ b/bin/dnssec/dnssectool.c -@@ -241,18 +241,16 @@ setup_entropy(isc_mem_t *mctx, const char *randomfile, isc_entropy_t **ectx) { - ISC_LIST_INIT(sources); - } - -+#ifdef ISC_PLATFORM_CRYPTORANDOM -+ if (randomfile == NULL) { -+ isc_entropy_usehook(*ectx, true); -+ } -+#endif - if (randomfile != NULL && strcmp(randomfile, "keyboard") == 0) { - usekeyboard = ISC_ENTROPY_KEYBOARDYES; - randomfile = NULL; - } - --#ifdef ISC_PLATFORM_CRYPTORANDOM -- if (randomfile != NULL && -- strcmp(randomfile, ISC_PLATFORM_CRYPTORANDOM) == 0) { -- randomfile = NULL; -- isc_entropy_usehook(*ectx, true); -- } --#endif - result = isc_entropy_usebestsource(*ectx, &source, randomfile, - usekeyboard); - -diff --git a/bin/named/client.c b/bin/named/client.c -index 50fa2cd..524d9a3 100644 ---- a/bin/named/client.c -+++ b/bin/named/client.c -@@ -1762,7 +1762,8 @@ ns_client_addopt(ns_client_t *client, dns_message_t *message, - - isc_buffer_init(&buf, cookie, sizeof(cookie)); - isc_stdtime_get(&now); -- isc_random_get(&nonce); -+ nonce = ((isc_rng_random(ns_g_server->rngctx) << 16) | -+ isc_rng_random(ns_g_server->rngctx)); - - compute_cookie(client, now, nonce, ns_g_server->secret, &buf); - -diff --git a/bin/named/config.c b/bin/named/config.c -index dbdff64..63da4b0 100644 ---- a/bin/named/config.c -+++ b/bin/named/config.c -@@ -98,7 +98,9 @@ options {\n\ - # pid-file \"" NS_LOCALSTATEDIR "/run/named/named.pid\"; /* or /lwresd.pid */\n\ - port 53;\n\ - prefetch 2 9;\n" --#ifdef PATH_RANDOMDEV -+#if defined(ISC_PLATFORM_CRYPTORANDOM) -+" random-device none;\n" -+#elif defined(PATH_RANDOMDEV) - " random-device \"" PATH_RANDOMDEV "\";\n" - #endif - " recursing-file \"named.recursing\";\n\ -diff --git a/bin/named/controlconf.c b/bin/named/controlconf.c -index d955c2f..40621f2 100644 ---- a/bin/named/controlconf.c -+++ b/bin/named/controlconf.c -@@ -325,9 +325,10 @@ log_invalid(isccc_ccmsg_t *ccmsg, isc_result_t result) { - - static void - control_recvmessage(isc_task_t *task, isc_event_t *event) { -- controlconnection_t *conn; -- controllistener_t *listener; -- controlkey_t *key; -+ controlconnection_t *conn = NULL; -+ controllistener_t *listener = NULL; -+ ns_server_t *server = NULL; -+ controlkey_t *key = NULL; - isccc_sexpr_t *request = NULL; - isccc_sexpr_t *response = NULL; - uint32_t algorithm; -@@ -338,16 +339,17 @@ control_recvmessage(isc_task_t *task, isc_event_t *event) { - isc_buffer_t *text; - isc_result_t result; - isc_result_t eresult; -- isccc_sexpr_t *_ctrl; -+ isccc_sexpr_t *_ctrl = NULL; - isccc_time_t sent; - isccc_time_t exp; - uint32_t nonce; -- isccc_sexpr_t *data; -+ isccc_sexpr_t *data = NULL; - - REQUIRE(event->ev_type == ISCCC_EVENT_CCMSG); - - conn = event->ev_arg; - listener = conn->listener; -+ server = listener->controls->server; - algorithm = DST_ALG_UNKNOWN; - secret.rstart = NULL; - text = NULL; -@@ -458,8 +460,11 @@ control_recvmessage(isc_task_t *task, isc_event_t *event) { - * Establish nonce. - */ - if (conn->nonce == 0) { -- while (conn->nonce == 0) -- isc_random_get(&conn->nonce); -+ while (conn->nonce == 0) { -+ uint16_t r1 = isc_rng_random(server->rngctx); -+ uint16_t r2 = isc_rng_random(server->rngctx); -+ conn->nonce = (r1 << 16) | r2; -+ } - eresult = ISC_R_SUCCESS; - } else - eresult = ns_control_docommand(request, listener->readonly, &text); -diff --git a/bin/named/include/named/server.h b/bin/named/include/named/server.h -index 7ee8f66..8982d26 100644 ---- a/bin/named/include/named/server.h -+++ b/bin/named/include/named/server.h -@@ -20,6 +20,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -134,6 +135,7 @@ struct ns_server { - char * lockfile; - - uint16_t transfer_tcp_message_size; -+ isc_rng_t * rngctx; - }; - - struct ns_altsecret { -diff --git a/bin/named/interfacemgr.c b/bin/named/interfacemgr.c -index 9dea7c1..272d300 100644 ---- a/bin/named/interfacemgr.c -+++ b/bin/named/interfacemgr.c -@@ -17,6 +17,7 @@ - - #include - #include -+#include - #include - #include - #include -diff --git a/bin/named/query.c b/bin/named/query.c -index c9e5469..0940714 100644 ---- a/bin/named/query.c -+++ b/bin/named/query.c -@@ -19,6 +19,7 @@ - #include - #include - #include -+#include - #include - #include - #include -diff --git a/bin/named/server.c b/bin/named/server.c -index 36fc047..3c1eec0 100644 ---- a/bin/named/server.c -+++ b/bin/named/server.c -@@ -8208,21 +8208,32 @@ load_configuration(const char *filename, ns_server_t *server, - * Open the source of entropy. - */ - if (first_time) { -+ const char *randomdev = NULL; -+ int level = ISC_LOG_ERROR; - obj = NULL; - result = ns_config_get(maps, "random-device", &obj); -- if (result != ISC_R_SUCCESS) { -+ if (result == ISC_R_SUCCESS) { -+ if (!cfg_obj_isvoid(obj)) { -+ level = ISC_LOG_INFO; -+ randomdev = cfg_obj_asstring(obj); -+ } -+ } -+ if (randomdev == NULL) { -+#ifdef ISC_PLATFORM_CRYPTORANDOM -+ isc_entropy_usehook(ns_g_entropy, true); -+#else -+ if ((obj != NULL) && !cfg_obj_isvoid(obj)) -+ level = ISC_LOG_INFO; - isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, -- NS_LOGMODULE_SERVER, ISC_LOG_INFO, -+ NS_LOGMODULE_SERVER, level, - "no source of entropy found"); -+ if ((obj == NULL) || cfg_obj_isvoid(obj)) { -+ CHECK(ISC_R_FAILURE); -+ } -+#endif - } else { -- const char *randomdev = cfg_obj_asstring(obj); --#ifdef ISC_PLATFORM_CRYPTORANDOM -- if (strcmp(randomdev, ISC_PLATFORM_CRYPTORANDOM) == 0) -- isc_entropy_usehook(ns_g_entropy, true); --#else -- int level = ISC_LOG_ERROR; - result = isc_entropy_createfilesource(ns_g_entropy, -- randomdev); -+ randomdev); - #ifdef PATH_RANDOMDEV - if (ns_g_fallbackentropy != NULL) { - level = ISC_LOG_INFO; -@@ -8233,8 +8244,8 @@ load_configuration(const char *filename, ns_server_t *server, - NS_LOGCATEGORY_GENERAL, - NS_LOGMODULE_SERVER, - level, -- "could not open entropy source " -- "%s: %s", -+ "could not open " -+ "entropy source %s: %s", - randomdev, - isc_result_totext(result)); - } -@@ -8254,7 +8265,6 @@ load_configuration(const char *filename, ns_server_t *server, - } - isc_entropy_detach(&ns_g_fallbackentropy); - } --#endif - #endif - } - -@@ -9022,6 +9032,7 @@ ns_server_create(isc_mem_t *mctx, ns_server_t **serverp) { - server->in_roothints = NULL; - server->blackholeacl = NULL; - server->keepresporder = NULL; -+ server->rngctx = NULL; - - /* Must be first. */ - CHECKFATAL(dst_lib_init2(ns_g_mctx, ns_g_entropy, -@@ -9048,6 +9059,9 @@ ns_server_create(isc_mem_t *mctx, ns_server_t **serverp) { - CHECKFATAL(dns_tkeyctx_create(ns_g_mctx, ns_g_entropy, - &server->tkeyctx), - "creating TKEY context"); -+ server->rngctx = NULL; -+ CHECKFATAL(isc_rng_create(ns_g_mctx, ns_g_entropy, &server->rngctx), -+ "creating random numbers context"); - - /* - * Setup the server task, which is responsible for coordinating -@@ -9254,7 +9268,8 @@ ns_server_destroy(ns_server_t **serverp) { - - if (server->zonemgr != NULL) - dns_zonemgr_detach(&server->zonemgr); -- -+ if (server->rngctx != NULL) -+ isc_rng_detach(&server->rngctx); - if (server->tkeyctx != NULL) - dns_tkeyctx_destroy(&server->tkeyctx); - -@@ -13230,10 +13245,10 @@ newzone_cfgctx_destroy(void **cfgp) { - - static isc_result_t - generate_salt(unsigned char *salt, size_t saltlen) { -- int i, n; -+ size_t i, n; - union { - unsigned char rnd[256]; -- uint32_t rnd32[64]; -+ uint16_t rnd16[128]; - } rnd; - unsigned char text[512 + 1]; - isc_region_t r; -@@ -13243,9 +13258,10 @@ generate_salt(unsigned char *salt, size_t saltlen) { - if (saltlen > 256U) - return (ISC_R_RANGE); - -- n = (int) (saltlen + sizeof(uint32_t) - 1) / sizeof(uint32_t); -- for (i = 0; i < n; i++) -- isc_random_get(&rnd.rnd32[i]); -+ n = (saltlen + sizeof(uint16_t) - 1) / sizeof(uint16_t); -+ for (i = 0; i < n; i++) { -+ rnd.rnd16[i] = isc_rng_random(ns_g_server->rngctx); -+ } - - memmove(salt, rnd.rnd, saltlen); - -diff --git a/bin/nsupdate/nsupdate.c b/bin/nsupdate/nsupdate.c -index 0286987..0376377 100644 ---- a/bin/nsupdate/nsupdate.c -+++ b/bin/nsupdate/nsupdate.c -@@ -283,9 +283,7 @@ setup_entropy(isc_mem_t *mctx, const char *randomfile, isc_entropy_t **ectx) { - } - - #ifdef ISC_PLATFORM_CRYPTORANDOM -- if (randomfile != NULL && -- strcmp(randomfile, ISC_PLATFORM_CRYPTORANDOM) == 0) { -- randomfile = NULL; -+ if (randomfile == NULL) { - isc_entropy_usehook(*ectx, true); - } - #endif -diff --git a/bin/tests/system/pipelined/pipequeries.c b/bin/tests/system/pipelined/pipequeries.c -index f0a6ff2..55064f6 100644 ---- a/bin/tests/system/pipelined/pipequeries.c -+++ b/bin/tests/system/pipelined/pipequeries.c -@@ -280,9 +280,7 @@ main(int argc, char *argv[]) { - ectx = NULL; - RUNCHECK(isc_entropy_create(mctx, &ectx)); - #ifdef ISC_PLATFORM_CRYPTORANDOM -- if (randomfile != NULL && -- strcmp(randomfile, ISC_PLATFORM_CRYPTORANDOM) == 0) { -- randomfile = NULL; -+ if (randomfile == NULL) { - isc_entropy_usehook(ectx, true); - } - #endif -diff --git a/bin/tests/system/tkey/keycreate.c b/bin/tests/system/tkey/keycreate.c -index fe8698e..937fcc3 100644 ---- a/bin/tests/system/tkey/keycreate.c -+++ b/bin/tests/system/tkey/keycreate.c -@@ -255,9 +255,7 @@ main(int argc, char *argv[]) { - ectx = NULL; - RUNCHECK(isc_entropy_create(mctx, &ectx)); - #ifdef ISC_PLATFORM_CRYPTORANDOM -- if (randomfile != NULL && -- strcmp(randomfile, ISC_PLATFORM_CRYPTORANDOM) == 0) { -- randomfile = NULL; -+ if (randomfile == NULL) { - isc_entropy_usehook(ectx, true); - } - #endif -diff --git a/bin/tests/system/tkey/keydelete.c b/bin/tests/system/tkey/keydelete.c -index 2146f9b..64b8e74 100644 ---- a/bin/tests/system/tkey/keydelete.c -+++ b/bin/tests/system/tkey/keydelete.c -@@ -171,6 +171,7 @@ main(int argc, char **argv) { - randomfile = argv[2]; - argv += 2; - argc -= 2; -+ POST(argc); - } - keyname = argv[1]; - -@@ -182,9 +183,7 @@ main(int argc, char **argv) { - ectx = NULL; - RUNCHECK(isc_entropy_create(mctx, &ectx)); - #ifdef ISC_PLATFORM_CRYPTORANDOM -- if (randomfile != NULL && -- strcmp(randomfile, ISC_PLATFORM_CRYPTORANDOM) == 0) { -- randomfile = NULL; -+ if (randomfile == NULL) { - isc_entropy_usehook(ectx, true); - } - #endif -diff --git a/doc/arm/Bv9ARM-book.xml b/doc/arm/Bv9ARM-book.xml -index 33e06e6..539973c 100644 ---- a/doc/arm/Bv9ARM-book.xml -+++ b/doc/arm/Bv9ARM-book.xml -@@ -5076,22 +5076,45 @@ badresp:1,adberr:0,findfail:0,valfail:0] - random-device - - -- The source of entropy to be used by the server. Entropy is -- primarily needed -- for DNSSEC operations, such as TKEY transactions and dynamic -- update of signed -- zones. This options specifies the device (or file) from which -- to read -- entropy. If this is a file, operations requiring entropy will -- fail when the -- file has been exhausted. If not specified, the default value -- is -- /dev/random -- (or equivalent) when present, and none otherwise. The -- random-device option takes -- effect during -- the initial configuration load at server startup time and -- is ignored on subsequent reloads. -+ Specifies a source of entropy to be used by the server. -+ This is a device or file from which to read entropy. -+ If it is a file, operations requiring entropy -+ will fail when the file has been exhausted. -+ -+ -+ Entropy is needed for cryptographic operations such as -+ TKEY transactions, dynamic update of signed zones, and -+ generation of TSIG session keys. It is also used for -+ seeding and stirring the pseudo-random number generator, -+ which is used for less critical functions requiring -+ randomness such as generation of DNS message transaction -+ ID's. -+ -+ -+ If random-device is not specified, or -+ if it is set to none, entropy will be -+ read from the random number generation function supplied -+ by the cryptographic library with which BIND was linked -+ (i.e. OpenSSL or a PKCS#11 provider). -+ -+ -+ The random-device option takes -+ effect during the initial configuration load at server -+ startup time and is ignored on subsequent reloads. -+ -+ -+ If BIND is built with -+ configure --disable-crypto-rand, then -+ entropy is not sourced from the -+ cryptographic library. In this case, if -+ random-device is not specified, the -+ default value is the system random device, -+ /dev/random or the equivalent. -+ This default can be overridden with -+ configure --with-randomdev. -+ If no system random device exists, then no entropy source -+ will be configured, and named will only -+ be able to use pseudo-random numbers. - - - -diff --git a/doc/arm/notes-rh-changes.xml b/doc/arm/notes-rh-changes.xml -new file mode 100644 -index 0000000..11c3a7c ---- /dev/null -+++ b/doc/arm/notes-rh-changes.xml -@@ -0,0 +1,43 @@ -+ -+ -+ -+
Red Hat Specific Changes -+ -+ -+ -+ By default, BIND now uses the random number generation functions -+ in the cryptographic library (i.e., OpenSSL or a PKCS#11 -+ provider) as a source of high-quality randomness rather than -+ /dev/random. This is suitable for virtual -+ machine environments, which may have limited entropy pools and -+ lack hardware random number generators. -+ -+ -+ This can be overridden by specifying another entropy source via -+ the random-device option in -+ named.conf, or via the -r -+ command line option. However, for functions requiring full -+ cryptographic strength, such as DNSSEC key generation, this -+ cannot be overridden. In particular, the -+ -r command line option no longer has any -+ effect on dnssec-keygen. -+ -+ -+ This can be disabled by building with -+ configure --disable-crypto-rand, in which -+ case /dev/random will be the default -+ entropy source. [RT #31459] [RT #46047] -+ -+ -+ -+
-+ -diff --git a/doc/arm/notes.xml b/doc/arm/notes.xml -index b16dab6..763ff7e 100644 ---- a/doc/arm/notes.xml -+++ b/doc/arm/notes.xml -@@ -36,6 +36,7 @@ - - - -+ - - - -diff --git a/lib/dns/dst_api.c b/lib/dns/dst_api.c -index 1614afa..0f52df9 100644 ---- a/lib/dns/dst_api.c -+++ b/lib/dns/dst_api.c -@@ -2017,10 +2017,12 @@ dst__entropy_getdata(void *buf, unsigned int len, bool pseudo) { - else - flags |= ISC_ENTROPY_BLOCKING; - #ifdef ISC_PLATFORM_CRYPTORANDOM -+ /* get entropy directly from crypto provider */ - return (dst_random_getdata(buf, len, NULL, flags)); - #else -+ /* get entropy from entropy source or hook function */ - return (isc_entropy_getdata(dst_entropy_pool, buf, len, NULL, flags)); --#endif -+#endif /* ISC_PLATFORM_CRYPTORANDOM */ - #endif /* PKCS11CRYPTO */ - } - -diff --git a/lib/dns/include/dst/dst.h b/lib/dns/include/dst/dst.h -index 6813c96..665574d 100644 ---- a/lib/dns/include/dst/dst.h -+++ b/lib/dns/include/dst/dst.h -@@ -163,8 +163,18 @@ isc_result_t - dst_random_getdata(void *data, unsigned int length, - unsigned int *returned, unsigned int flags); - /*%< -- * \brief Return data from the crypto random generator. -- * Specialization of isc_entropy_getdata(). -+ * Gets random data from the random generator provided by the -+ * crypto library, if BIND was built with --enable-crypto-rand. -+ * -+ * See isc_entropy_getdata() for parameter usage. Normally when -+ * this function is available, it will be set up as a hook in the -+ * entropy context, so that isc_entropy_getdata() is a front-end to -+ * this function. -+ * -+ * Returns: -+ * \li ISC_R_SUCCESS on success -+ * \li ISC_R_NOTIMPLEMENTED if BIND is built with --disable-crypto-rand -+ * \li DST_R_OPENSSLFAILURE, DST_R_CRYPTOFAILURE, or other codes on error - */ - - bool -diff --git a/lib/dns/openssl_link.c b/lib/dns/openssl_link.c -index 6849732..e00a0e4 100644 ---- a/lib/dns/openssl_link.c -+++ b/lib/dns/openssl_link.c -@@ -484,7 +484,8 @@ dst__openssl_getengine(const char *engine) { - - isc_result_t - dst_random_getdata(void *data, unsigned int length, -- unsigned int *returned, unsigned int flags) { -+ unsigned int *returned, unsigned int flags) -+{ - #ifdef ISC_PLATFORM_CRYPTORANDOM - #ifndef DONT_REQUIRE_DST_LIB_INIT - INSIST(dst__memory_pool != NULL); -diff --git a/lib/isc/include/isc/entropy.h b/lib/isc/include/isc/entropy.h -index 632166a..c7cb17d 100644 ---- a/lib/isc/include/isc/entropy.h -+++ b/lib/isc/include/isc/entropy.h -@@ -9,8 +9,6 @@ - * information regarding copyright ownership. - */ - --/* $Id: entropy.h,v 1.35 2009/10/19 02:37:08 marka Exp $ */ -- - #ifndef ISC_ENTROPY_H - #define ISC_ENTROPY_H 1 - -@@ -191,9 +189,8 @@ isc_entropy_createcallbacksource(isc_entropy_t *ent, - /*!< - * \brief Create an entropy source that is polled via a callback. - * -- * This would -- * be used when keyboard input is used, or a GUI input method. It can -- * also be used to hook in any external entropy source. -+ * This would be used when keyboard input is used, or a GUI input method. -+ * It can also be used to hook in any external entropy source. - * - * Samples are added via isc_entropy_addcallbacksample(), below. - * _addcallbacksample() is the only function which may be called from -@@ -234,15 +231,32 @@ isc_result_t - isc_entropy_getdata(isc_entropy_t *ent, void *data, unsigned int length, - unsigned int *returned, unsigned int flags); - /*!< -- * \brief Extract data from the entropy pool. This may load the pool from various -- * sources. -+ * \brief Get random data from entropy pool 'ent'. -+ * -+ * If a hook has been set up using isc_entropy_sethook() and -+ * isc_entropy_usehook(), then the hook function will be called to get -+ * random data. -+ * -+ * Otherwise, randomness is extracted from the entropy pool set up in BIND. -+ * This may cause the pool to be loaded from various sources. Ths is done -+ * by stirring the pool and returning a part of hash as randomness. -+ * (Note that no secrets are given away here since parts of the hash are -+ * XORed together before returning.) -+ * -+ * 'flags' may contain ISC_ENTROPY_GOODONLY, ISC_ENTROPY_PARTIAL, or -+ * ISC_ENTROPY_BLOCKING. These will be honored if the hook function is -+ * not in use. If it is, the flags will be passed to the hook function -+ * but it may ignore them. - * -- * Do this by stiring the pool and returning a part of hash as randomness. -- * Note that no secrets are given away here since parts of the hash are -- * xored together before returned. -+ * Up to 'length' bytes of randomness are retrieved and copied into 'data'. -+ * (If 'returned' is not NULL, and the number of bytes copied is less than -+ * 'length' - which may happen if ISC_ENTROPY_PARTIAL was used - then the -+ * number of bytes copied will be stored in *returned.) - * -- * Honor the request from the caller to only return good data, any data, -- * etc. -+ * Returns: -+ * \li ISC_R_SUCCESS on success -+ * \li ISC_R_NOENTROPY if entropy pool is empty -+ * \li other error codes are possible when a hook is in use - */ - - void -@@ -307,13 +321,21 @@ isc_entropy_usebestsource(isc_entropy_t *ectx, isc_entropysource_t **source, - void - isc_entropy_usehook(isc_entropy_t *ectx, bool onoff); - /*!< -- * \brief Mark/unmark the given entropy structure as being hooked. -+ * \brief Configure entropy context 'ectx' to use the hook function -+ * -+ * Sets the entropy context to call the hook function for random number -+ * generation, if such a function has been configured via -+ * isc_entropy_sethook(), whenever isc_entropy_getdata() is called. - */ - - void - isc_entropy_sethook(isc_entropy_getdata_t myhook); - /*!< -- * \brief Set the getdata hook (e.g., for a crypto random generator). -+ * \brief Set the hook function. -+ * -+ * The hook function is a global value: only one hook function -+ * can be set in the system. Individual entropy contexts may be -+ * configured to use it, or not, by calling isc_entropy_usehook(). - */ - - ISC_LANG_ENDDECLS -diff --git a/lib/isc/include/isc/random.h b/lib/isc/include/isc/random.h -index f8aed34..17c551b 100644 ---- a/lib/isc/include/isc/random.h -+++ b/lib/isc/include/isc/random.h -@@ -9,8 +9,6 @@ - * information regarding copyright ownership. - */ - --/* $Id: random.h,v 1.20 2009/01/17 23:47:43 tbox Exp $ */ -- - #ifndef ISC_RANDOM_H - #define ISC_RANDOM_H 1 - -@@ -21,13 +19,23 @@ - #include - - /*! \file isc/random.h -- * \brief Implements a random state pool which will let the caller return a -- * series of possibly non-reproducible random values. -+ * \brief Implements pseudo random number generators. -+ * -+ * Two pseudo-random number generators are implemented, in isc_random_* -+ * and isc_rng_*. Neither one is very strong; they should not be used -+ * in cryptography functions. -+ * -+ * isc_random_* is based on arc4random if it is available on the system. -+ * Otherwise it is based on the posix srand() and rand() functions. -+ * It is useful for jittering values a bit here and there, such as -+ * timeouts, etc, but should not be relied upon to generate -+ * unpredictable sequences (for example, when choosing transaction IDs). - * -- * Note that the -- * strength of these numbers is not all that high, and should not be -- * used in cryptography functions. It is useful for jittering values -- * a bit here and there, such as timeouts, etc. -+ * isc_rng_* is based on ChaCha20, and is seeded and stirred from the -+ * system entropy source. It is stronger than isc_random_* and can -+ * be used for generating unpredictable sequences. It is still not as -+ * good as using system entropy directly (see entropy.h) and should not -+ * be used for cryptographic functions such as key generation. - */ - - ISC_LANG_BEGINDECLS -@@ -115,8 +123,8 @@ isc_rng_random(isc_rng_t *rngctx); - uint16_t - isc_rng_uniformrandom(isc_rng_t *rngctx, uint16_t upper_bound); - /*%< -- * Returns a uniformly distributed pseudo random 16-bit unsigned -- * integer. -+ * Returns a uniformly distributed pseudo-random 16-bit unsigned integer -+ * less than 'upper_bound'. - */ - - ISC_LANG_ENDDECLS -diff --git a/lib/isccfg/namedconf.c b/lib/isccfg/namedconf.c -index 03890a3..7bad989 100644 ---- a/lib/isccfg/namedconf.c -+++ b/lib/isccfg/namedconf.c -@@ -1109,7 +1109,7 @@ options_clauses[] = { - { "pid-file", &cfg_type_qstringornone, 0 }, - { "port", &cfg_type_uint32, 0 }, - { "querylog", &cfg_type_boolean, 0 }, -- { "random-device", &cfg_type_qstring, 0 }, -+ { "random-device", &cfg_type_qstringornone, 0 }, - { "recursing-file", &cfg_type_qstring, 0 }, - { "recursive-clients", &cfg_type_uint32, 0 }, - { "reserved-sockets", &cfg_type_uint32, 0 }, --- -2.20.1 - diff --git a/bind.spec b/bind.spec index a525f1c..e96b5a3 100644 --- a/bind.spec +++ b/bind.spec @@ -143,22 +143,11 @@ Patch140:bind-9.11-rh1410433.patch Patch150:bind-9.11-engine-pkcs11.patch Patch153:bind-9.11-export-suffix.patch Patch154:bind-9.11-oot-manual.patch -# FIXME: needs review. Should not be required -#Patch156:bind-9.11-fips-code.patch Patch157:bind-9.11-fips-tests.patch -# [RT #31459] commit 06a8051d2476fb526fe6960832209392c763a9af -#Patch158:bind-9.11-rt31459.patch -# [RT #46047] commit 24172bd2eeba91441ab1c65d2717b0692309244a ISC 4724 -#Patch159:bind-9.11-rt46047.patch -# https://gitlab.isc.org/isc-projects/bind9/issues/819 Patch164:bind-9.11-rh1666814.patch -#Patch169:bind-9.11-feature-test-dlz.patch Patch170:bind-9.11-feature-test-named.patch Patch171:bind-9.11-tests-variants.patch Patch172:bind-9.11-tests-pkcs11.patch -# Make sure jsonccp-devel does not interfere -#Patch175:bind-9.11-fips-disable.patch -#Patch176: bind-9.11-unit-dnstap-pkcs11.patch # SDB patches Patch11: bind-9.3.2b2-sdbsrc.patch @@ -545,21 +534,11 @@ are used for building ISC DHCP. %patch153 -p1 -b .export_suffix %endif %patch154 -p1 -b .oot-man -#%patch156 -p1 -b .fips-code %patch157 -p1 -b .fips-tests -#%patch158 -p1 -b .rt31459 -#%patch159 -p1 -b .rt46047 -#%patch160 -p1 -b .rh1624100 -#%patch161 -p1 -b .host-idn-disable -#%patch163 -p1 -b .rh1663318 %patch164 -p1 -b .rh1666814 -#%patch169 -p1 -b .featuretest-dlz %patch170 -p1 -b .featuretest-named %patch171 -p1 -b .test-variant %patch172 -p1 -b .test-pkcs11 -#%patch174 -p1 -b .unit-timer -#%patch175 -p1 -b .rh1709553 -#%patch176 -p1 -b .unit-dnstap %if %{with PKCS11} %patch135 -p1 -b .config-pkcs11