|
|
7d1228 |
diff -up openssl-1.1.1g/crypto/x509/x509_vfy.c.seclevel openssl-1.1.1g/crypto/x509/x509_vfy.c
|
|
|
7d1228 |
--- openssl-1.1.1g/crypto/x509/x509_vfy.c.seclevel 2020-04-21 14:22:39.000000000 +0200
|
|
|
7d1228 |
+++ openssl-1.1.1g/crypto/x509/x509_vfy.c 2020-06-05 17:16:54.835536823 +0200
|
|
|
7d1228 |
@@ -3225,6 +3225,7 @@ static int build_chain(X509_STORE_CTX *c
|
|
|
acdedc |
}
|
|
|
acdedc |
|
|
|
acdedc |
static const int minbits_table[] = { 80, 112, 128, 192, 256 };
|
|
|
acdedc |
+static const int minbits_digest_table[] = { 80, 80, 128, 192, 256 };
|
|
|
acdedc |
static const int NUM_AUTH_LEVELS = OSSL_NELEM(minbits_table);
|
|
|
acdedc |
|
|
|
acdedc |
/*
|
|
|
7d1228 |
@@ -3276,6 +3277,11 @@ static int check_sig_level(X509_STORE_CT
|
|
|
acdedc |
|
|
|
acdedc |
if (!X509_get_signature_info(cert, NULL, NULL, &secbits, NULL))
|
|
|
acdedc |
return 0;
|
|
|
acdedc |
-
|
|
|
acdedc |
- return secbits >= minbits_table[level - 1];
|
|
|
7d1228 |
+ /*
|
|
|
7d1228 |
+ * Allow SHA1 in SECLEVEL 2 in non-FIPS mode or when the magic
|
|
|
7d1228 |
+ * disable SHA1 flag is not set.
|
|
|
7d1228 |
+ */
|
|
|
7d1228 |
+ if ((ctx->param->flags & 0x40000000) || FIPS_mode())
|
|
|
acdedc |
+ return secbits >= minbits_table[level - 1];
|
|
|
acdedc |
+ return secbits >= minbits_digest_table[level - 1];
|
|
|
acdedc |
}
|
|
|
7d1228 |
diff -up openssl-1.1.1g/doc/man3/SSL_CTX_set_security_level.pod.seclevel openssl-1.1.1g/doc/man3/SSL_CTX_set_security_level.pod
|
|
|
7d1228 |
--- openssl-1.1.1g/doc/man3/SSL_CTX_set_security_level.pod.seclevel 2020-04-21 14:22:39.000000000 +0200
|
|
|
7d1228 |
+++ openssl-1.1.1g/doc/man3/SSL_CTX_set_security_level.pod 2020-06-04 15:48:01.608178833 +0200
|
|
|
acdedc |
@@ -81,8 +81,10 @@ using MD5 for the MAC is also prohibited
|
|
|
acdedc |
|
|
|
acdedc |
=item B<Level 2>
|
|
|
acdedc |
|
|
|
acdedc |
-Security level set to 112 bits of security. As a result RSA, DSA and DH keys
|
|
|
acdedc |
-shorter than 2048 bits and ECC keys shorter than 224 bits are prohibited.
|
|
|
acdedc |
+Security level set to 112 bits of security with the exception of SHA1 allowed
|
|
|
acdedc |
+for signatures.
|
|
|
acdedc |
+As a result RSA, DSA and DH keys shorter than 2048 bits and ECC keys
|
|
|
acdedc |
+shorter than 224 bits are prohibited.
|
|
|
acdedc |
In addition to the level 1 exclusions any cipher suite using RC4 is also
|
|
|
acdedc |
prohibited. SSL version 3 is also not allowed. Compression is disabled.
|
|
|
acdedc |
|
|
|
7d1228 |
diff -up openssl-1.1.1g/ssl/ssl_cert.c.seclevel openssl-1.1.1g/ssl/ssl_cert.c
|
|
|
7d1228 |
--- openssl-1.1.1g/ssl/ssl_cert.c.seclevel 2020-04-21 14:22:39.000000000 +0200
|
|
|
7d1228 |
+++ openssl-1.1.1g/ssl/ssl_cert.c 2020-06-05 17:10:11.842198401 +0200
|
|
|
7d1228 |
@@ -27,6 +27,7 @@
|
|
|
7d1228 |
static int ssl_security_default_callback(const SSL *s, const SSL_CTX *ctx,
|
|
|
7d1228 |
int op, int bits, int nid, void *other,
|
|
|
7d1228 |
void *ex);
|
|
|
7d1228 |
+static unsigned long sha1_disable(const SSL *s, const SSL_CTX *ctx);
|
|
|
7d1228 |
|
|
|
7d1228 |
static CRYPTO_ONCE ssl_x509_store_ctx_once = CRYPTO_ONCE_STATIC_INIT;
|
|
|
7d1228 |
static volatile int ssl_x509_store_ctx_idx = -1;
|
|
|
7d1228 |
@@ -396,7 +397,7 @@ int ssl_verify_cert_chain(SSL *s, STACK_
|
|
|
7d1228 |
X509_VERIFY_PARAM_set_auth_level(param, SSL_get_security_level(s));
|
|
|
7d1228 |
|
|
|
7d1228 |
/* Set suite B flags if needed */
|
|
|
7d1228 |
- X509_STORE_CTX_set_flags(ctx, tls1_suiteb(s));
|
|
|
7d1228 |
+ X509_STORE_CTX_set_flags(ctx, tls1_suiteb(s) | sha1_disable(s, NULL));
|
|
|
7d1228 |
if (!X509_STORE_CTX_set_ex_data
|
|
|
7d1228 |
(ctx, SSL_get_ex_data_X509_STORE_CTX_idx(), s)) {
|
|
|
7d1228 |
goto end;
|
|
|
7d1228 |
@@ -953,12 +954,33 @@ static int ssl_security_default_callback
|
|
|
acdedc |
return 0;
|
|
|
acdedc |
break;
|
|
|
acdedc |
default:
|
|
|
acdedc |
+ /* allow SHA1 in SECLEVEL 2 in non FIPS mode */
|
|
|
7d1228 |
+ if (nid == NID_sha1 && minbits == 112 && !sha1_disable(s, ctx))
|
|
|
acdedc |
+ break;
|
|
|
acdedc |
if (bits < minbits)
|
|
|
acdedc |
return 0;
|
|
|
acdedc |
}
|
|
|
7d1228 |
return 1;
|
|
|
7d1228 |
}
|
|
|
7d1228 |
|
|
|
7d1228 |
+static unsigned long sha1_disable(const SSL *s, const SSL_CTX *ctx)
|
|
|
7d1228 |
+{
|
|
|
7d1228 |
+ unsigned long ret = 0x40000000; /* a magical internal value used by X509_VERIFY_PARAM */
|
|
|
7d1228 |
+ const CERT *c;
|
|
|
7d1228 |
+
|
|
|
7d1228 |
+ if (FIPS_mode())
|
|
|
7d1228 |
+ return ret;
|
|
|
7d1228 |
+
|
|
|
7d1228 |
+ if (ctx != NULL) {
|
|
|
7d1228 |
+ c = ctx->cert;
|
|
|
7d1228 |
+ } else {
|
|
|
7d1228 |
+ c = s->cert;
|
|
|
7d1228 |
+ }
|
|
|
7d1228 |
+ if (tls1_cert_sigalgs_have_sha1(c))
|
|
|
7d1228 |
+ return 0;
|
|
|
7d1228 |
+ return ret;
|
|
|
7d1228 |
+}
|
|
|
7d1228 |
+
|
|
|
7d1228 |
int ssl_security(const SSL *s, int op, int bits, int nid, void *other)
|
|
|
7d1228 |
{
|
|
|
7d1228 |
return s->cert->sec_cb(s, NULL, op, bits, nid, other, s->cert->sec_ex);
|
|
|
7d1228 |
diff -up openssl-1.1.1g/ssl/ssl_local.h.seclevel openssl-1.1.1g/ssl/ssl_local.h
|
|
|
7d1228 |
--- openssl-1.1.1g/ssl/ssl_local.h.seclevel 2020-06-04 15:48:01.602178783 +0200
|
|
|
7d1228 |
+++ openssl-1.1.1g/ssl/ssl_local.h 2020-06-05 17:02:22.666313410 +0200
|
|
|
7d1228 |
@@ -2576,6 +2576,7 @@ __owur int tls1_save_sigalgs(SSL *s, PAC
|
|
|
7d1228 |
__owur int tls1_process_sigalgs(SSL *s);
|
|
|
7d1228 |
__owur int tls1_set_peer_legacy_sigalg(SSL *s, const EVP_PKEY *pkey);
|
|
|
7d1228 |
__owur int tls1_lookup_md(const SIGALG_LOOKUP *lu, const EVP_MD **pmd);
|
|
|
7d1228 |
+int tls1_cert_sigalgs_have_sha1(const CERT *c);
|
|
|
7d1228 |
__owur size_t tls12_get_psigalgs(SSL *s, int sent, const uint16_t **psigs);
|
|
|
7d1228 |
# ifndef OPENSSL_NO_EC
|
|
|
7d1228 |
__owur int tls_check_sigalg_curve(const SSL *s, int curve);
|
|
|
7d1228 |
diff -up openssl-1.1.1g/ssl/t1_lib.c.seclevel openssl-1.1.1g/ssl/t1_lib.c
|
|
|
7d1228 |
--- openssl-1.1.1g/ssl/t1_lib.c.seclevel 2020-06-04 15:48:01.654179221 +0200
|
|
|
7d1228 |
+++ openssl-1.1.1g/ssl/t1_lib.c 2020-06-05 17:02:40.268459157 +0200
|
|
|
7d1228 |
@@ -2145,6 +2145,36 @@ int tls1_set_sigalgs(CERT *c, const int
|
|
|
7d1228 |
return 0;
|
|
|
7d1228 |
}
|
|
|
7d1228 |
|
|
|
7d1228 |
+static int tls1_sigalgs_have_sha1(const uint16_t *sigalgs, size_t sigalgslen)
|
|
|
7d1228 |
+{
|
|
|
7d1228 |
+ size_t i;
|
|
|
7d1228 |
+
|
|
|
7d1228 |
+ for (i = 0; i < sigalgslen; i++, sigalgs++) {
|
|
|
7d1228 |
+ const SIGALG_LOOKUP *lu = tls1_lookup_sigalg(*sigalgs);
|
|
|
7d1228 |
+
|
|
|
7d1228 |
+ if (lu == NULL)
|
|
|
7d1228 |
+ continue;
|
|
|
7d1228 |
+ if (lu->hash == NID_sha1)
|
|
|
7d1228 |
+ return 1;
|
|
|
7d1228 |
+ }
|
|
|
7d1228 |
+ return 0;
|
|
|
7d1228 |
+}
|
|
|
7d1228 |
+
|
|
|
7d1228 |
+
|
|
|
7d1228 |
+int tls1_cert_sigalgs_have_sha1(const CERT *c)
|
|
|
7d1228 |
+{
|
|
|
7d1228 |
+ if (c->client_sigalgs != NULL) {
|
|
|
7d1228 |
+ if (tls1_sigalgs_have_sha1(c->client_sigalgs, c->client_sigalgslen))
|
|
|
7d1228 |
+ return 1;
|
|
|
7d1228 |
+ }
|
|
|
7d1228 |
+ if (c->conf_sigalgs != NULL) {
|
|
|
7d1228 |
+ if (tls1_sigalgs_have_sha1(c->conf_sigalgs, c->conf_sigalgslen))
|
|
|
7d1228 |
+ return 1;
|
|
|
7d1228 |
+ return 0;
|
|
|
7d1228 |
+ }
|
|
|
7d1228 |
+ return 1;
|
|
|
7d1228 |
+}
|
|
|
7d1228 |
+
|
|
|
7d1228 |
static int tls1_check_sig_alg(SSL *s, X509 *x, int default_nid)
|
|
|
7d1228 |
{
|
|
|
7d1228 |
int sig_nid, use_pc_sigalgs = 0;
|
|
|
7d1228 |
diff -up openssl-1.1.1g/test/recipes/25-test_verify.t.seclevel openssl-1.1.1g/test/recipes/25-test_verify.t
|
|
|
7d1228 |
--- openssl-1.1.1g/test/recipes/25-test_verify.t.seclevel 2020-04-21 14:22:39.000000000 +0200
|
|
|
7d1228 |
+++ openssl-1.1.1g/test/recipes/25-test_verify.t 2020-06-04 15:48:01.608178833 +0200
|
|
|
7d1228 |
@@ -346,8 +346,8 @@ ok(verify("ee-pss-sha1-cert", "sslserver
|
|
|
acdedc |
ok(verify("ee-pss-sha256-cert", "sslserver", ["root-cert"], ["ca-cert"], ),
|
|
|
acdedc |
"CA with PSS signature using SHA256");
|
|
|
acdedc |
|
|
|
acdedc |
-ok(!verify("ee-pss-sha1-cert", "sslserver", ["root-cert"], ["ca-cert"], "-auth_level", "2"),
|
|
|
acdedc |
- "Reject PSS signature using SHA1 and auth level 2");
|
|
|
acdedc |
+ok(!verify("ee-pss-sha1-cert", "sslserver", ["root-cert"], ["ca-cert"], "-auth_level", "3"),
|
|
|
acdedc |
+ "Reject PSS signature using SHA1 and auth level 3");
|
|
|
acdedc |
|
|
|
acdedc |
ok(verify("ee-pss-sha256-cert", "sslserver", ["root-cert"], ["ca-cert"], "-auth_level", "2"),
|
|
|
acdedc |
"PSS signature using SHA256 and auth level 2");
|