]> git.ipfire.org Git - thirdparty/openssl.git/log
thirdparty/openssl.git
16 months agoDoc: fix style 23840/head
谭九鼎 [Sun, 10 Mar 2024 02:18:05 +0000 (02:18 +0000)] 
Doc: fix style

CLA: trivial

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

(cherry picked from commit 52a75f4088f2b2c59721152d9ec6ecf4d17c7e43)

16 months agoFAQ.md should be removed
Alexandr Nedvedicky [Fri, 1 Mar 2024 07:25:19 +0000 (08:25 +0100)] 
FAQ.md should be removed

the page the link refers to does not exist.
Anyone objects to delete file?

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

(cherry picked from commit 854539889d31ed2ea63280256fd7aab66e828ae5)

16 months agoTry to fix intermittent CI failures in sslapitest
Bernd Edlinger [Wed, 28 Feb 2024 06:14:08 +0000 (07:14 +0100)] 
Try to fix intermittent CI failures in sslapitest

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/23774)

(cherry picked from commit 98dd1f7266d66614a4e04e921e74303f14cea7df)

17 months agoDont run the self-hosted workflows when not available
Bernd Edlinger [Fri, 23 Feb 2024 11:04:38 +0000 (12:04 +0100)] 
Dont run the self-hosted workflows when not available

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23678)

(cherry picked from commit 74fd6823884e27c18ec3fe7bd99b9bc02e6f31f3)

17 months agoFix off by one issue in buf2hexstr_sep()
shridhar kalavagunta [Sat, 27 Jan 2024 03:10:32 +0000 (21:10 -0600)] 
Fix off by one issue in buf2hexstr_sep()

Fixes #23363

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23404)

(cherry picked from commit c5cc9c419a0a8d97a44f01f95f0e213f56da4574)

17 months agoEnsure `$(MAKE)` commands and `CFLAGS` are appropriately quoted in the Makefile.
Hamilton Chapman [Wed, 21 Feb 2024 13:47:19 +0000 (13:47 +0000)] 
Ensure `$(MAKE)` commands and `CFLAGS` are appropriately quoted in the Makefile.

If a user's `make` command came from a path that contained a space then both the
`$(MAKE)` variable (and parts of the generated `CFLAGS`, when building for iOS)
would not be properly quoted and the build would fail.

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23663)

(cherry picked from commit aba621934696ca52193bd41cd35816649b6b321b)

17 months agoSSL_set1_groups_list(): Fix memory corruption with 40 groups and more
Michael Baentsch [Mon, 19 Feb 2024 05:41:35 +0000 (06:41 +0100)] 
SSL_set1_groups_list(): Fix memory corruption with 40 groups and more

Fixes #23624

The calculation of the size for gid_arr reallocation was wrong.
A multiplication by gid_arr array item size was missing.

Testcase is added.

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Cherry-pick from https://github.com/openssl/openssl/pull/23625)

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/23661)

17 months agos_cb.c: Add missing return value checks
MrRurikov [Wed, 21 Feb 2024 08:11:34 +0000 (11:11 +0300)] 
s_cb.c: Add missing return value checks

Return value of function 'SSL_CTX_ctrl', that is called from
SSL_CTX_set1_verify_cert_store() and SSL_CTX_set1_chain_cert_store(),
is not checked, but it is usually checked for this function.

CLA: trivial

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23647)

17 months agoMinor wording fixes related to no-atexit
Tomas Mraz [Tue, 20 Feb 2024 17:42:24 +0000 (18:42 +0100)] 
Minor wording fixes related to no-atexit

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/23642)

(cherry picked from commit 66e6f72c3e4221580a7f456ddeaa5027f0bbb8b7)

17 months agoAdd atexit configuration option to using atexit() in libcrypto at build-time.
Randall S. Becker [Thu, 25 Jan 2024 22:11:27 +0000 (22:11 +0000)] 
Add atexit configuration option to using atexit() in libcrypto at build-time.

This fixes an issue with a mix of atexit() usage in DLL and statically linked
libcrypto that came out in the test suite on NonStop, which has slightly
different DLL unload processing semantics compared to Linux. The change
allows a build configuration to select whether to register OPENSSL_cleanup()
with atexit() or not, so avoid situations where atexit() registration causes
SIGSEGV.

INSTALL.md and CHANGES.md have been modified to include and describe this
option.

Signed-off-by: Randall S. Becker <randall.becker@nexbridge.ca>
Signed-off-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23642)

(cherry picked from commit 0e1989d4c7435809b60f614c23ba8c9a7c0373e8)

17 months agoDon't print excessively long ASN1 items in fuzzer
Matt Caswell [Tue, 20 Feb 2024 15:11:26 +0000 (15:11 +0000)] 
Don't print excessively long ASN1 items in fuzzer

Prevent spurious fuzzer timeouts by not printing ASN1 which is excessively
long.

This fixes a false positive encountered by OSS-Fuzz.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/23640)

(cherry picked from commit 4a6f70c03182b421d326831532edca32bcdb3fb1)

17 months agoCorrect the defined name of the parameter "micalg" in the documentation
Bernd Ritter [Sat, 17 Feb 2024 18:15:14 +0000 (19:15 +0100)] 
Correct the defined name of the parameter "micalg" in the documentation

The EVP_DigestInit(3) manual page contains wrong name for the define
macro for the OSSL_DIGEST_PARAM_MICALG param.

Fixes #23580

CLA: trivial

Reviewed-by: Paul Yang <kaishen.yy@antfin.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23615)

(cherry picked from commit 5e5c256bbad572cf8d8d9ef9127722ca028d2704)

17 months agoFixed Visual Studio 2008 compiler errors
Marcel Gosmann [Wed, 14 Feb 2024 10:35:47 +0000 (11:35 +0100)] 
Fixed Visual Studio 2008 compiler errors

CLA: trivial

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

(cherry picked from commit c3e8d67885c0c4295cfd1df35a41bf1f3fa9dc37)

17 months agoCheck for NULL cleanup function before using it in encoder_process
Neil Horman [Sat, 16 Dec 2023 20:32:48 +0000 (15:32 -0500)] 
Check for NULL cleanup function before using it in encoder_process

