Skip to content

Commit c85a519

Browse files
tniessenMylesBorins
authored andcommittedApr 4, 2021
deps: upgrade openssl sources to 1.1.1k
This updates all sources in deps/openssl/openssl by: $ cd deps/openssl/ $ rm -rf openssl $ tar zxf ~/tmp/openssl-1.1.1k.tar.gz $ mv openssl-1.1.1k openssl $ git add --all openssl $ git commit openssl PR-URL: #37939 Refs: #37913 Refs: #37916 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
1 parent 7d488fe commit c85a519

32 files changed

+254
-66
lines changed
 

Diff for: ‎deps/openssl/openssl/CHANGES

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

10+
Changes between 1.1.1j and 1.1.1k [25 Mar 2021]
11+
12+
*) Fixed a problem with verifying a certificate chain when using the
13+
X509_V_FLAG_X509_STRICT flag. This flag enables additional security checks
14+
of the certificates present in a certificate chain. It is not set by
15+
default.
16+
17+
Starting from OpenSSL version 1.1.1h a check to disallow certificates in
18+
the chain that have explicitly encoded elliptic curve parameters was added
19+
as an additional strict check.
20+
21+
An error in the implementation of this check meant that the result of a
22+
previous check to confirm that certificates in the chain are valid CA
23+
certificates was overwritten. This effectively bypasses the check
24+
that non-CA certificates must not be able to issue other certificates.
25+
26+
If a "purpose" has been configured then there is a subsequent opportunity
27+
for checks that the certificate is a valid CA. All of the named "purpose"
28+
values implemented in libcrypto perform this check. Therefore, where
29+
a purpose is set the certificate chain will still be rejected even when the
30+
strict flag has been used. A purpose is set by default in libssl client and
31+
server certificate verification routines, but it can be overridden or
32+
removed by an application.
33+
34+
In order to be affected, an application must explicitly set the
35+
X509_V_FLAG_X509_STRICT verification flag and either not set a purpose
36+
for the certificate verification or, in the case of TLS client or server
37+
applications, override the default purpose.
38+
(CVE-2021-3450)
39+
[Tomáš Mráz]
40+
41+
*) Fixed an issue where an OpenSSL TLS server may crash if sent a maliciously
42+
crafted renegotiation ClientHello message from a client. If a TLSv1.2
43+
renegotiation ClientHello omits the signature_algorithms extension (where
44+
it was present in the initial ClientHello), but includes a
45+
signature_algorithms_cert extension then a NULL pointer dereference will
46+
result, leading to a crash and a denial of service attack.
47+
48+
A server is only vulnerable if it has TLSv1.2 and renegotiation enabled
49+
(which is the default configuration). OpenSSL TLS clients are not impacted
50+
by this issue.
51+
(CVE-2021-3449)
52+
[Peter Kästle and Samuel Sapalski]
53+
1054
Changes between 1.1.1i and 1.1.1j [16 Feb 2021]
1155

1256
*) Fixed the X509_issuer_and_serial_hash() function. It attempts to

Diff for: ‎deps/openssl/openssl/Configurations/unix-Makefile.tmpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -917,8 +917,8 @@ errors:
917917
done )
918918

919919
ordinals:
920-
( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl crypto update )
921-
( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl ssl update )
920+
$(PERL) $(SRCDIR)/util/mkdef.pl crypto update
921+
$(PERL) $(SRCDIR)/util/mkdef.pl ssl update
922922

923923
test_ordinals:
924924
( cd test; \

Diff for: ‎deps/openssl/openssl/NEWS

+8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
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.1j and OpenSSL 1.1.1k [25 Mar 2021]
9+
10+
o Fixed a problem with verifying a certificate chain when using the
11+
X509_V_FLAG_X509_STRICT flag (CVE-2021-3450)
12+
o Fixed an issue where an OpenSSL TLS server may crash if sent a
13+
maliciously crafted renegotiation ClientHello message from a client
14+
(CVE-2021-3449)
15+
816
Major changes between OpenSSL 1.1.1i and OpenSSL 1.1.1j [16 Feb 2021]
917

1018
o Fixed a NULL pointer deref in the X509_issuer_and_serial_hash()

Diff for: ‎deps/openssl/openssl/README

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

2-
OpenSSL 1.1.1j 16 Feb 2021
2+
OpenSSL 1.1.1k 25 Mar 2021
33

4-
Copyright (c) 1998-2020 The OpenSSL Project
4+
Copyright (c) 1998-2021 The OpenSSL Project
55
Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson
66
All rights reserved.
77

Diff for: ‎deps/openssl/openssl/apps/s_cb.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
2+
* Copyright 1995-2021 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
@@ -934,7 +934,8 @@ static int set_cert_cb(SSL *ssl, void *arg)
934934
if (!SSL_build_cert_chain(ssl, 0))
935935
return 0;
936936
} else if (exc->chain != NULL) {
937-
SSL_set1_chain(ssl, exc->chain);
937+
if (!SSL_set1_chain(ssl, exc->chain))
938+
return 0;
938939
}
939940
}
940941
exc = exc->prev;

