]> git.ipfire.org Git - thirdparty/openssl.git/log
thirdparty/openssl.git
4 weeks agoPrepare for 3.5.2 27933/head
openssl-machine [Tue, 1 Jul 2025 11:52:18 +0000 (11:52 +0000)] 
Prepare for 3.5.2

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Release: yes

4 weeks agoPrepare for release of 3.5.1 openssl-3.5.1
openssl-machine [Tue, 1 Jul 2025 11:52:08 +0000 (11:52 +0000)] 
Prepare for release of 3.5.1

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Release: yes

4 weeks agomake update
openssl-machine [Tue, 1 Jul 2025 11:52:07 +0000 (11:52 +0000)] 
make update

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Release: yes

4 weeks agoCopyright year updates
openssl-machine [Tue, 1 Jul 2025 11:50:25 +0000 (11:50 +0000)] 
Copyright year updates

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Release: yes

4 weeks agoCHANGES.md / NEWS.md fixups ahead of release
Neil Horman [Tue, 1 Jul 2025 11:21:56 +0000 (07:21 -0400)] 
CHANGES.md / NEWS.md fixups ahead of release

Release: yes

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

(cherry picked from commit f6c400f4ccaf6b36f5430aa3f6c94b704e335738)

5 weeks agoFixes #27831: Decreased NAMEMAP_HT_BUCKETS to 512.
INDIA\kanagavels [Wed, 18 Jun 2025 13:12:54 +0000 (18:42 +0530)] 
Fixes #27831: Decreased NAMEMAP_HT_BUCKETS to 512.

Decreased the NAMEMAP_HT_BUCKETS value to 512, to avoid memory
allocation fail issues.

CLA: Trivial

Signed-off-by: Kanagavel S <kanagavels@ami.com>
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/27850)

(cherry picked from commit b3161bd9a9329be3d6bf6b29a06835e2721898bb)

5 weeks agofix: msg callback in dtls1_do_write that incorrectly shows message (like a certificat...
noctuelles [Thu, 29 May 2025 19:01:21 +0000 (21:01 +0200)] 
fix: msg callback in dtls1_do_write that incorrectly shows message (like a certificate) that spans over multiple fragments.

Reviewed-by: Paul Yang <paulyang.inf@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27811)

(cherry picked from commit de5a619aa015e7c8648e415975e5e2b722b2cbf7)

5 weeks agoFix nullpointer dereference in OSSL_PARAM_merge
Christian Vögl [Thu, 26 Jun 2025 16:37:37 +0000 (18:37 +0200)] 
Fix nullpointer dereference in OSSL_PARAM_merge

OSSL_PARAM_merge contained an error, where a nullpointer was
dereferenced when both parameter arrays ended with the same key

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

(cherry picked from commit 63cb8f99a13fdc4c7c3b1e88d66a3ff70b72e642)

5 weeks agoEnforce permissions 0600 for SSLKEYLOGFILE
Dmitry Belyavskiy [Wed, 25 Jun 2025 14:41:30 +0000 (16:41 +0200)] 
Enforce permissions 0600 for SSLKEYLOGFILE

Fixes #27890

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

(cherry picked from commit e7e79509986a3b6134ce3bbf30d7afcfd117c7eb)

5 weeks agoBetter lookup for openssl executable
Dmitry Belyavskiy [Wed, 25 Jun 2025 15:33:16 +0000 (17:33 +0200)] 
Better lookup for openssl executable

Fixes #27891

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

(cherry picked from commit fa0c67a28a5a7d6ebeae7cb14d036780485e2fcd)

5 weeks agospeed: Increase MAX_SIG_NUM and fix its usage in loopargs_t fields
Ingo Franzki [Mon, 23 Jun 2025 11:42:08 +0000 (13:42 +0200)] 
speed: Increase MAX_SIG_NUM and fix its usage in loopargs_t fields

Increase the maximum number of signature algorithms.

With the introduction of the SignMessage and VerifyMessage API with
OpenSSL 3.4 the providers that support combined digest and sign algorithms
register quite a lot more signature algorithms, so the current limit of
111 is hit easily.

While at it correct the definitions of the signature fields within the
loopargs_t structure to use MAX_SIG_NUM instead of MAX_KEM_NUM.

Closes: https://github.com/openssl/openssl/issues/27873
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/27878)

(cherry picked from commit 7bdc0d13d2b9ce1c1d0ec1f89dacc16e5d045314)

6 weeks agoNit: macro parameters should always be parenthesised in expressions
Richard Levitte [Fri, 20 Jun 2025 12:29:04 +0000 (14:29 +0200)] 
Nit: macro parameters should always be parenthesised in expressions

Affected macros: ossl_likely and ossl_unlikely

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

(cherry picked from commit cdd01b5e0734b0324251b32a8edd97f42ba90429)

6 weeks agoFix exit code for s_time when -new command line switch specified
Neil Horman [Thu, 19 Jun 2025 16:38:41 +0000 (12:38 -0400)] 
Fix exit code for s_time when -new command line switch specified

When operating with the -new switch in apps/openssl s_time, we neglect
to set the exit code properly, and so the app exits with a code of 1
rather than 0 as expected

Fixes #27856

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

(cherry picked from commit b6ff5598539bf91608246ed81b4b534cbea6539d)

6 weeks agoFix buggy stringop-overflow error on s390
Neil Horman [Fri, 20 Jun 2025 14:22:10 +0000 (10:22 -0400)] 
Fix buggy stringop-overflow error on s390

Despite some recent changes to our s390 builds, we're still seeing
errors due to some stringop-overflow warnings:
https://github.com/openssl/openssl/actions/runs/15748518222/job/44389197443

It appears to be caused because the static analysis that gcc preforms in
gcc 12 (the version of the compiler on our s390 runner), fails to infer
the proper sizes of the buffer on which we do the reverse memcpy in
swap_copy(), resulting in warnings, which on --strict-warnings builds,
breaks us.

Fix it by using inlen rather than outlen to limit the copy length,
adjusting it if need be to match the size of the output buffer in
le_copy().  This allows the compiler to properly infer the array length
constraints and suppress the warnings.

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

(cherry picked from commit 837592dcd994a22a7c8d08bf3cf421f6b2e51280)

6 weeks agoPreserve connection custom extensions in SSL_set_SSL_CTX()
Sergey Kandaurov [Wed, 28 May 2025 17:58:26 +0000 (21:58 +0400)] 
Preserve connection custom extensions in SSL_set_SSL_CTX()

