]> git.ipfire.org Git - thirdparty/openssl.git/log
thirdparty/openssl.git
11 months agoFix SSL_CTX_set1_groups documentation on preference orders
David Benjamin [Fri, 8 Mar 2024 04:38:58 +0000 (23:38 -0500)] 
Fix SSL_CTX_set1_groups documentation on preference orders

The documentation currently describes SSL_CTX_set1_groups as a
preference order, but this does not match the typical interpretation of
"preference order" in OpenSSL and TLS. Typically, an application can
order more secure options ahead of less secure ones and pick up TLS's
usual downgrade protection guarantees.

TLS 1.3 servers need to balance an additional consideration: some
options will perform worse than others due to key share prediction. The
prototypical selection procedure is to first select the set of more
secure options, then select the most performant among those.

OpenSSL follows this procedure, but it *unconditionally* treats all
configured curves as equivalent security. Per discussion on GitHub,
OpenSSL's position is that this is an intended behavior.

While not supported by built-in providers, OpenSSL now documents that
external providers can extend the group list and CHANGES.md explicitly
cites post-quantum as a use case. With post-quantum providers, it's
unlikely that application developers actually wanted options to be
equivalent security. To avoid security vulnerabilities arising from
mismatched expectations, update the documentation to clarify the server
behavior.

Per the OTC decision in
https://github.com/openssl/openssl/issues/22203#issuecomment-1744465829,
this documentation fix should be backported to stable branches.

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23776)

(cherry picked from commit 2ec4e9501423cdc886c5a300b4f8bb249a3df4da)

11 months agoUpdate krb5 to latest master to pick up CVE fixes
Shih-Yi Chen [Wed, 7 Aug 2024 21:33:53 +0000 (21:33 +0000)] 
Update krb5 to latest master to pick up CVE fixes

CLA: trivial

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

(cherry picked from commit 099a71b48b6e1f27f39b2905fb67f2afaefd9171)

11 months agotest: add FIPS provider version checks for 3.4 compatibility
Pauli [Thu, 8 Aug 2024 00:55:15 +0000 (10:55 +1000)] 
test: add FIPS provider version checks for 3.4 compatibility

Tests that are changed by #25020 mandate updates to older test suite data to
pass because the FIPS provider's behaviour changes in 3.4.

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

11 months agolimit bignums to 128 bytes
Neil Horman [Fri, 26 Jul 2024 15:01:05 +0000 (11:01 -0400)] 
limit bignums to 128 bytes

Keep us from spinning forever doing huge amounts of math in the fuzzer

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/25013)

(cherry picked from commit f0768376e1639d12a328745ef69c90d584138074)

11 months agoUpdate BN_add.pod documentation so it is consistent with header declarations
JulieDzeze1 [Fri, 19 Apr 2024 21:50:19 +0000 (17:50 -0400)] 
Update BN_add.pod documentation so it is consistent with header declarations

CLA: trivial

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24215)

(cherry picked from commit e77eb1dc0be75c98c53c932c861dd52e8896cc13)

11 months agorsa_pss_compute_saltlen(): Avoid integer overflows and check MD and RSA sizes
Tomas Mraz [Mon, 5 Aug 2024 13:08:39 +0000 (15:08 +0200)] 
rsa_pss_compute_saltlen(): Avoid integer overflows and check MD and RSA sizes

Fixes Coverity 1604651

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

(cherry picked from commit 217e215e99dd526ad2e6f83601449742d1d03d6a)

11 months agodo_print_ex(): Avoid possible integer overflow
Tomas Mraz [Mon, 5 Aug 2024 12:49:52 +0000 (14:49 +0200)] 
do_print_ex(): Avoid possible integer overflow

Fixes Coverity 1604657
Fixes openssl/project#780

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/25084)

(cherry picked from commit e3e15e77f14cc4026fd456cc8a2b5190b2d79610)

12 months agoFix typos found by codespell in openssl-3.3 doc
Dimitri Papadopoulos [Sun, 21 Jul 2024 09:37:03 +0000 (11:37 +0200)] 
Fix typos found by codespell in openssl-3.3 doc

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Paul Yang <kaishen.yy@antfin.com>
(Merged from https://github.com/openssl/openssl/pull/24950)

12 months agoUse parent directory instead of index.html
Andrew Dinh [Fri, 2 Aug 2024 14:01:12 +0000 (21:01 +0700)] 
Use parent directory instead of index.html

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

(cherry picked from commit 5854b764a762598b662a5166be8d0030af06c1c0)

12 months agoUpdate links in CONTRIBUTING.md
Andrew Dinh [Fri, 2 Aug 2024 13:58:13 +0000 (20:58 +0700)] 
Update links in CONTRIBUTING.md

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

(cherry picked from commit ad3d57d27141c09fe07ef39c49af5afe69c59383)

12 months agoFix some small typos
Andrew Dinh [Fri, 2 Aug 2024 13:54:13 +0000 (20:54 +0700)] 
Fix some small typos

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

(cherry picked from commit d0a49eea4a8bb50f7d2269bac390a0ce2cddeb1f)

12 months agoDo not implicitly start connection with SSL_handle_events() or SSL_poll()
Tomas Mraz [Thu, 1 Aug 2024 17:36:00 +0000 (19:36 +0200)] 
Do not implicitly start connection with SSL_handle_events() or SSL_poll()

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

(cherry picked from commit ca1d2db291530a827555b40974ed81efb91c2d19)

12 months agoReturn infinity time from SSL_get_event_timeout when the connection is not started
Tomas Mraz [Thu, 1 Aug 2024 17:14:16 +0000 (19:14 +0200)] 
Return infinity time from SSL_get_event_timeout when the connection is not started

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

(cherry picked from commit b1f4aebb74192afb197487bf6f4998fbb87cd1c1)

12 months agoDo not falsely start the connection through SSL_pending()/_has_pending()
Tomas Mraz [Thu, 1 Aug 2024 15:17:42 +0000 (17:17 +0200)] 
Do not falsely start the connection through SSL_pending()/_has_pending()

Fixes #25054

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

(cherry picked from commit b7f93c7fcb37c81b88895c3e8d22ad69c2576cd4)

12 months agofix: util/mkinstallvars.pl mistreated LDLIBS on Unix (and Windows)
Richard Levitte [Sun, 28 Jul 2024 08:47:08 +0000 (10:47 +0200)] 
fix: util/mkinstallvars.pl mistreated LDLIBS on Unix (and Windows)

Don't do comma separation on those platforms.

Fixes #24986

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

(cherry picked from commit 0beef0ba00f7864b7367899d859509a99237fcf0)

12 months agoFree fetched digest in show_digests
Marc Brooks [Tue, 30 Jul 2024 20:29:34 +0000 (15:29 -0500)] 
Free fetched digest in show_digests

Fixes #24892

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25046)