Diff for: ‎deps/openssl/openssl/apps/s_time.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
2+
* Copyright 1995-2021 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
@@ -263,7 +263,8 @@ int s_time_main(int argc, char **argv)
263263
nConn, totalTime, ((double)nConn / totalTime), bytes_read);
264264
printf
265265
("%d connections in %ld real seconds, %ld bytes read per connection\n",
266-
nConn, (long)time(NULL) - finishtime + maxtime, bytes_read / nConn);
266+
nConn, (long)time(NULL) - finishtime + maxtime,
267+
nConn > 0 ? bytes_read / nConn : 0l);
267268

268269
/*
269270
* Now loop and time connections using the same session id over and over

Diff for: ‎deps/openssl/openssl/crypto/asn1/asn1_par.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
2+
* Copyright 1995-2021 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
@@ -325,6 +325,7 @@ static int asn1_parse2(BIO *bp, const unsigned char **pp, long length,
325325
}
326326
if (BIO_puts(bp, "]") <= 0)
327327
goto end;
328+
dump_cont = 0;
328329
}
329330

330331
if (!nl) {

Diff for: ‎deps/openssl/openssl/crypto/asn1/bio_ndef.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2008-2018 The OpenSSL Project Authors. All Rights Reserved.
2+
* Copyright 2008-2021 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
@@ -113,6 +113,8 @@ static int ndef_prefix(BIO *b, unsigned char **pbuf, int *plen, void *parg)
113113
ndef_aux = *(NDEF_SUPPORT **)parg;
114114

115115
derlen = ASN1_item_ndef_i2d(ndef_aux->val, NULL, ndef_aux->it);
116+
if (derlen < 0)
117+
return 0;
116118
if ((p = OPENSSL_malloc(derlen)) == NULL) {
117119
ASN1err(ASN1_F_NDEF_PREFIX, ERR_R_MALLOC_FAILURE);
118120
return 0;

Diff for: ‎deps/openssl/openssl/crypto/engine/eng_devcrypto.c

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017-2019 The OpenSSL Project Authors. All Rights Reserved.
2+
* Copyright 2017-2021 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
@@ -758,15 +758,28 @@ static int devcrypto_unload(ENGINE *e)
758758
void engine_load_devcrypto_int()
759759
{
760760
ENGINE *e = NULL;
761+
int fd;
761762

762-
if ((cfd = open("/dev/crypto", O_RDWR, 0)) < 0) {
763+
if ((fd = open("/dev/crypto", O_RDWR, 0)) < 0) {
763764
#ifndef ENGINE_DEVCRYPTO_DEBUG
764765
if (errno != ENOENT)
765766
#endif
766767
fprintf(stderr, "Could not open /dev/crypto: %s\n", strerror(errno));
767768
return;
768769
}
769770

771+
#ifdef CRIOGET
772+
if (ioctl(fd, CRIOGET, &cfd) < 0) {
773+
fprintf(stderr, "Could not create crypto fd: %s\n", strerror(errno));
774+
close(fd);
775+
cfd = -1;
776+
return;
777+
}
778+
close(fd);
779+
#else
780+
cfd = fd;
781+
#endif
782+
770783
if ((e = ENGINE_new()) == NULL
771784
|| !ENGINE_set_destroy_function(e, devcrypto_unload)) {
772785
ENGINE_free(e);

Diff for: ‎deps/openssl/openssl/crypto/evp/evp_enc.c

+1-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-2021 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

Diff for: ‎deps/openssl/openssl/crypto/modes/cbc128.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2008-2020 The OpenSSL Project Authors. All Rights Reserved.
2+
* Copyright 2008-2021 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
@@ -69,7 +69,8 @@ void CRYPTO_cbc128_encrypt(const unsigned char *in, unsigned char *out,
6969
in += 16;
7070
out += 16;
7171
}
72-
memcpy(ivec, iv, 16);
72+
if (ivec != iv)
73+
memcpy(ivec, iv, 16);
7374
}
7475

7576
void CRYPTO_cbc128_decrypt(const unsigned char *in, unsigned char *out,
@@ -114,7 +115,8 @@ void CRYPTO_cbc128_decrypt(const unsigned char *in, unsigned char *out,
114115
out += 16;
115116
}
116117
}
117-
memcpy(ivec, iv, 16);
118+
if (ivec != iv)
119+
memcpy(ivec, iv, 16);
118120
} else {
119121
if (STRICT_ALIGNMENT &&
120122
((size_t)in | (size_t)out | (size_t)ivec) % sizeof(size_t) != 0) {

Diff for: ‎deps/openssl/openssl/crypto/modes/gcm128.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2010-2020 The OpenSSL Project Authors. All Rights Reserved.
2+
* Copyright 2010-2021 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
@@ -1385,8 +1385,8 @@ int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx,
13851385
else
13861386
ctx->Yi.d[3] = ctr;
13871387
for (i = 0; i < 16 / sizeof(size_t); ++i) {
1388-
size_t c = in[i];
1389-
out[i] = c ^ ctx->EKi.t[i];
1388+
size_t c = in_t[i];
1389+
out_t[i] = c ^ ctx->EKi.t[i];
13901390
ctx->Xi.t[i] ^= c;
13911391
}
13921392
GCM_MUL(ctx);

Diff for: ‎deps/openssl/openssl/crypto/o_time.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2001-2020 The OpenSSL Project Authors. All Rights Reserved.
2+
* Copyright 2001-2021 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
@@ -133,8 +133,8 @@ int OPENSSL_gmtime_diff(int *pday, int *psec,
133133
static int julian_adj(const struct tm *tm, int off_day, long offset_sec,
134134
long *pday, int *psec)
135135
{
136-
int offset_hms, offset_day;
137-
long time_jd;
136+
int offset_hms;
137+
long offset_day, time_jd;
138138
int time_year, time_month, time_day;
139139
/* split offset into days and day seconds */
140140
offset_day = offset_sec / SECS_PER_DAY;