The SSL_set_SSL_CTX() function is used to switch SSL contexts for
the given SSL object.  If contexts differ, this includes updating
a cert structure with custom extensions from the new context.  This
however overwrites connection custom extensions previously set on
top of inherited from the old context.

The fix is to preserve connection custom extensions using a newly
introduced flag SSL_EXT_FLAG_CONN in custom_ext_copy_conn().
Similar to custom_ext_copy(), it is a no-op if there are no custom
extensions to copy.

The only such consumer is ossl_quic_tls_configure() used to set the
"quic_transport_parameters" extension.  Before this change, context
switch resulted in transport parameters not being sent due to the
missing extension.

Initially reported at https://github.com/nginx/nginx/issues/711

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

(cherry picked from commit 403ba31a02e47d37070036529966d5a94d98c6fd)

6 weeks agoAdd a helper function to copy custom extensions with old style arguments
Sergey Kandaurov [Tue, 27 May 2025 19:01:40 +0000 (23:01 +0400)] 
Add a helper function to copy custom extensions with old style arguments

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

(cherry picked from commit f7b10004dce1444a9712fc9e578e30576fcca6b6)

6 weeks agoUpdate pkeyutl documentation for PQC algorithms (Fixes #27415)
Samson S. Kolge [Thu, 17 Apr 2025 15:54:27 +0000 (21:24 +0530)] 
Update pkeyutl documentation for PQC algorithms (Fixes #27415)

Add examples and documentation for using ML-DSA, ML-KEM, and SLH-DSA algorithms with pkeyutl. This includes information about the context-string option for ML-DSA and examples of encapsulation/decapsulation with ML-KEM.

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

(cherry picked from commit 27eea04b0616847022847f6737e53704becae4c4)

6 weeks agoAvoid potential double close of client_skt in sslecho
Levi Zim [Wed, 16 Apr 2025 06:21:33 +0000 (14:21 +0800)] 
Avoid potential double close of client_skt in sslecho

The server_running variable is declared as volatile and some comments in
the code are mentioning about implementing CTRL+C handler in the future.

In the client handling loop, the client_skt is closed at the end of the
loop if server_running is true. If (future) CTRL+C handler changes
server_running to false at this time. The next accept will not happen
and the exit clean up code will close client_skt for the second time.

This patch fixes this potential double close by setting client_skt back
to -1 after closing it.

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

(cherry picked from commit 48e3fe08639d84bd557c0d5248f5600f2fb1f7de)

6 weeks agoAdd strlen to symbols allowed on Windows
Tomas Mraz [Thu, 19 Jun 2025 08:59:10 +0000 (10:59 +0200)] 
Add strlen to symbols allowed on Windows

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27854)

(cherry picked from commit c296e1ce24d192d7ba52df4cd74eaec1a00ca7de)

6 weeks agoReport errors in ML-KEM pkey hash
Viktor Dukhovni [Fri, 11 Apr 2025 14:35:57 +0000 (00:35 +1000)] 
Report errors in ML-KEM pkey hash

When on import the public key hash of a private key fails to match the
public part, add an appropriate message to the error stack.  Previously,
the just failed to parse, without a reason.

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

(cherry picked from commit 8721def7fce8f895fa3e7b0eae9e577e5ecf32bb)

6 weeks agoAdd a test for SSL_set_verify with QUIC
Matt Caswell [Mon, 16 Jun 2025 15:01:52 +0000 (16:01 +0100)] 
Add a test for SSL_set_verify with QUIC

Check that we get the correct SSL object passed to the callback.

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

(cherry picked from commit fbb2a20732277ebf185ecaadb9e8570f8e9771d7)

6 weeks agoEnsure we pass the user SSL object for the SSL_set_verify callback
Matt Caswell [Mon, 16 Jun 2025 15:00:13 +0000 (16:00 +0100)] 
Ensure we pass the user SSL object for the SSL_set_verify callback

When calling the verify callback we need to ensure we supply the user SSL
object, and not any internal SSL object.

Fixes #27830

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

(cherry picked from commit 4b148ebb66cdac8a095f22cbdfa475d68c947f7a)

6 weeks agocheck-format.pl: prevent false positive on typedef with space and '(' after type...
Dr. David von Oheimb [Mon, 16 Jun 2025 14:43:03 +0000 (16:43 +0200)] 
check-format.pl: prevent false positive on typedef with space and '(' after type name

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

(cherry picked from commit 4a3809f7056b78031e72fc4e90eec3e708ca27e1)

6 weeks agocheck-format-test-negatives.c: add 2nd macro indent test and hint on how known false...
Dr. David von Oheimb [Fri, 13 Jun 2025 14:44:08 +0000 (16:44 +0200)] 
check-format-test-negatives.c: add 2nd macro indent test and hint on how known false positives are marked

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

(cherry picked from commit e925b99f9435826aca3fa41b7661e6e9fa7e10b6)

6 weeks agocheck-format.pl: prevent reporting "{ 1 stmt }" on "else if" branch unless -1 or...
Dr. David von Oheimb [Mon, 9 Jun 2025 13:54:05 +0000 (15:54 +0200)] 
check-format.pl: prevent reporting "{ 1 stmt }" on "else if" branch unless -1 or --1-stmt option is given

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

(cherry picked from commit f21a8391dd0ec3a0dbdc5dc5fa8b44a0b07abf6d)

6 weeks agocheck-format.pl: allow block for switch case/default
Dr. David von Oheimb [Mon, 9 Jun 2025 11:15:58 +0000 (13:15 +0200)] 
check-format.pl: allow block for switch case/default

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

(cherry picked from commit 560ea7ffbf5abac871a8d53f6aa3a44ac0349619)

6 weeks agocheck-format-test-positives.c slightly improve comment describing the '*@' tags
Dr. David von Oheimb [Tue, 6 May 2025 07:01:37 +0000 (09:01 +0200)] 
check-format-test-positives.c slightly improve comment describing the '*@' tags

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

(cherry picked from commit 58eb08985c485bf2fe010fb59c13ad0df2e0faa3)

6 weeks agoadapt check-format-test-positives.c for too long lines after limit was relaxed from...
Dr. David von Oheimb [Tue, 6 May 2025 06:56:52 +0000 (08:56 +0200)] 
adapt check-format-test-positives.c for too long lines after limit was relaxed from 80 to 100

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

(cherry picked from commit e6476de58d8e3440e3585843fd9ee62dd187f957)

7 weeks agofix: Better documentation on DTLS_set_timer_cb()
noctuelles [Tue, 10 Jun 2025 20:37:46 +0000 (22:37 +0200)] 
fix: Better documentation on DTLS_set_timer_cb()

Also more precise description of DTLS timeout mechanism.

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

(cherry picked from commit 49885aebe7cafc5caaa6929d0ed5a946e7f09c45)

7 weeks agoossl_rio_poll_builder_add_fd(): Fixup pfds after reallocation
sashan [Wed, 11 Jun 2025 06:23:38 +0000 (08:23 +0200)] 
ossl_rio_poll_builder_add_fd(): Fixup pfds after reallocation

Local variable `pfds` used in `ossl_rio_poll_builder_add_fd()` must be consistent
with `rpb->pfd_heap`. The function maintains array of SSL objects for SSL_poll(3ossl).
It works with no issues until we need to reallocate `rbp->pfd_heap` in `rpb_ensure_alloc()`.
After `rpb_ensure_alloc()` returns we must update local variable `pfds` with `rpb->pfd_heap`
not doing so makes function to write to dead buffer.

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/27804)