encoder_process assumes a cleanup function has been set in the currently
in-use encoder during processing, which can lead to segfaults if said
function hasn't been set

Add a NULL check for this condition, returning -1 if it is not set

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

(cherry picked from commit cf57c3ecfa416afbc47d36633981034809ee6792)

17 months agoKDF_CTX_new API has incorrect signature (const should not be there)
Shakti Shah [Sat, 10 Feb 2024 19:39:10 +0000 (01:09 +0530)] 
KDF_CTX_new API has incorrect signature (const should not be there)

https://www.openssl.org/docs/man3.1/man3/EVP_KDF_CTX.html

The pages for 3.0/3.1/master seem to have the following
EVP_KDF_CTX *EVP_KDF_CTX_new(const EVP_KDF *kdf);

which does not match with the actual header which is
EVP_KDF_CTX *EVP_KDF_CTX_new(EVP_KDF *kdf);

Fixes #23532

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23541)

(cherry picked from commit 4f6133f9db2b9b7ce5e59d8b8ec38202a154c524)

17 months agoFix typos found by codespell in openssl-3.0
Dimitri Papadopoulos [Sun, 11 Feb 2024 17:31:23 +0000 (18:31 +0100)] 
Fix typos found by codespell in openssl-3.0

Only modify doc/man* in the openssl-3.0 branch.

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23546)

17 months agoFix memory leaks on error cases during drbg initializations
Tomas Mraz [Wed, 7 Feb 2024 09:27:50 +0000 (10:27 +0100)] 
Fix memory leaks on error cases during drbg initializations

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/23503)

(cherry picked from commit cb4f7a6ee053e8c51cf3ac35fee333d1f25552c0)

17 months agoRearrange terms in gf_mul to prevent segfault
Angel Baez [Wed, 7 Feb 2024 15:34:48 +0000 (10:34 -0500)] 
Rearrange terms in gf_mul to prevent segfault

CLA: trivial

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23512)

(cherry picked from commit 76cecff5e9bedb2bafc60062283f99722697082a)

17 months agoFix testcases to run on duplicated keys
Tomas Mraz [Fri, 12 Jan 2024 17:47:56 +0000 (18:47 +0100)] 
Fix testcases to run on duplicated keys

The existing loop pattern did not really run the expected
tests on the duplicated keys.

Fixes #23129

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23292)

(cherry picked from commit 387b93e14907cd8203d6f2c9d78e49df01cb6e1f)

18 months agoMake IV/buf in prov_cipher_ctx_st aligned
Hongren (Zenithal) Zheng [Mon, 9 May 2022 11:42:39 +0000 (19:42 +0800)] 
Make IV/buf in prov_cipher_ctx_st aligned

Make IV/buf aligned will drastically improve performance
as some architecture performs badly on misaligned memory
access.

Ref to
https://gist.github.com/ZenithalHourlyRate/7b5175734f87acb73d0bbc53391d7140#file-2-openssl-long-md
Ref to
openssl#18197

Signed-off-by: Hongren (Zenithal) Zheng <i@zenithal.me>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(cherry picked from commit 2787a709c984d3884e1726383c2f2afca428d795)

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23463)

18 months agoFix a few incorrect paths in some build.info files
Richard Levitte [Thu, 1 Feb 2024 09:57:51 +0000 (10:57 +0100)] 
Fix a few incorrect paths in some build.info files

The following files referred to ../liblegacy.a when they should have
referred to ../../liblegacy.a.  This cause the creation of a mysterious
directory 'crypto/providers', and because of an increased strictness
with regards to where directories are created, configuration failure
on some platforms.

Fixes #23436

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/23452)

(cherry picked from commit 667b45454a47959ce2934b74c899662e686993de)

18 months agoSync pyca workflow with master
Bernd Edlinger [Wed, 31 Jan 2024 13:52:38 +0000 (14:52 +0100)] 
Sync pyca workflow with master

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/23444)

(cherry picked from commit 3b62e031418369ba5f62b32f12f9ccf3bdd3a3c0)

18 months agoDocument the implications of setting engine-based low-level methods
Tomas Mraz [Wed, 27 Dec 2023 18:21:49 +0000 (19:21 +0100)] 
Document the implications of setting engine-based low-level methods

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23063)

(cherry picked from commit dbb478a51d3f695ec713e9829a2353a0d2d61a59)

18 months agoRevert "Improved detection of engine-provided private "classic" keys"
Tomas Mraz [Fri, 15 Dec 2023 12:45:50 +0000 (13:45 +0100)] 
Revert "Improved detection of engine-provided private "classic" keys"

This reverts commit 2b74e75331a27fc89cad9c8ea6a26c70019300b5.

The commit was wrong. With 3.x versions the engines must be themselves
responsible for creating their EVP_PKEYs in a way that they are treated
as legacy - either by using the respective set1 calls or by setting
non-default EVP_PKEY_METHOD.

The workaround has caused more problems than it solved.

Fixes #22945

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23063)

(cherry picked from commit 39ea78379826fa98e8dc8c0d2b07e2c17cd68380)

18 months agoFix error reporting in EVP_PKEY_{sign,verify,verify_recover}
Richard Levitte [Mon, 29 Jan 2024 07:51:52 +0000 (08:51 +0100)] 
Fix error reporting in EVP_PKEY_{sign,verify,verify_recover}

For some reason, those functions (and the _init functions too) would
raise EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE when the passed
ctx is NULL, and then not check if the provider supplied the function
that would support these libcrypto functions.

This corrects the situation, and has all those libcrypto functions
raise ERR_R_PASS_NULL_PARAMETER if ctx is NULL, and then check for the
corresponding provider supplied, and only when that one is missing,
raise EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE.

Because 0 doesn't mean error for EVP_PKEY_verify(), -1 is returned when
ERR_R_PASSED_NULL_PARAMETER is raised.  This is done consistently for all
affected functions.

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23411)

(cherry picked from commit 5a25177d1b07ef6e754fec1747b57ee90ab1e028)

