From 59ea44322ea468e3dfcc056870f66136707b475d Mon Sep 17 00:00:00 2001 From: "W.C.A. Wijngaards" Date: Fri, 7 May 2021 14:28:20 +0200 Subject: [PATCH] - Add ./configure --with-deprecate-rsa-1024 that turns off RSA 1024. --- config.h.in | 3 +++ configure | 17 ++++++++++++++++ configure.ac | 5 +++++ doc/Changelog | 1 + validator/autotrust.c | 4 +++- validator/val_anchor.c | 3 ++- validator/val_sigcrypt.c | 42 ++++++++++++++++++++++++++++++++++++++++ validator/val_sigcrypt.h | 17 ++++++++++++++++ validator/val_utils.c | 39 ++++++++++++++++++++++++++++++++----- 9 files changed, 124 insertions(+), 7 deletions(-) diff --git a/config.h.in b/config.h.in index a843d703d..cb27afa4f 100644 --- a/config.h.in +++ b/config.h.in @@ -28,6 +28,9 @@ /* Whether daemon is deprecated */ #undef DEPRECATED_DAEMON +/* Deprecate RSA 1024 bit length, makes that an unsupported key */ +#undef DEPRECATE_RSA_1024 + /* Define this to enable kernel based UDP source port randomization. */ #undef DISABLE_EXPLICIT_PORT_RANDOMISATION diff --git a/configure b/configure index 30e061f35..fb3bcffe2 100755 --- a/configure +++ b/configure @@ -877,6 +877,7 @@ enable_subnet enable_gost enable_ecdsa enable_dsa +with_deprecate_rsa_1024 enable_ed25519 enable_ed448 enable_event_api @@ -1639,6 +1640,10 @@ Optional Packages: /usr/ssl /usr/pkg /usr/local /opt/local /usr/sfw /usr) --with-libbsd Use portable libbsd functions + --with-deprecate-rsa-1024 + Deprecate RSA 1024 bit length, makes that an + unsupported key, for use when OpenSSL FIPS refuses + 1024 bit verification --with-libevent=pathname use libevent (will check /usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr or you can specify @@ -19035,6 +19040,18 @@ _ACEOF ;; esac + +# Check whether --with-deprecate-rsa-1024 was given. +if test "${with_deprecate_rsa_1024+set}" = set; then : + withval=$with_deprecate_rsa_1024; +fi + +if test "$with_deprecate_rsa_1024" = "yes"; then + +$as_echo "#define DEPRECATE_RSA_1024 1" >>confdefs.h + +fi + # Check whether --enable-ed25519 was given. if test "${enable_ed25519+set}" = set; then : enableval=$enable_ed25519; diff --git a/configure.ac b/configure.ac index 14d9b02c2..62bcee1df 100644 --- a/configure.ac +++ b/configure.ac @@ -1155,6 +1155,11 @@ AC_INCLUDES_DEFAULT ;; esac +AC_ARG_WITH(deprecate-rsa-1024, AS_HELP_STRING([--with-deprecate-rsa-1024],[Deprecate RSA 1024 bit length, makes that an unsupported key, for use when OpenSSL FIPS refuses 1024 bit verification])) +if test "$with_deprecate_rsa_1024" = "yes"; then + AC_DEFINE([DEPRECATE_RSA_1024], [1], [Deprecate RSA 1024 bit length, makes that an unsupported key]) +fi + AC_ARG_ENABLE(ed25519, AS_HELP_STRING([--disable-ed25519],[Disable ED25519 support])) use_ed25519="no" case "$enable_ed25519" in diff --git a/doc/Changelog b/doc/Changelog index 61fd924c3..2ed0bf92c 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,5 +1,6 @@ 7 May 2021: Wouter - Fix #485: Unbound occasionally reports broken stats. + - Add ./configure --with-deprecate-rsa-1024 that turns off RSA 1024. 4 May 2021: George - Fix for #367: only attempt to get the interface for queries that are no diff --git a/validator/autotrust.c b/validator/autotrust.c index 7ce07e0d8..adf836754 100644 --- a/validator/autotrust.c +++ b/validator/autotrust.c @@ -1579,6 +1579,7 @@ key_matches_a_ds(struct module_env* env, struct val_env* ve, for(ds_idx=0; ds_idxnumDNSKEY; i++) { - if(!dnskey_algo_is_supported(ta->dnskey_rrset, i)) + if(!dnskey_algo_is_supported(ta->dnskey_rrset, i) || + !dnskey_size_is_supported(ta->dnskey_rrset, i)) num++; } return num; diff --git a/validator/val_sigcrypt.c b/validator/val_sigcrypt.c index 14e13da06..5ce20b223 100644 --- a/validator/val_sigcrypt.c +++ b/validator/val_sigcrypt.c @@ -386,6 +386,48 @@ int dnskey_algo_is_supported(struct ub_packed_rrset_key* dnskey_rrset, dnskey_idx)); } +int dnskey_size_is_supported(struct ub_packed_rrset_key* dnskey_rrset, + size_t dnskey_idx) +{ +#ifdef DEPRECATE_RSA_1024 + uint8_t* rdata; + size_t len; + int alg = dnskey_get_algo(dnskey_rrset, dnskey_idx); + size_t keysize; + + rrset_get_rdata(dnskey_rrset, dnskey_idx, &rdata, &len); + if(len < 2+4) + return 0; + keysize = sldns_rr_dnskey_key_size_raw(rdata+2+4, len-2-4, alg); + + switch((sldns_algorithm)alg) { + case LDNS_RSAMD5: + case LDNS_RSASHA1: + case LDNS_RSASHA1_NSEC3: + case LDNS_RSASHA256: + case LDNS_RSASHA512: + /* reject RSA keys of 1024 bits and shorter */ + if(keysize <= 1024) + return 0; + default: + break; + } +#else + (void)dnskey_rrset; (void)dnskey_idx; +#endif /* DEPRECATE_RSA_1024 */ + return 1; +} + +int dnskeyset_size_is_supported(struct ub_packed_rrset_key* dnskey_rrset) +{ + size_t i, num = rrset_get_count(dnskey_rrset); + for(i=0; i