(cherry picked from commit 5ee8248d083c00583d52350ed9464bfb58d2f60c)

7 weeks agotest/helpers/quictestlib.c: Use goto instead of return to avoid memory leak
JiashengJiang [Mon, 12 May 2025 13:59:02 +0000 (09:59 -0400)] 
test/helpers/quictestlib.c: Use goto instead of return to avoid memory leak

When TEST_ptr(*cssl) fails, bdata should be freed to avoid memory leak.

Fixes: a55b689 ("Use reported short conn id len in qtestlib")
Signed-off-by: JiashengJiang <jiasheng@purdue.edu>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27599)

(cherry picked from commit de1e4989d564ea9a6d2960204806a1f3537419ad)

7 weeks agos390x: Fix HMAC to fail update or final call when already finalized
Ingo Franzki [Fri, 6 Jun 2025 12:20:38 +0000 (14:20 +0200)] 
s390x: Fix HMAC to fail update or final call when already finalized

After commit a5d1eadde1d566b528cfe495953300cd9f9fe1e9 the test step
'test_hmac_final_update_fail' of 'test_hmac' fails.

Return an error when update or final is used after the context has
already been finalized. Flag 'iimp' (intermediate-input-message-part)
must be 1 to allow an update or final call. If iimp is 0, then the
context has already been finalized.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27781)

(cherry picked from commit 339ced70da1206bf090c3de981093b99cfa0d39a)

7 weeks agoreturn NULL if gctx allocation fails.
Bartel Artem [Wed, 11 Jun 2025 03:58:31 +0000 (06:58 +0300)] 
return NULL if gctx allocation fails.

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

(cherry picked from commit 443298e0f0e2c8225f8c6d6fdc01c6c4d434028b)

7 weeks agocheck gctx for NULL before cleanup.
Bartel Artem [Tue, 10 Jun 2025 10:11:41 +0000 (13:11 +0300)] 
check gctx for NULL before cleanup.

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

(cherry picked from commit 02f9c9342d54c99981b0a83088982bf0d1083d7f)

7 weeks agoAllow our *_gen_cleanup functions to tolerate a NULL ctx
Matt Caswell [Wed, 11 Jun 2025 08:50:16 +0000 (09:50 +0100)] 
Allow our *_gen_cleanup functions to tolerate a NULL ctx

Our *_gen_cleanup functions are essentially "free" functions. Our
free functions tolerate NULL being passed. We are being inconsistent with
our *_gen_cleanup functions. Some of them tolerate NULL and others do not.

We should consistently tolerate NULL.

See also #27795

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

(cherry picked from commit fcc5df53697a63d0f153b0086054f509aad8e6bb)

7 weeks agogenpkey.c: Fix filename copy & paste bug in error output
Bartel Artem [Mon, 9 Jun 2025 04:23:06 +0000 (07:23 +0300)] 
genpkey.c: Fix filename copy & paste bug in error output

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

(cherry picked from commit a4c5096d16a78d2c24f2880fba1ec7056eb3a96f)

7 weeks agoSilence -Wstringop-overflow warnings with gcc 14 on s390x
Ingo Franzki [Wed, 28 May 2025 06:55:49 +0000 (08:55 +0200)] 
Silence -Wstringop-overflow warnings with gcc 14 on s390x

Compiling OpenSSL on s390x with gcc 14 (i.e. in Fedora 41) shows several
-Wstringop-overflow warnings in providers/implementations/rands/drbg_ctr.c
and test/params_api_test.c.

Add explicit length checks to let the compiler know that it won't overrun
the buffer. This also silences the warnings.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27710)

(cherry picked from commit 9a788281d91f698d6a229d588b9cb36987549669)

7 weeks agoAllow keygen after dup of minimal PKEY ctx
Viktor Dukhovni [Tue, 13 May 2025 15:23:25 +0000 (01:23 +1000)] 
Allow keygen after dup of minimal PKEY ctx

It should be possible to repeatedly duplicate a PKEY CTX created via
EVP_PKEY_CTX_new_from_name() that has not yet been assigned an
"operation" (e.g. via EVP_PKEY_CTX_keygen_init()), and then perform
keygen_init() and keygen() on the duplicated copies.

When the operation is not yet set, all that's needed is to not try to
use the key if one isn't set yet.

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

(cherry picked from commit 2c74a8d1ef4e9c4b4468afefedb1f72425772a37)

7 weeks agoFix SHAKE AlgorithmIdentifier encodings
Daniel Van Geest [Fri, 28 Mar 2025 10:40:32 +0000 (10:40 +0000)] 
Fix SHAKE AlgorithmIdentifier encodings

NIST CSOR specifies that the id-shake128 and id-shake256
algorithm identifiers, like the SHA-3 ones, do not carry
any parameters.

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

(cherry picked from commit bef03c6a24f02df4e670697b16b6d7c8b1b604b4)

7 weeks agofix: add parsing check in TLS compress_certificate extension handler
yexiaochuan [Sat, 31 May 2025 09:47:58 +0000 (17:47 +0800)] 
fix: add parsing check in TLS compress_certificate extension handler