18 months agoFix a possible memleak in bind_afalg
Bernd Edlinger [Sun, 28 Jan 2024 22:50:16 +0000 (23:50 +0100)] 
Fix a possible memleak in bind_afalg

bind_afalg calls afalg_aes_cbc which allocates
cipher_handle->_hidden global object(s)
but if one of them fails due to out of memory,
the function bind_afalg relies on the engine destroy
method to be called.  But that does not happen
because the dynamic engine object is not destroyed
in the usual way in dynamic_load in this case:

If the bind_engine function fails, there will be no
further calls into the shared object.
See ./crypto/engine/eng_dyn.c near the comment:
/* Copy the original ENGINE structure back */

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23409)

(cherry picked from commit 729a1496cc4cda669dea6501c991113c78f04560)

18 months agofix missing null check in kdf_test_ctrl
Neil Horman [Fri, 26 Jan 2024 16:33:18 +0000 (11:33 -0500)] 
fix missing null check in kdf_test_ctrl

Coverity issue 1453632 noted a missing null check in kdf_test_ctrl
recently.  If a malformed value is passed in from the test file that
does not contain a ':' character, the p variable will be NULL, leading
to a NULL derefence prepare_from_text

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/23398)

(cherry picked from commit 6ca1d3ee81b61bc973e4e1079ec68ac73331c159)

18 months agoPrepare for 3.0.14 23431/head
Matt Caswell [Tue, 30 Jan 2024 13:28:22 +0000 (13:28 +0000)] 
Prepare for 3.0.14

Reviewed-by: Richard Levitte <levitte@openssl.org>
Release: yes

18 months agoPrepare for release of 3.0.13 openssl-3.0.13
Matt Caswell [Tue, 30 Jan 2024 13:28:16 +0000 (13:28 +0000)] 
Prepare for release of 3.0.13

Reviewed-by: Richard Levitte <levitte@openssl.org>
Release: yes

18 months agomake update
Matt Caswell [Tue, 30 Jan 2024 13:28:15 +0000 (13:28 +0000)] 
make update

Reviewed-by: Richard Levitte <levitte@openssl.org>
Release: yes

18 months agoCopyright year updates
Matt Caswell [Tue, 30 Jan 2024 13:26:54 +0000 (13:26 +0000)] 
Copyright year updates

Reviewed-by: Richard Levitte <levitte@openssl.org>
Release: yes

18 months agoUpdate CHANGES.md and NEWS.md for new release
Matt Caswell [Mon, 29 Jan 2024 16:19:24 +0000 (16:19 +0000)] 
Update CHANGES.md and NEWS.md for new release

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Release: yes
(Merged from https://github.com/openssl/openssl/pull/23423)

(cherry picked from commit 6782406c069c3146cf7b5026811e3935e84e3ab8)

18 months agoHave OSSL_PARAM_allocate_from_text() fail on odd number of hex digits
Richard Levitte [Tue, 23 Jan 2024 12:17:31 +0000 (13:17 +0100)] 
Have OSSL_PARAM_allocate_from_text() fail on odd number of hex digits

The failure would be caught later on, so this went unnoticed, until someone
tried with just one hex digit, which was simply ignored.

Fixes #23373

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23374)

(cherry picked from commit ea6268cfceaba24328d66bd14bfc97c4fac14a58)

18 months agoAdd some tests for various PKCS12 files with NULL ContentInfo
Matt Caswell [Fri, 19 Jan 2024 14:32:18 +0000 (14:32 +0000)] 
Add some tests for various PKCS12 files with NULL ContentInfo

PKCS7 ContentInfo fields held within a PKCS12 file can be NULL, even if the
type has been set to a valid value. CVE-2024-0727 is a result of OpenSSL
attempting to dereference the NULL pointer as a result of this.

We add test for various instances of this problem.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23362)

(cherry picked from commit febb086d0fc1ea12181f4d833aa9b8fdf2133b3b)

18 months agoAdd NULL checks where ContentInfo data can be NULL
Matt Caswell [Fri, 19 Jan 2024 11:28:58 +0000 (11:28 +0000)] 
Add NULL checks where ContentInfo data can be NULL

PKCS12 structures contain PKCS7 ContentInfo fields. These fields are
optional and can be NULL even if the "type" is a valid value. OpenSSL
was not properly accounting for this and a NULL dereference can occur
causing a crash.

CVE-2024-0727

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23362)

(cherry picked from commit d135eeab8a5dbf72b3da5240bab9ddb7678dbd2c)

18 months agoFix a possible memory leak in req_main
Bernd Edlinger [Mon, 22 Jan 2024 15:02:59 +0000 (16:02 +0100)] 
Fix a possible memory leak in req_main

if the private key is output to stdout using the HARNESS_OSSL_PREFIX,
out is a stack of BIOs and must therefore free'd using BIO_free_all.

Steps to reproduce:

$ HARNESS_OSSL_PREFIX=x OPENSSL_CONF=apps/openssl.cnf util/shlib_wrap.sh apps/openssl req -new -keyout - -passout pass: </dev/null
[...]
Direct leak of 128 byte(s) in 1 object(s) allocated from:
    #0 0x7f6f692b89cf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
    #1 0x7f6f686eda00 in CRYPTO_malloc crypto/mem.c:202
    #2 0x7f6f686edba0 in CRYPTO_zalloc crypto/mem.c:222
    #3 0x7f6f68471bdf in BIO_new_ex crypto/bio/bio_lib.c:83
    #4 0x7f6f68491a8f in BIO_new_fp crypto/bio/bss_file.c:95
    #5 0x555c5f58b378 in dup_bio_out apps/lib/apps.c:3014
    #6 0x555c5f58f9ac in bio_open_default_ apps/lib/apps.c:3175
    #7 0x555c5f58f9ac in bio_open_default apps/lib/apps.c:3203
    #8 0x555c5f528537 in req_main apps/req.c:683
    #9 0x555c5f50e315 in do_cmd apps/openssl.c:426
    #10 0x555c5f4c5575 in main apps/openssl.c:307
    #11 0x7f6f680461c9 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