Diff for: ‎deps/openssl/openssl/crypto/rand/rand_lib.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
2+
* Copyright 1995-2021 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
@@ -432,9 +432,13 @@ int RAND_poll(void)
432432
RAND_POOL *rand_pool_new(int entropy_requested, int secure,
433433
size_t min_len, size_t max_len)
434434
{
435-
RAND_POOL *pool = OPENSSL_zalloc(sizeof(*pool));
435+
RAND_POOL *pool;
436436
size_t min_alloc_size = RAND_POOL_MIN_ALLOCATION(secure);
437437

438+
if (!RUN_ONCE(&rand_init, do_rand_init))
439+
return NULL;
440+
441+
pool = OPENSSL_zalloc(sizeof(*pool));
438442
if (pool == NULL) {
439443
RANDerr(RAND_F_RAND_POOL_NEW, ERR_R_MALLOC_FAILURE);
440444
return NULL;

Diff for: ‎deps/openssl/openssl/crypto/rsa/rsa_ssl.c

+1-1
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-2021 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

Diff for: ‎deps/openssl/openssl/crypto/x509/x509_vfy.c

+8-4
Original file line numberDiff line numberDiff line change
@@ -524,15 +524,19 @@ static int check_chain_extensions(X509_STORE_CTX *ctx)
524524
ret = 1;
525525
break;
526526
}
527-
if ((ctx->param->flags & X509_V_FLAG_X509_STRICT) && num > 1) {
527+
if (ret > 0
528+
&& (ctx->param->flags & X509_V_FLAG_X509_STRICT) && num > 1) {
528529
/* Check for presence of explicit elliptic curve parameters */
529530
ret = check_curve(x);
530-
if (ret < 0)
531+
if (ret < 0) {
531532
ctx->error = X509_V_ERR_UNSPECIFIED;
532-
else if (ret == 0)
533+
ret = 0;
534+
} else if (ret == 0) {
533535
ctx->error = X509_V_ERR_EC_KEY_EXPLICIT_PARAMS;
536+
}
534537
}
535-
if ((x->ex_flags & EXFLAG_CA) == 0
538+
if (ret > 0
539+
&& (x->ex_flags & EXFLAG_CA) == 0
536540
&& x->ex_pathlen != -1
537541
&& (ctx->param->flags & X509_V_FLAG_X509_STRICT)) {
538542
ctx->error = X509_V_ERR_INVALID_EXTENSION;

Diff for: ‎deps/openssl/openssl/fuzz/x509.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
2+
* Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved.
33
*
44
* Licensed under the OpenSSL licenses, (the "License");
55
* you may not use this file except in compliance with the License.

Diff for: ‎deps/openssl/openssl/include/crypto/bn_conf.h

-1
This file was deleted.

Diff for: ‎deps/openssl/openssl/include/crypto/dso_conf.h

-1
This file was deleted.

Diff for: ‎deps/openssl/openssl/include/openssl/opensslconf.h

-1
This file was deleted.

Diff for: ‎deps/openssl/openssl/include/openssl/opensslv.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 1999-2020 The OpenSSL Project Authors. All Rights Reserved.
2+
* Copyright 1999-2021 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
@@ -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 0x101010afL
43-
# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1j 16 Feb 2021"
42+
# define OPENSSL_VERSION_NUMBER 0x101010bfL
43+
# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1k 25 Mar 2021"
4444

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

Diff for: ‎deps/openssl/openssl/ssl/s3_lib.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
2+
* Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
33
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
44
* Copyright 2005 Nokia. All rights reserved.
55
*
@@ -4629,6 +4629,7 @@ int ssl_generate_master_secret(SSL *s, unsigned char *pms, size_t pmslen,
46294629

46304630
OPENSSL_clear_free(s->s3->tmp.psk, psklen);
46314631
s->s3->tmp.psk = NULL;
4632+
s->s3->tmp.psklen = 0;
46324633
if (!s->method->ssl3_enc->generate_master_secret(s,
46334634
s->session->master_key, pskpms, pskpmslen,
46344635
&s->session->master_key_length)) {
@@ -4658,8 +4659,10 @@ int ssl_generate_master_secret(SSL *s, unsigned char *pms, size_t pmslen,
46584659
else
46594660
OPENSSL_cleanse(pms, pmslen);
46604661
}
4661-
if (s->server == 0)
4662+
if (s->server == 0) {
46624663
s->s3->tmp.pms = NULL;
4664+
s->s3->tmp.pmslen = 0;
4665+
}
46634666
return ret;
46644667
}
46654668

Diff for: ‎deps/openssl/openssl/ssl/ssl_lib.c

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
2+
* Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
33
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
44
* Copyright 2005 Nokia. All rights reserved.
55
*
@@ -779,8 +779,10 @@ SSL *SSL_new(SSL_CTX *ctx)
779779
s->ext.ecpointformats =
780780
OPENSSL_memdup(ctx->ext.ecpointformats,
781781
ctx->ext.ecpointformats_len);
782-
if (!s->ext.ecpointformats)
782+
if (!s->ext.ecpointformats) {
783+
s->ext.ecpointformats_len = 0;
783784
goto err;
785+
}
784786
s->ext.ecpointformats_len =
785787
ctx->ext.ecpointformats_len;
786788
}
@@ -789,8 +791,10 @@ SSL *SSL_new(SSL_CTX *ctx)
789791
OPENSSL_memdup(ctx->ext.supportedgroups,
790792
ctx->ext.supportedgroups_len
791793
* sizeof(*ctx->ext.supportedgroups));
792-
if (!s->ext.supportedgroups)
794+
if (!s->ext.supportedgroups) {
795+
s->ext.supportedgroups_len = 0;
793796
goto err;
797+
}
794798
s->ext.supportedgroups_len = ctx->ext.supportedgroups_len;
795799
}
796800
#endif
@@ -800,8 +804,10 @@ SSL *SSL_new(SSL_CTX *ctx)
800804

801805
if (s->ctx->ext.alpn) {
802806
s->ext.alpn = OPENSSL_malloc(s->ctx->ext.alpn_len);
803-
if (s->ext.alpn == NULL)
807+
if (s->ext.alpn == NULL) {
808+
s->ext.alpn_len = 0;
804809
goto err;
810+
}
805811
memcpy(s->ext.alpn, s->ctx->ext.alpn, s->ctx->ext.alpn_len);
806812
s->ext.alpn_len = s->ctx->ext.alpn_len;
807813
}
@@ -2834,6 +2840,7 @@ int SSL_CTX_set_alpn_protos(SSL_CTX *ctx, const unsigned char *protos,
28342840
OPENSSL_free(ctx->ext.alpn);
28352841
ctx->ext.alpn = OPENSSL_memdup(protos, protos_len);
28362842
if (ctx->ext.alpn == NULL) {
2843+
ctx->ext.alpn_len = 0;
28372844
SSLerr(SSL_F_SSL_CTX_SET_ALPN_PROTOS, ERR_R_MALLOC_FAILURE);
28382845
return 1;
28392846
}
@@ -2853,6 +2860,7 @@ int SSL_set_alpn_protos(SSL *ssl, const unsigned char *protos,
28532860
OPENSSL_free(ssl->ext.alpn);
28542861
ssl->ext.alpn = OPENSSL_memdup(protos, protos_len);
28552862
if (ssl->ext.alpn == NULL) {
2863+
ssl->ext.alpn_len = 0;
28562864
SSLerr(SSL_F_SSL_SET_ALPN_PROTOS, ERR_R_MALLOC_FAILURE);
28572865
return 1;
28582866
}

Diff for: ‎deps/openssl/openssl/ssl/statem/extensions.c

+4
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,8 @@ static const EXTENSION_DEFINITION ext_defs[] = {
336336
tls_construct_stoc_key_share, tls_construct_ctos_key_share,
337337
final_key_share
338338
},
339+
#else
340+
INVALID_EXTENSION,
339341
#endif
340342
{
341343
/* Must be after key_share */
@@ -1137,6 +1139,7 @@ static int init_sig_algs(SSL *s, unsigned int context)
11371139
/* Clear any signature algorithms extension received */
11381140
OPENSSL_free(s->s3->tmp.peer_sigalgs);
11391141
s->s3->tmp.peer_sigalgs = NULL;
1142+
s->s3->tmp.peer_sigalgslen = 0;
11401143

11411144
return 1;
11421145
}
@@ -1146,6 +1149,7 @@ static int init_sig_algs_cert(SSL *s, unsigned int context)
11461149
/* Clear any signature algorithms extension received */
11471150
OPENSSL_free(s->s3->tmp.peer_cert_sigalgs);
11481151
s->s3->tmp.peer_cert_sigalgs = NULL;
1152+
s->s3->tmp.peer_cert_sigalgslen = 0;
11491153

11501154
return 1;
11511155
}

Diff for: ‎deps/openssl/openssl/ssl/statem/extensions_clnt.c

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2019 The OpenSSL Project Authors. All Rights Reserved.
2+
* Copyright 2016-2021 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
@@ -816,6 +816,7 @@ EXT_RETURN tls_construct_ctos_early_data(SSL *s, WPACKET *pkt,
816816
OPENSSL_free(s->psksession_id);
817817
s->psksession_id = OPENSSL_memdup(id, idlen);
818818
if (s->psksession_id == NULL) {
819+
s->psksession_id_len = 0;
819820
SSLfatal(s, SSL_AD_INTERNAL_ERROR,
820821
SSL_F_TLS_CONSTRUCT_CTOS_EARLY_DATA, ERR_R_INTERNAL_ERROR);
821822
return EXT_RETURN_FAIL;
@@ -1375,6 +1376,7 @@ int tls_parse_stoc_ec_pt_formats(SSL *s, PACKET *pkt, unsigned int context,
13751376
OPENSSL_free(s->ext.peer_ecpointformats);
13761377
s->ext.peer_ecpointformats = OPENSSL_malloc(ecpointformats_len);
13771378
if (s->ext.peer_ecpointformats == NULL) {
1379+
s->ext.peer_ecpointformats_len = 0;
13781380
SSLfatal(s, SSL_AD_INTERNAL_ERROR,
13791381
SSL_F_TLS_PARSE_STOC_EC_PT_FORMATS, ERR_R_INTERNAL_ERROR);
13801382
return 0;
@@ -1492,8 +1494,13 @@ int tls_parse_stoc_sct(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
14921494
s->ext.scts_len = (uint16_t)size;
14931495
if (size > 0) {
14941496
s->ext.scts = OPENSSL_malloc(size);
1495-
if (s->ext.scts == NULL
1496-
|| !PACKET_copy_bytes(pkt, s->ext.scts, size)) {
1497+
if (s->ext.scts == NULL) {
1498+
s->ext.scts_len = 0;
1499+
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PARSE_STOC_SCT,
1500+
ERR_R_MALLOC_FAILURE);
1501+
return 0;
1502+
}
1503+
if (!PACKET_copy_bytes(pkt, s->ext.scts, size)) {
14971504
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PARSE_STOC_SCT,
14981505
ERR_R_INTERNAL_ERROR);
14991506
return 0;
@@ -1592,6 +1599,7 @@ int tls_parse_stoc_npn(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
15921599
OPENSSL_free(s->ext.npn);
15931600
s->ext.npn = OPENSSL_malloc(selected_len);
15941601
if (s->ext.npn == NULL) {
1602+
s->ext.npn_len = 0;
15951603
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PARSE_STOC_NPN,
15961604
ERR_R_INTERNAL_ERROR);
15971605
return 0;
@@ -1632,6 +1640,7 @@ int tls_parse_stoc_alpn(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
16321640
OPENSSL_free(s->s3->alpn_selected);
16331641
s->s3->alpn_selected = OPENSSL_malloc(len);
16341642
if (s->s3->alpn_selected == NULL) {
1643+
s->s3->alpn_selected_len = 0;
16351644
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PARSE_STOC_ALPN,
16361645
ERR_R_INTERNAL_ERROR);
16371646
return 0;
@@ -1663,6 +1672,7 @@ int tls_parse_stoc_alpn(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
16631672
s->session->ext.alpn_selected =
16641673
OPENSSL_memdup(s->s3->alpn_selected, s->s3->alpn_selected_len);
16651674
if (s->session->ext.alpn_selected == NULL) {
1675+
s->session->ext.alpn_selected_len = 0;
16661676
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PARSE_STOC_ALPN,
16671677
ERR_R_INTERNAL_ERROR);
16681678
return 0;

Diff for: ‎deps/openssl/openssl/ssl/statem/statem_clnt.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -2462,6 +2462,7 @@ MSG_PROCESS_RETURN tls_process_certificate_request(SSL *s, PACKET *pkt)
24622462
s->s3->tmp.ctype_len = 0;
24632463
OPENSSL_free(s->pha_context);
24642464
s->pha_context = NULL;
2465+
s->pha_context_len = 0;
24652466

24662467
if (!PACKET_get_length_prefixed_1(pkt, &reqctx) ||
24672468
!PACKET_memdup(&reqctx, &s->pha_context, &s->pha_context_len)) {
@@ -2771,16 +2772,17 @@ int tls_process_cert_status_body(SSL *s, PACKET *pkt)
27712772
}
27722773
s->ext.ocsp.resp = OPENSSL_malloc(resplen);
27732774
if (s->ext.ocsp.resp == NULL) {
2775+
s->ext.ocsp.resp_len = 0;
27742776
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PROCESS_CERT_STATUS_BODY,
27752777
ERR_R_MALLOC_FAILURE);
27762778
return 0;
27772779
}
2780+
s->ext.ocsp.resp_len = resplen;
27782781
if (!PACKET_copy_bytes(pkt, s->ext.ocsp.resp, resplen)) {
27792782
SSLfatal(s, SSL_AD_DECODE_ERROR, SSL_F_TLS_PROCESS_CERT_STATUS_BODY,
27802783
SSL_R_LENGTH_MISMATCH);
27812784
return 0;
27822785
}
2783-
s->ext.ocsp.resp_len = resplen;
27842786

27852787
return 1;
27862788
}
@@ -2905,6 +2907,7 @@ static int tls_construct_cke_psk_preamble(SSL *s, WPACKET *pkt)
29052907
if (psklen > PSK_MAX_PSK_LEN) {
29062908
SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE,
29072909
SSL_F_TLS_CONSTRUCT_CKE_PSK_PREAMBLE, ERR_R_INTERNAL_ERROR);
2910+
psklen = PSK_MAX_PSK_LEN; /* Avoid overrunning the array on cleanse */
29082911
goto err;
29092912
} else if (psklen == 0) {
29102913
SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE,
@@ -3350,9 +3353,11 @@ int tls_construct_client_key_exchange(SSL *s, WPACKET *pkt)
33503353
err:
33513354
OPENSSL_clear_free(s->s3->tmp.pms, s->s3->tmp.pmslen);
33523355
s->s3->tmp.pms = NULL;
3356+
s->s3->tmp.pmslen = 0;
33533357
#ifndef OPENSSL_NO_PSK
33543358
OPENSSL_clear_free(s->s3->tmp.psk, s->s3->tmp.psklen);
33553359
s->s3->tmp.psk = NULL;
3360+
s->s3->tmp.psklen = 0;
33563361
#endif
33573362
return 0;
33583363
}
@@ -3427,6 +3432,7 @@ int tls_client_key_exchange_post_work(SSL *s)
34273432
err:
34283433
OPENSSL_clear_free(pms, pmslen);
34293434
s->s3->tmp.pms = NULL;
3435+
s->s3->tmp.pmslen = 0;
34303436
return 0;
34313437
}
34323438

Diff for: ‎deps/openssl/openssl/ssl/statem/statem_srvr.c

+15-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
2+
* Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
33
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
44
* Copyright 2005 Nokia. All rights reserved.
55
*
@@ -2178,6 +2178,7 @@ int tls_handle_alpn(SSL *s)
21782178
OPENSSL_free(s->s3->alpn_selected);
21792179
s->s3->alpn_selected = OPENSSL_memdup(selected, selected_len);
21802180
if (s->s3->alpn_selected == NULL) {
2181+
s->s3->alpn_selected_len = 0;
21812182
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_HANDLE_ALPN,
21822183
ERR_R_INTERNAL_ERROR);
21832184
return 0;
@@ -2853,9 +2854,16 @@ int tls_construct_certificate_request(SSL *s, WPACKET *pkt)
28532854
if (s->post_handshake_auth == SSL_PHA_REQUEST_PENDING) {
28542855
OPENSSL_free(s->pha_context);
28552856
s->pha_context_len = 32;
2856-
if ((s->pha_context = OPENSSL_malloc(s->pha_context_len)) == NULL
2857-
|| RAND_bytes(s->pha_context, s->pha_context_len) <= 0
2858-
|| !WPACKET_sub_memcpy_u8(pkt, s->pha_context, s->pha_context_len)) {
2857+
if ((s->pha_context = OPENSSL_malloc(s->pha_context_len)) == NULL) {
2858+
s->pha_context_len = 0;
2859+
SSLfatal(s, SSL_AD_INTERNAL_ERROR,
2860+
SSL_F_TLS_CONSTRUCT_CERTIFICATE_REQUEST,
2861+
ERR_R_INTERNAL_ERROR);
2862+
return 0;
2863+
}
2864+
if (RAND_bytes(s->pha_context, s->pha_context_len) <= 0
2865+
|| !WPACKET_sub_memcpy_u8(pkt, s->pha_context,
2866+
s->pha_context_len)) {
28592867
SSLfatal(s, SSL_AD_INTERNAL_ERROR,
28602868
SSL_F_TLS_CONSTRUCT_CERTIFICATE_REQUEST,
28612869
ERR_R_INTERNAL_ERROR);
@@ -2969,6 +2977,7 @@ static int tls_process_cke_psk_preamble(SSL *s, PACKET *pkt)
29692977
OPENSSL_cleanse(psk, psklen);
29702978

29712979
if (s->s3->tmp.psk == NULL) {
2980+
s->s3->tmp.psklen = 0;
29722981
SSLfatal(s, SSL_AD_INTERNAL_ERROR,
29732982
SSL_F_TLS_PROCESS_CKE_PSK_PREAMBLE, ERR_R_MALLOC_FAILURE);
29742983
return 0;
@@ -3508,6 +3517,7 @@ MSG_PROCESS_RETURN tls_process_client_key_exchange(SSL *s, PACKET *pkt)
35083517
#ifndef OPENSSL_NO_PSK
35093518
OPENSSL_clear_free(s->s3->tmp.psk, s->s3->tmp.psklen);
35103519
s->s3->tmp.psk = NULL;
3520+
s->s3->tmp.psklen = 0;
35113521
#endif
35123522
return MSG_PROCESS_ERROR;
35133523
}
@@ -4117,6 +4127,7 @@ int tls_construct_new_session_ticket(SSL *s, WPACKET *pkt)
41174127
s->session->ext.alpn_selected =
41184128
OPENSSL_memdup(s->s3->alpn_selected, s->s3->alpn_selected_len);
41194129
if (s->session->ext.alpn_selected == NULL) {
4130+
s->session->ext.alpn_selected_len = 0;
41204131
SSLfatal(s, SSL_AD_INTERNAL_ERROR,
41214132
SSL_F_TLS_CONSTRUCT_NEW_SESSION_TICKET,
41224133
ERR_R_MALLOC_FAILURE);

Diff for: ‎deps/openssl/openssl/test/recipes/70-test_renegotiation.t

+36-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#! /usr/bin/env perl
2-
# Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
2+
# Copyright 2016-2021 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
@@ -38,7 +38,7 @@ my $proxy = TLSProxy::Proxy->new(
3838
$proxy->clientflags("-no_tls1_3");
3939
$proxy->reneg(1);
4040
$proxy->start() or plan skip_all => "Unable to start up Proxy for tests";
41-
plan tests => 3;
41+
plan tests => 4;
4242
ok(TLSProxy::Message->success(), "Basic renegotiation");
4343

4444
#Test 2: Client does not send the Reneg SCSV. Reneg should fail
@@ -77,6 +77,20 @@ SKIP: {
7777
"Check ClientHello version is the same");
7878
}
7979

80+
SKIP: {
81+
skip "TLSv1.2 disabled", 1
82+
if disabled("tls1_2");
83+
84+
#Test 4: Test for CVE-2021-3449. client_sig_algs instead of sig_algs in
85+
# resumption ClientHello
86+
$proxy->clear();
87+
$proxy->filter(\&sigalgs_filter);
88+
$proxy->clientflags("-tls1_2");
89+
$proxy->reneg(1);
90+
$proxy->start();
91+
ok(TLSProxy::Message->fail(), "client_sig_algs instead of sig_algs");
92+
}
93+
8094
sub reneg_filter
8195
{
8296
my $proxy = shift;
@@ -96,3 +110,23 @@ sub reneg_filter
96110
}
97111
}
98112
}
113+
114+
sub sigalgs_filter
115+
{
116+
my $proxy = shift;
117+
my $cnt = 0;
118+
119+
# We're only interested in the second ClientHello message
120+
foreach my $message (@{$proxy->message_list}) {
121+
if ($message->mt == TLSProxy::Message::MT_CLIENT_HELLO) {
122+
next if ($cnt++ == 0);
123+
124+
my $sigs = pack "C10", 0x00, 0x08,
125+
# rsa_pkcs_sha{256,384,512,1}
126+
0x04, 0x01, 0x05, 0x01, 0x06, 0x01, 0x02, 0x01;
127+
$message->set_extension(TLSProxy::Message::EXT_SIG_ALGS_CERT, $sigs);
128+
$message->delete_extension(TLSProxy::Message::EXT_SIG_ALGS);
129+
$message->repack();
130+
}
131+
}
132+
}

Diff for: ‎deps/openssl/openssl/test/rsa_test.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 1999-2020 The OpenSSL Project Authors. All Rights Reserved.
2+
* Copyright 1999-2021 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
@@ -304,7 +304,7 @@ static int test_rsa_sslv23(int idx)
304304
static int test_rsa_oaep(int idx)
305305
{
306306
int ret = 0;
307-
RSA *key;
307+
RSA *key = NULL;
308308
unsigned char ptext[256];
309309
unsigned char ctext[256];
310310
static unsigned char ptext_ex[] = "\x54\x85\x9b\x34\x2c\x49\xea\x2a";

Diff for: ‎deps/openssl/openssl/test/verify_extra_test.c

+14-2
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,22 @@ static int test_alt_chains_cert_forgery(void)
140140

141141
i = X509_verify_cert(sctx);
142142

143-
if (i == 0 && X509_STORE_CTX_get_error(sctx) == X509_V_ERR_INVALID_CA) {
143+
if (i != 0 || X509_STORE_CTX_get_error(sctx) != X509_V_ERR_INVALID_CA)
144+
goto err;
145+
146+
/* repeat with X509_V_FLAG_X509_STRICT */
147+
X509_STORE_CTX_cleanup(sctx);
148+
X509_STORE_set_flags(store, X509_V_FLAG_X509_STRICT);
149+
150+
if (!X509_STORE_CTX_init(sctx, store, x, untrusted))
151+
goto err;
152+
153+
i = X509_verify_cert(sctx);
154+
155+
if (i == 0 && X509_STORE_CTX_get_error(sctx) == X509_V_ERR_INVALID_CA)
144156
/* This is the result we were expecting: Test passed */
145157
ret = 1;
146-
}
158+
147159
err:
148160
X509_STORE_CTX_free(sctx);
149161
X509_free(x);

Diff for: ‎deps/openssl/openssl/tools/c_rehash.in

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!{- $config{HASHBANGPERL} -}
22

33
# {- join("\n# ", @autowarntext) -}
4-
# Copyright 1999-2018 The OpenSSL Project Authors. All Rights Reserved.
4+
# Copyright 1999-2021 The OpenSSL Project Authors. All Rights Reserved.
55
#
66
# Licensed under the OpenSSL license (the "License"). You may not use
77
# this file except in compliance with the License. You can obtain a copy
@@ -161,7 +161,7 @@ sub check_file {
161161

162162
sub link_hash_cert {
163163
my $fname = $_[0];
164-
$fname =~ s/'/'\\''/g;
164+
$fname =~ s/\"/\\\"/g;
165165
my ($hash, $fprint) = `"$openssl" x509 $x509hash -fingerprint -noout -in "$fname"`;
166166
chomp $hash;
167167
chomp $fprint;

Diff for: ‎deps/openssl/openssl/util/perl/TLSProxy/Message.pm

+31-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2016-2019 The OpenSSL Project Authors. All Rights Reserved.
1+
# Copyright 2016-2021 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
@@ -448,7 +448,7 @@ sub ciphersuite
448448
}
449449

450450
#Update all the underlying records with the modified data from this message
451-
#Note: Only supports re-encrypting for TLSv1.3
451+
#Note: Only supports TLSv1.3 and ETM encryption
452452
sub repack
453453
{
454454
my $self = shift;
@@ -490,15 +490,38 @@ sub repack
490490
# (If a length override is ever needed to construct invalid packets,
491491
# use an explicit override field instead.)
492492
$rec->decrypt_len(length($rec->decrypt_data));
493-
$rec->len($rec->len + length($msgdata) - $old_length);
494-
# Only support re-encryption for TLSv1.3.
495-
if (TLSProxy::Proxy->is_tls13() && $rec->encrypted()) {
496-
#Add content type (1 byte) and 16 tag bytes
497-
$rec->data($rec->decrypt_data
498-
.pack("C", TLSProxy::Record::RT_HANDSHAKE).("\0"x16));
493+
# Only support re-encryption for TLSv1.3 and ETM.
494+
if ($rec->encrypted()) {
495+
if (TLSProxy::Proxy->is_tls13()) {
496+
#Add content type (1 byte) and 16 tag bytes
497+
$rec->data($rec->decrypt_data
498+
.pack("C", TLSProxy::Record::RT_HANDSHAKE).("\0"x16));
499+
} elsif ($rec->etm()) {
500+
my $data = $rec->decrypt_data;
501+
#Add padding
502+
my $padval = length($data) % 16;
503+
$padval = 15 - $padval;
504+
for (0..$padval) {
505+
$data .= pack("C", $padval);
506+
}
507+
508+
#Add MAC. Assumed to be 20 bytes
509+
foreach my $macval (0..19) {
510+
$data .= pack("C", $macval);
511+
}
512+
513+
if ($rec->version() >= TLSProxy::Record::VERS_TLS_1_1) {
514+
#Explicit IV
515+
$data = ("\0"x16).$data;
516+
}
517+
$rec->data($data);
518+
} else {
519+
die "Unsupported encryption: No ETM";
520+
}
499521
} else {
500522
$rec->data($rec->decrypt_data);
501523
}
524+
$rec->len(length($rec->data));
502525

503526
#Update the fragment len in case we changed it above
504527
${$self->message_frag_lens}[0] = length($msgdata)

0 commit comments

Comments
 (0)
Please sign in to comment.