The tls_parse_compress_certificate function was missing validation
for trailing bytes after parsing the algorithm list, violating
RFC8446 section 4.2 which requires sending a decode_error alert
for unparseable messages.

This commit adds a check for remaining bytes in the packet after
the while loop and sends SSL_AD_DECODE_ERROR if any trailing
bytes are found.

Fixes #27717

CLA: trivial

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

(cherry picked from commit 8e787b102848e462a6d231883e2c42d91978c049)

8 weeks agocrypto/evp/ctrl_params_translate.c: prevent clashes of generic names NONE, GET, SET
Dr. David von Oheimb [Thu, 5 Jun 2025 11:16:13 +0000 (13:16 +0200)] 
crypto/evp/ctrl_params_translate.c: prevent clashes of generic names NONE, GET, SET

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/27773)

(cherry picked from commit c37b9e3425c8576d089342c7cfdcc4dc0aedde54)

8 weeks agorand: add argument error checking to EVP_RAND_nonce()
Pauli [Thu, 5 Jun 2025 03:28:37 +0000 (13:28 +1000)] 
rand: add argument error checking to EVP_RAND_nonce()

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27766)

(cherry picked from commit a2cd7ecd75dcd0de214319ec11bf5b3701bec7a3)

8 weeks agorand: document the EVP_RAND_nonce() return correctly
Pauli [Thu, 5 Jun 2025 02:02:52 +0000 (12:02 +1000)] 
rand: document the EVP_RAND_nonce() return correctly

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27766)

(cherry picked from commit e81b252a955ae380c3af6129b0f9054c2594b8d6)

8 weeks agorand: produce correct return from EVP_RAND_nonce
Pauli [Wed, 4 Jun 2025 23:50:59 +0000 (09:50 +1000)] 
rand: produce correct return from EVP_RAND_nonce

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27766)

(cherry picked from commit a2b9120d15073ab596452fc361d01bb26ee13773)

8 weeks agorand: fix memory overrun bug
Pauli [Wed, 4 Jun 2025 23:50:34 +0000 (09:50 +1000)] 
rand: fix memory overrun bug

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27766)

(cherry picked from commit da585e214cf98468e28f4c12ec96ecc7a6192746)

8 weeks agorand: add unit test exhibiting memory overrun
Pauli [Wed, 4 Jun 2025 23:50:20 +0000 (09:50 +1000)] 
rand: add unit test exhibiting memory overrun

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27766)

(cherry picked from commit 6d490a92fe49ea6e41cb7874086dbad5462078c6)

8 weeks agoAdd a test to confirm that we can repeatedly create and destroy keys
Neil Horman [Thu, 5 Jun 2025 12:54:56 +0000 (08:54 -0400)] 
Add a test to confirm that we can repeatedly create and destroy keys

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27775)

(cherry picked from commit b994ce4088fb52e769ee5e3e49bdde3030fadaf7)

8 weeks agoAllow for reuse of thread_local keys in threads_none
Neil Horman [Thu, 5 Jun 2025 12:25:52 +0000 (08:25 -0400)] 
Allow for reuse of thread_local keys in threads_none

If openssl is configured with no-threads, the implementation has a hard
limit of 256 LIB_CTX values, as each LIB_CTX allocates a thread local
key, and we never reuse them (like libc does when using
pthread_key_create/destroy.

Improve the situation by allowing for marking freed keys as unsued and
searching for an available key when allocating

Fixes #27757

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27775)

(cherry picked from commit b6d01d1b1fef2e98a956b7ba4e8443cf7d916dcb)

8 weeks agoFix NIST ACVP server URLs in SLH-DSA test files
Yaroslav Lelkin [Thu, 5 Jun 2025 05:50:43 +0000 (10:50 +0500)] 
Fix NIST ACVP server URLs in SLH-DSA test files

CLA: trivial

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

(cherry picked from commit 07c772847de682412448daea07582f566d30f7ac)

8 weeks agoRemove _strlen31
Neil Horman [Wed, 4 Jun 2025 19:48:45 +0000 (15:48 -0400)] 
Remove _strlen31

This function is old and fairly broken.  Code archeology in our git tree
hasn't revealed why it was creted (though it may have possibly been to
support older win32 systems that couldn't do 64 bit integers properly,
like windows 95/98).

There seems to be no good reason to keep it around, and given that it
has potentially serious side effects, lets just remove it.

Fixes #27761

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Richard Levitte <levitte@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/27763)

(cherry picked from commit b0d363a2cb039eac2908b7cb00b395235373193e)

8 weeks agoFix use of IO::Socket::IP on windows 2025
Neil Horman [Fri, 6 Jun 2025 00:57:35 +0000 (20:57 -0400)] 
Fix use of IO::Socket::IP on windows 2025

Apparently IO::Socket::IP has several odd behaviors on windows 2025,
notably indicating that AF_INET6 isn't a supported family when it
clearly is.

Follow the pattern in determinig the haveIPV6 variable in Proxy.pm, and
record if we determine IPv6 availablity with the IP class or the INET6
class and use the same method when testing port binding

Fixes project/#1213

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Paul Yang <kaishen.yy@antfin.com>
(Merged from https://github.com/openssl/openssl/pull/27780)

(cherry picked from commit ae404a9b3bd052963b76434bcc97757d1d6d502e)

8 weeks agoTest randomly selected client port for availabilty in sslrecords test
Neil Horman [Tue, 3 Jun 2025 20:02:15 +0000 (16:02 -0400)] 
Test randomly selected client port for availabilty in sslrecords test

Encountered this error in a pr today:
https://github.com/openssl/openssl/actions/runs/15418713146/job/43387767612

===
Proxy started on port [::1]:56662
Engine "ossltest" set.
Using default temp DH parameters
ACCEPT [::1]:59189
Server responds on [::1]:59189
Engine "ossltest" set.
C0774F02907F0000:error:80000062:system library:BIO_bind:Address already in use:crypto/bio/bio_sock2.c:240:calling bind()
C0774F02907F0000:error:10000075:BIO routines:BIO_bind:unable to bind socket:crypto/bio/bio_sock2.c:242:
connect:errno=98
===

Its occuring because we randomly select a port to use for our client
connection in the sslrecords test.  Thats usually fine, but sometimes,
we get unlucky and pick a port thats already in use.  This presents as
random failures in our CI on this test.

So lets try harden ourselves against it.  When creating the client
connection, test the randomly selected port by trying to bind to it via
a call to IO::Socket::IP->new(). If that fails, try a different port
number, until we get one that works.  If it works, use that port in the
assignment for the clients local port value.

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27752)

