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