Commit Graph

30705 Commits

Author SHA1 Message Date
Alexandros Roussos
a595e3286a Fix Configure variable spill
* Evaluating code-refs in Configure can sometimes set the default
variable `$_`
* Prevent spillage influencing the target property by using named
variable in loop

CLA: trivial

Fixes gh-17321

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17322)
2021-12-23 12:31:33 +11:00
Pauli
7a85dd46e0 namemap: handle a NULL return when looking for a non-legacy cipher/MD
Fixes #17313

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17324)
2021-12-23 10:50:28 +11:00
Dr. David von Oheimb
cdaf072f90 HTTP client: Fix cleanup of TLS BIO via 'bio_update_fn' callback function
Make app_http_tls_cb() tidy up on disconnect the SSL BIO it pushes on connect.
Make OSSL_HTTP_close() respect this.

Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17318)
2021-12-22 12:24:24 +01:00
Piotr Kubaj
c2d1ad0e04 Add support for BSD-riscv64 target
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Ben Kaduk <kaduk@mit.edu>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17306)
2021-12-22 10:45:10 +11:00
Dr. David von Oheimb
606c79e29b HTTP client: Work around the 'gets' method not being supported by SSL BIOs
It turned out that loading non-ASN.1 contents using the HTTP client
fails over TLS because SSL BIOs do not support the gets method.

This PR provides a workaround by using the less efficient BIO_get_line() function
in case BIO_gets() returns -2, which means that it is not supported by the BIO.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17317)
2021-12-21 13:04:14 +01:00
Dr. David von Oheimb
a497a90213 http_test.c: Simplify constant init of 'server_args' struct for gcc-4.8.x
Reviewed-by: Ben Kaduk <kaduk@mit.edu>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17308)
2021-12-21 12:18:04 +01:00
Dr. David von Oheimb
79b2a2f2ee add OSSL_STACK_OF_X509_free() for commonly used pattern
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17307)
2021-12-21 12:11:49 +01:00
Tomas Mraz
0d4c52320d Fix fixup postrelease scripts to avoid creating errors
Otherwise the NEWS.md and CHANGES.md will contain trailing spaces.

Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17304)

(cherry picked from commit 132ab70fd8)
2021-12-20 10:13:50 +01:00
Carlo Teubner
7db69a35f9 crypto/dsa.h: fix include guard name
The current include guard name is a duplicate of the one in dsaerr.h.

Noticed via https://lgtm.com/projects/g/openssl/openssl

CLA: trivial

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17303)
2021-12-20 10:59:02 +11:00
Kan
f050745fe6 Fix the null pointer dereference
Fixes #17296

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17297)
2021-12-20 10:55:57 +11:00
ABautkin
68b78dd7e4 Fix deref after null
ctx may be NULL at 178 line

CLA: trivial

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17293)
2021-12-20 10:54:00 +11:00
Dr. David von Oheimb
08dfbe0798 cmp_ctx.c: Remove redundancy form the defs of many getters and setters
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17284)
2021-12-18 13:01:08 +01:00
Pauli
2437832be1 rsa exp: move declarations before code
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17287)
2021-12-18 12:54:35 +11:00
Tomas Mraz
7ca3bf792a context_init: Fix cleanup in error handling
Also never use OSSL_LIB_CTX_free() on incompletely initialized context.

Fixes #17291

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17294)
2021-12-17 17:59:36 +01:00
Tomas Mraz
33df7cbe5e ossl_provider_add_to_store: Avoid use-after-free
Avoid freeing a provider that was not up-ref-ed before.