(cherry picked from commit f78f824c8e4064148af1186490e9b445871765fd)

2 months agoapps/x509.c: re-add ERR queue printing on errors
Dr. David von Oheimb [Sun, 1 Jun 2025 14:35:31 +0000 (16:35 +0200)] 
apps/x509.c: re-add ERR queue printing on errors

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

(cherry picked from commit ac85974bc34dc18830fa9401a7d4756dbd2d9e35)

2 months agoSplit arguments taking quotes into account
Viktor Dukhovni [Sun, 1 Jun 2025 02:47:15 +0000 (12:47 +1000)] 
Split arguments taking quotes into account

CA.pl supports interpolating multiple arguments into the executed
commands.  Previously these were evaluated by a shell, which supported
quoting of values that contain whitespace, backslashes, ...

With a shell no longer used (avoid command injection), backwards
compatibility requires some similar functionality.  The code now handles
double and single-quoted strings (shell-style word splitting), but not
parameter expansion ($foo remains unexpanded) or command substitution
(`cmd` and $(cmd) remain unexpanded).

On Windows system(@LIST) does not correctly preserve argv, do our
own quoting instead and use system(<$quoted_cmd>).

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

(cherry picked from commit 287bbb28b09e930a8691efc92a5087bb951edb6b)

2 months agoAvoid shell commandline processing in CA.pl
Viktor Dukhovni [Fri, 18 Apr 2025 04:18:09 +0000 (14:18 +1000)] 
Avoid shell commandline processing in CA.pl

The CA.pl script used to build single-string string commandlines to pass
to a shell via `system(command_string)`.  That was fragile and not a best
practice.

This PR replaces `system(command_string)` with `system { executable } @argv`,
which avoids the shell whenever possible (at least Unix-like systems and
Windows).  The only question mark is whether some sort of quoting is
needed for VMS to preserve the case of commandline arguments even when
processes are spawned directly, rather than via the shell.

Unfortunately, given the way that some environment variables and
command-line options are used to construct the commands to run,
the result is still brittle.  The CA.pl utility really should
be replaced with something better.

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

(cherry picked from commit 0b1bdef38ef1e3369a7bcde1b9a6eabe44b10e54)

2 months agoAdd a CHANGES.md entry regarding no_renegotiation alert
Matt Caswell [Mon, 2 Jun 2025 14:45:06 +0000 (15:45 +0100)] 
Add a CHANGES.md entry regarding no_renegotiation alert

Highight the bug being fixed for DTLS users

Reviewed-by: Frederik Wedel-Heinen <fwh.openssl@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27591)

(cherry picked from commit df5dff26efb6cdc96ebe50c35af394a1121e77fe)

2 months agoUpdate documentation regarding no_renegotiation handling
Matt Caswell [Mon, 2 Jun 2025 14:39:45 +0000 (15:39 +0100)] 
Update documentation regarding no_renegotiation handling

Clarify what happens in the event that a no_renegotiation alert is
received.

Reviewed-by: Frederik Wedel-Heinen <fwh.openssl@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27591)

(cherry picked from commit 0db6a59ea7931024d673024c2d17ff1ec44a4e69)

2 months agoTest that a no_renegotiation alert is handled correctly
Matt Caswell [Fri, 9 May 2025 09:28:16 +0000 (10:28 +0100)] 
Test that a no_renegotiation alert is handled correctly

If we receive a no_renegotiation alert we should abort the connection. We
add a test for this.

Reviewed-by: Frederik Wedel-Heinen <fwh.openssl@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27591)

(cherry picked from commit 7f6e66b048cb50dd5381211ef2006ae5e912a914)

2 months agoFix DTLS handling when receiving a no_renegotiation alert
Matt Caswell [Fri, 9 May 2025 08:58:15 +0000 (09:58 +0100)] 
Fix DTLS handling when receiving a no_renegotiation alert

no_renegotiation is a warning alert sent from the server when it is not
prepared to accept a renegotiation attempt. In TLS we abort the connection
when we receive one of these - which is a reasonable response. However,
in DTLS we incorrectly ignore this and keep trying to renegotiate.

We bring the DTLS handling of a no_renegotiation alert into line with
how TLS handles this. In versions prior to 3.2 handling of a warning
alert in DTLS was mishandled resulting in a failure of the connection,
which ends up being the right thing to do "by accident" in the case of
"no_renegotiation". From 3.2 this mishandling was fixed, but exposed this
latent bug.

Fixes #27419

Reviewed-by: Frederik Wedel-Heinen <fwh.openssl@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27591)

(cherry picked from commit e5feca0659ef6119f6cedfab1b6af034735723ff)

2 months agoci: remove windows-2019 runner images
Dmitry Misharov [Tue, 3 Jun 2025 11:04:57 +0000 (13:04 +0200)] 
ci: remove windows-2019 runner images

According to https://github.com/actions/runner-images/issues/12045
The Windows 2019 Actions runner image will begin deprecation on
2025-06-01 and will be fully unsupported by 2025-06-30. Jobs using
the windows-2019 YAML workflow label should be updated to
windows-2022, windows-2025 or windows-latest.

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

(cherry picked from commit 19dfc4672a3e7d152195c890edfdb9bd81d878a7)

2 months agoReset qtls->local_transport_params_consumed to 0 on SSL_clear()
Andrew Dinh [Tue, 20 May 2025 16:37:20 +0000 (09:37 -0700)] 
Reset qtls->local_transport_params_consumed to 0 on SSL_clear()

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

(cherry picked from commit 9bad2b86e892b70ea65e87c409ae90f625d3c12c)

2 months agoAdd test for yielding of write secrets before read
Neil Horman [Thu, 29 May 2025 14:26:02 +0000 (15:26 +0100)] 
Add test for yielding of write secrets before read

Test that, in QUIC, we yield write secrets before read secrets

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

(cherry picked from commit 9a5ac06921357bdfd4e2f74b5b32955464bf9b75)

2 months agoEnsure client read app data secret change occurs after write for QUIC
Matt Caswell [Thu, 29 May 2025 11:52:35 +0000 (12:52 +0100)] 
Ensure client read app data secret change occurs after write for QUIC

