Skip to content

Commit c47b6ad

Browse files
committed
deps: upgrade openssl sources to OpenSSL_1_1_1l
This updates all sources in deps/openssl/openssl by: $ git clone https://github.com/openssl/openssl $ cd openssl $ git checkout OpenSSL_1_1_1l $ cd ../node/deps/openssl $ rm -rf openssl $ cp -R ../openssl openssl $ rm -rf openssl/.git* openssl/.travis* $ git add --all openssl $ git commit openssl
1 parent f0b7b93 commit c47b6ad

File tree

15,219 files changed

+22058
-525
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

15,219 files changed

+22058
-525
lines changed

deps/openssl/openssl/CHANGES

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,71 @@
77
https://github.com/openssl/openssl/commits/ and pick the appropriate
88
release branch.
99

10+
Changes between 1.1.1k and 1.1.1l [24 Aug 2021]
11+
12+
*) Fixed an SM2 Decryption Buffer Overflow.
13+
14+
In order to decrypt SM2 encrypted data an application is expected to call the
15+
API function EVP_PKEY_decrypt(). Typically an application will call this
16+
function twice. The first time, on entry, the "out" parameter can be NULL and,
17+
on exit, the "outlen" parameter is populated with the buffer size required to
18+
hold the decrypted plaintext. The application can then allocate a sufficiently
19+
sized buffer and call EVP_PKEY_decrypt() again, but this time passing a non-NULL
20+
value for the "out" parameter.
21+
22+
A bug in the implementation of the SM2 decryption code means that the
23+
calculation of the buffer size required to hold the plaintext returned by the
24+
first call to EVP_PKEY_decrypt() can be smaller than the actual size required by
25+
the second call. This can lead to a buffer overflow when EVP_PKEY_decrypt() is
26+
called by the application a second time with a buffer that is too small.
27+
28+
A malicious attacker who is able present SM2 content for decryption to an
29+
application could cause attacker chosen data to overflow the buffer by up to a
30+
maximum of 62 bytes altering the contents of other data held after the
31+
buffer, possibly changing application behaviour or causing the application to
32+
crash. The location of the buffer is application dependent but is typically
33+
heap allocated.
34+
(CVE-2021-3711)
35+
[Matt Caswell]
36+
37+
*) Fixed various read buffer overruns processing ASN.1 strings
38+
39+
ASN.1 strings are represented internally within OpenSSL as an ASN1_STRING
40+
structure which contains a buffer holding the string data and a field holding
41+
the buffer length. This contrasts with normal C strings which are repesented as
42+
a buffer for the string data which is terminated with a NUL (0) byte.
43+
44+
Although not a strict requirement, ASN.1 strings that are parsed using OpenSSL's
45+
own "d2i" functions (and other similar parsing functions) as well as any string
46+
whose value has been set with the ASN1_STRING_set() function will additionally
47+
NUL terminate the byte array in the ASN1_STRING structure.
48+
49+
However, it is possible for applications to directly construct valid ASN1_STRING
50+
structures which do not NUL terminate the byte array by directly setting the
51+
"data" and "length" fields in the ASN1_STRING array. This can also happen by
52+
using the ASN1_STRING_set0() function.
53+
54+
Numerous OpenSSL functions that print ASN.1 data have been found to assume that
55+
the ASN1_STRING byte array will be NUL terminated, even though this is not
56+
guaranteed for strings that have been directly constructed. Where an application
57+
requests an ASN.1 structure to be printed, and where that ASN.1 structure
58+
contains ASN1_STRINGs that have been directly constructed by the application
59+
without NUL terminating the "data" field, then a read buffer overrun can occur.
60+
61+
The same thing can also occur during name constraints processing of certificates
62+
(for example if a certificate has been directly constructed by the application
63+
instead of loading it via the OpenSSL parsing functions, and the certificate
64+
contains non NUL terminated ASN1_STRING structures). It can also occur in the
65+
X509_get1_email(), X509_REQ_get1_email() and X509_get1_ocsp() functions.
66+
67+
If a malicious actor can cause an application to directly construct an
68+
ASN1_STRING and then process it through one of the affected OpenSSL functions
69+
then this issue could be hit. This might result in a crash (causing a Denial of
70+
Service attack). It could also result in the disclosure of private memory
71+
contents (such as private keys, or sensitive plaintext).
72+
(CVE-2021-3712)
73+
[Matt Caswell]
74+
1075
Changes between 1.1.1j and 1.1.1k [25 Mar 2021]
1176