(cherry picked from commit 871c534d39efecc2087da0fd24ff72e2712031a4)

12 months agoevp_get_digest/cipherbyname_ex(): Try to fetch if not found
Tomas Mraz [Fri, 19 Jul 2024 10:24:47 +0000 (12:24 +0200)] 
evp_get_digest/cipherbyname_ex(): Try to fetch if not found

If the name is not found in namemap, we need
to try to fetch the algorithm and query the
namemap again.

Fixes #19338

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

(cherry picked from commit 454ca902c7d5337249172b38efc5e4fd63f483f4)

12 months agoAvoid leaking *ba_ret on reconnections
Tomas Mraz [Thu, 18 Jul 2024 09:01:00 +0000 (11:01 +0200)] 
Avoid leaking *ba_ret on reconnections

Also fixes Coverity 1604639
There is no point in checking ba_ret as it can never be NULL.

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/24931)

(cherry picked from commit 4fa9d1f40fc85d8c70c93168dc812217db349359)

12 months agoUpdate X509V3_get_d2i.pod returned pointer needs to be freed
jasper-smit-servicenow [Thu, 18 Jul 2024 07:45:22 +0000 (09:45 +0200)] 
Update X509V3_get_d2i.pod returned pointer needs to be freed

CLA: trivial

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/24927)

(cherry picked from commit a4fd94851261c55f9ad020bf22d4f29bda0b58be)

12 months agoi2d_name_canon(): Check overflow in len accumulation
Tomas Mraz [Thu, 18 Jul 2024 08:48:58 +0000 (10:48 +0200)] 
i2d_name_canon(): Check overflow in len accumulation

Fixes Coverity 1604638

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/24930)

(cherry picked from commit b2deefb9d262f0f9eae6964006df98c2fa24daac)

12 months agogitignore: add .DS_Store
Georgi Valkov [Fri, 19 Jul 2024 10:24:27 +0000 (13:24 +0300)] 
gitignore: add .DS_Store

macOS creates .DS_Store files all over the place while browsing
directories. Add it to the list of ignored files.

Signed-off-by: Georgi Valkov <gvalkov@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/24942)

(cherry picked from commit 10c36d2f8d81a6f2b9a75f914fe094300835ba01)

12 months agoAllow short reads in asn1_d2i_read_bio()
Tomas Mraz [Tue, 24 Oct 2023 07:27:23 +0000 (09:27 +0200)] 
Allow short reads in asn1_d2i_read_bio()

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/22486)

(cherry picked from commit 202ef97edc8e5561a6f4db28919d5ed73d411cc7)

12 months agoImprove clarity and readability of password input documentation
erbsland-dev [Sun, 14 Jul 2024 17:14:49 +0000 (19:14 +0200)] 
Improve clarity and readability of password input documentation

Fixed #7310: Enhanced existing documentation for password input methods
- Refined descriptions for password input methods: `file:`, `fd:`, and `stdin`
- Enhanced readability and consistency in the instructions
- Clarified handling of multiple lines in read files.
- Clarified that `fd:` is not supported on Windows.

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

(cherry picked from commit 0d4663ca6a91eb5eeb7bbe24a3b5a7cbee9e0fad)

12 months agoEVP_PKEY-DH.pod: Clarify the manpage in regards to DH and DHX types
Tomas Mraz [Tue, 9 Jul 2024 15:58:47 +0000 (17:58 +0200)] 
EVP_PKEY-DH.pod: Clarify the manpage in regards to DH and DHX types

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/24819)

(cherry picked from commit cf3d65b8664f11904ad34f21fe78a6694f23ae62)

12 months agoDocument that DH and DHX key types cannot be used together in KEX
Tomas Mraz [Tue, 9 Jul 2024 07:17:05 +0000 (09:17 +0200)] 
Document that DH and DHX key types cannot be used together in KEX

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/24819)

(cherry picked from commit 45611a8a8962c06e1d7ba0e5c00974da17e9c37a)

12 months agoFix coverity-1604666
Neil Horman [Mon, 15 Jul 2024 18:30:16 +0000 (14:30 -0400)] 
Fix coverity-1604666

Coverity recently flaged an error in which the return value for
EVP_MD_get_size wasn't checked for negative values prior to use, which
can cause underflow later in the function.

Just add the check and error out if get_size returns an error.

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24896)

(cherry picked from commit 22e08c7cdc596d4f16749811d1022fb8b07a8e41)

12 months agoFix coverity-1604665
Neil Horman [Mon, 15 Jul 2024 19:59:14 +0000 (15:59 -0400)] 
Fix coverity-1604665

Coverity issued an error in the opt_uintmax code, detecting a potential
overflow on a cast to ossl_intmax_t

Looks like it was just a typo, casting m from uintmax_t to ossl_intmax_t

Fix it by correcting the cast to be ossl_uintmax_t, as would be expected