We don't want read secrets to be issue before write for QUIC, because
we want to avoid the situation where we want to ack something we've read
but we don't have the write secret yet.

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

(cherry picked from commit 098cfd216b9b54106cbf9338a511c7dda972b8c1)

2 months agoImplement explicit storing of the server_finished_hash
Matt Caswell [Thu, 29 May 2025 11:31:33 +0000 (12:31 +0100)] 
Implement explicit storing of the server_finished_hash

tls13_change_cipher_state was storing the server_finished_hash as a
side effect of its operation. This decision is better made by the state
machine which actually knows what state we are in.

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

(cherry picked from commit c7f9c4d7d184cec988251b2a9c697302774fbe77)

2 months agoEnsure client read handshake secret change occurs after write for QUIC
Matt Caswell [Thu, 29 May 2025 11:16:14 +0000 (12:16 +0100)] 
Ensure client read handshake secret change occurs after write for QUIC

We don't want read secrets to be issue before write for QUIC, because
we want to avoid the situation where we want to ack something we've read
but we don't have the write secret yet.

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

(cherry picked from commit 86e75792622b39a9cf49c0915e58cca5c9d316d3)

2 months agoImplement explicit storing of the handshake_traffic_hash
Matt Caswell [Thu, 29 May 2025 10:59:25 +0000 (11:59 +0100)] 
Implement explicit storing of the handshake_traffic_hash

tls13_change_cipher_state was storing the handshake_traffic_hash as a
side effect of its operation. This decision is better made by the state
machine which actually knows what state we are in.

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

(cherry picked from commit 4579a18cf5129479e781bf05e168204ca739fa3c)

2 months agoRegression test for incorrect HMAC API usage
Nicky Mouha [Sat, 24 May 2025 16:15:54 +0000 (12:15 -0400)] 
Regression test for incorrect HMAC API usage

Fixes #13210

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

(cherry picked from commit a5d1eadde1d566b528cfe495953300cd9f9fe1e9)

2 months agoHandle 0 return values from DH key computations as errors
Frederik Wedel-Heinen [Tue, 20 May 2025 17:58:11 +0000 (19:58 +0200)] 
Handle 0 return values from DH key computations as errors

Returned 0 from ossl_dh_compute_key(), DH_compute_key_padded() and
DH_compute_key() needs to be treated as an error.

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

(cherry picked from commit 1c1ce2a6eeb18b3102e0618a988b2dfe96b709aa)

2 months agoUse value barrier for constant_time_cond_swap_*
Jai S [Wed, 7 May 2025 18:01:06 +0000 (23:31 +0530)] 
Use value barrier for constant_time_cond_swap_*

Resolves #27497

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

(cherry picked from commit 8a9e0d0f499a288cf3363668870806d5e7be3924)

2 months agoCleanup - this constant and functions are no longer in use
Dmitry Belyavskiy [Thu, 29 May 2025 11:38:29 +0000 (13:38 +0200)] 
Cleanup - this constant and functions are no longer in use

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27716)

(cherry picked from commit 0b968a3572d2932e7e756fc9977dbf808510a958)

2 months agosslapitest: Add failing test for quic double free
Norbert Pocs [Wed, 28 May 2025 20:12:06 +0000 (22:12 +0200)] 
sslapitest: Add failing test for quic double free

The double free happened on the EVP_MD object, when we used external
quic implementation. This test makes the yield secret callback fail, to
make the kdfdigest free path happen.

Signed-off-by: Norbert Pocs <norbertp@openssl.org>
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/27713)

(cherry picked from commit 9ed90fd44cc1b8039d82610d90f56275d519c204)

2 months agoquic_tls.c: Precede double free on EVP_MD variable
Norbert Pocs [Wed, 28 May 2025 14:28:54 +0000 (16:28 +0200)] 
quic_tls.c: Precede double free on EVP_MD variable

When external quic implementation is used, the variable is not used and
double free happens whe the yield_secret_cb fails.

Resolves: #27504

Signed-off-by: Norbert Pocs <norbertp@openssl.org>
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/27713)

(cherry picked from commit 258d3a695e32828df7dbda6ee9ae67d31e128f62)

2 months ago[design] Functions for explicitly fetched signature algorithms
Richard Levitte [Thu, 9 Nov 2023 09:42:25 +0000 (10:42 +0100)] 
[design] Functions for explicitly fetched signature algorithms

This design goes into more details what was outlined in the design for
[fetching composite (PKEY) algorithms and using them].

It also changes what functionality will be used for this.  The design for
signature was originally to add modified initializers for DigestSign and
DigestVerify, but recent OTC discussions redirected us to have a closer look
at EVP_PKEY_sign() and EVP_PKEY_verify().

[fetching composite (PKEY) algorithms and using them]:
    ./fetching-composite-algorithms.md

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

(cherry picked from commit 66454bf8bac860212bb959c1e847a0483a053025)

2 months agoDocument that FIPS provider cannot be used by multiple libcryptos
Tomas Mraz [Tue, 27 May 2025 09:36:31 +0000 (11:36 +0200)] 
Document that FIPS provider cannot be used by multiple libcryptos

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

(cherry picked from commit 08b2042a20e76472416c8c7c48e479d893ba904f)

2 months agotest/evp_test.c: Free fetched_digest on error to avoid memory leak
JiashengJiang [Sat, 17 May 2025 00:20:47 +0000 (20:20 -0400)] 
test/evp_test.c: Free fetched_digest on error to avoid memory leak

Call EVP_MD_free() to release fetched_digest if OPENSSL_zalloc() fails, preventing a memory leak.

Fixes: 2208ba56eb ("evp_test: Add the missing check after calling OPENSSL_malloc")
Signed-off-by: JiashengJiang <jiasheng@purdue.edu>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27648)

(cherry picked from commit e8deb32af4874c781838c1596c6355712b5d0ed0)

2 months agocrypto/property/property.c: Free impl->method to avoid memory leak
JiashengJiang [Fri, 16 May 2025 18:21:07 +0000 (14:21 -0400)] 
crypto/property/property.c: Free impl->method to avoid memory leak

After ossl_method_up_ref() succeeds, impl_free() should be called to free impl->method.

Fixes: 860ecfd ("property: check return values from the property locking
calls.")
Signed-off-by: JiashengJiang <jiasheng@purdue.edu>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27564)