SUMMARY: AddressSanitizer: 128 byte(s) leaked in 1 allocation(s).

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23365)

(cherry picked from commit ff78d94b131d7bb3b761509d3ce0dd864b1420e3)

18 months agoci.yml: Replace actions-rs/toolchain@v1 with dtolnay/rust-toolchain
Tomas Mraz [Mon, 8 Jan 2024 13:13:49 +0000 (14:13 +0100)] 
ci.yml: Replace actions-rs/toolchain@v1 with dtolnay/rust-toolchain

actions-rs/toolchain is unmaintained and generates warnings

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23232)

(cherry picked from commit cd5911a6b300453eefb4b6d9d797c9d1cdefb956)

18 months agogost_engine.sh: Set OPENSSL_ENGINES_DIR
Tomas Mraz [Wed, 3 Jan 2024 11:36:10 +0000 (12:36 +0100)] 
gost_engine.sh: Set OPENSSL_ENGINES_DIR

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/23342)

(cherry picked from commit 017c7cf2bb5f5461071d9e992eb3206c34a69c2c)

18 months agoUninitialized array variable
shashankmca80 [Sat, 13 Jan 2024 12:46:25 +0000 (18:16 +0530)] 
Uninitialized array variable

array"key" is uninitialized and it is being read directly in function SipHash_Init() as per the below statements making a way for the garbage values :
uint64_t k0 = U8TO64_LE(k);
uint64_t k1 = U8TO64_LE(k + 8);

CLA: trivial

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23298)

(cherry picked from commit a0826b184eed2dccc56cdf80e3e0bc061cc89ddc)

18 months agoDocument SSL_R_UNEXPECTED_EOF_WHILE_READING
Matt Caswell [Mon, 15 Jan 2024 08:55:48 +0000 (08:55 +0000)] 
Document SSL_R_UNEXPECTED_EOF_WHILE_READING

Also document that it is ok to use this for control flow decisions.

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23327)

(cherry picked from commit b7275c5e5c1c7b025bf2eb74fd1344b6abe48c06)

18 months agoX509_dup.pod: add caveat that extra data is not copied and hints, e.g., to use X509_u...
Dr. David von Oheimb [Thu, 14 Dec 2023 11:48:33 +0000 (12:48 +0100)] 
X509_dup.pod: add caveat that extra data is not copied and hints, e.g., to use X509_up_ref() instead

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23043)

(cherry picked from commit 66adaf2b31bb51e00ffad784f60bdf195e5dd736)

18 months agoAdd a deprecation warning for a function in docs
Kevin Jerebica [Tue, 16 Jan 2024 15:30:26 +0000 (16:30 +0100)] 
Add a deprecation warning for a function in docs

The function in question is SSL_get_peer_certificate()

CLA: trivial

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23315)

(cherry picked from commit 3e938453be47751d50917e25b8f7334b482844b3)

18 months agoCheck whether the pubkey exists in ossl_ecx_key_dup
lan1120 [Wed, 13 Dec 2023 11:02:29 +0000 (19:02 +0800)] 
Check whether the pubkey exists in ossl_ecx_key_dup

Signed-off-by: lan1120 <lanming@huawei.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22984)

(cherry picked from commit aac531e5daa2edec5d47e702a7f115cf77fe07f9)

18 months agoError in s_server when -rev option is used with dtls.
Frederik Wedel-Heinen [Fri, 12 Jan 2024 09:14:43 +0000 (10:14 +0100)] 
Error in s_server when -rev option is used with dtls.

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

(cherry picked from commit 575117efe1e0eb8073c2d26ae3dff8926be00591)

18 months agoAdd CHANGES.md and NEWS.md entries for CVE-2023-6237
Tomas Mraz [Tue, 9 Jan 2024 17:08:22 +0000 (18:08 +0100)] 
Add CHANGES.md and NEWS.md entries for CVE-2023-6237

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23243)

(cherry picked from commit 38b2508f638787842750aec9a75745e1d8786743)

18 months agoLimit the execution time of RSA public key check
Tomas Mraz [Fri, 22 Dec 2023 15:25:56 +0000 (16:25 +0100)] 
Limit the execution time of RSA public key check

Fixes CVE-2023-6237

If a large and incorrect RSA public key is checked with
EVP_PKEY_public_check() the computation could take very long time
due to no limit being applied to the RSA public key size and
unnecessarily high number of Miller-Rabin algorithm rounds
used for non-primality check of the modulus.

Now the keys larger than 16384 bits (OPENSSL_RSA_MAX_MODULUS_BITS)
will fail the check with RSA_R_MODULUS_TOO_LARGE error reason.
Also the number of Miller-Rabin rounds was set to 5.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23243)

(cherry picked from commit e09fc1d746a4fd15bb5c3d7bbbab950aadd005db)

18 months agoFix arithmetic expression overflow
Drokov Pavel [Fri, 12 Jan 2024 07:10:17 +0000 (02:10 -0500)] 
Fix arithmetic expression overflow

If the value of a->length is large (>= 2^12), then an integer overflow will
occur for the signed type, which according to the C standard is UB.

CLA: trivial

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

(cherry picked from commit 486ab0fb003d05f89620662260486d31bd3faa8c)

18 months agoAdd test/recipes/15-test_gensm2.t, to test SM2 key generation results
Richard Levitte [Thu, 4 Jan 2024 11:42:05 +0000 (12:42 +0100)] 
Add test/recipes/15-test_gensm2.t, to test SM2 key generation results

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22529)

(cherry picked from commit d4d9b57530b2ecdca6b4263b5841b42c820e5275)

18 months agoFix the encoding of SM2 keys
Richard Levitte [Fri, 27 Oct 2023 07:01:19 +0000 (09:01 +0200)] 
Fix the encoding of SM2 keys

OpenSSL's encoding of SM2 keys used the SM2 OID for the algorithm OID
where an AlgorithmIdentifier is encoded (for encoding into the structures
PrivateKeyInfo and SubjectPublicKeyInfo).

Such keys should be encoded as ECC keys.