Fixes #17292

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17295)
2021-12-17 17:33:49 +01:00
Peiwei Hu
c81eed84e4 X509_STORE_new: memory needs to be freed
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17278)
2021-12-17 15:10:06 +01:00
Peiwei Hu
ec9135a623 get_ecdsa_sig_rs_bytes: free value of d2i_ECDSA_SIG() before return
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17280)
2021-12-17 08:58:19 +01:00
Peiwei Hu
869b7dd000 test/cmp_vfy_test.c: free before return
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17279)
2021-12-17 08:50:11 +01:00
Pauli
27f7f52765 Add test case to verify that the use after free issue is fixed.
Test case based on reproducer by Guido Vranken.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17263)
2021-12-17 14:39:20 +11:00
Pauli
ad2fcee163 evp: address a use after free state when using HMAC and MD copy.
Fixes #17261

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17263)
2021-12-17 14:39:20 +11:00
Peiwei Hu
dd2fcc1f7c EC_POINT_hex2point: forget to free pt
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17276)
2021-12-16 12:40:05 +01:00
Orr Toledano
e8b597f331 Documentation for RNDR and RNDRRS
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15361)
2021-12-16 12:38:09 +01:00
Orr Toledano
1f8ce0c9fa Add tests for RNDR and combine tests with RDRAND
Add test cases for RNDR and RNDRRS. Combine tests for RDRAND and RNDR to
share common logic.

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15361)
2021-12-16 12:38:09 +01:00
Orr Toledano
eb28fda797 Add support for RNDRRS Provider
Create new provider for RNDRRS. Modify support for rand_cpu to default to
RDRAND/RDSEED on x86 and RNDRRS on aarch64.

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15361)
2021-12-16 12:38:09 +01:00
Orr Toledano
efa1f22483 Add Arm Assembly (aarch64) support for RNG
Include aarch64 asm instructions for random number generation using the
RNDR and RNDRRS instructions. Provide detection functions for RNDR and
RNDRRS getauxval.

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15361)
2021-12-16 12:38:09 +01:00
Dr. David von Oheimb
a56bb5d64e APPS/cmp: Fix logic and doc of mutually exclusive -server/-use_mock_srv/-port/-rspin options
Ignore -server with -rspin and exclude all of -use_mock_srv/-port/-rspin.
On the other hand, -server is required if no -use_mock_srv/-port/-rspin is given.
Ignore -tls_used with -use_mock_srv and -rspin; it is not supported with -port.
If -server is not given, ignore -proxy, -no_proxy, and -tls_used.
Also slightly improve the documentation of the two mock server variants.

Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17254)
2021-12-15 11:47:10 +01:00
Tomas Mraz
1f8ca9e3d3 NEWS.md: Add missing empty line
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17274)
2021-12-14 18:10:44 +01:00
Richard Levitte
0e4e4e27df Add some CHANGES entries for 3.0.1
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17274)
2021-12-14 17:44:06 +01:00
Tomas Mraz
c868d1f9ca Add some CHANGES.md entries for the 3.0.1 release
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17274)
2021-12-14 17:43:59 +01:00
Matt Caswell
0fcf2351ec Add a test case for the name constraints bug
Where a chain has name constraints but a certificate does not have a SAN
extension but the CN meets the constraints, then this should be acceptable.
However, and OpenSSL bug meant that an internal error was being reported.
This adds a test case for that scenario.

Test for CVE-2021-4044

Reviewed-by: Tomas Mraz <tomas@openssl.org>
2021-12-14 13:48:34 +00:00
Matt Caswell
752aa4a6f0 Add a TLS test for name constraints with an EE cert without a SAN
It is valid for name constraints to be in force but for there to be no
SAN extension in a certificate. Previous versions of OpenSSL mishandled
this.

Test for CVE-2021-4044

Reviewed-by: Tomas Mraz <tomas@openssl.org>
2021-12-14 13:48:34 +00:00
Matt Caswell
3269c8bd94 Add a new Name Constraints test cert
Add a cert which complies with the name constraints but has no
SAN extension

Reviewed-by: Tomas Mraz <tomas@openssl.org>
2021-12-14 13:48:34 +00:00
Tobias Nießen
6894e20b50 Fix infinite verification loops due to has_san_id
Where name constraints apply, X509_verify() would incorrectly report an
internal error in the event that a certificate has no SAN extension.

CVE-2021-4044

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
2021-12-14 13:48:34 +00:00
Matt Caswell
c1c1bb7c5e Fix invalid handling of verify errors in libssl
In the event that X509_verify() returned an internal error result then
libssl would mishandle this and set rwstate to SSL_RETRY_VERIFY. This
subsequently causes SSL_get_error() to return SSL_ERROR_WANT_RETRY_VERIFY.
That return code is supposed to only ever be returned if an application
is using an app verify callback to complete replace the use of
X509_verify(). Applications may not be written to expect that return code
and could therefore crash (or misbehave in some other way) as a result.

CVE-2021-4044

Reviewed-by: Tomas Mraz <tomas@openssl.org>
2021-12-14 13:48:34 +00:00
Matt Caswell
5eef9e1deb Update CHANGES and NEWS for new release
Reviewed-by: Richard Levitte <levitte@openssl.org>
2021-12-14 13:42:49 +00:00
Richard Levitte
32a3b9b766 Fix VMS installation - Document in CHANGES.md
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16842)

(cherry picked from commit 2daa2a0d00)
2021-12-14 11:53:53 +00:00
Richard Levitte
1b9fbae6a6 Fix VMS installation - Override the openssl logical name in descrip.mms.tmpl
This was part of 0cbb6f6a9a, but was
incomplete in that commit.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16842)

(cherry picked from commit 71a78784e8)
2021-12-14 11:50:16 +00:00
Richard Levitte
0c5307ef4b Fix VMS installation - Check the presence of providers in the IVP script
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16842)

(cherry picked from commit fe27680fc6)
2021-12-14 11:50:16 +00:00
Richard Levitte
0df8e71a6e Fix VMS installation - deassign the same logical names that were defined
The logical name for the engines directory is named one way in
VMS/openssl_startup.com.in, but a different name was deassigned in
VMS/openssl_shutdown.com.in.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16842)

(cherry picked from commit 73e47e39a5)
2021-12-14 11:50:16 +00:00
Richard Levitte
93b670abd1 Fix VMS installation - use platform->shlib_version_as_filename() consistently
It's used in Configurations/descrip.mms.tmpl, but was forgotten in the
VMS installation scripts.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16842)