Theres also some conditionals that seem like they should be removed, but
I'll save that for later, as there may be some corner cases in which
ossl_uintmax_t isn't equal in size to uintmax_t..maybe.

Fixes openssl/private#567

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

(cherry picked from commit a753547eefc9739f341824a0cb0642afe7a06fcc)

12 months agoUnit test for switching from KMAC to other MAC in kbkdf.
Pauli [Mon, 15 Jul 2024 04:53:54 +0000 (14:53 +1000)] 
Unit test for switching from KMAC to other MAC in kbkdf.

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

(cherry picked from commit 90c3db9e6a2bfbc1086d6d4b90d4fc7c7e565b93)

12 months agoFix kbkdf bug if MAC is set to KMAC and then something else
Pauli [Mon, 15 Jul 2024 03:26:50 +0000 (13:26 +1000)] 
Fix kbkdf bug if MAC is set to KMAC and then something else

A context that is set to KMAC sets the is_kmac flag and this cannot be reset.
So a user that does kbkdf using KMAC and then wants to use HMAC or CMAC will
experience a failure.

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

(cherry picked from commit f35fc4f184fa8a2088cd16648c4017fa321d6712)

12 months agoAdd tests for long configuration lines with backslashes
erbsland-dev [Mon, 15 Jul 2024 15:07:52 +0000 (17:07 +0200)] 
Add tests for long configuration lines with backslashes

Introduce new test files to verify behavior with config lines longer than 512 characters containing backslashes. Updated test plan to include these new test scenarios.

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

(cherry picked from commit 2dd74d3acb9425251a2028504f07623bd97bfe87)

12 months agoFix line continuation check in config parser
erbsland-dev [Mon, 15 Jul 2024 10:16:09 +0000 (12:16 +0200)] 
Fix line continuation check in config parser

Fixes #8038: Previously, line continuation logic did not account for the 'again' flag, which could cause incorrect removal of a backslash character in the middle of a line. This fix ensures that line continuation is correctly handled only when 'again' is false, thus improving the reliability of the configuration parser.

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

(cherry picked from commit f54e4bc51b78c10dc99a61c087861ee2c11d7a41)

12 months agoClarify in-place encryption behavior in documentation
erbsland-dev [Mon, 15 Jul 2024 08:50:37 +0000 (10:50 +0200)] 
Clarify in-place encryption behavior in documentation

Fixes #7941: Update the `EVP_EncryptUpdate` documentation to specify that in-place encryption is guaranteed only if the context does not contain incomplete data from previous operations.

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

(cherry picked from commit f692ceeedcd104407b7672c67d62d6f86f8ac182)

12 months agoFix cmake generator
Neil Horman [Sun, 14 Jul 2024 12:57:25 +0000 (08:57 -0400)] 
Fix cmake generator

PR #24678 modified some environment variables and locations that the
cmake exporter depended on, resulting in empty directory resolution.
Adjust build build.info and input variable names to match up again

Fixes #24874

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

(cherry picked from commit c1a27bdeb9a4f915aa92ed0e74ed48a1f9b94176)

12 months agoSet down_load factor on hash table when culling items in doall
Neil Horman [Fri, 12 Jul 2024 13:38:52 +0000 (09:38 -0400)] 
Set down_load factor on hash table when culling items in doall

oss-fuzz noted this issue:
https://oss-fuzz.com/testcase-detail/5363002606419968

Which reports a heap buffer overflow during ossl_method_cache_flush_some

Its occuring because we delete items from the hash table while inside
its doall iterator

The iterator in lhash.c does a reverse traversal of all buckets in the
hash table, and at some point a removal during an iteration leads to the
hash table shrinking, by calling contract.  When that happens, the
bucket index becomes no longer valid, and if the index we are on is
large, it exceeds the length of the list, leading to an out of band
reference, and the heap buffer overflow report.

Fix it by preventing contractions from happening during the iteration,
but setting the down_load factor to 0, and restoring it to its initial
value after the iteration is done

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/24867)

(cherry picked from commit 01753c09bbfdffcefd555b4c21e50e68af346129)

12 months agoFix a copy & paste error in the EVP_RAND docs
Matt Caswell [Fri, 12 Jul 2024 08:16:36 +0000 (09:16 +0100)] 
Fix a copy & paste error in the EVP_RAND docs

The "max_request" string is defined via the OSSL_RAND_PARAM_MAX_REQUEST
macro.

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

(cherry picked from commit 5c6975bd44dce4bb342b7bc130de5aaefbe2c35b)

12 months agoRearrange code examples in docs for clarity
Daniel Gustafsson [Fri, 12 Jul 2024 10:08:04 +0000 (12:08 +0200)] 
Rearrange code examples in docs for clarity

The introduction of a deprecation notice between the header include
line and the function prototypes left the inclusion in the previous
block.  Move the #include to after the deprecation notice to ensure
that the headers is included together with the corresponding MDX_y*
functions.

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

(cherry picked from commit b33f2697d953ac5dbadbe99d4110fe907b215ad8)

12 months agoFix a minor typo in the documentation of RAND_set_seed_source_type()
Matt Caswell [Thu, 11 Jul 2024 14:49:21 +0000 (15:49 +0100)] 
Fix a minor typo in the documentation of RAND_set_seed_source_type()

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/24858)

(cherry picked from commit e8c7febc8f1b0ef9e5b62b0944748d2830b1a0b4)

12 months agoDocument Internal EVP_MD_CTX_ Flags
erbsland-dev [Thu, 11 Jul 2024 12:02:53 +0000 (14:02 +0200)] 
Document Internal EVP_MD_CTX_ Flags

Add documentation for the internal flags `EVP_MD_CTX_FLAG_CLEANED` and
`EVP_MD_CTX_FLAG_REUSE`, explicitly stating that these flags are for
internal use only and must not be used in user code.

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

(cherry picked from commit b74646b627ade4ff801914d45a7733af2ebf4b5f)