Fixes #22184

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22529)

(cherry picked from commit 1d490694dfa790d8e47f8f2ea62ea1d9b1251179)

18 months agoFix NULL pointer deref when parsing the stable section
Neil Horman [Thu, 7 Dec 2023 21:56:39 +0000 (16:56 -0500)] 
Fix NULL pointer deref when parsing the stable section

When parsing the stable section of a config such as this:
openssl_conf = openssl_init
[openssl_init]
stbl_section = mstbl
[mstbl]
id-tc26 = min

Can lead to a SIGSEGV, as the parsing code doesnt recognize min as a
proper section name without a trailing colon to associate it with a
value.  As a result the stack of configuration values has an entry with
a null value in it, which leads to the SIGSEGV in do_tcreate when we
attempt to pass NULL to strtoul.

Fix it by skipping any entry in the config name/value list that has a
null value, prior to passing it to stroul

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

(cherry picked from commit 0981c20f8efa68bf9d68d7715280f83812c19a7e)

18 months agoAdd tests for re-using cipher contexts
Holger Dengler [Thu, 4 Jan 2024 18:25:08 +0000 (19:25 +0100)] 
Add tests for re-using cipher contexts

Add test case for re-using a cipher context with the same key, iv and
cipher. It detects, if the hardware-specific cipher context is reset
correctly, like reported in issue #23175.

This test has encrypt and decrypt iterations for cfb128 and
ofb128. All iteations use the same key, iv and plaintext.

Signed-off-by: Holger Dengler <dengler@linux.ibm.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23201)

(cherry picked from commit 3cb1b51dddf4deaf5e3886b827f3245d81670bc7)

18 months agoFix partial block encryption in cfb and ofb for s390x (legacy)
Holger Dengler [Fri, 5 Jan 2024 13:16:53 +0000 (14:16 +0100)] 
Fix partial block encryption in cfb and ofb for s390x (legacy)

Use the number of processed bytes information (num) from the generic
cipher context for the partial block handling in cfb and ofb also in
s390x-legacy code. For more details see 4df92c1a14 ("Fix partial block
encryption in cfb and ofb for s390x").

Signed-off-by: Holger Dengler <dengler@linux.ibm.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23201)

(cherry picked from commit f9ccd209c3d121668c51a992613c698f2a774cb3)

18 months agoFix partial block encryption in cfb and ofb for s390x
Holger Dengler [Thu, 4 Jan 2024 08:37:39 +0000 (09:37 +0100)] 
Fix partial block encryption in cfb and ofb for s390x

Use the number of processed bytes information (num) from the generic
cipher context for the partial block handling in cfb and ofb, instead
of keep this information in the s390x-specific part of the cipher
context. The information in the generic context is reset properly,
even if the context is re-initialized without resetting the key or iv.

Fixes: #23175
Signed-off-by: Holger Dengler <dengler@linux.ibm.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23201)

(cherry picked from commit 576a3572bebf6115df1c03527114cbf74d06f861)

18 months agoUpdate Docs for EVP_MAC
Neil Horman [Mon, 8 Jan 2024 19:29:52 +0000 (14:29 -0500)] 
Update Docs for EVP_MAC

For GMAC/CMAC, its not possible to re-init the algorithm without
explicitly passing an OSSL_MAC_PARAM_IV to each init call, as it is
not possible to extract the IV value from the prior init call (be it
explicitly passed or auto generated).  As such, document the fact that
re-initalization requires passing an IV parameter

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

(cherry picked from commit 7c1d533a512181b13de3bc0b7fa2fd8c481032d3)

18 months agoevp_fetch.c: Check meth_id instead of name_id
sashan [Mon, 8 Jan 2024 21:53:42 +0000 (22:53 +0100)] 
evp_fetch.c: Check meth_id instead of name_id

Fixes #23226

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23238)

(cherry picked from commit da840c3775f52fc9766c654b5ad6ee031ffc9fd9)

18 months agoFix a similar memory leak in SXNET_add_id_INTEGER
Bernd Edlinger [Tue, 9 Jan 2024 14:05:30 +0000 (15:05 +0100)] 
Fix a similar memory leak in SXNET_add_id_INTEGER

Even in the good case there was memory leak here.
Add a simple test case to have at least some test coverage.

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

(cherry picked from commit 398011848468c7e8e481b295f7904afc30934217)

18 months agoFix a possible memory leak in sxnet_v2i
Bernd Edlinger [Mon, 8 Jan 2024 14:31:32 +0000 (15:31 +0100)] 
Fix a possible memory leak in sxnet_v2i

When a subsequent call to SXNET_add_id_asc fails
e.g. because user is a string larger than 64 char
or the zone is a duplicate zone id,
or the zone is not an integer,
a memory leak may be the result.

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

(cherry picked from commit 0151e772195fc03cce0f12e5e266e51dc15243a0)

18 months agoAdd CHANGES.md and NEWS.md entries for CVE-2023-6129
Tomas Mraz [Thu, 4 Jan 2024 09:32:32 +0000 (10:32 +0100)] 
Add CHANGES.md and NEWS.md entries for CVE-2023-6129

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23200)

(cherry picked from commit 858c7bc210a406cc7f891ac2aed78692d2e02937)

18 months agopoly1305-ppc.pl: Fix vector register clobbering
Rohan McLure [Thu, 4 Jan 2024 09:25:50 +0000 (10:25 +0100)] 
poly1305-ppc.pl: Fix vector register clobbering

Fixes CVE-2023-6129

The POLY1305 MAC (message authentication code) implementation in OpenSSL for
PowerPC CPUs saves the the contents of vector registers in different order
than they are restored. Thus the contents of some of these vector registers
is corrupted when returning to the caller. The vulnerable code is used only
on newer PowerPC processors supporting the PowerISA 2.07 instructions.

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

(cherry picked from commit 8d847a3ffd4f0b17ee33962cf69c36224925b34f)

18 months agoAvoid memory leak if SXNET_add_id_INTEGER() fails
Tomas Mraz [Fri, 5 Jan 2024 10:01:34 +0000 (11:01 +0100)] 
Avoid memory leak if SXNET_add_id_INTEGER() fails

