Skip to content

Commit bf999cc

Browse files
committed
deps: upgrade openssl sources to OpenSSL_1_1_1v+quic
This updates all sources in deps/openssl/openssl by: $ git clone https://github.com/quictls/openssl $ cd openssl $ git checkout OpenSSL_1_1_1v+quic $ cd ../node/deps/openssl $ rm -rf openssl $ cp -R ../openssl openssl $ rm -rf openssl/.git* openssl/.travis* $ git add --all openssl $ git commit openssl PR-URL: #49098 Refs: #49043 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
1 parent bfac291 commit bf999cc

File tree

14 files changed

+97
-17
lines changed

14 files changed

+97
-17
lines changed

deps/openssl/openssl/CHANGES

+35
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,41 @@
77
https://github.com/openssl/openssl/commits/ and pick the appropriate
88
release branch.
99

10+
Changes between 1.1.1u and 1.1.1v [1 Aug 2023]
11+
12+
*) Fix excessive time spent checking DH q parameter value.
13+
14+
The function DH_check() performs various checks on DH parameters. After
15+
fixing CVE-2023-3446 it was discovered that a large q parameter value can
16+
also trigger an overly long computation during some of these checks.
17+
A correct q value, if present, cannot be larger than the modulus p
18+
parameter, thus it is unnecessary to perform these checks if q is larger
19+
than p.
20+
21+
If DH_check() is called with such q parameter value,
22+
DH_CHECK_INVALID_Q_VALUE return flag is set and the computationally
23+
intensive checks are skipped.
24+
25+
(CVE-2023-3817)
26+
[Tomáš Mráz]
27+
28+
*) Fix DH_check() excessive time with over sized modulus
29+
30+
The function DH_check() performs various checks on DH parameters. One of
31+
those checks confirms that the modulus ("p" parameter) is not too large.
32+
Trying to use a very large modulus is slow and OpenSSL will not normally use
33+
a modulus which is over 10,000 bits in length.
34+
35+
However the DH_check() function checks numerous aspects of the key or
36+
parameters that have been supplied. Some of those checks use the supplied
37+
modulus value even if it has already been found to be too large.
38+
39+
A new limit has been added to DH_check of 32,768 bits. Supplying a
40+
key/parameters with a modulus over this size will simply cause DH_check()
41+
to fail.
42+
(CVE-2023-3446)
43+
[Matt Caswell]
44+
1045
Changes between 1.1.1t and 1.1.1u [30 May 2023]
1146

1247
*) Mitigate for the time it takes for `OBJ_obj2txt` to translate gigantic

deps/openssl/openssl/NEWS

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
This file gives a brief overview of the major changes between each OpenSSL
66
release. For more details please read the CHANGES file.
77

8+
Major changes between OpenSSL 1.1.1u and OpenSSL 1.1.1v [1 Aug 2023]
9+
10+
o Fix excessive time spent checking DH q parameter value (CVE-2023-3817)
11+
o Fix DH_check() excessive time with over sized modulus (CVE-2023-3446)
12+
813
Major changes between OpenSSL 1.1.1t and OpenSSL 1.1.1u [30 May 2023]
914

1015
o Mitigate for very slow `OBJ_obj2txt()` performance with gigantic

deps/openssl/openssl/README-OpenSSL.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
OpenSSL 1.1.1u 30 May 2023
2+
OpenSSL 1.1.1v 1 Aug 2023
33

44
Copyright (c) 1998-2023 The OpenSSL Project
55
Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson

deps/openssl/openssl/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ What This Is
44
This is a fork of [OpenSSL](https://www.openssl.org) to enable QUIC. In addition
55
to the website, the official source distribution is at
66
<https://github.com/openssl/openssl>. The OpenSSL `README` can be found at
7-
[README-OpenSSL.md](https://github.com/quictls/openssl/blob/OpenSSL_1_1_1u%2Bquic/README-OpenSSL.md).
7+
[README-OpenSSL.md](https://github.com/quictls/openssl/blob/OpenSSL_1_1_1v%2Bquic/README-OpenSSL.md).
88

99
This fork adds APIs that can be used by QUIC implementations for connection
1010
handshakes. Quoting the IETF Working group

deps/openssl/openssl/crypto/dh/dh_check.c

+17-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
2+
* Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved.
33
*
44
* Licensed under the OpenSSL license (the "License"). You may not use
55
* this file except in compliance with the License. You can obtain a copy
@@ -97,10 +97,17 @@ int DH_check_ex(const DH *dh)
9797

9898
int DH_check(const DH *dh, int *ret)
9999
{
100-
int ok = 0, r;
100+
int ok = 0, r, q_good = 0;
101101
BN_CTX *ctx = NULL;
102102
BIGNUM *t1 = NULL, *t2 = NULL;
103103

104+
/* Don't do any checks at all with an excessively large modulus */
105+
if (BN_num_bits(dh->p) > OPENSSL_DH_CHECK_MAX_MODULUS_BITS) {
106+
DHerr(DH_F_DH_CHECK, DH_R_MODULUS_TOO_LARGE);
107+
*ret = DH_CHECK_P_NOT_PRIME;
108+
return 0;
109+
}
110+
104111
if (!DH_check_params(dh, ret))
105112
return 0;
106113

@@ -113,7 +120,14 @@ int DH_check(const DH *dh, int *ret)
113120
if (t2 == NULL)
114121
goto err;
115122

116-
if (dh->q) {
123+
if (dh->q != NULL) {
124+
if (BN_ucmp(dh->p, dh->q) > 0)
125+
q_good = 1;
126+
else
127+
*ret |= DH_CHECK_INVALID_Q_VALUE;
128+
}
129+
130+
if (q_good) {
117131
if (BN_cmp(dh->g, BN_value_one()) <= 0)
118132
*ret |= DH_NOT_SUITABLE_GENERATOR;
119133
else if (BN_cmp(dh->g, dh->p) >= 0)

deps/openssl/openssl/crypto/dh/dh_err.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Generated by util/mkerr.pl DO NOT EDIT
3-
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
3+
* Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved.
44
*
55
* Licensed under the OpenSSL license (the "License"). You may not use
66
* this file except in compliance with the License. You can obtain a copy
@@ -18,6 +18,7 @@ static const ERR_STRING_DATA DH_str_functs[] = {
1818
{ERR_PACK(ERR_LIB_DH, DH_F_DHPARAMS_PRINT_FP, 0), "DHparams_print_fp"},
1919
{ERR_PACK(ERR_LIB_DH, DH_F_DH_BUILTIN_GENPARAMS, 0),
2020
"dh_builtin_genparams"},
21+
{ERR_PACK(ERR_LIB_DH, DH_F_DH_CHECK, 0), "DH_check"},
2122
{ERR_PACK(ERR_LIB_DH, DH_F_DH_CHECK_EX, 0), "DH_check_ex"},
2223
{ERR_PACK(ERR_LIB_DH, DH_F_DH_CHECK_PARAMS_EX, 0), "DH_check_params_ex"},
2324
{ERR_PACK(ERR_LIB_DH, DH_F_DH_CHECK_PUB_KEY_EX, 0), "DH_check_pub_key_ex"},

deps/openssl/openssl/crypto/err/openssl.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 1999-2021 The OpenSSL Project Authors. All Rights Reserved.
1+
# Copyright 1999-2023 The OpenSSL Project Authors. All Rights Reserved.
22
#
33
# Licensed under the OpenSSL license (the "License"). You may not use
44
# this file except in compliance with the License. You can obtain a copy
@@ -401,6 +401,7 @@ CT_F_SCT_SET_VERSION:104:SCT_set_version
401401
DH_F_COMPUTE_KEY:102:compute_key
402402
DH_F_DHPARAMS_PRINT_FP:101:DHparams_print_fp
403403
DH_F_DH_BUILTIN_GENPARAMS:106:dh_builtin_genparams
404+
DH_F_DH_CHECK:126:DH_check
404405
DH_F_DH_CHECK_EX:121:DH_check_ex
405406
DH_F_DH_CHECK_PARAMS_EX:122:DH_check_params_ex
406407
DH_F_DH_CHECK_PUB_KEY_EX:123:DH_check_pub_key_ex

deps/openssl/openssl/include/crypto/bn_conf.h

-1
This file was deleted.

deps/openssl/openssl/include/crypto/dso_conf.h

-1
This file was deleted.

deps/openssl/openssl/include/openssl/dh.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
2+
* Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved.
33
*
44
* Licensed under the OpenSSL license (the "License"). You may not use
55
* this file except in compliance with the License. You can obtain a copy
@@ -29,6 +29,9 @@ extern "C" {
2929
# ifndef OPENSSL_DH_MAX_MODULUS_BITS
3030
# define OPENSSL_DH_MAX_MODULUS_BITS 10000
3131
# endif
32+
# ifndef OPENSSL_DH_CHECK_MAX_MODULUS_BITS
33+
# define OPENSSL_DH_CHECK_MAX_MODULUS_BITS 32768
34+
# endif
3235

3336
# define OPENSSL_DH_FIPS_MIN_MODULUS_BITS 1024
3437

deps/openssl/openssl/include/openssl/dherr.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Generated by util/mkerr.pl DO NOT EDIT
3-
* Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
3+
* Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved.
44
*
55
* Licensed under the OpenSSL license (the "License"). You may not use
66
* this file except in compliance with the License. You can obtain a copy
@@ -30,6 +30,7 @@ int ERR_load_DH_strings(void);
3030
# define DH_F_COMPUTE_KEY 102
3131
# define DH_F_DHPARAMS_PRINT_FP 101
3232
# define DH_F_DH_BUILTIN_GENPARAMS 106
33+
# define DH_F_DH_CHECK 126
3334
# define DH_F_DH_CHECK_EX 121
3435
# define DH_F_DH_CHECK_PARAMS_EX 122
3536
# define DH_F_DH_CHECK_PUB_KEY_EX 123

deps/openssl/openssl/include/openssl/opensslconf.h

-1
This file was deleted.

deps/openssl/openssl/include/openssl/opensslv.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ extern "C" {
3939
* (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for
4040
* major minor fix final patch/beta)
4141
*/
42-
# define OPENSSL_VERSION_NUMBER 0x1010115fL
43-
# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1u+quic 30 May 2023"
42+
# define OPENSSL_VERSION_NUMBER 0x1010116fL
43+
# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1v+quic 1 Aug 2023"
4444

4545
/*-
4646
* The macros below are to be used for shared library (.so, .dll, ...)

deps/openssl/openssl/test/dhtest.c

+26-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
2+
* Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved.
33
*
44
* Licensed under the OpenSSL license (the "License"). You may not use
55
* this file except in compliance with the License. You can obtain a copy
@@ -63,7 +63,7 @@ static int dh_test(void)
6363
|| !TEST_true(DH_set0_pqg(dh, p, q, g)))
6464
goto err1;
6565

66-
if (!DH_check(dh, &i))
66+
if (!TEST_true(DH_check(dh, &i)))
6767
goto err2;
6868
if (!TEST_false(i & DH_CHECK_P_NOT_PRIME)
6969
|| !TEST_false(i & DH_CHECK_P_NOT_SAFE_PRIME)
@@ -123,6 +123,29 @@ static int dh_test(void)
123123
/* check whether the public key was calculated correctly */
124124
TEST_uint_eq(BN_get_word(pub_key2), 3331L);
125125

126+
if (!TEST_ptr(BN_copy(q, p)) || !TEST_true(BN_add(q, q, BN_value_one())))
127+
goto err3;
128+
129+
if (!TEST_true(DH_check(dh, &i)))
130+
goto err3;
131+
if (!TEST_true(i & DH_CHECK_INVALID_Q_VALUE)
132+
|| !TEST_false(i & DH_CHECK_Q_NOT_PRIME))
133+
goto err3;
134+
135+
/* Modulus of size: dh check max modulus bits + 1 */
136+
if (!TEST_true(BN_set_word(p, 1))
137+
|| !TEST_true(BN_lshift(p, p, OPENSSL_DH_CHECK_MAX_MODULUS_BITS)))
138+
goto err3;
139+
140+
/*
141+
* We expect no checks at all for an excessively large modulus
142+
*/
143+
if (!TEST_false(DH_check(dh, &i)))
144+
goto err3;
145+
146+
/* We'll have a stale error on the queue from the above test so clear it */
147+
ERR_clear_error();
148+
126149
/*
127150
* II) key generation
128151
*/
@@ -137,7 +160,7 @@ static int dh_test(void)
137160
goto err3;
138161

139162
/* ... and check whether it is valid */
140-
if (!DH_check(a, &i))
163+
if (!TEST_true(DH_check(a, &i)))
141164
goto err3;
142165
if (!TEST_false(i & DH_CHECK_P_NOT_PRIME)
143166
|| !TEST_false(i & DH_CHECK_P_NOT_SAFE_PRIME)

0 commit comments

Comments
 (0)