forked from pool/openssl-3
259f0441ec
- Update to 3.2.0: * The BLAKE2b hash algorithm supports a configurable output length by setting the "size" parameter. * Enable extra Arm64 optimization on Windows for GHASH, RAND and AES. * Added a function to delete objects from store by URI - OSSL_STORE_delete() and the corresponding provider-storemgmt API function OSSL_FUNC_store_delete(). * Added OSSL_FUNC_store_open_ex() provider-storemgmt API function to pass a passphrase callback when opening a store. * Changed the default salt length used by PBES2 KDF's (PBKDF2 and scrypt) from 8 bytes to 16 bytes. The PKCS5 (RFC 8018) standard uses a 64 bit salt length for PBE, and recommends a minimum of 64 bits for PBES2. For FIPS compliance PBKDF2 requires a salt length of 128 bits. This affects OpenSSL command line applications such as "genrsa" and "pkcs8" and API's such as PEM_write_bio_PrivateKey() that are reliant on the default value. The additional commandline option 'saltlen' has been added to the OpenSSL command line applications for "pkcs8" and "enc" to allow the salt length to be set to a non default value. * Changed the default value of the ess_cert_id_alg configuration option which is used to calculate the TSA's public key certificate identifier. The default algorithm is updated to be sha256 instead of sha1. * Added optimization for SM2 algorithm on aarch64. It uses a huge precomputed table for point multiplication of the base point, which increases the size of libcrypto from 4.4 MB to 4.9 MB. A new configure option no-sm2-precomp has been added to disable the precomputed table. * Added client side support for QUIC OBS-URL: https://build.opensuse.org/request/show/1129505 OBS-URL: https://build.opensuse.org/package/show/security:tls/openssl-3?expand=0&rev=80
321 lines
12 KiB
Diff
321 lines
12 KiB
Diff
From 736d709ec194b3a763e004696df22792c62a11fc Mon Sep 17 00:00:00 2001
|
|
From: Tomas Mraz <tmraz@fedoraproject.org>
|
|
Date: Thu, 24 Sep 2020 10:16:46 +0200
|
|
Subject: Add support for PROFILE=SYSTEM system default cipherlist
|
|
|
|
(was openssl-1.1.1-system-cipherlist.patch)
|
|
---
|
|
Configurations/unix-Makefile.tmpl | 5 ++
|
|
Configure | 11 ++++
|
|
doc/man1/openssl-ciphers.pod.in | 9 +++
|
|
include/openssl/ssl.h.in | 5 ++
|
|
ssl/ssl_ciph.c | 87 +++++++++++++++++++++++++++++++++-----
|
|
ssl/ssl_lib.c | 4 -
|
|
test/cipherlist_test.c | 2
|
|
util/libcrypto.num | 1
|
|
8 files changed, 110 insertions(+), 14 deletions(-)
|
|
|
|
Index: openssl-3.2.0/Configurations/unix-Makefile.tmpl
|
|
===================================================================
|
|
--- openssl-3.2.0.orig/Configurations/unix-Makefile.tmpl
|
|
+++ openssl-3.2.0/Configurations/unix-Makefile.tmpl
|
|
@@ -324,6 +324,10 @@ MANDIR=$(INSTALLTOP)/share/man
|
|
DOCDIR=$(INSTALLTOP)/share/doc/$(BASENAME)
|
|
HTMLDIR=$(DOCDIR)/html
|
|
|
|
+{- output_off() if $config{system_ciphers_file} eq ""; "" -}
|
|
+SYSTEM_CIPHERS_FILE_DEFINE=-DSYSTEM_CIPHERS_FILE="\"{- $config{system_ciphers_file} -}\""
|
|
+{- output_on() if $config{system_ciphers_file} eq ""; "" -}
|
|
+
|
|
# MANSUFFIX is for the benefit of anyone who may want to have a suffix
|
|
# appended after the manpage file section number. "ssl" is popular,
|
|
# resulting in files such as config.5ssl rather than config.5.
|
|
@@ -347,6 +351,7 @@ CC=$(CROSS_COMPILE){- $config{CC} -}
|
|
CXX={- $config{CXX} ? "\$(CROSS_COMPILE)$config{CXX}" : '' -}
|
|
CPPFLAGS={- our $cppflags1 = join(" ",
|
|
(map { "-D".$_} @{$config{CPPDEFINES}}),
|
|
+ "\$(SYSTEM_CIPHERS_FILE_DEFINE)",
|
|
(map { "-I".$_} @{$config{CPPINCLUDES}}),
|
|
@{$config{CPPFLAGS}}) -}
|
|
CFLAGS={- join(' ', @{$config{CFLAGS}}) -}
|
|
Index: openssl-3.2.0/Configure
|
|
===================================================================
|
|
--- openssl-3.2.0.orig/Configure
|
|
+++ openssl-3.2.0/Configure
|
|
@@ -27,7 +27,7 @@ use OpenSSL::config;
|
|
my $orig_death_handler = $SIG{__DIE__};
|
|
$SIG{__DIE__} = \&death_handler;
|
|
|
|
-my $usage="Usage: Configure [no-<feature> ...] [enable-<feature> ...] [-Dxxx] [-lxxx] [-Lxxx] [-fxxx] [-Kxxx] [no-hw-xxx|no-hw] [[no-]threads] [[no-]thread-pool] [[no-]default-thread-pool] [[no-]shared] [[no-]zlib|zlib-dynamic] [no-asm] [no-egd] [sctp] [386] [--prefix=DIR] [--openssldir=OPENSSLDIR] [--with-xxx[=vvv]] [--config=FILE] os/compiler[:flags]\n";
|
|
+my $usage="Usage: Configure [no-<feature> ...] [enable-<feature> ...] [-Dxxx] [-lxxx] [-Lxxx] [-fxxx] [-Kxxx] [no-hw-xxx|no-hw] [[no-]threads] [[no-]thread-pool] [[no-]default-thread-pool] [[no-]shared] [[no-]zlib|zlib-dynamic] [no-asm] [no-egd] [sctp] [386] [--prefix=DIR] [--openssldir=OPENSSLDIR] [--system-ciphers-file=SYSTEMCIPHERFILE] [--with-xxx[=vvv]] [--config=FILE] os/compiler[:flags]\n";
|
|
|
|
my $banner = <<"EOF";
|
|
|
|
@@ -61,6 +61,10 @@ EOF
|
|
# given with --prefix.
|
|
# This becomes the value of OPENSSLDIR in Makefile and in C.
|
|
# (Default: PREFIX/ssl)
|
|
+#
|
|
+# --system-ciphers-file A file to read cipher string from when the PROFILE=SYSTEM
|
|
+# cipher is specified (default).
|
|
+#
|
|
# --banner=".." Output specified text instead of default completion banner
|
|
#
|
|
# -w Don't wait after showing a Configure warning
|
|
@@ -394,6 +398,7 @@ $config{prefix}="";
|
|
$config{openssldir}="";
|
|
$config{processor}="";
|
|
$config{libdir}="";
|
|
+$config{system_ciphers_file}="";
|
|
my $auto_threads=1; # enable threads automatically? true by default
|
|
my $default_ranlib;
|
|
|
|
@@ -1047,6 +1052,10 @@ while (@argvcopy)
|
|
die "FIPS key too long (64 bytes max)\n"
|
|
if length $1 > 64;
|
|
}
|
|
+ elsif (/^--system-ciphers-file=(.*)$/)
|
|
+ {
|
|
+ $config{system_ciphers_file}=$1;
|
|
+ }
|
|
elsif (/^--banner=(.*)$/)
|
|
{
|
|
$banner = $1 . "\n";
|
|
Index: openssl-3.2.0/doc/man1/openssl-ciphers.pod.in
|
|
===================================================================
|
|
--- openssl-3.2.0.orig/doc/man1/openssl-ciphers.pod.in
|
|
+++ openssl-3.2.0/doc/man1/openssl-ciphers.pod.in
|
|
@@ -190,6 +190,15 @@ As of OpenSSL 1.0.0, the B<ALL> cipher s
|
|
|
|
The cipher suites not enabled by B<ALL>, currently B<eNULL>.
|
|
|
|
+=item B<PROFILE=SYSTEM>
|
|
+
|
|
+The list of enabled cipher suites will be loaded from the system crypto policy
|
|
+configuration file B</etc/crypto-policies/back-ends/openssl.config>.
|
|
+See also L<update-crypto-policies(8)>.
|
|
+This is the default behavior unless an application explicitly sets a cipher
|
|
+list. If used in a cipher list configuration value this string must be at the
|
|
+beginning of the cipher list, otherwise it will not be recognized.
|
|
+
|
|
=item B<HIGH>
|
|
|
|
"High" encryption cipher suites. This currently means those with key lengths
|
|
Index: openssl-3.2.0/include/openssl/ssl.h.in
|
|
===================================================================
|
|
--- openssl-3.2.0.orig/include/openssl/ssl.h.in
|
|
+++ openssl-3.2.0/include/openssl/ssl.h.in
|
|
@@ -214,6 +214,11 @@ extern "C" {
|
|
* throwing out anonymous and unencrypted ciphersuites! (The latter are not
|
|
* actually enabled by ALL, but "ALL:RSA" would enable some of them.)
|
|
*/
|
|
+# ifdef SYSTEM_CIPHERS_FILE
|
|
+# define SSL_SYSTEM_DEFAULT_CIPHER_LIST "PROFILE=SYSTEM"
|
|
+# else
|
|
+# define SSL_SYSTEM_DEFAULT_CIPHER_LIST OSSL_default_cipher_list()
|
|
+# endif
|
|
|
|
/* Used in SSL_set_shutdown()/SSL_get_shutdown(); */
|
|
# define SSL_SENT_SHUTDOWN 1
|
|
Index: openssl-3.2.0/ssl/ssl_ciph.c
|
|
===================================================================
|
|
--- openssl-3.2.0.orig/ssl/ssl_ciph.c
|
|
+++ openssl-3.2.0/ssl/ssl_ciph.c
|
|
@@ -1455,6 +1455,53 @@ int SSL_set_ciphersuites(SSL *s, const c
|
|
return ret;
|
|
}
|
|
|
|
+#ifdef SYSTEM_CIPHERS_FILE
|
|
+static char *load_system_str(const char *suffix)
|
|
+{
|
|
+ FILE *fp;
|
|
+ char buf[1024];
|
|
+ char *new_rules;
|
|
+ const char *ciphers_path;
|
|
+ unsigned len, slen;
|
|
+
|
|
+ if ((ciphers_path = ossl_safe_getenv("OPENSSL_SYSTEM_CIPHERS_OVERRIDE")) == NULL)
|
|
+ ciphers_path = SYSTEM_CIPHERS_FILE;
|
|
+ fp = fopen(ciphers_path, "r");
|
|
+ if (fp == NULL || fgets(buf, sizeof(buf), fp) == NULL) {
|
|
+ /* cannot open or file is empty */
|
|
+ snprintf(buf, sizeof(buf), "%s", SSL_DEFAULT_CIPHER_LIST);
|
|
+ }
|
|
+
|
|
+ if (fp)
|
|
+ fclose(fp);
|
|
+
|
|
+ slen = strlen(suffix);
|
|
+ len = strlen(buf);
|
|
+
|
|
+ if (buf[len - 1] == '\n') {
|
|
+ len--;
|
|
+ buf[len] = 0;
|
|
+ }
|
|
+ if (buf[len - 1] == '\r') {
|
|
+ len--;
|
|
+ buf[len] = 0;
|
|
+ }
|
|
+
|
|
+ new_rules = OPENSSL_malloc(len + slen + 1);
|
|
+ if (new_rules == 0)
|
|
+ return NULL;
|
|
+
|
|
+ memcpy(new_rules, buf, len);
|
|
+ if (slen > 0) {
|
|
+ memcpy(&new_rules[len], suffix, slen);
|
|
+ len += slen;
|
|
+ }
|
|
+ new_rules[len] = 0;
|
|
+
|
|
+ return new_rules;
|
|
+}
|
|
+#endif
|
|
+
|
|
STACK_OF(SSL_CIPHER) *ssl_create_cipher_list(SSL_CTX *ctx,
|
|
STACK_OF(SSL_CIPHER) *tls13_ciphersuites,
|
|
STACK_OF(SSL_CIPHER) **cipher_list,
|
|
@@ -1469,15 +1516,25 @@ STACK_OF(SSL_CIPHER) *ssl_create_cipher_
|
|
CIPHER_ORDER *co_list = NULL, *head = NULL, *tail = NULL, *curr;
|
|
const SSL_CIPHER **ca_list = NULL;
|
|
const SSL_METHOD *ssl_method = ctx->method;
|
|
+#ifdef SYSTEM_CIPHERS_FILE
|
|
+ char *new_rules = NULL;
|
|
+
|
|
+ if (rule_str != NULL && strncmp(rule_str, "PROFILE=SYSTEM", 14) == 0) {
|
|
+ char *p = rule_str + 14;
|
|
+
|
|
+ new_rules = load_system_str(p);
|
|
+ rule_str = new_rules;
|
|
+ }
|
|
+#endif
|
|
|
|
/*
|
|
* Return with error if nothing to do.
|
|
*/
|
|
if (rule_str == NULL || cipher_list == NULL || cipher_list_by_id == NULL)
|
|
- return NULL;
|
|
+ goto err;
|
|
|
|
if (!check_suiteb_cipher_list(ssl_method, c, &rule_str))
|
|
- return NULL;
|
|
+ goto err;
|
|
|
|
/*
|
|
* To reduce the work to do we only want to process the compiled
|
|
@@ -1499,7 +1556,7 @@ STACK_OF(SSL_CIPHER) *ssl_create_cipher_
|
|
if (num_of_ciphers > 0) {
|
|
co_list = OPENSSL_malloc(sizeof(*co_list) * num_of_ciphers);
|
|
if (co_list == NULL)
|
|
- return NULL; /* Failure */
|
|
+ goto err;
|
|
}
|
|
|
|
ssl_cipher_collect_ciphers(ssl_method, num_of_ciphers,
|
|
@@ -1565,8 +1622,7 @@ STACK_OF(SSL_CIPHER) *ssl_create_cipher_
|
|
* in force within each class
|
|
*/
|
|
if (!ssl_cipher_strength_sort(&head, &tail)) {
|
|
- OPENSSL_free(co_list);
|
|
- return NULL;
|
|
+ goto err;
|
|
}
|
|
|
|
/*
|
|
@@ -1610,8 +1666,7 @@ STACK_OF(SSL_CIPHER) *ssl_create_cipher_
|
|
num_of_alias_max = num_of_ciphers + num_of_group_aliases + 1;
|
|
ca_list = OPENSSL_malloc(sizeof(*ca_list) * num_of_alias_max);
|
|
if (ca_list == NULL) {
|
|
- OPENSSL_free(co_list);
|
|
- return NULL; /* Failure */
|
|
+ goto err;
|
|
}
|
|
ssl_cipher_collect_aliases(ca_list, num_of_group_aliases,
|
|
disabled_mkey, disabled_auth, disabled_enc,
|
|
@@ -1644,8 +1699,7 @@ STACK_OF(SSL_CIPHER) *ssl_create_cipher_
|
|
OPENSSL_free(ca_list); /* Not needed anymore */
|
|
|
|
if (!ok) { /* Rule processing failure */
|
|
- OPENSSL_free(co_list);
|
|
- return NULL;
|
|
+ goto err;
|
|
}
|
|
|
|
/*
|
|
@@ -1653,10 +1707,13 @@ STACK_OF(SSL_CIPHER) *ssl_create_cipher_
|
|
* if we cannot get one.
|
|
*/
|
|
if ((cipherstack = sk_SSL_CIPHER_new_null()) == NULL) {
|
|
- OPENSSL_free(co_list);
|
|
- return NULL;
|
|
+ goto err;
|
|
}
|
|
|
|
+#ifdef SYSTEM_CIPHERS_FILE
|
|
+ OPENSSL_free(new_rules); /* Not needed anymore */
|
|
+#endif
|
|
+
|
|
/* Add TLSv1.3 ciphers first - we always prefer those if possible */
|
|
for (i = 0; i < sk_SSL_CIPHER_num(tls13_ciphersuites); i++) {
|
|
const SSL_CIPHER *sslc = sk_SSL_CIPHER_value(tls13_ciphersuites, i);
|
|
@@ -1708,6 +1765,14 @@ STACK_OF(SSL_CIPHER) *ssl_create_cipher_
|
|
*cipher_list = cipherstack;
|
|
|
|
return cipherstack;
|
|
+
|
|
+err:
|
|
+ OPENSSL_free(co_list);
|
|
+#ifdef SYSTEM_CIPHERS_FILE
|
|
+ OPENSSL_free(new_rules);
|
|
+#endif
|
|
+ return NULL;
|
|
+
|
|
}
|
|
|
|
char *SSL_CIPHER_description(const SSL_CIPHER *cipher, char *buf, int len)
|
|
Index: openssl-3.2.0/ssl/ssl_lib.c
|
|
===================================================================
|
|
--- openssl-3.2.0.orig/ssl/ssl_lib.c
|
|
+++ openssl-3.2.0/ssl/ssl_lib.c
|
|
@@ -689,7 +689,7 @@ int SSL_CTX_set_ssl_version(SSL_CTX *ctx
|
|
ctx->tls13_ciphersuites,
|
|
&(ctx->cipher_list),
|
|
&(ctx->cipher_list_by_id),
|
|
- OSSL_default_cipher_list(), ctx->cert);
|
|
+ SSL_SYSTEM_DEFAULT_CIPHER_LIST, ctx->cert);
|
|
if ((sk == NULL) || (sk_SSL_CIPHER_num(sk) <= 0)) {
|
|
ERR_raise(ERR_LIB_SSL, SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS);
|
|
return 0;
|
|
@@ -3955,7 +3955,7 @@ SSL_CTX *SSL_CTX_new_ex(OSSL_LIB_CTX *li
|
|
if (!ssl_create_cipher_list(ret,
|
|
ret->tls13_ciphersuites,
|
|
&ret->cipher_list, &ret->cipher_list_by_id,
|
|
- OSSL_default_cipher_list(), ret->cert)
|
|
+ SSL_SYSTEM_DEFAULT_CIPHER_LIST, ret->cert)
|
|
|| sk_SSL_CIPHER_num(ret->cipher_list) <= 0) {
|
|
ERR_raise(ERR_LIB_SSL, SSL_R_LIBRARY_HAS_NO_CIPHERS);
|
|
goto err;
|
|
Index: openssl-3.2.0/test/cipherlist_test.c
|
|
===================================================================
|
|
--- openssl-3.2.0.orig/test/cipherlist_test.c
|
|
+++ openssl-3.2.0/test/cipherlist_test.c
|
|
@@ -261,7 +261,9 @@ end:
|
|
|
|
int setup_tests(void)
|
|
{
|
|
+#ifndef SYSTEM_CIPHERS_FILE
|
|
ADD_TEST(test_default_cipherlist_implicit);
|
|
+#endif
|
|
ADD_TEST(test_default_cipherlist_explicit);
|
|
ADD_TEST(test_default_cipherlist_clear);
|
|
ADD_TEST(test_stdname_cipherlist);
|
|
Index: openssl-3.2.0/util/libcrypto.num
|
|
===================================================================
|
|
--- openssl-3.2.0.orig/util/libcrypto.num
|
|
+++ openssl-3.2.0/util/libcrypto.num
|
|
@@ -5536,3 +5536,4 @@ X509_STORE_CTX_set_get_crl
|
|
X509_STORE_CTX_set_current_reasons 5664 3_2_0 EXIST::FUNCTION:
|
|
OSSL_STORE_delete 5665 3_2_0 EXIST::FUNCTION:
|
|
BIO_ADDR_copy 5666 3_2_0 EXIST::FUNCTION:SOCK
|
|
+ossl_safe_getenv ? 3_0_0 EXIST::FUNCTION:
|