Fixes Coverity 1560046

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23211)

(cherry picked from commit 7054fc1ca3945342777f588fba43b77f669509ad)

18 months agoVMS: Add the missing -p32 and -p64 variants for x86_64
Richard Levitte [Wed, 20 Dec 2023 07:25:22 +0000 (08:25 +0100)] 
VMS: Add the missing -p32 and -p64 variants for x86_64

The pointer size support is already in the code, and is present for
all other supported hardwares.

Fixes #22899

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/23081)

18 months agoFix VMS installation - update vmsconfig.pm for consistency
Richard Levitte [Mon, 18 Dec 2023 11:49:08 +0000 (12:49 +0100)] 
Fix VMS installation - update vmsconfig.pm for consistency

An effort was made to update the VMS installation data to align with
configuration data.  This touched the script templates in VMS/, but
didn't update the generation of vmsconfig.pm to match...  and also
missed a spot.

This change adds the missing updates

Ref:
https://github.com/openssl/openssl/pull/16842

Fixes #22899

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/23081)

19 months agocleanse stack variable in kdf_pbkdf1_do_derive
Neil Horman [Wed, 3 Jan 2024 18:47:05 +0000 (13:47 -0500)] 
cleanse stack variable in kdf_pbkdf1_do_derive

kdf_pbkdf1_do_derive stores key derivation information in a stack
variable, which is left uncleansed prior to returning.  Ensure that the
stack information is zeroed prior to return to avoid potential leaks of
key information

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

(cherry picked from commit 5963aa8c196d7c5a940a979299a07418527932af)

19 months agoValidate config options during x509 extension creation
Neil Horman [Tue, 2 Jan 2024 20:48:00 +0000 (15:48 -0500)] 
Validate config options during x509 extension creation

There are several points during x509 extension creation which rely on
configuration options which may have been incorrectly parsed due to
invalid settings.  Preform a value check for null in those locations to
avoid various crashes/undefined behaviors

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

(cherry picked from commit bac7e687d71b124b09ad6ad3e15be9b38c08a1ba)

19 months agofixup! Adding interop tests
Neil Horman [Fri, 15 Dec 2023 19:35:04 +0000 (14:35 -0500)] 
fixup! Adding interop tests

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

(cherry picked from commit b062a3c552bf283319dede3437598f1747730053)

19 months agoAdding interop tests
Neil Horman [Tue, 14 Nov 2023 11:01:51 +0000 (06:01 -0500)] 
Adding interop tests

Fedora has some fairly nice interoperability tests that we can leverage
to build a PR and test it against gnutls and nss libraries.  This commit
adds the interop-tests.yml ci job to do that work, and run the interop
tests from beaker.

Fixes #20685

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

(cherry picked from commit 83783dd16e767483020e5b2dc3b1c0ac26520917)

19 months agoUpdate workflow to use GITHUB_WORKSPACE
Neil Horman [Tue, 19 Dec 2023 11:15:39 +0000 (06:15 -0500)] 
Update workflow to use GITHUB_WORKSPACE

It was pointed out the GITHUB_WORKSPACE points to the container path of
the workspace, so we can use it instead of hardcoding the
__w/openssl/openssl path

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

(cherry picked from commit 638ad52ae53ece2e870984430493e454f75d048a)

19 months agoAdding interop tests
Neil Horman [Tue, 14 Nov 2023 11:01:51 +0000 (06:01 -0500)] 
Adding interop tests

Fedora has some fairly nice interoperability tests that we can leverage
to build a PR and test it against gnutls and nss libraries.  This commit
adds the interop-tests.yml ci job to do that work, and run the interop
tests from beaker.

Fixes #20685

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

(cherry picked from commit 337eb99c8474ed380f3aa6fbd6b2a4ab5d39aa26)

19 months agofix buildtest job runner
Dmitry Misharov [Thu, 4 Jan 2024 13:19:10 +0000 (14:19 +0100)] 
fix buildtest job runner

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23203)

(cherry picked from commit 63256ca9edfc94d06de0a68097950039515fe852)

19 months agoFix a key repointing in various ciphers
Neil Horman [Tue, 12 Sep 2023 21:09:06 +0000 (17:09 -0400)] 
Fix a key repointing in various ciphers

In the dupctx fixups I missed a pointer that needed to be repointed to
the surrounding structures AES_KEY structure for the sm4/aes/aria
ccm/gcm variants.  This caused a colliding use of the key and possible
use after free issues.

Fixes #22076

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

19 months agoAdd dupctx support to rc4_hmac_md5 algo
Neil Horman [Fri, 1 Sep 2023 17:47:15 +0000 (13:47 -0400)] 
Add dupctx support to rc4_hmac_md5 algo

Pretty straightforward, just clone the requested context, no pointers to
fixup

Fixes #21887

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

19 months agoimplement dupctx for chacha20_poly1305
Neil Horman [Fri, 1 Sep 2023 17:22:03 +0000 (13:22 -0400)] 
implement dupctx for chacha20_poly1305

Same as chacha20 in the last commit, just clone the ctx and its
underlying tlsmac array if its allocated

Fixes #21887

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

19 months agoimplement dupctx for aes_WRAP methods
Neil Horman [Fri, 1 Sep 2023 15:28:33 +0000 (11:28 -0400)] 
implement dupctx for aes_WRAP methods

create a dupctx method for aes_WRAP implementations of all sizes

Fixes #21887

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

19 months agoAdd dupctx support to aead ciphers
Neil Horman [Fri, 1 Sep 2023 13:10:35 +0000 (09:10 -0400)] 
Add dupctx support to aead ciphers

Add dupctx method support to to ciphers implemented with IMPLEMENT_aead_cipher
This includes:
aes-<kbits>-gcm
aria-<kbits>-ccm
aria-<kbits>-gcm

Fixes #21887

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

19 months agomake inability to dup/clone ciphers an error
Neil Horman [Tue, 29 Aug 2023 19:42:48 +0000 (15:42 -0400)] 
make inability to dup/clone ciphers an error