12 months agoriscv: Fix cpuid_obj asm checks for sm4/sm3
Hongren Zheng [Fri, 24 May 2024 06:12:47 +0000 (14:12 +0800)] 
riscv: Fix cpuid_obj asm checks for sm4/sm3

Similar to #22881 / #23752

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

(cherry picked from commit 6cf42ad392241c9fee586d99b53d9bfa74130b0b)

12 months agodeploy docs.openssl.org on doc changes
Dmitry Misharov [Wed, 10 Jul 2024 12:51:04 +0000 (14:51 +0200)] 
deploy docs.openssl.org on doc changes

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

(cherry picked from commit 8b591dceeff52965dbde14a0e455c5d3548a2609)

12 months agoEVP_DigestUpdate(): Check if ctx->update is set
sashan [Thu, 27 Jun 2024 14:31:41 +0000 (16:31 +0200)] 
EVP_DigestUpdate(): Check if ctx->update is set

The issue has been discovered by libFuzzer running on provider target.
There are currently three distinct reports which are addressed by
code change here.

    https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=69236#c1
    https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=69243#c1
    https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=69261#c1

the issue has been introduced with openssl 3.0.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24753)

(cherry picked from commit ad33d62396b7e9db04fdf060481ced394d391688)

12 months agoDependabot update
dependabot[bot] [Wed, 10 Jul 2024 17:07:01 +0000 (17:07 +0000)] 
Dependabot update

CLA: trivial

(deps): Bump actions/setup-python

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 5.1.0 to 5.1.1.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v5.1.0...v5.1.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24843)

(cherry picked from commit 00163371fa502df62465163185a9a434574d6746)

12 months agoAdd a style-check workflow
Neil Horman [Mon, 8 Jul 2024 12:32:29 +0000 (08:32 -0400)] 
Add a style-check workflow

Add a CI job that evaluates style issues, restricted only to lines
changed for the affected files in a given commit

Also provide a mechanism to waive those style issues.  by applying the
style:exempted label to a PR, the checks are still run (its nice to see
what they are regardless), but the test will pass CI regardless of
weather any issues are found.

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

(cherry picked from commit fc22d74c53720d14f99fd880b767d8a3e4986ae2)

12 months agoAdd a check-format-commit.sh script
Neil Horman [Mon, 8 Jul 2024 12:30:49 +0000 (08:30 -0400)] 
Add a check-format-commit.sh script

Add a wrapper script to check-format.pl, which is capable of analyzing
commits rather than just a file.  for a provided commit this script:

1) runs check-format.pl on the files changed in the provided commit

2) filters the output of check-format.pl, only producing lines that
   match ranges of changed lines in those files

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

(cherry picked from commit acae12eb781658479b4fb3fee6334fd14a3c2739)

12 months agoEnhance documentation for `BN_mask_bits()`
erbsland-dev [Mon, 8 Jul 2024 10:35:55 +0000 (12:35 +0200)] 
Enhance documentation for `BN_mask_bits()`

Fixes #5537

Added a note that the error check for `BN_mask_bits()` depends
on the internal representation that depends on the platform's word size.
Included a reference to the `BN_num_bits()` function for precise bit checking.

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

(cherry picked from commit 2a45839778955ffcab01918f10544d46e42f9a5b)

12 months agoClarify supported curves in the s_client/s_server documentation
olszomal [Mon, 8 Jul 2024 09:50:35 +0000 (11:50 +0200)] 
Clarify supported curves in the s_client/s_server documentation

Mention that supported curves (aka groups) include named EC parameters
as well as X25519 and X448 or FFDHE groups.

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

(cherry picked from commit 775188702574dcd6cc53b7a9d3501a639c146121)

12 months agoread lock store on ossl_method_store_do_all
Neil Horman [Tue, 2 Jul 2024 18:27:42 +0000 (14:27 -0400)] 
read lock store on ossl_method_store_do_all

Theres a data race between ossl_method_store_insert and
ossl_method_store_do_all, as the latter doesn't take the property lock
before iterating.

However, we can't lock in do_all, as the call stack in several cases
later attempts to take the write lock.

The choices to fix it are I think:
1) add an argument to indicate to ossl_method_store_do_all weather to
   take the read or write lock when doing iterations, and add an
   is_locked api to the ossl_property_[read|write] lock family so that
   subsequent callers can determine if they need to take a lock or not

2) Clone the algs sparse array in ossl_method_store_do_all and use the
   clone to iterate with no lock held, ensuring that updates to the
   parent copy of the sparse array are left untoucheTheres a data race
   between ossl_method_store_insert and ossl_method_store_do_all, as the
   latter doesn't take the property lock before iterating.

I think method (2), while being a bit more expensive, is probably the
far less invasive way to go here

Fixes #24672

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

(cherry picked from commit d8def79838cd0d5e7c21d217aa26edb5229f0ab4)

12 months agoAvoid NULL pointer dereference
Radek Krejci [Thu, 21 Mar 2024 12:19:23 +0000 (13:19 +0100)] 
Avoid NULL pointer dereference

Function readbuffer_gets() misses some of the initial checks of its
arguments. Not checking them can lead to a later NULL pointer
dereferences.

The checks are now unified with the checks in readbuffer_read()
function.

CLA: trivial
Fixes #23915

Signed-off-by: Radek Krejci <radek.krejci@oracle.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23918)

(cherry picked from commit c215d75f94fcaa598817e739221f33b71b53fb39)

12 months agocheck_format.pl: fix detection of 'if' with single stmt in braces without 'else'
Dr. David von Oheimb [Sat, 6 Jul 2024 15:55:25 +0000 (17:55 +0200)] 
check_format.pl: fix detection of 'if' with single stmt in braces without 'else'

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

(cherry picked from commit f35c0894130e34ff46a429f4373c14ca98437405)

