| |
@@ -1,4 +1,4 @@
|
| |
- From f695f140255f9b564cac4d5e9e38ba27ec927256 Mon Sep 17 00:00:00 2001
|
| |
+ From f470b130139919f32926b3f5a75ba4d161cbcf88 Mon Sep 17 00:00:00 2001
|
| |
From: Clemens Lang <cllang@redhat.com>
|
| |
Date: Tue, 1 Mar 2022 15:44:18 +0100
|
| |
Subject: [PATCH 2/2] Allow SHA1 in seclevel 1 if rh-allow-sha1-signatures =
|
| |
@@ -26,14 +26,14 @@
|
| |
Related: rhbz#2055796
|
| |
Related: rhbz#2070977
|
| |
---
|
| |
- crypto/x509/x509_vfy.c | 19 ++++++++++-
|
| |
+ crypto/x509/x509_vfy.c | 20 ++++++++++-
|
| |
doc/man5/config.pod | 7 ++++
|
| |
- ssl/t1_lib.c | 64 ++++++++++++++++++++++++++++-------
|
| |
+ ssl/t1_lib.c | 67 ++++++++++++++++++++++++++++-------
|
| |
test/recipes/25-test_verify.t | 4 +--
|
| |
- 4 files changed, 78 insertions(+), 16 deletions(-)
|
| |
+ 4 files changed, 82 insertions(+), 16 deletions(-)
|
| |
|
| |
diff --git a/crypto/x509/x509_vfy.c b/crypto/x509/x509_vfy.c
|
| |
- index 2f175ca517..60aa26f552 100644
|
| |
+ index 2f175ca517..bf0c608839 100644
|
| |
--- a/crypto/x509/x509_vfy.c
|
| |
+++ b/crypto/x509/x509_vfy.c
|
| |
@@ -25,6 +25,7 @@
|
| |
@@ -44,7 +44,7 @@
|
| |
#include "crypto/x509.h"
|
| |
#include "x509_local.h"
|
| |
|
| |
- @@ -3441,14 +3442,30 @@ static int check_sig_level(X509_STORE_CTX *ctx, X509 *cert)
|
| |
+ @@ -3441,14 +3442,31 @@ static int check_sig_level(X509_STORE_CTX *ctx, X509 *cert)
|
| |
{
|
| |
int secbits = -1;
|
| |
int level = ctx->param->auth_level;
|
| |
@@ -67,17 +67,18 @@
|
| |
+ if (!X509_get_signature_info(cert, &nid, NULL, &secbits, NULL))
|
| |
return 0;
|
| |
|
| |
- + if (nid == NID_sha1
|
| |
+ + if ((nid == NID_sha1 || nid == NID_md5_sha1)
|
| |
+ && ossl_ctx_legacy_digest_signatures_allowed(libctx, 0)
|
| |
+ && ctx->param->auth_level < 2)
|
| |
+ /* When rh-allow-sha1-signatures = yes and security level <= 1,
|
| |
- + * explicitly allow SHA1 for backwards compatibility. */
|
| |
+ + * explicitly allow SHA1 for backwards compatibility. Also allow
|
| |
+ + * MD5-SHA1 because TLS 1.0 is still supported, which uses it. */
|
| |
+ return 1;
|
| |
+
|
| |
return secbits >= minbits_table[level - 1];
|
| |
}
|
| |
diff --git a/doc/man5/config.pod b/doc/man5/config.pod
|
| |
- index 0c9110d28a..02e7ca706f 100644
|
| |
+ index 0c9110d28a..e0516d20b8 100644
|
| |
--- a/doc/man5/config.pod
|
| |
+++ b/doc/man5/config.pod
|
| |
@@ -309,6 +309,13 @@ this option is set to B<no>. Because TLS 1.1 or lower use MD5-SHA1 as
|
| |
@@ -86,16 +87,16 @@
|
| |
|
| |
+Note that enabling B<rh-allow-sha1-signatures> will allow TLS signature
|
| |
+algorithms that use SHA1 in security level 1, despite the definition of
|
| |
- +security level 1 of FIXME bits of security, which SHA1 does not meet. This
|
| |
- +allows using SHA1 in TLS in the LEGACY crypto-policy on Fedora without
|
| |
- +requiring to set the security level to 0, which would include further insecure
|
| |
- +algorithms.
|
| |
+ +security level 1 of 80 bits of security, which SHA1 and MD5-SHA1 do not meet.
|
| |
+ +This allows using SHA1 and MD5-SHA1 in TLS in the LEGACY crypto-policy on
|
| |
+ +Fedora without requiring to set the security level to 0, which would include
|
| |
+ +further insecure algorithms, and thus restores support for TLS 1.0 and 1.1.
|
| |
+
|
| |
=item B<fips_mode> (deprecated)
|
| |
|
| |
The value is a boolean that can be B<yes> or B<no>. If the value is
|
| |
diff --git a/ssl/t1_lib.c b/ssl/t1_lib.c
|
| |
- index dcd487ec2e..e47ddf56f1 100644
|
| |
+ index dcd487ec2e..0b50266b69 100644
|
| |
--- a/ssl/t1_lib.c
|
| |
+++ b/ssl/t1_lib.c
|
| |
@@ -20,6 +20,7 @@
|
| |
@@ -106,7 +107,7 @@
|
| |
#include "internal/sslconf.h"
|
| |
#include "internal/nelem.h"
|
| |
#include "internal/sizes.h"
|
| |
- @@ -1561,19 +1562,27 @@ int tls12_check_peer_sigalg(SSL *s, uint16_t sig, EVP_PKEY *pkey)
|
| |
+ @@ -1561,19 +1562,28 @@ int tls12_check_peer_sigalg(SSL *s, uint16_t sig, EVP_PKEY *pkey)
|
| |
SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE, SSL_R_UNKNOWN_DIGEST);
|
| |
return 0;
|
| |
}
|
| |
@@ -124,11 +125,12 @@
|
| |
- SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE, SSL_R_WRONG_SIGNATURE_TYPE);
|
| |
- return 0;
|
| |
+
|
| |
- + if (lu->hash == NID_sha1
|
| |
+ + if ((lu->hash == NID_sha1 || lu->hash == NID_md5_sha1)
|
| |
+ && ossl_ctx_legacy_digest_signatures_allowed(s->ctx->libctx, 0)
|
| |
+ && SSL_get_security_level(s) < 2) {
|
| |
- + /* when rh-allow-sha1-signatures = yes and security level <= 1,
|
| |
- + * explicitly allow SHA1 for backwards compatibility */
|
| |
+ + /* When rh-allow-sha1-signatures = yes and security level <= 1,
|
| |
+ + * explicitly allow SHA1 for backwards compatibility. Also allow
|
| |
+ + * MD5-SHA1 because TLS 1.0 is still supported, which uses it. */
|
| |
+ } else {
|
| |
+ /*
|
| |
+ * Make sure security callback allows algorithm. For historical
|
| |
@@ -147,22 +149,23 @@
|
| |
}
|
| |
/* Store the sigalg the peer uses */
|
| |
s->s3.tmp.peer_sigalg = lu;
|
| |
- @@ -2106,6 +2115,14 @@ static int tls12_sigalg_allowed(const SSL *s, int op, const SIGALG_LOOKUP *lu)
|
| |
+ @@ -2106,6 +2116,15 @@ static int tls12_sigalg_allowed(const SSL *s, int op, const SIGALG_LOOKUP *lu)
|
| |
}
|
| |
}
|
| |
|
| |
- + if (lu->hash == NID_sha1
|
| |
+ + if ((lu->hash == NID_sha1 || lu->hash == NID_md5_sha1)
|
| |
+ && ossl_ctx_legacy_digest_signatures_allowed(s->ctx->libctx, 0)
|
| |
+ && SSL_get_security_level(s) < 2) {
|
| |
- + /* when rh-allow-sha1-signatures = yes and security level <= 1,
|
| |
- + * explicitly allow SHA1 for backwards compatibility */
|
| |
+ + /* When rh-allow-sha1-signatures = yes and security level <= 1,
|
| |
+ + * explicitly allow SHA1 for backwards compatibility. Also allow
|
| |
+ + * MD5-SHA1 because TLS 1.0 is still supported, which uses it. */
|
| |
+ return 1;
|
| |
+ }
|
| |
+
|
| |
/* Finally see if security callback allows it */
|
| |
secbits = sigalg_security_bits(s->ctx, lu);
|
| |
sigalgstr[0] = (lu->sigalg >> 8) & 0xff;
|
| |
- @@ -2977,6 +2994,8 @@ static int ssl_security_cert_sig(SSL *s, SSL_CTX *ctx, X509 *x, int op)
|
| |
+ @@ -2977,6 +2996,8 @@ static int ssl_security_cert_sig(SSL *s, SSL_CTX *ctx, X509 *x, int op)
|
| |
{
|
| |
/* Lookup signature algorithm digest */
|
| |
int secbits, nid, pknid;
|
| |
@@ -171,7 +174,7 @@
|
| |
/* Don't check signature if self signed */
|
| |
if ((X509_get_extension_flags(x) & EXFLAG_SS) != 0)
|
| |
return 1;
|
| |
- @@ -2985,6 +3004,25 @@ static int ssl_security_cert_sig(SSL *s, SSL_CTX *ctx, X509 *x, int op)
|
| |
+ @@ -2985,6 +3006,26 @@ static int ssl_security_cert_sig(SSL *s, SSL_CTX *ctx, X509 *x, int op)
|
| |
/* If digest NID not defined use signature NID */
|
| |
if (nid == NID_undef)
|
| |
nid = pknid;
|
| |
@@ -185,13 +188,14 @@
|
| |
+ else
|
| |
+ libctx = OSSL_LIB_CTX_get0_global_default();
|
| |
+
|
| |
- + if (nid == NID_sha1
|
| |
+ + if ((nid == NID_sha1 || nid == NID_md5_sha1)
|
| |
+ && ossl_ctx_legacy_digest_signatures_allowed(libctx, 0)
|
| |
+ && ((s != NULL && SSL_get_security_level(s) < 2)
|
| |
+ || (ctx != NULL && SSL_CTX_get_security_level(ctx) < 2)
|
| |
+ ))
|
| |
+ /* When rh-allow-sha1-signatures = yes and security level <= 1,
|
| |
- + * explicitly allow SHA1 for backwards compatibility. */
|
| |
+ + * explicitly allow SHA1 for backwards compatibility. Also allow
|
| |
+ + * MD5-SHA1 because TLS 1.0 is still supported, which uses it. */
|
| |
+ return 1;
|
| |
+
|
| |
if (s)
|
| |
Fedora supports TLS down to 1.0 in LEGACY crypto-policy, but TLS 1.0
defaults to rsa_pkcs1_md5_sha1 with RSA certificates by default.
However, MD5-SHA1 would require SECLEVEL=0, because its 67 bits of
security do not meet SECLEVEL=1's requirement of 80 bits.
Instead of setting SECLEVEL to 0 in the LEGACY crypto-policy (which
would include all algorithms, regardless of their security level), allow
MD5-SHA1 if rh-allow-sha1-signatures is yes and SECLEVEL is 1.
Additionally, fix a regression in evp_pkey_name2type caused by the tr_TR
locale fix.
Resolves: rhbz#2069239
Signed-off-by: Clemens Lang cllang@redhat.com