There should be no reason that a cipher can't be duplicated

Fixes #21887

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

19 months agoadd missing doc of X509_REQ_get_extensions() and X509_REQ_add_extensions{,_nid}()
Dr. David von Oheimb [Mon, 1 Aug 2022 14:35:42 +0000 (16:35 +0200)] 
add missing doc of X509_REQ_get_extensions() and X509_REQ_add_extensions{,_nid}()

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(cherry picked from commit 47dc828c6b652feb9cef5b0e4186d010986f197c)

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/23190)

(cherry picked from commit 8632c09a2cd7be884b62e3cc94de84167c806f3d)

19 months agoClarify the PKCS12 docs
Matt Caswell [Wed, 3 Jan 2024 11:03:03 +0000 (11:03 +0000)] 
Clarify the PKCS12 docs

Issue #23151 asks a question about the meaning of the PKCS12
documentation. This PR attempts to clarify how friendlyName and localKeyID
are added to the PKCS12 structure.

Fixes #23151

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/23188)

(cherry picked from commit 3348713ad390372ba5a0a0f98b46b2f637475e47)

19 months agoevp_test.c: Fix provider compat tests CI failure
Tomas Mraz [Tue, 19 Dec 2023 17:52:12 +0000 (18:52 +0100)] 
evp_test.c: Fix provider compat tests CI failure

As in the provider compatibility tests we also run the
3.1.2 fips provider against the up-to-date 3.0 branch
the CI would still fail as 3.1.2 provider would be
expected to pass this check.

Update the required fips provider version to be
>3.1.4 or <3.1.0 and >3.0.12 instead.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Ben Kaduk <kaduk@mit.edu>
(Merged from https://github.com/openssl/openssl/pull/23099)

19 months agocleanse stack variable in blake2[b|s] finalization
Neil Horman [Mon, 1 Jan 2024 14:25:03 +0000 (09:25 -0500)] 
cleanse stack variable in blake2[b|s] finalization

If the output of a blake2[b|s] digest isn't a multipl of 8, then a stack
buffer is used to compute the final output, which is left un-zeroed
prior to return, allowing the potential leak of key data.  Ensure that,
if the stack variable is used, it gets cleared prior to return.

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

(cherry picked from commit 8b9cf1bc2c3085b6e9493a057209ffd0bddf48a6)

19 months agovalidate requested key length in kdf_pbkdf1_do_derive
Neil Horman [Mon, 1 Jan 2024 16:53:50 +0000 (11:53 -0500)] 
validate requested key length in kdf_pbkdf1_do_derive

When using pbkdf1 key deriviation, it is possible to request a key
length larger than the maximum digest size a given digest can produce,
leading to a read of random stack memory.

fix it by returning an error if the requested key size n is larger than
the EVP_MD_size of the digest

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

(cherry picked from commit 8d89050f0f676b429043fd5445e5a570d54ad225)

19 months agoprovider-keymgmt.pod: fix typo
rilysh [Fri, 29 Dec 2023 07:30:56 +0000 (02:30 -0500)] 
provider-keymgmt.pod: fix typo

Fix a typo from asymmmetric to asymmetric

CLA: trivial

Reviewed-by: Paul Yang <kaishen.yy@antfin.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23164)

(cherry picked from commit cf8fea86f73c4606f132133cb34c07f8dad42482)

19 months agoAdd missing documentation for X509_ATTRIBUTE related functions.
slontis [Wed, 8 Nov 2023 06:14:44 +0000 (16:14 +1000)] 
Add missing documentation for X509_ATTRIBUTE related functions.

Partial fix for #8026

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22656)

(cherry picked from commit f1f0731ddf6cb31d62a2c0f406b009ae9817ed7f)

19 months agoAllow duplicate CMS attributes
Tomas Mraz [Wed, 13 Dec 2023 11:21:04 +0000 (12:21 +0100)] 
Allow duplicate CMS attributes

Fixes regression introduced with https://github.com/openssl/openssl/pull/21505

Fixes #22266

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23029)

(cherry picked from commit d7e707cb4983a35b1a265c6042da410d829f3b19)

19 months agogate calling of evp_method_id on having a non-zero name id
Neil Horman [Wed, 20 Dec 2023 15:01:17 +0000 (10:01 -0500)] 
gate calling of evp_method_id on having a non-zero name id

If a name is passed to EVP_<OBJ>_fetch of the form:
name1:name2:name3

The names are parsed on the separator ':' and added to the store, but
during the lookup in inner_evp_generic_fetch, the subsequent search of
the store uses the full name1:name2:name3 string, which fails lookup,
and causes subsequent assertion failures in evp_method_id.

instead catch the failure in inner_evp_generic_fetch and return an error
code if the name_id against a colon separated list of names fails.  This
provides a graceful error return path without asserts, and leaves room
for a future feature in which such formatted names can be parsed and
searched for iteratively

Add a simple test to verify that providing a colon separated name
results in an error indicating an invalid lookup.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/23110)

(cherry picked from commit 94be985cbcc1f0a5cf4f172d4a8d06c5c623122b)

19 months agoDetect and prevent recursive config parsing
Neil Horman [Thu, 30 Nov 2023 19:28:09 +0000 (14:28 -0500)] 
Detect and prevent recursive config parsing

If a malformed config file is provided such as the following:

openssl_conf = openssl_init
[openssl_init]
providers = provider_sect
[provider_sect]
 = provider_sect

The config parsing library will crash overflowing the stack, as it
recursively parses the same provider_sect ad nauseum.

Prevent this by maintaing a list of visited nodes as we recurse through
referenced sections, and erroring out in the event we visit any given
section node more than once.

Note, adding the test for this revealed that our diagnostic code
inadvertently pops recorded errors off the error stack because
provider_conf_load returns success even in the event that a
configuration parse failed. The call path to provider_conf_load has been
updated in this commit to address that shortcoming, allowing recorded
errors to be visibile to calling applications.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/23120)

19 months agodoc: fix "the a" typos (and other things nearby)
James Muir [Sat, 16 Dec 2023 02:21:46 +0000 (21:21 -0500)] 
doc: fix "the a" typos (and other things nearby)

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/23068)