(cherry picked from commit 883008b21b)
2021-12-14 11:50:16 +00:00
Richard Levitte
a3a79ab322 Fix VMS installation - Define the logical name OSSL$MODULES
Also, the modules installation directory is version agnostic on other
platforms, there's no real reason why it shouldn't be on VMS.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16842)

(cherry picked from commit a4f1e23e6c)
2021-12-14 11:50:16 +00:00
Richard Levitte
59cf75435d Fix VMS installation - $config{pointer_size} -> $target{pointer_size}
Configurations/descrip.mms.tmpl uses $target{pointer_size}, not
$config{pointer_size}, so the same should be used in installation
scripts, for consistency.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16842)

(cherry picked from commit e30545e9bd)
2021-12-14 11:50:16 +00:00
Richard Levitte
bc0ac16417 Fix VMS installation - consistent program names with version info
The program name version info is supposed to be the major release
version number.  This was forgotten when the versioning scheme was
changed for 3.0, so the minor release version number slipped in as
well.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16842)

(cherry picked from commit 3c9293b471)
2021-12-14 11:50:16 +00:00
Bernd Edlinger
17cca0e85e Remove some unnecessary undefs in bn_asm.c
This is likely the leftover of a previous hack,
and thus should be removed now.

Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17259)
2021-12-14 06:45:18 +01:00
Bernd Edlinger
336923c0c8 Fix a carry overflow bug in bn_sqr_comba4/8 for mips 32-bit targets
bn_sqr_comba8 does for instance compute a wrong result for the value:
a=0x4aaac919 62056c84 fba7334e 1a6be678 022181ba fd3aa878 899b2346 ee210f45

The correct result is:
r=0x15c72e32 605a3061 d11b1012 3c187483 6df96999 bd0c22ba d3e7d437 4724a82f
    912c5e61 6a187efe 8f7c47fc f6945fe5 75be8e3d 97ed17d4 7950b465 3cb32899

but the actual result was:
r=0x15c72e32 605a3061 d11b1012 3c187483 6df96999 bd0c22ba d3e7d437 4724a82f
    912c5e61 6a187efe 8f7c47fc f6945fe5 75be8e3c 97ed17d4 7950b465 3cb32899

so the forth word of the result was 0x75be8e3c but should have been
0x75be8e3d instead.

Likewise bn_sqr_comba4 has an identical bug for the same value as well:
a=0x022181ba fd3aa878 899b2346 ee210f45

correct result:
r=0x00048a69 9fe82f8b 62bd2ed1 88781335 75be8e3d 97ed17d4 7950b465 3cb32899

wrong result:
r=0x00048a69 9fe82f8b 62bd2ed1 88781335 75be8e3c 97ed17d4 7950b465 3cb32899

Fortunately the bn_mul_comba4/8 code paths are not affected.

Also the mips64 target does in fact not handle the carry propagation
correctly.

Example:
a=0x4aaac91900000000 62056c8400000000 fba7334e00000000 1a6be67800000000
    022181ba00000000 fd3aa87800000000 899b234635dad283 ee210f4500000001

correct result:
r=0x15c72e32272c4471 392debf018c679c8 b85496496bf8254c d0204f36611e2be1
    0cdb3db8f3c081d8 c94ba0e1bacc5061 191b83d47ff929f6 5be0aebfc13ae68d
    3eea7a7fdf2f5758 42f7ec656cab3cb5 6a28095be34756f2 64f24687bf37de06
    2822309cd1d292f9 6fa698c972372f09 771e97d3a868cda0 dc421e8a00000001

wrong result:
r=0x15c72e32272c4471 392debf018c679c8 b85496496bf8254c d0204f36611e2be1
    0cdb3db8f3c081d8 c94ba0e1bacc5061 191b83d47ff929f6 5be0aebfc13ae68d
    3eea7a7fdf2f5758 42f7ec656cab3cb5 6a28095be34756f2 64f24687bf37de06
    2822309cd1d292f8 6fa698c972372f09 771e97d3a868cda0 dc421e8a00000001

Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17258)
2021-12-14 06:43:04 +01:00
Dr. David von Oheimb
2490d10d5c OSSL_HTTP_proxy_connect(): Fix glitch in response HTTP header parsing
Fixes #17247

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17250)
2021-12-13 12:13:30 +01:00
Tomas Mraz
858d5ac16d bn2binpad: Use memset as the buffer will be used later
Apparently using OPENSSL_cleanse() confuses the fuzzer so it
makes the buffer to appear uninitialized. And memset can be
safely used here and it is also potentially faster.

Fixes #17237

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/17240)
2021-12-13 11:32:39 +01:00
Dr. David von Oheimb
61fa00a4d0 APPS/cmp: Simplify read_write_req_resp() - 'req' arg must not be NULL anyway
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17251)
2021-12-13 09:52:02 +01:00
Dr. David von Oheimb
e46997111a ossl_cmp_msg_check_update(): align recipNone check with improved transactionID check
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17251)
2021-12-13 09:52:02 +01:00
Dr. David von Oheimb
20b0579cbf CMP test_commands.csv: improve test for -reqin, adding -reqin_new_tid
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17252)
2021-12-13 09:48:25 +01:00