1277
*) Fixed a problem with verifying a certificate chain when using the

deps/openssl/openssl/Configurations/10-main.conf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,13 @@ my %targets = (
754754
multilib => "64",
755755
},
756756

757+
# riscv64 below refers to contemporary RISCV Architecture
758+
# specifications,
759+
"linux64-riscv64" => {
760+
inherit_from => [ "linux-generic64"],
761+
perlasm_scheme => "linux64",
762+
},
763+
757764
#### IA-32 targets...
758765
#### These two targets are a bit aged and are to be used on older Linux
759766
#### machines where gcc doesn't understand -m32 and -m64

deps/openssl/openssl/Configurations/15-android.conf

Lines changed: 52 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,18 @@
2929
$ndk = $ENV{$ndk_var};
3030
last if defined $ndk;
3131
}
32-
die "\$ANDROID_NDK_HOME is not defined" if (!$ndk);
33-
if (!-d "$ndk/platforms" && !-f "$ndk/AndroidVersion.txt") {
34-
# $ndk/platforms is traditional "all-inclusive" NDK, while
35-
# $ndk/AndroidVersion.txt is so-called standalone toolchain
36-
# tailored for specific target down to API level.
32+
die "\$ANDROID_NDK_HOME is not defined" if (!$ndk);
33+
my $is_standalone_toolchain = -f "$ndk/AndroidVersion.txt";
34+
my $ndk_src_props = "$ndk/source.properties";
35+
my $is_ndk = -f $ndk_src_props;
36+
if ($is_ndk == $is_standalone_toolchain) {
3737
die "\$ANDROID_NDK_HOME=$ndk is invalid";
3838
}
3939
$ndk = canonpath($ndk);
4040

4141
my $ndkver = undef;
4242

43-
if (open my $fh, "<$ndk/source.properties") {
43+
if (open my $fh, "<$ndk_src_props") {
4444
local $_;
4545
while(<$fh>) {
4646
if (m|Pkg\.Revision\s*=\s*([0-9]+)|) {
@@ -59,7 +59,7 @@
5959
if ($sysroot = $ENV{CROSS_SYSROOT}) {
6060
$sysroot =~ m|/android-([0-9]+)/arch-(\w+)/?$|;
6161
($api, $arch) = ($1, $2);
62-
} elsif (-f "$ndk/AndroidVersion.txt") {
62+
} elsif ($is_standalone_toolchain) {
6363
$sysroot = "$ndk/sysroot";
6464
} else {
6565
$api = "*";
@@ -72,17 +72,31 @@
7272
}
7373
}
7474

75-
# list available platforms (numerically)
76-
my @platforms = sort { $a =~ m/-([0-9]+)$/; my $aa = $1;
77-
$b =~ m/-([0-9]+)$/; $aa <=> $1;
78-
} glob("$ndk/platforms/android-$api");
79-
die "no $ndk/platforms/android-$api" if ($#platforms < 0);
75+
if (-d "$ndk/platforms") {
76+
# list available platforms (numerically)
77+
my @platforms = sort { $a =~ m/-([0-9]+)$/; my $aa = $1;
78+
$b =~ m/-([0-9]+)$/; $aa <=> $1;
79+
} glob("$ndk/platforms/android-$api");
80+
die "no $ndk/platforms/android-$api" if ($#platforms < 0);
8081

81-
$sysroot = "@platforms[$#platforms]/arch-$arch";
82-
$sysroot =~ m|/android-([0-9]+)/arch-$arch|;
83-
$api = $1;
82+
$sysroot = "@platforms[$#platforms]/arch-$arch";
83+
$sysroot =~ m|/android-([0-9]+)/arch-$arch|;
84+
$api = $1;
85+
} elsif ($api eq "*") {
86+
# r22 Removed platforms dir, use this JSON file
87+
my $path = "$ndk/meta/platforms.json";
88+
open my $fh, $path or die "Could not open '$path' $!";
89+
while (<$fh>) {
90+
if (/"max": (\d+),/) {
91+
$api = $1;
92+
last;
93+
}
94+
}
95+
close $fh;
96+
}
97+
die "Could not get default API Level" if ($api eq "*");
8498
}
85-
die "no sysroot=$sysroot" if (!-d $sysroot);
99+
die "no sysroot=$sysroot" if (length $sysroot && !-d $sysroot);
86100

87101
my $triarch = $triplet{$arch};
88102
my $cflags;
@@ -95,17 +109,21 @@
95109
my $arm = $ndkver > 16 ? "armv7a" : "armv5te";
96110
(my $tridefault = $triarch) =~ s/^arm-/$arm-/;
97111
(my $tritools = $triarch) =~ s/(?:x|i6)86(_64)?-.*/x86$1/;
98-
$cflags .= " -target $tridefault "
99-
. "-gcc-toolchain \$($ndk_var)/toolchains"
100-
. "/$tritools-4.9/prebuilt/$host";
101-
$user{CC} = "clang" if ($user{CC} !~ m|clang|);
112+
if (length $sysroot) {
113+
$cflags .= " -target $tridefault "
114+
. "-gcc-toolchain \$($ndk_var)/toolchains"
115+
. "/$tritools-4.9/prebuilt/$host";
116+
$user{CC} = "clang" if ($user{CC} !~ m|clang|);
117+
} else {
118+
$user{CC} = "$tridefault$api-clang";
119+
}
102120
$user{CROSS_COMPILE} = undef;
103121
if (which("llvm-ar") =~ m|^$ndk/.*/prebuilt/([^/]+)/|) {
104122
$user{AR} = "llvm-ar";
105123
$user{ARFLAGS} = [ "rs" ];
106124
$user{RANLIB} = ":";
107125
}
108-
} elsif (-f "$ndk/AndroidVersion.txt") { #"standalone toolchain"
126+
} elsif ($is_standalone_toolchain) {
109127
my $cc = $user{CC} // "clang";
110128
# One can probably argue that both clang and gcc should be
111129
# probed, but support for "standalone toolchain" was added
@@ -127,19 +145,21 @@
127145
$user{CROSS_COMPILE} = "$triarch-";
128146
}
129147

130-
if (!-d "$sysroot/usr/include") {
131-
my $incroot = "$ndk/sysroot/usr/include";
132-
die "no $incroot" if (!-d $incroot);
133-
die "no $incroot/$triarch" if (!-d "$incroot/$triarch");
134-
$incroot =~ s|^$ndk/||;
135-
$cppflags = "-D__ANDROID_API__=$api";
136-
$cppflags .= " -isystem \$($ndk_var)/$incroot/$triarch";
137-
$cppflags .= " -isystem \$($ndk_var)/$incroot";
148+
if (length $sysroot) {
149+
if (!-d "$sysroot/usr/include") {
150+
my $incroot = "$ndk/sysroot/usr/include";
151+
die "no $incroot" if (!-d $incroot);
152+
die "no $incroot/$triarch" if (!-d "$incroot/$triarch");
153+
$incroot =~ s|^$ndk/||;
154+
$cppflags = "-D__ANDROID_API__=$api";
155+
$cppflags .= " -isystem \$($ndk_var)/$incroot/$triarch";
156+
$cppflags .= " -isystem \$($ndk_var)/$incroot";
157+
}
158+
$sysroot =~ s|^$ndk/||;
159+
$sysroot = " --sysroot=\$($ndk_var)/$sysroot";
138160
}
139-
140-
$sysroot =~ s|^$ndk/||;
141161
$android_ndk = {
142-
cflags => "$cflags --sysroot=\$($ndk_var)/$sysroot",
162+
cflags => $cflags . $sysroot,
143163
cppflags => $cppflags,
144164
bn_ops => $arch =~ m/64$/ ? "SIXTY_FOUR_BIT_LONG"
145165
: "BN_LLONG",
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
## -*- mode: perl; -*-
2+
## Build configuration targets for openssl-team members
3+
4+
my %targets = (
5+
"purify" => {
6+
inherit_from => [ 'BASE_unix' ],
7+
cc => "purify gcc",
8+
CFLAGS => "-g -Wall",
9+
thread_scheme => "(unknown)",
10+
ex_libs => add(" ","-lsocket -lnsl"),
11+
},
12+
"debug" => {
13+
inherit_from => [ 'BASE_unix' ],
14+
cc => "gcc",
15+
cflags => "-DBN_DEBUG -DREF_DEBUG -DCONF_DEBUG -DBN_CTX_DEBUG -DOPENSSL_NO_ASM -ggdb -g2 -Wformat -Wshadow -Wmissing-prototypes -Wmissing-declarations -Werror",
16+
thread_scheme => "(unknown)",
17+
},
18+
"debug-erbridge" => {
19+
inherit_from => [ 'BASE_unix', "x86_64_asm" ],
20+
cc => "gcc",
21+
cflags => combine(join(' ', @gcc_devteam_warn),
22+
"-DBN_DEBUG -DCONF_DEBUG -m64 -DL_ENDIAN -DTERMIO -g",
23+
threads("-D_REENTRANT")),
24+
ex_libs => add(" ","-ldl"),
25+
bn_ops => "SIXTY_FOUR_BIT_LONG",
26+
thread_scheme => "pthreads",
27+
perlasm_scheme => "elf",
28+
dso_scheme => "dlfcn",
29+
shared_target => "linux-shared",
30+
shared_cflag => "-fPIC",
31+
shared_ldflag => "-m64",
32+
shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
33+
multilib => "64",
34+
},
35+
"debug-linux-pentium" => {
36+
inherit_from => [ 'BASE_unix', "x86_elf_asm" ],
37+
cc => "gcc",
38+
cflags => combine("-DBN_DEBUG -DREF_DEBUG -DCONF_DEBUG -DBN_CTX_DEBUG -DL_ENDIAN -g -mcpu=pentium -Wall",
39+
threads("-D_REENTRANT")),
40+
ex_libs => add(" ","-ldl"),
41+
bn_ops => "BN_LLONG",
42+
thread_scheme => "pthreads",
43+
dso_scheme => "dlfcn",
44+
},
45+
"debug-linux-ppro" => {
46+
inherit_from => [ 'BASE_unix', "x86_elf_asm" ],
47+
cc => "gcc",
48+
cflags => combine("-DBN_DEBUG -DREF_DEBUG -DCONF_DEBUG -DBN_CTX_DEBUG -DL_ENDIAN -g -mcpu=pentiumpro -Wall",
49+
threads("-D_REENTRANT")),
50+
ex_libs => add(" ","-ldl"),
51+
bn_ops => "BN_LLONG",
52+
thread_scheme => "pthreads",
53+
dso_scheme => "dlfcn",
54+
},
55+
"debug-linux-ia32-aes" => {
56+
inherit_from => [ 'BASE_unix' ],
57+
cc => "gcc",
58+
cflags => combine("-DL_ENDIAN -O3 -fomit-frame-pointer -Wall",
59+
threads("-D_REENTRANT")),
60+
ex_libs => add(" ","-ldl"),
61+
bn_ops => "BN_LLONG",
62+
cpuid_asm_src => "x86cpuid.s",
63+
bn_asm_src => "bn-586.s co-586.s x86-mont.s",
64+
des_asm_src => "des-586.s crypt586.s",
65+
aes_asm_src => "aes_x86core.s aes_cbc.s aesni-x86.s",
66+
bf_asm_src => "bf-586.s",
67+
md5_asm_src => "md5-586.s",
68+
sha1_asm_src => "sha1-586.s sha256-586.s sha512-586.s",
69+
cast_asm_src => "cast-586.s",
70+
rc4_asm_src => "rc4-586.s",
71+
rmd160_asm_src => "rmd-586.s",
72+
rc5_asm_src => "rc5-586.s",
73+
wp_asm_src => "wp_block.s wp-mmx.s",
74+
modes_asm_src => "ghash-x86.s",
75+
padlock_asm_src => "e_padlock-x86.s",
76+
thread_scheme => "pthreads",
77+
perlasm_scheme => "elf",
78+
dso_scheme => "dlfcn",
79+
shared_target => "linux-shared",
80+
shared_cflag => "-fPIC",
81+
shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
82+
},
83+
"debug-test-64-clang" => {
84+
inherit_from => [ 'BASE_unix', "x86_64_asm" ],
85+
cc => "clang",
86+
cflags => combine(join(' ', @gcc_devteam_warn),
87+
"-Wno-error=overlength-strings -Wno-error=extended-offsetof -Wno-error=language-extension-token -Wno-error=unused-const-variable -Wstrict-overflow -Qunused-arguments -DBN_DEBUG -DCONF_DEBUG -DDEBUG_UNUSED -g3 -O3 -pipe",
88+
threads("${BSDthreads}")),
89+
bn_ops => "SIXTY_FOUR_BIT_LONG",
90+
thread_scheme => "pthreads",
91+
perlasm_scheme => "elf",
92+
dso_scheme => "dlfcn",
93+
shared_target => "bsd-gcc-shared",
94+
shared_cflag => "-fPIC",
95+
shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
96+
},
97+
"darwin64-debug-test-64-clang" => {
98+
inherit_from => [ 'BASE_unix', "x86_64_asm" ],
99+
cc => "clang",
100+
cflags => combine("-arch x86_64 -DL_ENDIAN",
101+
join(' ', @gcc_devteam_warn),
102+
"-Wno-error=overlength-strings -Wno-error=extended-offsetof -Wno-error=language-extension-token -Wno-error=unused-const-variable -Wstrict-overflow -Qunused-arguments -DBN_DEBUG -DCONF_DEBUG -DDEBUG_UNUSED -g3 -O3 -pipe",
103+
threads("${BSDthreads}")),
104+
sys_id => "MACOSX",
105+
bn_ops => "SIXTY_FOUR_BIT_LONG",
106+
thread_scheme => "pthreads",
107+
perlasm_scheme => "macosx",
108+
dso_scheme => "dlfcn",
109+
shared_target => "darwin-shared",
110+
shared_cflag => "-fPIC -fno-common",
111+
shared_ldflag => "-arch x86_64 -dynamiclib",
112+
shared_extension => ".\$(SHLIB_VERSION_NUMBER).dylib",
113+
},
114+
);

deps/openssl/openssl/Configurations/unix-Makefile.tmpl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,6 @@ clean: libclean
523523
$(RM) -r test/test-runs
524524
$(RM) openssl.pc libcrypto.pc libssl.pc
525525
-$(RM) `find . -type l \! -name '.*' -print`
526-
$(RM) $(TARFILE)
527526

528527
distclean: clean
529528
$(RM) configdata.pm

0 commit comments

Comments
 (0)