12 months agoFix possible double-free in pkcs7 add_attribute function
Bernd Edlinger [Tue, 14 Nov 2023 01:55:36 +0000 (02:55 +0100)] 
Fix possible double-free in pkcs7 add_attribute function

The problem is the ownership of the input parameter value
is transfered to the X509_ATTRIBUTE object attr, as soon
as X509_ATTRIBUTE_create succeeds, but when an error happens
after that point there is no way to get the ownership back
to the caller, which is necessary to fullfill the API contract.

Fixed that by moving the call to X509_ATTRIBUTE_create to the
end of the function, and make sure that no errors are possible
after that point.

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

(cherry picked from commit 82a13a1f5053462f826bfb90061f0f77e3cc98a5)

13 months agofuzz/decoder.c: Lower the limits on key checks
Tomas Mraz [Tue, 2 Jul 2024 13:36:03 +0000 (15:36 +0200)] 
fuzz/decoder.c: Lower the limits on key checks

These checks still take too long time on clusterfuzz
so they are longer than the timeout limit.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/24781)

(cherry picked from commit 29696af689df734cae05181d85ee04470c3839d3)

13 months agoFix incorrect sentence
Daniel Gustafsson [Wed, 3 Jul 2024 13:12:01 +0000 (15:12 +0200)] 
Fix incorrect sentence

Remove superfluous "the" from sentence.

CLA: trivial

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24790)

(cherry picked from commit 59c415a45f47cb34147427e46c78d945919b1da2)

13 months agoAllow shared iOS builds
Frederik Wedel-Heinen [Fri, 14 Jun 2024 12:57:28 +0000 (14:57 +0200)] 
Allow shared iOS builds

Fixes #24545

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

(cherry picked from commit 070b6a965485e91b02453919e0a47c0659420d9a)

13 months agoUnlock only when lock was successful
cchinchole [Tue, 2 Jul 2024 01:16:03 +0000 (20:16 -0500)] 
Unlock only when lock was successful

Addressing issue (#24517):
Updated the example in CRYPTO_THREAD_run_once.pod to reflect that an unlock call should not be made if a write_lock failed.
Updated BIO_lookup_ex in bio_addr.c and ossl_engine_table_select in eng_table.c to not call unlock if the lock failed.

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

(cherry picked from commit 3f4da93678497fe64d262d03c388932f7ecfe74e)

13 months agoFixes for potential deadlock
cchinchole [Tue, 2 Jul 2024 07:56:22 +0000 (02:56 -0500)] 
Fixes for potential deadlock

Fixes (#24517):
(3/3) Addresses the potential deadlock if an error occurs from up_ref
in functions ENGINE_get_first, ENGINE_get_last, ENGINE_get_next, and
ENGINE_get_prev in file crypto/engine/eng_list.c

CLA: trivial

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

(cherry picked from commit e6174ca4d48f6f4f954dd87f2cdf3718af14f064)

13 months agoConfigure: Remove -Wswitch-default from strict warnings
Tomas Mraz [Fri, 28 Jun 2024 08:34:23 +0000 (10:34 +0200)] 
Configure: Remove -Wswitch-default from strict warnings

Also move -Wno-tautological-constant-out-of-range-compare to
clang-specific options as it is not supported by gcc.

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24758)

13 months agofix: remove some odd empty lines
Richard Levitte [Mon, 1 Jul 2024 13:28:39 +0000 (15:28 +0200)] 
fix: remove some odd empty lines

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

(cherry picked from commit cfe0bbdecadaebc6ad7ba5a3335b7a03522c434f)

13 months agofix: openssl speed: RSA encryption is on the pubkey, not the privkey
Richard Levitte [Mon, 1 Jul 2024 13:28:14 +0000 (15:28 +0200)] 
fix: openssl speed: RSA encryption is on the pubkey, not the privkey

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

(cherry picked from commit bb90a7861cbf27e29790b66077c23a2e9805014b)

13 months agoBIO_f_base64.pod and openssl-enc.pod.in: improve description on newline handling
Dr. David von Oheimb [Mon, 11 Jul 2022 17:55:10 +0000 (19:55 +0200)] 
BIO_f_base64.pod and openssl-enc.pod.in: improve description on newline handling

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

(cherry picked from commit b1e7bc5bdfc73ef841afa30ac321975b0d63219a)

13 months agoOPENSSL_hexstr2buf_ex(): Handle zero-length input correctly
Tomas Mraz [Mon, 1 Jul 2024 07:30:56 +0000 (09:30 +0200)] 
OPENSSL_hexstr2buf_ex(): Handle zero-length input correctly

In case of zero-length input the code wrote one byte
before the start of the output buffer. The length
of the output was also reported incorrectly in this case.

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24770)

(cherry picked from commit 3f7b355733407cf777bfad5ce5b79610588bacc5)

13 months agoCheck EC_GROUP_get0_order result before dereference
JohnnySavages [Thu, 27 Jun 2024 01:59:52 +0000 (21:59 -0400)] 
Check EC_GROUP_get0_order result before dereference

CLA: trivial

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

(cherry picked from commit 16311dbf53c464726d73b76d77ecf6275c9f9d08)

13 months agoOpenSSL::Test: Avoid running IPv6 related tests if IPv6 was explicitly disabled
Richard Levitte [Thu, 27 Jun 2024 06:30:28 +0000 (08:30 +0200)] 
OpenSSL::Test: Avoid running IPv6 related tests if IPv6 was explicitly disabled

It's possible to disable IPv6  explicitly when configuring OpenSSL.  In that
case, IPv6 related tests should be skipped.

This is solved by having OpenSSL::Test::Utils::have_IPv6() check configuration
first, before trying to determine if the machine supports IPv6.

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

(cherry picked from commit 5a9c90b1e59b2c368876229862fbff29f2bcf006)

13 months agoClarify DRBG seeding.
Pauli [Thu, 27 Jun 2024 00:08:05 +0000 (10:08 +1000)] 
Clarify DRBG seeding.