(cherry picked from commit 00c531a5e327320f0ec78ce4b153fac65ebca229)

2 months agoapps: lib: Prevent potential NULL dereference in init_client()
AntonMoryakov [Fri, 16 May 2025 14:19:21 +0000 (17:19 +0300)] 
apps: lib: Prevent potential NULL dereference in init_client()

apps: lib: Simplify ba_ret handling in init_client()

Simplify logic around ba_ret assignment:
- Fail early if ba_ret == NULL
- Assign directly otherwise, without checking *ba_ret

This avoids extra nesting and matches OpenSSL's conventions.

CLA: trivial
Signed-off-by: Anton Moryakov <ant.v.moryakov@gmail.com>
Co-authored-by: Tomas Mraz <tomas@openssl.org>
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/26783)

(cherry picked from commit 3161f460fa7eacc7a93f8edf413c78b4dcf65823)

2 months agoNote finished state in cipher BIO EOF
Viktor Dukhovni [Wed, 21 May 2025 15:33:03 +0000 (01:33 +1000)] 
Note finished state in cipher BIO EOF

When the cipher BIO encounters a non-retriable EOF (or error), mark the
state as "finished", else a subsequent BIO_flush() or attempted read may
attempt to finalise the crypto state again, and fail, leading, for
example, to users seeing erroneous apparent decryption failure.

This is not a new problem, the fix should be backported to all supported
releases.  It was made more apparent by recent changes to the base64
BIO, which returns a non-retriable EOF when padding is seen at the end
of the base64 data, even if the underlying next BIO is "retriable".

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

(cherry picked from commit 005fa3e00e1ccfd83aa99d28e2eff55597dd5fc2)

2 months agoAttempt to fix occasional failure of quicapi test in ci
Neil Horman [Tue, 27 May 2025 13:36:35 +0000 (09:36 -0400)] 
Attempt to fix occasional failure of quicapi test in ci

https://github.com/openssl/openssl/actions/runs/15214054228/job/42795224720

the theory I have for the cause of this failure is:

1. qtest_create_quic_connection_ex is called for the client
2. The client is in blocking mode, so we fall into the conditional on line 512
3. We create the server thread on line 519, which is non-blocking
4. The scheduler in the failing case, lets the server run ahead of the client
5. Server thread enters qtest_create_quic_connection_ex and iterates steps
   6-9 in the do_while loop starting on line 530
6. Server calls qtest_add_time
7. Server calls ossl_quic_tserver_tick
8. Server calls ossl_quic_tserver_is_term_any, received NULL return
9. Server calls qtest_wait_for_timeout
10. Eventually qtest_wait_for_timeout returns zero, adn the server jumps to
    the error label, returning zero to globservret, and the thread exits
11. Client thread regains the cpu, and attempts to call SSL_connect, which
    fails, as the server is no longer listening
12. We fall into the error case on line 556, and SSL_get_error returns
    SSL_ERROR_SSL, which causes clienterr to get set to 1
13. We exit the do{} while loop on line 581, and do the TEST_true check on
    line 593. The server having exited wait_for_thread returns true, but
    globserverret is still zero from step 10 above, and so the test fails

I can't prove this is the case, as the test only appears to fail in CI,
and we can't dump verbose logging there, lest we affect the timing of
the tests, so this is just a theory, but it seems to fit the
observations we have.

Attempting to fix this, by creating a thread interlock with a condition
variable that blocks the server from ticking the quic reactor until such
time as the client is about to call SSL_connect to prevent the race
condition

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27704)

(cherry picked from commit 864333b455eb36ba84562d6482547bf4c8b49581)

2 months agoDocument EVP_CIPHER failure for missing provider function
Norbert Pocs [Mon, 26 May 2025 08:08:06 +0000 (10:08 +0200)] 
Document EVP_CIPHER failure for missing provider function

When writing a new CIPHER implementation the OSSL_FUNC_cipher_get_params
must be present, otherwise the fetch fails. This behaviour is seen in
function evp_cipher_cache_constants@crypto/evp/evp_lib.c.

Resolves: #25801

Signed-off-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27696)

(cherry picked from commit 3423c30db3aa044f46e1f0270e2ecd899415bf5f)

2 months agoapps/cmp.c: Free bio on error to avoid memory leak
JiashengJiang [Fri, 16 May 2025 22:34:03 +0000 (18:34 -0400)] 
apps/cmp.c: Free bio on error to avoid memory leak

Call BIO_free() to release bio if ASN1_i2d_bio_of() fails, preventing a memory leak.

Fixes: 6a3579e190 ("CMP: add support for requesting cert template using genm/genp")
Signed-off-by: JiashengJiang <jiasheng@purdue.edu>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27647)

(cherry picked from commit e0ae801728776b53e2be0972846072ce32bea304)

2 months agoOSSL_CMP_MSG_http_perform(): Remove extraneous %s from debug log print
Tomas Mraz [Fri, 16 May 2025 09:08:37 +0000 (11:08 +0200)] 
OSSL_CMP_MSG_http_perform(): Remove extraneous %s from debug log print

Also add missing ":" to another log print.

Fixes #27634

Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/27635)

(cherry picked from commit 0873cd1b680d2f54de3dbcc754ea6b1b397f112b)

2 months agocrypto/pkcs7/pk7_smime.c: Add BIO_free() to avoid memory leak
JiashengJiang [Thu, 22 May 2025 01:12:18 +0000 (21:12 -0400)] 
crypto/pkcs7/pk7_smime.c: Add BIO_free() to avoid memory leak

Add BIO_free() to free tmpout if OPENSSL_malloc() fails to avoid memory leak.

Fixes: 8e70485 ("RT3955: Reduce some stack usage")
Signed-off-by: JiashengJiang <jiasheng@purdue.edu>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27631)

(cherry picked from commit 9882d389df71ef7163c7769b4431a0dbe713ab65)

2 months agoapps/pkeyutl.c: Add OPENSSL_free() to avoid a memory leak
JiashengJiang [Tue, 22 Apr 2025 13:03:44 +0000 (09:03 -0400)] 
apps/pkeyutl.c: Add OPENSSL_free() to avoid a memory leak

If EVP_PKEY_CTX_ctrl_str() fails, the code jumps to 'end' label without freeing passwd, causing a memory leak.