(cherry picked from commit aa3347ba9d670a747b46974ce46f2ed9ecb38662)

19 months agoAdd missing settable entry OSSL_ASYM_CIPHER_PARAM_OAEP_DIGEST_PROPS for RSA asym
slontis [Fri, 17 Feb 2023 00:00:50 +0000 (10:00 +1000)] 
Add missing settable entry OSSL_ASYM_CIPHER_PARAM_OAEP_DIGEST_PROPS for RSA asym

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20319)

(cherry picked from commit 26183614ed1dc03f509f26839b8a465684ca0f84)

19 months agoLimit RSA-OAEP related functions to RSA keys only
slontis [Thu, 16 Feb 2023 23:54:58 +0000 (09:54 +1000)] 
Limit RSA-OAEP related functions to RSA keys only

Make EVP_PKEY_CTX_set_rsa_oaep_md() and
EVP_PKEY_CTX_get_rsa_oaep_md_name() only work for RSA keys.

Since these calls use "digest" as a OSSL_PARAM, they should not
work for other key types.

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20319)

(cherry picked from commit 0c3eb31b55d3c1544e4e044c2e3c939655bac93d)

19 months agoFix memleak in rsa_cms_decrypt
slontis [Thu, 16 Feb 2023 23:51:59 +0000 (09:51 +1000)] 
Fix memleak in rsa_cms_decrypt

If a call to EVP_PKEY_CTX_set_rsa_mgf1_md() fails then the caller
needs to free the label.

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20319)

(cherry picked from commit d32dd65053431ee744d213b336b9a03a035807e6)

19 months agoFixed windows compilation issue
Gopal Sharma [Tue, 19 Dec 2023 06:14:42 +0000 (11:44 +0530)] 
Fixed windows compilation issue

Fixed - Windows compilation issue - unbale to find correct definitions of _InterlockedExchangeAdd.
Issue number - https://github.com/openssl/openssl/issues/21080

CLA: trivial

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23087)

19 months agoFix a possible memory leak in dh_cms_encrypt
Bernd Edlinger [Sun, 10 Dec 2023 14:07:08 +0000 (15:07 +0100)] 
Fix a possible memory leak in dh_cms_encrypt

Add a missing check of the return code of X509_ALGOR_set0,
otherwise the ASN1_STRING object wrap_str may be leaked.

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22998)

(cherry picked from commit a26635e0d7f3228035ae1d0d110ea88479f84754)

19 months agoAES: Document that the XTS, SIV, WRAP modes do not support streaming
Tomas Mraz [Wed, 13 Dec 2023 09:06:59 +0000 (10:06 +0100)] 
AES: Document that the XTS, SIV, WRAP modes do not support streaming

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/23028)

(cherry picked from commit 8f0f814d791e0825b96c30494594de619da3e5a5)

19 months agoBump actions/setup-python from 4.7.1 to 5.0.0
dependabot[bot] [Tue, 19 Dec 2023 18:00:12 +0000 (18:00 +0000)] 
Bump actions/setup-python from 4.7.1 to 5.0.0

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.7.1 to 5.0.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v4.7.1...v5.0.0)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
CLA: trivial

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22963)

(cherry picked from commit 51c85496dc227f277adbe0748d596e07d9a34bc2)

19 months agoFix a possible memory leak in ossl_x509_algor_md_to_mgf1
Bernd Edlinger [Sun, 10 Dec 2023 14:21:19 +0000 (15:21 +0100)] 
Fix a possible memory leak in ossl_x509_algor_md_to_mgf1

Add a missing check of the return code of X509_ALGOR_set0.
otherwise a memory leak may occur.

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22999)

(cherry picked from commit 493d6c9ab37b18b110c977a2bc896f06b18f6065)

19 months agoFix no-des failure in test_cms
Bernd Edlinger [Mon, 18 Dec 2023 20:38:22 +0000 (21:38 +0100)] 
Fix no-des failure in test_cms

The newly introduced test case do not work
when configured with no-des, fix that by
choosing -aes128 as cipher.

Fixes ffed597882ba ("cms: avoid intermittent test failure")

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

(cherry picked from commit 5b4f4474b2562c4422193e1719461a0ef5cbc3e5)

19 months agoci.yml: Fix bad conflict fix in backported patch
Tomas Mraz [Tue, 19 Dec 2023 11:11:51 +0000 (12:11 +0100)] 
ci.yml: Fix bad conflict fix in backported patch

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23090)

(cherry picked from commit b80cee9658ff18a6dbb575015589ebde1a94ffdc)

19 months agoConsolidate raising errors in SSL_CONF_cmd()
Tomas Mraz [Thu, 14 Dec 2023 17:33:57 +0000 (18:33 +0100)] 
Consolidate raising errors in SSL_CONF_cmd()

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/23048)

(cherry picked from commit 430dcbd0463573fece704263648cc15e891c3d49)

19 months agoTest that incorrect entry in the ssl section is not fatal
Tomas Mraz [Thu, 14 Dec 2023 15:37:58 +0000 (16:37 +0100)] 
Test that incorrect entry in the ssl section is not fatal

The following entries should be still applied.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/23048)

(cherry picked from commit 17b4277d9ac6665e9b53a6270949418154cab2dc)

19 months agoAlways apply all configuration settings from the ssl section
Tomas Mraz [Thu, 14 Dec 2023 15:26:21 +0000 (16:26 +0100)] 
Always apply all configuration settings from the ssl section

Even if some configuration entry is incorrect, do not
skip the remaining ones.

Fixes #20789

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/23048)

(cherry picked from commit 69c067ffbc2c02295e20c90e557b6fcb2f7da69c)

19 months agorun Windows GitHub CI workflow on self-hosted runners
Dmitry Misharov [Thu, 14 Dec 2023 12:36:04 +0000 (13:36 +0100)] 
run Windows GitHub CI workflow on self-hosted runners

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23042)

(cherry picked from commit ce42b72cb1ca2ba8669bc28a70ed9dca28b7a551)