There is a legacy code path that OpenSSL won't use anymore but applications
could.  Add a comment indicating this to avoid confusion for people not
intimately conversant with the nuances in the RNG code.

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

(cherry picked from commit 1eb122aa0ca152dc564e61674caf3f11acd85b57)

13 months agoAdd aix-clang and aix64-clang configuration
sanumesh [Tue, 11 Jun 2024 14:47:07 +0000 (09:47 -0500)] 
Add aix-clang and aix64-clang configuration

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

(cherry picked from commit 7afa7731e924d5ac10fc992d8cd777f407d33af9)

13 months agoFree appname if it was set after initializing crypto.
sgzmd [Tue, 25 Jun 2024 14:53:32 +0000 (15:53 +0100)] 
Free appname if it was set after initializing crypto.

Fixes #24729

CLA: trivial

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24730)

(cherry picked from commit fbd6609bb21b125c9454d07c484d166a33b4815b)

13 months agodocs: document that *_free(NULL) does nothing
Vita Batrla [Tue, 25 Jun 2024 09:58:49 +0000 (11:58 +0200)] 
docs: document that *_free(NULL) does nothing

Explicitly documents that *_free(NULL) does nothing.
Fixes two cases where that wasn't true.
Fixes #24675.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Sasa Nedvedicky <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24735)

(cherry picked from commit 981d129a5609ee2e031367c34c67a9f61a5bfd66)

13 months agoAdd a test for an empty NextProto message
Matt Caswell [Fri, 21 Jun 2024 13:29:26 +0000 (14:29 +0100)] 
Add a test for an empty NextProto message

It is valid according to the spec for a NextProto message to have no
protocols listed in it. The OpenSSL implementation however does not allow
us to create such a message. In order to check that we work as expected
when communicating with a client that does generate such messages we have
to use a TLSProxy test.

Follow on from CVE-2024-5535

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

(cherry picked from commit 214c724e00d594c3eecf4b740ee7af772f0ee04a)

13 months agoAdd explicit testing of ALN and NPN in sslapitest
Matt Caswell [Fri, 21 Jun 2024 09:09:41 +0000 (10:09 +0100)] 
Add explicit testing of ALN and NPN in sslapitest

We already had some tests elsewhere - but this extends that testing with
additional tests.

Follow on from CVE-2024-5535

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

(cherry picked from commit de71058567b84c6e14b758a383e1862eb3efb921)

13 months agoAdd ALPN validation in the client
Matt Caswell [Fri, 21 Jun 2024 10:51:54 +0000 (11:51 +0100)] 
Add ALPN validation in the client

The ALPN protocol selected by the server must be one that we originally
advertised. We should verify that it is.

Follow on from CVE-2024-5535

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

(cherry picked from commit 238fa464d6e38aa2c92af70ef9580c74cff512e4)

13 months agoCorrect return values for tls_construct_stoc_next_proto_neg
Matt Caswell [Fri, 21 Jun 2024 09:41:55 +0000 (10:41 +0100)] 
Correct return values for tls_construct_stoc_next_proto_neg

Return EXT_RETURN_NOT_SENT in the event that we don't send the extension,
rather than EXT_RETURN_SENT. This actually makes no difference at all to
the current control flow since this return value is ignored in this case
anyway. But lets make it correct anyway.

Follow on from CVE-2024-5535

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

(cherry picked from commit e10a3a84bf73a3e6024c338b51f2fb4e78a3dee9)

13 months agoAllow an empty NPN/ALPN protocol list in the tests
Matt Caswell [Tue, 4 Jun 2024 14:47:32 +0000 (15:47 +0100)] 
Allow an empty NPN/ALPN protocol list in the tests

Allow ourselves to configure an empty NPN/ALPN protocol list and test what
happens if we do.

Follow on from CVE-2024-5535

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

(cherry picked from commit 9925c97a8e8c9887765a0979c35b516bc8c3af85)

13 months agoAdd a test for SSL_select_next_proto
Matt Caswell [Fri, 31 May 2024 15:35:16 +0000 (16:35 +0100)] 
Add a test for SSL_select_next_proto

Follow on from CVE-2024-5535

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

(cherry picked from commit 0d883f6309b6905d29ffded6d703ded39385579c)

13 months agoClarify the SSL_select_next_proto() documentation
Matt Caswell [Fri, 31 May 2024 10:46:38 +0000 (11:46 +0100)] 
Clarify the SSL_select_next_proto() documentation

We clarify the input preconditions and the expected behaviour in the event
of no overlap.

Follow on from CVE-2024-5535

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

(cherry picked from commit a210f580f450bbd08fac85f06e27107b8c580f9b)

13 months agoUse correctly formatted ALPN data in tserver
Matt Caswell [Fri, 31 May 2024 10:22:13 +0000 (11:22 +0100)] 
Use correctly formatted ALPN data in tserver

The QUIC test server was using incorrectly formatted ALPN data. With the
previous implementation of SSL_select_next_proto this went unnoticed. With
the new stricter implemenation it was failing.

Follow on from CVE-2024-5535

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

(cherry picked from commit fc8ff75814767d6c55ea78d05adc72cd346d0f0a)

13 months agoMore correctly handle a selected_len of 0 when processing NPN
Matt Caswell [Fri, 31 May 2024 10:18:27 +0000 (11:18 +0100)] 
More correctly handle a selected_len of 0 when processing NPN

In the case where the NPN callback returns with SSL_TLEXT_ERR_OK, but
the selected_len is 0 we should fail. Previously this would fail with an
internal_error alert because calling OPENSSL_malloc(selected_len) will
return NULL when selected_len is 0. We make this error detection more
explicit and return a handshake failure alert.

Follow on from CVE-2024-5535

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

(cherry picked from commit c6e1ea223510bb7104bf0c41c0c45eda5a16b718)