Fixes: 9d1bf5f7de ("Add option to read pkeyopts interactively")
Signed-off-by: JiashengJiang <jiasheng@purdue.edu>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27470)

(cherry picked from commit 0dc6ea55a13dbe27af234b5328527d0a31ae68eb)

2 months agoAdd more instructions in HACKING.md
Richard Levitte [Wed, 21 May 2025 06:22:50 +0000 (08:22 +0200)] 
Add more instructions in HACKING.md

It's been long since it was updated or refined, and it was a bit too
vague in certain areas.

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

(cherry picked from commit 8bd89f15c967db43e34d9d2986b6fa9614a0a9ac)

2 months agoAvoid leaking duplicated EVP_PKEY_CTX in case of error
Tomas Mraz [Thu, 22 May 2025 14:22:13 +0000 (16:22 +0200)] 
Avoid leaking duplicated EVP_PKEY_CTX in case of error

Fixes Coverity 1647946 1647947

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

2 months agoFix memory leaks after failure of PKCS7_add_signed_attribute()
widneve [Tue, 20 May 2025 14:23:09 +0000 (16:23 +0200)] 
Fix memory leaks after failure of PKCS7_add_signed_attribute()

If PKCS7_add_signed_attribute fails,
seq never escapes out of the callee and will
therefore result in a memory leak.
This is similar to ed3d277127.

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/27670)

(cherry picked from commit 6543f34dda8908db56372581eef6eafa0ae4add4)

2 months agoUpdated Windows notes on the use of “no-makedepend” for new builds
klaus triendl [Sat, 12 Apr 2025 08:26:34 +0000 (11:26 +0300)] 
Updated Windows notes on the use of “no-makedepend” for new builds

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

(cherry picked from commit afd32bcb5456a9e33b0f4e07f572263b404d4d4b)

2 months agoapps/x509.c: Fix the -addreject option adding trust instead of rejection
Tomas Mraz [Tue, 20 May 2025 14:34:10 +0000 (16:34 +0200)] 
apps/x509.c: Fix the -addreject option adding trust instead of rejection

Fixes CVE-2025-4575

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/27672)

(cherry picked from commit 0eb9acc24febb1f3f01f0320cfba9654cf66b0ac)

2 months agocrypto/evp/signature.c: add checks for consistent presence of 'update' and 'final...
Dr. David von Oheimb [Wed, 16 Apr 2025 04:20:23 +0000 (06:20 +0200)] 
crypto/evp/signature.c: add checks for consistent presence of 'update' and 'final' functions

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27367)

(cherry picked from commit 8626a716b0776e4203dc89f2e81c54d078a7ad07)

2 months agoprovider-signature.pod: add missing doc of OSSL_FUNC_signature_query_key_types()...
Dr. David von Oheimb [Mon, 14 Apr 2025 14:05:01 +0000 (16:05 +0200)] 
provider-signature.pod: add missing doc of OSSL_FUNC_signature_query_key_types(), fix doc of return types, etc.

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27367)

(cherry picked from commit 1146b74a8a5784cc51426695d038ad8d9a4cc717)

2 months agocrypto/evp/signature.c: add more specific diagnostic data in case provider does not...
Dr. David von Oheimb [Mon, 14 Apr 2025 14:03:00 +0000 (16:03 +0200)] 
crypto/evp/signature.c: add more specific diagnostic data in case provider does not implement functions needed

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27367)

(cherry picked from commit 4a9a59cb075ee2fe0f76040f92f451e954ec8f64)

2 months agocrypto/evp/signature.c: compensate for providers not adding error queue entries on...
Dr. David von Oheimb [Mon, 14 Apr 2025 14:01:30 +0000 (16:01 +0200)] 
crypto/evp/signature.c: compensate for providers not adding error queue entries on operation failure

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27367)

(cherry picked from commit 3a57fb1386df87481233ed046fc16bf3332de046)

2 months agocrypto/evp: compensate for providers not adding error queue entries for keymgmt,...
Dr. David von Oheimb [Sun, 13 Apr 2025 05:25:46 +0000 (07:25 +0200)] 
crypto/evp: compensate for providers not adding error queue entries for keymgmt, sigver, and asymcipher

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27367)

(cherry picked from commit 72351b0d18078170af270418b2d5e9fc579cb1af)

2 months agostore_result.c: add to error queue which provider failed to load credential and hint...
Dr. David von Oheimb [Sun, 13 Apr 2025 05:28:08 +0000 (07:28 +0200)] 
store_result.c: add to error queue which provider failed to load credential and hint on using default provider

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27367)

(cherry picked from commit 1fc96a3cff124777597ed18c2405dc7181bda2ef)

2 months agoFix some typos in the man pages
Jan Luebbe [Fri, 9 May 2025 07:56:26 +0000 (09:56 +0200)] 
Fix some typos in the man pages

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

(cherry picked from commit 8fd0d230fdf80f7b6a3ee6c1197923600ce45c6a)

2 months agoThe condition that is never checked has been removed.
Dmitriy Denisov [Tue, 13 May 2025 08:56:33 +0000 (11:56 +0300)] 
The condition that is never checked has been removed.

If criterion == OSSL_STORE_SEARCH_BY_KEY_FINGERPRINT, the criterion !=0 condition will be triggered.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

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

(cherry picked from commit 00480f1def86aab882f2bd4d15d2d03862009718)

2 months agoCheck NASM version for {vex} prefix support
Zhiguo Zhou [Wed, 14 May 2025 14:30:47 +0000 (22:30 +0800)] 
Check NASM version for {vex} prefix support

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27632)

(cherry picked from commit b9282ecafa36bf3192bdc2cd54c729fb70a92814)

2 months agoRemove redundant space in effective address
Zhiguo Zhou [Wed, 14 May 2025 12:39:01 +0000 (20:39 +0800)] 
Remove redundant space in effective address

To have effective address of vmovapd instruction recognized and
translated to Intel format by the x86_64 assembler translator.

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27632)

(cherry picked from commit de4a7fad9ef84fe902119b58b1fca58d7437816f)

2 months agoPick up {vex} in x86_64 assembler translator
Zhiguo Zhou [Wed, 14 May 2025 12:35:43 +0000 (20:35 +0800)] 
Pick up {vex} in x86_64 assembler translator

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27632)

(cherry picked from commit 4189992f5bd8e38d640ec0cbe602d7dfc8c78a7e)