13 months agoFix SSL_select_next_proto
Matt Caswell [Fri, 31 May 2024 10:14:33 +0000 (11:14 +0100)] 
Fix SSL_select_next_proto

Ensure that the provided client list is non-NULL and starts with a valid
entry. When called from the ALPN callback the client list should already
have been validated by OpenSSL so this should not cause a problem. When
called from the NPN callback the client list is locally configured and
will not have already been validated. Therefore SSL_select_next_proto
should not assume that it is correctly formatted.

We implement stricter checking of the client protocol list. We also do the
same for the server list while we are about it.

CVE-2024-5535

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

(cherry picked from commit 2ebbe2d7ca8551c4cb5fbb391ab9af411708090e)

13 months agoevp_pkey_ctx_setget_params_to_ctrl(): Always properly set ctx.action_type
Tomas Mraz [Mon, 24 Jun 2024 09:25:12 +0000 (11:25 +0200)] 
evp_pkey_ctx_setget_params_to_ctrl(): Always properly set ctx.action_type

Fixes #24698

Some applicable translations are bidirectional so they have
NONE action_type. However we need to set the real action_type
in the ctx.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/24709)

(cherry picked from commit 55c1458303c0fef88e4b2b35a090e9145f3e07eb)

13 months agoAdapt all the exporter files to the new vars from util/mkinstallvars.pl
Richard Levitte [Thu, 20 Jun 2024 12:33:15 +0000 (14:33 +0200)] 
Adapt all the exporter files to the new vars from util/mkinstallvars.pl

With this, the pkg-config files take better advantage of relative directory
values.

Fixes #24298

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

(cherry picked from commit 30dc37d798a0428fd477d3763086e7e97b3d596f)

13 months agoGive util/mkinstallvars.pl more fine grained control over var dependencies
Richard Levitte [Thu, 20 Jun 2024 12:30:16 +0000 (14:30 +0200)] 
Give util/mkinstallvars.pl more fine grained control over var dependencies

Essentially, we try to do what GNU does.  'prefix' is used to define the
defaults for 'exec_prefix' and 'libdir', and these are then used to define
further directory values.  util/mkinstallvars.pl is changed to reflect that
to the best of our ability.

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

(cherry picked from commit 6e0fd246e7a6e51f92b2ef3520bfc4414b7773c0)

13 months agobio_ssl.c: Do not call SSL_shutdown if not inited
erbsland-dev [Sat, 22 Jun 2024 07:14:25 +0000 (09:14 +0200)] 
bio_ssl.c: Do not call SSL_shutdown if not inited

Fixes #4545

If free is called for an SSL BIO that is in initialization phase,
the `SSL_shutdown` call is omitted.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24705)

(cherry picked from commit 57b83edc46926662491d63666231ba7ddc954a38)

13 months agoFix usage of deallocated EVP_RAND_CTX after execution of FIPS on-demand self tests
Karol Brzuskiewicz [Mon, 10 Jun 2024 08:48:31 +0000 (01:48 -0700)] 
Fix usage of deallocated EVP_RAND_CTX after execution of FIPS on-demand self tests

Once RNG is used, triggering FIPS on-demand self tests (via
OSSL_PROVIDER_self_test() API) crashes the application. This happens because the
RNG context is stored before self tests, and restored after their execution.
In the meantime - before context restoration - RAND_set0_private() function is
called, which decrements the stored RNG context reference counter and frees it.
To resolve the issue, the stored RNG context refcount has been incremented via
the EVP_RAND_CTX_up_ref() API to avoid its deallocation during the RNG context
switch performed by the self test function.
The provider_status_test test has been updated to reproduce the issue as
a regression test.

Signed-off-by: Karol Brzuskiewicz <kabr@arista.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24599)

(cherry picked from commit 42a8ef844e5fca55abb608beb62695abe80c6b6d)

13 months agoAllow calling OPENSSL_INIT_free() with NULL argument
Tomas Mraz [Wed, 19 Jun 2024 15:40:21 +0000 (17:40 +0200)] 
Allow calling OPENSSL_INIT_free() with NULL argument

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

(cherry picked from commit d38f62ea118170fc40e10f6f95b180cccbaa7581)

13 months agoAdd Provider compatibility on PR CI job
Tomas Mraz [Fri, 31 May 2024 12:59:21 +0000 (14:59 +0200)] 
Add Provider compatibility on PR CI job

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/24537)

(cherry picked from commit 94567d6889b8b48ac618cd8a90911e6732d0e4df)

13 months ago[DOCS] Correct history in doc/man3/OSSL_STORE_LOADER.pod
Richard Levitte [Wed, 19 Jun 2024 06:06:45 +0000 (08:06 +0200)] 
[DOCS] Correct history in doc/man3/OSSL_STORE_LOADER.pod

Bulk editing had history wrongly specify current functions as deprecated,
among other small errors.

Fixes #24678

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24680)

(cherry picked from commit b23cd39f0a4e3cfe142694402a5246a498a3574f)

13 months agoFix regression of EVP_PKEY_CTX_add1_hkdf_info() with older providers
Tomas Mraz [Mon, 17 Jun 2024 14:48:26 +0000 (16:48 +0200)] 
Fix regression of EVP_PKEY_CTX_add1_hkdf_info() with older providers

If there is no get_ctx_params() implemented in the key exchange
provider implementation the fallback will not work. Instead
check the gettable_ctx_params() to see if the fallback should be
performed.

Fixes #24611

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/24661)

(cherry picked from commit 663dbc9c9c897392a9f9d18aa9a8400ca024dc5d)

13 months agoIncorporate more review feedback
Robert Schulze [Wed, 19 Jun 2024 08:40:16 +0000 (08:40 +0000)] 
Incorporate more review feedback

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

(cherry picked from commit af82623d32962b3eff5b0f0b0dedec5eb730b231)

13 months agoIncorporate review feedback
Robert Schulze [Tue, 18 Jun 2024 20:31:14 +0000 (20:31 +0000)] 
Incorporate review feedback

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

(cherry picked from commit 8d934a75929d058bbc4566a6ebc9f804e1dd081f)

13 months agoFix data race between SSL_SESSION_list_add and ssl_session_dup
Robert Schulze [Tue, 18 Jun 2024 14:43:26 +0000 (14:43 +0000)] 
Fix data race between SSL_SESSION_list_add and ssl_session_dup

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

(cherry picked from commit 79886c85b378d73aec4d96f8e258f12915faddf7)

13 months agoAdd test for ASN1_item_verify()
Tomas Mraz [Mon, 17 Jun 2024 10:19:45 +0000 (12:19 +0200)] 
Add test for ASN1_item_verify()

This is a test for https://github.com/openssl/openssl/issues/24575
Original idea by Theo Buehler.

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

(cherry picked from commit 2f0b4974dfbd9bc71e1164e0742fc7fdb2b2b70e)

13 months agoASN1_item_verify_ctx(): Return -1 on fatal errors
Tomas Mraz [Thu, 6 Jun 2024 13:36:00 +0000 (15:36 +0200)] 
ASN1_item_verify_ctx(): Return -1 on fatal errors

Fixes #24575

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

(cherry picked from commit 8d380f85da215012570347f156e642d69909877a)

13 months agoAdd CHANGES.md entry for the EC/DSA nonce generation fixes
Tomas Mraz [Mon, 17 Jun 2024 10:35:39 +0000 (12:35 +0200)] 
Add CHANGES.md entry for the EC/DSA nonce generation fixes

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

13 months agoSome minor nit corrections in the thread code for rcu
Neil Horman [Mon, 17 Jun 2024 18:12:46 +0000 (14:12 -0400)] 
Some minor nit corrections in the thread code for rcu

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

13 months agoMake rcu_thread_key context-aware
Neil Horman [Mon, 15 Apr 2024 20:56:29 +0000 (16:56 -0400)] 
Make rcu_thread_key context-aware

Currently, rcu has a global bit of data, the CRYPTO_THREAD_LOCAL object
to store per thread data.  This works in some cases, but fails in FIPS,
becuase it contains its own copy of the global key.

So
1) Make the rcu_thr_key a per-context variable, and force
   ossl_rcu_lock_new to be context aware

2) Store a pointer to the context in the lock object

3) Use the context to get the global thread key on read/write lock

4) Use ossl_thread_start_init to properly register a cleanup on thread
   exit

5) Fix up missed calls to OSSL_thread_stop() in our tests

(cherry picked from commit 24d16d3a1915a06a2130385a87de9a37fc09c4b9)

Fixes #24581

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

13 months agoFix handling of max_fragment_length extension for PSK
Frederik Wedel-Heinen [Tue, 28 May 2024 11:59:44 +0000 (13:59 +0200)] 
Fix handling of max_fragment_length extension for PSK

A psk session was assumed to be a resumption which failed a check
when parsing the max_fragment_length extension hello from the client.

Relevant code from PR#18130 which was a suggested fix to the issue
was cherry-picked.

Fixes #18121

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

(cherry picked from commit fa495604516a610d988f02298c8d97a6ac4777bb)

13 months agodocs: fix SSL_CTX_set_tlsext_ticket_key_cb typos
Daniel McCarney [Mon, 17 Jun 2024 20:53:50 +0000 (16:53 -0400)] 
docs: fix SSL_CTX_set_tlsext_ticket_key_cb typos

* "shortcuts the TLS" -> "shortcuts the TLS handshake"
* "don't occur" -> "doesn't occur"
* "storing client certificate" -> "storing the client certificate"
* "an all other" -> "and all other"

CLA: trivial

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

(cherry picked from commit e2a4d68a03b8a3576b0fe917a602b3a283d105a5)

13 months agoossl_store.pod: Correct the example of OSSL_STORE API usage
Et7f3 [Sat, 6 Apr 2024 19:09:30 +0000 (21:09 +0200)] 
ossl_store.pod: Correct the example of OSSL_STORE API usage

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

(cherry picked from commit d5412c94a399d3923b2dec2431ead60288d857c8)

13 months agoFix typo in openssl-verification-options documentation.
Jaime Hablutzel [Mon, 17 Jun 2024 16:40:08 +0000 (11:40 -0500)] 
Fix typo in openssl-verification-options documentation.

CLA: trivial

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24662)

(cherry picked from commit f159d861e2761ffc6421b0486fdd482f37215f9f)

13 months agoCMP app: fix combination of -certout and -chainout with equal filename argument
Dr. David von Oheimb [Thu, 25 Apr 2024 18:05:22 +0000 (20:05 +0200)] 
CMP app: fix combination of -certout and -chainout with equal filename argument

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

(cherry picked from commit 5aec3f4a72604d76970581f1ea445b331beda608)

13 months agofix potential memory leak in PKCS12_add_key_ex()
sashan [Wed, 22 May 2024 07:16:49 +0000 (09:16 +0200)] 
fix potential memory leak in PKCS12_add_key_ex()

function must make sure memorry allocated for `p8`
gets freed in error path. Issue reported by LuMingYinDetect

Fixes #24453

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

13 months agoOSSL_CMP_{validate_msg,CTX_new}.pod: add warning notes on OSSL_CMP_OPT_PERMIT_TA_IN_E...
Dr. David von Oheimb [Mon, 11 Mar 2024 12:06:13 +0000 (13:06 +0100)] 
OSSL_CMP_{validate_msg,CTX_new}.pod: add warning notes on OSSL_CMP_OPT_PERMIT_TA_IN_EXTRACERTS_FOR_IR

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

(cherry picked from commit 40948c4c74099ae21843d9265dfe65f13cb9e6c5)