]> git.ipfire.org Git - thirdparty/openssl.git/log
thirdparty/openssl.git
2 weeks agoFix socket descriptor checks on Windows
olszomal [Thu, 4 Apr 2024 09:34:33 +0000 (11:34 +0200)] 
Fix socket descriptor checks on Windows

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

2 weeks agoFix typos found by codespell
Dimitri Papadopoulos [Wed, 14 Feb 2024 09:03:05 +0000 (10:03 +0100)] 
Fix typos found by codespell

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

2 weeks agoman EVP_PKEY_CTX_set_params: document params is a list
Hubert Kario [Wed, 27 Mar 2024 16:44:42 +0000 (17:44 +0100)] 
man EVP_PKEY_CTX_set_params: document params is a list

Signed-off-by: Hubert Kario <hkario@redhat.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23986)

2 weeks agoaarch64: fix BTI in bsaes assembly code
Tom Cosgrove [Tue, 26 Mar 2024 13:18:00 +0000 (13:18 +0000)] 
aarch64: fix BTI in bsaes assembly code

Change-Id: I63f0fb2af5eb9cea515dec96485325f8efd50511

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/23982)

2 weeks agoEnsure proper memory barriers around ossl_rcu_deref/ossl_rcu_assign_ptr
Neil Horman [Tue, 26 Mar 2024 13:59:14 +0000 (09:59 -0400)] 
Ensure proper memory barriers around ossl_rcu_deref/ossl_rcu_assign_ptr

Since the addition of macos14 M1 runners in our CI jobs we've been
seeing periodic random failures in the test_threads CI job.
Specifically we've seen instances in which the shared pointer in the
test (which points to a monotonically incrementing uint64_t went
backwards.

From taking a look at the disassembled code in the failing case, we see
that __atomic_load_n when emitted in clang 15 looks like this
0000000100120488 <_ossl_rcu_uptr_deref>:
100120488f8bfc000     ldapr   x0, [x0]
10012048cd65f03c0     ret

Notably, when compiling with gcc on the same system we get this output
instead:
0000000100120488 <_ossl_rcu_uptr_deref>:
100120488f8bfc000     ldar   x0, [x0]
10012048cd65f03c0     ret

Checking the arm docs for the difference between ldar and ldapr:
https://developer.arm.com/documentation/ddi0602/2023-09/Base-Instructions/LDAPR--Load-Acquire-RCpc-Register-
https://developer.arm.com/documentation/dui0802/b/A64-Data-Transfer-Instructions/LDAR

It seems that the ldar instruction provides a global cpu fence, not
completing until all writes in a given cpus writeback queue have
completed

Conversely, the ldapr instruction attmpts to achieve performance
improvements by honoring the Local Ordering register available in the
system coprocessor, only flushing writes in the same address region as
other cpus on the system.

I believe that on M1 virtualized cpus the ldapr is not properly ordering
writes, leading to an out of order read, despite the needed fencing.
I've opened an issue with apple on this here:
https://developer.apple.com/forums/thread/749530

I believe that it is not safe to issue an ldapr instruction unless the
programmer knows that the Local order registers are properly configured
for use on the system.

So to fix it I'm proposing with this patch that we, in the event that:
1) __APPLE__ is defined
AND
2) __clang__ is defined
AND
3) __aarch64__ is defined

during the build, that we override the ATOMIC_LOAD_N macro in the rcu
code such that it uses a custom function with inline assembly to emit
the ldar instruction rather than the ldapr instruction.  The above
conditions should get us to where this is only used on more recent MAC
cpus, and only in the case where the affected clang compiler emits the
offending instruction.

I've run this patch 10 times in our CI and failed to reproduce the
issue, whereas previously I could trigger it within 5 runs routinely.

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

2 weeks agoDowngrade also the download-artifact action
Tomas Mraz [Mon, 8 Apr 2024 15:29:51 +0000 (17:29 +0200)] 
Downgrade also the download-artifact action

It has to have the same version as upload-artifact.

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

3 weeks agoffc/ffc_params_generate.c: Add the check for the EVP_MD_get_size()
Jiasheng Jiang [Mon, 25 Mar 2024 16:54:55 +0000 (16:54 +0000)] 
ffc/ffc_params_generate.c: Add the check for the EVP_MD_get_size()

Add the check for the EVP_MD_get_size() to avoid invalid negative numbers.

Fixes: 4f2271d58a ("Add ACVP fips module tests")
Signed-off-by: Jiasheng Jiang <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/23970)

3 weeks agots/ts_rsp_sign.c: Add the check for the EVP_MD_CTX_get_size()
Jiasheng Jiang [Sat, 23 Mar 2024 16:09:01 +0000 (16:09 +0000)] 
ts/ts_rsp_sign.c: Add the check for the EVP_MD_CTX_get_size()

Add the check for the return value of EVP_MD_CTX_get_size() to avoid invalid negative numbers.

Fixes: c7235be6e3 ("RFC 3161 compliant time stamp request creation, response generation and response verification.")
Signed-off-by: Jiasheng Jiang <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/23960)

3 weeks agosignature/dsa_sig.c: Add checks for the EVP_MD_get_size()
Jiasheng Jiang [Fri, 22 Mar 2024 22:12:50 +0000 (22:12 +0000)] 
signature/dsa_sig.c: Add checks for the EVP_MD_get_size()

Add checks for the EVP_MD_get_size() to avoid integer overflow and then explicitly cast from int to size_t.

Fixes: 45a845e40b ("Add EVP_DigestSign/EVP_DigestVerify support for DSA")
Signed-off-by: Jiasheng Jiang <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/23948)

3 weeks agosignature/ecdsa_sig.c: Add checks for the EVP_MD_get_size()
Jiasheng Jiang [Fri, 22 Mar 2024 20:49:27 +0000 (20:49 +0000)] 
signature/ecdsa_sig.c: Add checks for the EVP_MD_get_size()

Add checks for the EVP_MD_get_size() to avoid integer overflow and then explicitly cast from int to size_t.

Fixes: edd3b7a309 ("Add ECDSA to providers")
Signed-off-by: Jiasheng Jiang <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/23947)

3 weeks agoAdd docs noting requirements for SM2 signing
Neil Horman [Tue, 19 Mar 2024 08:52:57 +0000 (04:52 -0400)] 
Add docs noting requirements for SM2 signing

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

3 weeks agoAdd check for public key presence on sm2 signing
Neil Horman [Mon, 18 Mar 2024 18:59:32 +0000 (14:59 -0400)] 
Add check for public key presence on sm2 signing

SM2 requires that the public EC_POINT be present in a key when signing.
If its not there we crash on a NULL pointer.  Add a check to ensure that
its present, and raise an error if its not

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

3 weeks agoAPPS: Add missing OPENSSL_free() and combine the error handler
Jiasheng Jiang [Sat, 16 Mar 2024 21:27:14 +0000 (21:27 +0000)] 
APPS: Add missing OPENSSL_free() and combine the error handler

Add the OPENSSL_free() in the error handler to release the "*md_value"
allocated by app_malloc(). To make the code clear and avoid possible
future errors, combine the error handler in the "err" tag.
Then, we only need to use "goto err" instead of releasing the memory
separately.

Since the EVP_MD_get_size() may return negative numbers when an error occurs,
create_query() may fail to catch the error since it only considers 0 as an
error code.

Therefore, unifying the error codes of create_digest() from non-positive
numbers to 0 is better, which also benefits future programming.

Fixes: c7235be ("RFC 3161 compliant time stamp request creation, response generation and response verification.")
Signed-off-by: Jiasheng Jiang <jiasheng@purdue.edu>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/23873)

3 weeks agoFix "Error finalizing cipher loop" when running openssl speed -evp -decrypt
Tom Cosgrove [Mon, 26 Feb 2024 17:14:48 +0000 (17:14 +0000)] 
Fix "Error finalizing cipher loop" when running openssl speed -evp -decrypt

When using CCM, openssl speed uses the loop function EVP_Update_loop_ccm() which
sets a (fake) tag when decrypting. When using -aead (which benchmarks a different
sequence than normal, to be comparable to TLS operation), the loop function
EVP_Update_loop_aead() is used, which also sets a tag when decrypting.

However, when using defaults, the loop function EVP_Update_loop() is used, which
does not set a tag on decryption, leading to "Error finalizing cipher loop".

To fix this, set a fake tag value if we're doing decryption on an AEAD cipher in
EVP_Update_loop(). We don't check the return value: this shouldn't really be able
to fail, and if it does, the following EVP_DecryptUpdate() is almost certain to
fail, so that can catch it.

The decryption is certain to fail (well, almost certain, but with a very low
probability of success), but this is no worse than at present. This minimal
change means that future benchmarking data should be comparable to previous
benchmarking data.

(This is benchmarking code: don't write real apps like this!)

Fixes #23657

Change-Id: Id581cf30503c1eb766464e315b1f33914040dcf7

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

3 weeks agoFix EVP_PKEY_CTX_add1_hkdf_info() behavior
Todd Short [Fri, 2 Feb 2024 04:09:38 +0000 (23:09 -0500)] 
Fix EVP_PKEY_CTX_add1_hkdf_info() behavior

Fix #23448

`EVP_PKEY_CTX_add1_hkdf_info()` behaves like a `set1` function.

Fix the setting of the parameter in the params code.
Update the TLS_PRF code to also use the params code.
Add tests.

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

3 weeks agoAdd demo for ECDH key exchange
slontis [Sat, 2 Dec 2023 23:09:46 +0000 (09:09 +1000)] 
Add demo for ECDH key exchange

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

3 weeks agoapps: ca,req,x509: Add explicit start and end dates options
Stephan Wurm [Wed, 9 Aug 2023 07:07:46 +0000 (09:07 +0200)] 
apps: ca,req,x509: Add explicit start and end dates options

- Added options `-not_before` (start date) and `-not-after` (end date)
  for explicit setting of the validity period of a certificate in the
  apps `ca`, `req` and `x509`
- The new options accept time strings or "today"
- In app `ca`, use the new options as aliases of the already existing
  options `-startdate` and `-enddate`
- When used in apps `req` and `x509`, the end date must be >= the start
  date, in app `ca` end date < start date is also accepted
- In any case, `-not-after` overrides the `-days` option
- Added helper function `check_cert_time_string` to validate given
  certificate time strings
- Use the new helper function in apps `ca`, `req` and `x509`
- Moved redundant code for time string checking into `set_cert_times`
  helper function.
- Added tests for explicit start and end dates in apps `req` and `x509`
- test: Added auxiliary functions for parsing fields from `-text`
  formatted output to `tconversion.pl`
- CHANGES: Added to new section 3.4

Signed-off-by: Stephan Wurm <atomisirsi@gsklan.de>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21716)

3 weeks agoCheck range of RSA plaintext and ciphertext when using no padding.
slontis [Mon, 8 Apr 2024 07:12:58 +0000 (17:12 +1000)] 
Check range of RSA plaintext and ciphertext when using no padding.

Fixes #24051

RSA with 'no padding' corresponds to RSAEP/RSADP.
The code was not checking the lower bounds.
The bounds are specified in SP800-56Br2, section 7.1.1.1 and 7.1.2.1
Note that RFC8017 expresses the range in a sentence using the word
between, and there is some ambiguity in this.
The upper bounds have change to match the definition in SP800.

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

3 weeks agoCopyright year updates
Matt Caswell [Fri, 29 Mar 2024 14:05:51 +0000 (14:05 +0000)] 
Copyright year updates

Reviewed-by: Neil Horman <nhorman@openssl.org>
Release: yes
(cherry picked from commit 3764f200f9d44622faa8ac1b15d2f3eb7c39e473)

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

3 weeks agoCopyright year updates
Richard Levitte [Wed, 20 Mar 2024 12:07:54 +0000 (13:07 +0100)] 
Copyright year updates

Reviewed-by: Neil Horman <nhorman@openssl.org>
Release: yes
(cherry picked from commit 0ce7d1f355c1240653e320a3f6f8109c1f05f8c0)

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

3 weeks agoSync libcrypto.num and libssl.num with 3.3 branch
Tomas Mraz [Thu, 4 Apr 2024 09:08:19 +0000 (11:08 +0200)] 
Sync libcrypto.num and libssl.num with 3.3 branch

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

3 weeks agoSync CHANGES.md and NEWS.md with 3.3 branch
Tomas Mraz [Thu, 4 Apr 2024 09:06:53 +0000 (11:06 +0200)] 
Sync CHANGES.md and NEWS.md with 3.3 branch

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

3 weeks agoUpdate the version to 3.4.0-dev
Tomas Mraz [Thu, 4 Apr 2024 08:57:43 +0000 (10:57 +0200)] 
Update the version to 3.4.0-dev

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

3 weeks agoAdd a test for session cache overflow
Matt Caswell [Fri, 15 Jul 2022 12:26:33 +0000 (13:26 +0100)] 
Add a test for session cache overflow

Test sessions behave as we expect even in the case that an overflow
occurs when adding a new session into the session cache.

Related to CVE-2024-2511

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

3 weeks agoHardening around not_resumable sessions
Matt Caswell [Fri, 15 Mar 2024 17:58:42 +0000 (17:58 +0000)] 
Hardening around not_resumable sessions

Make sure we can't inadvertently use a not_resumable session

Related to CVE-2024-2511

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

3 weeks agoAdd a CHANGES.md/NEWS.md entry for the unbounded memory growth bug
Matt Caswell [Tue, 5 Mar 2024 16:01:20 +0000 (16:01 +0000)] 
Add a CHANGES.md/NEWS.md entry for the unbounded memory growth bug

Related to CVE-2024-2511

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

3 weeks agoFix unconstrained session cache growth in TLSv1.3
Matt Caswell [Tue, 5 Mar 2024 15:43:53 +0000 (15:43 +0000)] 
Fix unconstrained session cache growth in TLSv1.3

In TLSv1.3 we create a new session object for each ticket that we send.
We do this by duplicating the original session. If SSL_OP_NO_TICKET is in
use then the new session will be added to the session cache. However, if
early data is not in use (and therefore anti-replay protection is being
used), then multiple threads could be resuming from the same session
simultaneously. If this happens and a problem occurs on one of the threads,
then the original session object could be marked as not_resumable. When we
duplicate the session object this not_resumable status gets copied into the
new session object. The new session object is then added to the session
cache even though it is not_resumable.

Subsequently, another bug means that the session_id_length is set to 0 for
sessions that are marked as not_resumable - even though that session is
still in the cache. Once this happens the session can never be removed from
the cache. When that object gets to be the session cache tail object the
cache never shrinks again and grows indefinitely.

CVE-2024-2511

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

3 weeks agoExtend the multi_resume test for simultaneous resumptions
Matt Caswell [Tue, 5 Mar 2024 15:35:51 +0000 (15:35 +0000)] 
Extend the multi_resume test for simultaneous resumptions

Test what happens if the same session gets resumed multiple times at the
same time - and one of them gets marked as not_resumable.

Related to CVE-2024-2511

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

3 weeks agoAdd a test for session cache handling
Matt Caswell [Mon, 4 Mar 2024 13:45:23 +0000 (13:45 +0000)] 
Add a test for session cache handling

Repeatedly create sessions to be added to the cache and ensure we never
exceed the expected size.

Related to CVE-2024-2511

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

3 weeks agoEnable SHA3 unrolling and EOR3 optimization for Ampere
Jiangning Liu [Thu, 21 Mar 2024 23:52:28 +0000 (16:52 -0700)] 
Enable SHA3 unrolling and EOR3 optimization for Ampere

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

3 weeks agoNonStop: Do not call sleep() with a 0 value
Randall S. Becker [Sat, 30 Mar 2024 22:28:02 +0000 (22:28 +0000)] 
NonStop: Do not call sleep() with a 0 value

This change ensures that sleep(0) is not invoked to cause unexpected
duplicate thread context switches when _REENTRANT is specified.

Fixes: #24009
Signed-off-by: Randall S. Becker <randall.becker@nexbridge.ca>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24012)

(cherry picked from commit c89fe574493f438dd0e94bb9a89227e4ca84c0b7)

3 weeks agoDiverse small VMS build fixups
Richard Levitte [Sat, 30 Mar 2024 11:52:50 +0000 (12:52 +0100)] 
Diverse small VMS build fixups

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

(cherry picked from commit 1a4b029af51ba6128a37959796381ca5b8b7ac00)

3 weeks agodowngrade upload-artifact action to v3
Dmitry Misharov [Wed, 3 Apr 2024 11:47:39 +0000 (13:47 +0200)] 
downgrade upload-artifact action to v3

GitHub Enterpise Server is not compatible with upload-artifact@v4+.
https://github.com/actions/upload-artifact/tree/v4

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

3 weeks agoopenssl-crl(1): The -verify option is implied by -CA* options
Tomas Mraz [Tue, 2 Apr 2024 16:47:26 +0000 (18:47 +0200)] 
openssl-crl(1): The -verify option is implied by -CA* options

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/24024)

3 weeks agoDEFINE_STACK_OF.pod: Fix prototypes of sk_TYPE_free/zero()
Tomas Mraz [Tue, 2 Apr 2024 14:43:27 +0000 (16:43 +0200)] 
DEFINE_STACK_OF.pod: Fix prototypes of sk_TYPE_free/zero()

They take non-const STACK_OF(TYPE)* 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/24023)

3 weeks agoFix syntax of dependabot.yml
Kurt Roeckx [Wed, 20 Mar 2024 09:00:42 +0000 (10:00 +0100)] 
Fix syntax of dependabot.yml

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23899)

3 weeks agoposix_async: FreeBSD also defines {make|swap|get|set}context
Warner Losh [Mon, 18 Mar 2024 18:23:08 +0000 (12:23 -0600)] 
posix_async: FreeBSD also defines {make|swap|get|set}context

FreeBSD also defines {make|swap|get|set}context for backward
compatibility, despite also exposing POSIX_VERSION 200809L
in FreeBSD 15-current.

Note: There's no fallback for POSIX_VERSION 200809 without
these routines, so maybe that should be a #error?

CLA: Trivial

Sponsored by: Netflix

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

3 weeks agoAdd design document about handing some MAX defines
Tomas Mraz [Fri, 15 Mar 2024 16:18:46 +0000 (17:18 +0100)] 
Add design document about handing some MAX defines

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

3 weeks agoAdd 'documentation policy' link to CONTRIBUTING guide.
slontis [Mon, 18 Mar 2024 00:46:12 +0000 (11:46 +1100)] 
Add 'documentation policy' link to CONTRIBUTING guide.

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

3 weeks agoUpdate Documentation for EVP_DigestSign, EVP_DigestVerify.
slontis [Thu, 14 Mar 2024 05:11:40 +0000 (16:11 +1100)] 
Update Documentation for EVP_DigestSign, EVP_DigestVerify.

Fixes #23075

In OpenSSL 3.2 EVP_DigestSign and EVP_DigestVerify
were changed so that a flag is set once these functions
do a one-shot sign or verify operation. This PR updates the
documentation to match the behaviour.

Investigations showed that prior to 3.2 different key
type behaved differently if multiple calls were done.

By accident X25519 and X448 would produce the same signature,
but ECDSA and RSA remembered the digest state between calls,
so the signature was different when multiple calls were done.

Because of this undefined behaviour something needed to be done,
so keeping the 'only allow it to be called once' behaviour
seems a reasonable approach.

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

3 weeks agoAlign 'openssl req' string_mask docs to how the software really works
Job Snijders [Tue, 27 Feb 2024 19:14:32 +0000 (19:14 +0000)] 
Align 'openssl req' string_mask docs to how the software really works

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

3 weeks agotypo fix
willmafh [Sat, 24 Feb 2024 09:34:25 +0000 (17:34 +0800)] 
typo fix

CLA: trivial

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

3 weeks agoSSL_alert_desc_string_long(): Delete unnecessary underline
willmafh [Sat, 24 Feb 2024 09:34:11 +0000 (17:34 +0800)] 
SSL_alert_desc_string_long(): Delete unnecessary underline

It is not present in other alert description strings.

CLA: trivial

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

3 weeks agoRemove receiving of unused return value
Drokov Pavel [Fri, 12 Jan 2024 08:38:35 +0000 (03:38 -0500)] 
Remove receiving of unused return value

CLA: trivial

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

3 weeks agoWorkaround the relocation truncated to fit problem on m68k builds
Tomas Mraz [Wed, 3 Apr 2024 10:41:21 +0000 (12:41 +0200)] 
Workaround the relocation truncated to fit problem on m68k builds

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

3 weeks agorsa/rsa_pmeth.c: Add the checks for the EVP_MD_CTX_get_size()
Jiasheng Jiang [Fri, 22 Mar 2024 23:23:35 +0000 (23:23 +0000)] 
rsa/rsa_pmeth.c: Add the checks for the EVP_MD_CTX_get_size()

Add the checks for the return value of EVP_MD_CTX_get_size() before explicitly
cast them to size_t to avoid the integer overflow.

Fixes: 75d44c0452 ("Store digests as EVP_MD instead of a NID.")
Signed-off-by: Jiasheng Jiang <jiasheng@purdue.edu>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23953)

4 weeks agoFix GCC compilation -Waggressive-loop-optimizations
Adrien Zinger [Wed, 20 Mar 2024 08:39:16 +0000 (09:39 +0100)] 
Fix GCC compilation -Waggressive-loop-optimizations

GCC 13.1.0 were reporting a compilation warning with -O2/3 and
-Waggressive-loop-optimizations. GCC is raising an undefined behavior in the
while loop. Replace the while loop with a memset call at the top of the
function.

Fixes #21088

CLA: trivial

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

4 weeks agoBIO_s_connect: Do not set keepalive on dgram sockets
Hugo Landau [Mon, 1 Apr 2024 08:03:20 +0000 (09:03 +0100)] 
BIO_s_connect: Do not set keepalive on dgram sockets

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

4 weeks agoDocument change of -verify behavior in crl and req apps
Vladimir Kotal [Wed, 27 Mar 2024 09:51:22 +0000 (10:51 +0100)] 
Document change of -verify behavior in crl and req apps

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

4 weeks agoUse RFC 5869 test case for HKDF self-test
pohsingwu [Wed, 13 Mar 2024 06:42:14 +0000 (14:42 +0800)] 
Use RFC 5869 test case for HKDF self-test

According to NIST SP 800-131Ar2 section 8, the length of the
key-derivation key shall be at least 112 bits.

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

4 weeks agoRemove handling of NULL sig param in ossl_ecdsa_deterministic_sign
Bernd Edlinger [Thu, 8 Feb 2024 21:44:33 +0000 (22:44 +0100)] 
Remove handling of NULL sig param in ossl_ecdsa_deterministic_sign

The handling of sig=NULL was broken in this function, but since it
is only used internally and was never called with sig=NULL, it is
better to return an error in that case.

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

4 weeks agoFix handling of NULL sig parameter in ECDSA_sign and similar
Bernd Edlinger [Thu, 8 Feb 2024 21:21:55 +0000 (22:21 +0100)] 
Fix handling of NULL sig parameter in ECDSA_sign and similar

The problem is, that it almost works to pass sig=NULL to the
ECDSA_sign, ECDSA_sign_ex and DSA_sign, to compute the necessary
space for the resulting signature.
But since the ECDSA signature is non-deterministic
(except when ECDSA_sign_setup/ECDSA_sign_ex are used)
the resulting length may be different when the API is called again.
This can easily cause random memory corruption.
Several internal APIs had the same issue, but since they are
never called with sig=NULL, it is better to make them return an
error in that case, instead of making the code more complex.

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

4 weeks agoFix openssl req with -addext subjectAltName=dirName
Bernd Edlinger [Fri, 23 Feb 2024 09:32:14 +0000 (10:32 +0100)] 
Fix openssl req with -addext subjectAltName=dirName

The syntax check of the -addext fails because the
X509V3_CTX is used to lookup the referenced section,
but the wrong configuration file is used, where only
a default section with all passed in -addext lines is available.
Thus it was not possible to use the subjectAltName=dirName:section
as an -addext parameter.  Probably other extensions as well.

This change affects only the syntax check, the real extension
was already created with correct parameters.

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

4 weeks agoASYNC_start_job: more readable documentation for handling ASYNC* APIs
Hubert Kario [Fri, 22 Mar 2024 16:41:35 +0000 (17:41 +0100)] 
ASYNC_start_job: more readable documentation for handling ASYNC* APIs

Signed-off-by: Hubert Kario <hkario@redhat.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23941)

4 weeks agoAlter the check
Jiasheng Jiang [Fri, 22 Mar 2024 18:09:18 +0000 (18:09 +0000)] 
Alter the check

Alter the check since 0 md size is an error.

Signed-off-by: Jiasheng Jiang <jiasheng@purdue.edu>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/23940)

4 weeks agossl/ssl_lib.c: Add the check before cast from int to unsigned
Jiasheng Jiang [Fri, 22 Mar 2024 16:26:44 +0000 (16:26 +0000)] 
ssl/ssl_lib.c: Add the check before cast from int to unsigned

Add the check before cast from int to unsigned to avoid integer overflow since EVP_MD_get_size() may return negative numbers.

Fixes: 919ba00942 ("DANE support structures, constructructors and accessors")
Signed-off-by: Jiasheng Jiang <jiasheng@purdue.edu>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/23940)

4 weeks agoBump actions/setup-python from 5.0.0 to 5.1.0
dependabot[bot] [Tue, 26 Mar 2024 17:39:00 +0000 (17:39 +0000)] 
Bump actions/setup-python from 5.0.0 to 5.1.0

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

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

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

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

4 weeks agoExplicitly state what -keys does
Simo Sorce [Thu, 21 Mar 2024 14:00:52 +0000 (10:00 -0400)] 
Explicitly state what -keys does

Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/23919)

4 weeks agoAlter the variable name
Jiasheng Jiang [Fri, 22 Mar 2024 19:36:34 +0000 (19:36 +0000)] 
Alter the variable name

Alter the variable name to make it more meaningful.

Signed-off-by: Jiasheng Jiang <jiasheng@purdue.edu>
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/23942)

4 weeks agossl/tls13_enc.c: Replace size_t with int and add the checks
Jiasheng Jiang [Fri, 22 Mar 2024 18:41:58 +0000 (18:41 +0000)] 
ssl/tls13_enc.c: Replace size_t with int and add the checks

Replace the type of variables with int to avoid implicit cast when they are assigned by EVP_MD_get_size().
Moreover, add the checks to avoid integer overflow.

Fixes: 6612d87b89 ("Use the correct size for TLSv1.3 finished keys")
Fixes: 34574f193b ("Add support for TLS1.3 secret generation")
Signed-off-by: Jiasheng Jiang <jiasheng@purdue.edu>
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/23942)

4 weeks agossl/t1_lib.c: Add checks for the EVP_MD_get_size()
Jiasheng Jiang [Fri, 22 Mar 2024 19:18:34 +0000 (19:18 +0000)] 
ssl/t1_lib.c: Add checks for the EVP_MD_get_size()

Add checks for the EVP_MD_get_size() to avoid unexpected negative numbers.

Fixes: b362ccab5c ("Security framework.")
Fixes: 0fe3db251a ("Use size of server key when selecting signature algorithm.")
Signed-off-by: Jiasheng Jiang <jiasheng@purdue.edu>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/23943)

4 weeks agorands/drbg_hash.c: Add checks for the EVP_MD_get_size()
Jiasheng Jiang [Fri, 22 Mar 2024 19:51:28 +0000 (19:51 +0000)] 
rands/drbg_hash.c: Add checks for the EVP_MD_get_size()

Add checks for the EVP_MD_get_size() to avoid integer overflow and then explicitly cast from int to size_t.

Fixes: 8bf3665196 ("Added DRBG_HMAC & DRBG_HASH + Added defaults for setting DRBG for master/public/private + renamed generate_counter back to reseed_counter + generated new cavs data tests")
Signed-off-by: Jiasheng Jiang <jiasheng@purdue.edu>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23944)

4 weeks agoAdd locking to atomic operations in rw/rcu tests
Neil Horman [Fri, 29 Mar 2024 15:39:12 +0000 (11:39 -0400)] 
Add locking to atomic operations in rw/rcu tests

I neglected to add locks to the calls to CRYPTO_atomic_add in these
test, which on newer compilers is fine, as atomic operations are
defined.  However on older compilers the __ATOMIC_ACQ_REL definition is
missing causing these function to be implemented using an rwlock, which
when NULL causes the locks to fail.

Fix this my creating the lock and using them appropriately

Fixes #24000

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

4 weeks agorands/drbg_hmac.c: Add checks for the EVP_MD_get_size()
Jiasheng Jiang [Fri, 22 Mar 2024 20:01:52 +0000 (20:01 +0000)] 
rands/drbg_hmac.c: Add checks for the EVP_MD_get_size()

Add checks for the EVP_MD_get_size() to avoid integer overflow and then explicitly cast from int to size_t.

Fixes: 8bf3665196 ("Added DRBG_HMAC & DRBG_HASH + Added defaults for setting DRBG for master/public/private + renamed generate_counter back to reseed_counter + generated new cavs data tests")
Signed-off-by: Jiasheng Jiang <jiasheng@purdue.edu>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23945)

4 weeks agomacs/kmac_prov.c: Add checks for the EVP_MD_get_size()
Jiasheng Jiang [Fri, 22 Mar 2024 20:21:46 +0000 (20:21 +0000)] 
macs/kmac_prov.c: Add checks for the EVP_MD_get_size()

Add checks for the EVP_MD_get_size() to avoid integer overflow and then explicitly cast from int to size_t.

Fixes: 6e624a6453 ("KMAC implementation using EVP_MAC")
Signed-off-by: Jiasheng Jiang <jiasheng@purdue.edu>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23946)

4 weeks agosignature/rsa_sig.c: Add checks for the EVP_MD_get_size()
Jiasheng Jiang [Fri, 22 Mar 2024 22:22:23 +0000 (22:22 +0000)] 
signature/rsa_sig.c: Add checks for the EVP_MD_get_size()

Add checks for the EVP_MD_get_size() to avoid integer overflow and then explicitly cast from int to size_t.

Fixes: 6f4b766315 ("PROV: add RSA signature implementation")
Signed-off-by: Jiasheng Jiang <jiasheng@purdue.edu>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23949)

4 weeks agokdfs/hmacdrbg_kdf.c: Add checks for the EVP_MD_get_size()
Jiasheng Jiang [Fri, 22 Mar 2024 22:33:57 +0000 (22:33 +0000)] 
kdfs/hmacdrbg_kdf.c: Add checks for the EVP_MD_get_size()

Add checks for the EVP_MD_get_size() to avoid integer overflow and then explicitly cast from int to size_t.

Fixes: f3090fc710 ("Implement deterministic ECDSA sign (RFC6979)")
Signed-off-by: Jiasheng Jiang <jiasheng@purdue.edu>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23950)

4 weeks agotest/bad_dtls_test.c: Add checks for the EVP_MD_CTX_get_size()
Jiasheng Jiang [Fri, 22 Mar 2024 23:05:00 +0000 (23:05 +0000)] 
test/bad_dtls_test.c: Add checks for the EVP_MD_CTX_get_size()

Add the check for the EVP_MD_CTX_get_size() to avoid integer overflow when it is implicitly casted from int to size_t in evp_pkey_ctx_store_cached_data().
The call path is do_PRF() -> EVP_PKEY_CTX_add1_tls1_prf_seed() -> evp_pkey_ctx_set1_octet_string() -> EVP_PKEY_CTX_ctrl() -> evp_pkey_ctx_store_cached_data().

Fixes: 16938284cf ("Add basic test for Cisco DTLS1_BAD_VER and record replay handling")
Signed-off-by: Jiasheng Jiang <jiasheng@purdue.edu>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23952)

4 weeks agoAdd OPENSSL_free to avoid mem leak
Jiasheng Jiang [Mon, 25 Mar 2024 14:20:04 +0000 (14:20 +0000)] 
Add OPENSSL_free to avoid mem leak

Signed-off-by: Jiasheng Jiang <jiasheng@purdue.edu>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23955)

4 weeks agostore/store_lib.c: Add the checks for the EVP_MD_CTX_get_size()
Jiasheng Jiang [Fri, 22 Mar 2024 23:39:19 +0000 (23:39 +0000)] 
store/store_lib.c: Add the checks for the EVP_MD_CTX_get_size()

Add the checks for the return value of EVP_MD_CTX_get_size() before explicitly cast them to size_t to avoid the integer overflow.

Fixes: fac8673b8a ("STORE: Add the possibility to search for specific information")
Signed-off-by: Jiasheng Jiang <jiasheng@purdue.edu>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23955)

4 weeks agodsa/dsa_pmeth.c: Add the checks for the EVP_MD_CTX_get_size()
Jiasheng Jiang [Fri, 22 Mar 2024 23:32:44 +0000 (23:32 +0000)] 
dsa/dsa_pmeth.c: Add the checks for the EVP_MD_CTX_get_size()

Add the checks for the return value of EVP_MD_CTX_get_size() before explicitly cast them to size_t to avoid the integer overflow.

Fixes: 9d04f83410 ("Add DSA digest length checks.")
Signed-off-by: Jiasheng Jiang <jiasheng@purdue.edu>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23954)

4 weeks agox509/x509_set.c: Add the check for the EVP_MD_CTX_get_size()
Jiasheng Jiang [Fri, 22 Mar 2024 23:47:21 +0000 (23:47 +0000)] 
x509/x509_set.c: Add the check for the EVP_MD_CTX_get_size()

Add the check for the return value of EVP_MD_CTX_get_size() to avoid invalid negative numbers.

Fixes: 786dd2c22c ("Add support for custom signature parameters")
Signed-off-by: Jiasheng Jiang <jiasheng@purdue.edu>
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/23956)

4 weeks agoBreak the if statement up into 2 if statements
Jiasheng Jiang [Mon, 25 Mar 2024 14:16:51 +0000 (14:16 +0000)] 
Break the if statement up into 2 if statements

Break the if statement up into 2 if statements to avoid call
EVP_MD_get_size() twice.

Signed-off-by: Jiasheng Jiang <jiasheng@purdue.edu>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23959)

4 weeks agosignature/sm2_sig.c: Add the check for the EVP_MD_CTX_get_size()
Jiasheng Jiang [Sat, 23 Mar 2024 15:37:43 +0000 (15:37 +0000)] 
signature/sm2_sig.c: Add the check for the EVP_MD_CTX_get_size()

Add the check for the return value of EVP_MD_CTX_get_size() to avoid invalid negative numbers.

Fixes: d0b79f8631 ("Add SM2 signature algorithm to default provider")
Signed-off-by: Jiasheng Jiang <jiasheng@purdue.edu>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23959)

4 weeks agoAllow provider sigalgs in SignatureAlgorithms conf
Alex Bozarth [Mon, 20 Nov 2023 21:20:31 +0000 (15:20 -0600)] 
Allow provider sigalgs in SignatureAlgorithms conf

Though support for provider-based signature algorithms was added in
ee58915 this functionality did not work with the SignatureAlgorithms
configuration command. If SignatureAlgorithms is set then the provider
sigalgs are not used and instead it used the default value.

This PR adds a check against the provider-base sigalg list when parsing
the SignatureAlgorithms value.

Based-on-patch-by: Martin Schmatz <mrt@zurich.ibm.com>
Fixes #22761

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

4 weeks agoReject setting invalid CSR versions
Job Snijders [Mon, 25 Mar 2024 10:49:12 +0000 (10:49 +0000)] 
Reject setting invalid CSR versions

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

4 weeks agorsa/rsa_ameth.c: Add the check for the EVP_MD_get_size()
Jiasheng Jiang [Mon, 25 Mar 2024 21:07:46 +0000 (21:07 +0000)] 
rsa/rsa_ameth.c: Add the check for the EVP_MD_get_size()

Add the check for the EVP_MD_get_size() to avoid invalid negative numbers.

Fixes: 17c63d1cca ("RSA PSS ASN1 signing method")
Signed-off-by: Jiasheng Jiang <jiasheng@purdue.edu>
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/23973)

5 weeks agoFix threadstest wrapping again
Neil Horman [Mon, 25 Mar 2024 13:18:27 +0000 (09:18 -0400)] 
Fix threadstest wrapping again

Stochastic failures in the RCU test on MACOSX are occuring.  Due to beta
release, disabling this test on MACOSX until post 3.3 release

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

5 weeks agoUpdate gost-engine submodule to fix the CI
Tomas Mraz [Tue, 26 Mar 2024 10:53:53 +0000 (11:53 +0100)] 
Update gost-engine submodule to fix the CI

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/23773)

5 weeks agoapps/req,crl: exit with 1 on verification failure
Vladimir Kotal [Thu, 7 Mar 2024 16:00:07 +0000 (17:00 +0100)] 
apps/req,crl: exit with 1 on verification failure

Fixes #23771

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/23773)

5 weeks agoAdd NULL check before accessing PKCS7 encrypted algorithm
Viliam Lejčík [Mon, 19 Feb 2024 20:39:05 +0000 (21:39 +0100)] 
Add NULL check before accessing PKCS7 encrypted algorithm

Printing content of an invalid test certificate causes application crash, because of NULL dereference:

user@user:~/openssl$ openssl pkcs12 -in test/recipes/80-test_pkcs12_data/bad2.p12 -passin pass: -info
MAC: sha256, Iteration 2048
MAC length: 32, salt length: 8
PKCS7 Encrypted data: Segmentation fault (core dumped)

Added test cases for pkcs12 bad certificates

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

5 weeks agoReplace size_t with int and add the check for the EVP_MD_get_size()
Jiasheng Jiang [Thu, 21 Mar 2024 20:22:01 +0000 (20:22 +0000)] 
Replace size_t with int and add the check for the EVP_MD_get_size()

Replace the type of "digest_size" with int to avoid implicit conversion when it is assigned by EVP_MD_get_size().
Moreover, add the check for the "digest_size".

Fixes: 29ce1066bc ("Update the demos/README file because it is really old. New demos should provide best practice for API use. Add demonstration for computing a SHA3-512 digest - digest/EVP_MD_demo")
Signed-off-by: Jiasheng Jiang <jiasheng@purdue.edu>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23924)

5 weeks agoReplace unsigned with int
Jiasheng Jiang [Thu, 21 Mar 2024 19:55:34 +0000 (19:55 +0000)] 
Replace unsigned with int

Replace the type of "digest_length" with int to avoid implicit conversion when it is assigned by EVP_MD_get_size().
Otherwise, it may pass the following check and cause the integer overflow error when EVP_MD_get_size() returns negative numbers.
Signed-off-by: Jiasheng Jiang <jiasheng@purdue.edu>
Reviewed-by: Matt Caswell <matt@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/23922)

5 weeks agofix demos/sslecho/main.c so it builds on OpenBSD too
sashan [Fri, 22 Mar 2024 14:19:53 +0000 (15:19 +0100)] 
fix demos/sslecho/main.c so it builds on OpenBSD too

trying to build `demos/sslecho/main.c` shipped by current openssl
fails with error as follows:
```
cc -I../../include -g -Wall   -c -o main.o main.c
main.c:35:24: error: variable has incomplete type 'struct sockaddr_in'
    struct sockaddr_in addr;
                       ^
main.c:35:12: note: forward declaration of 'struct sockaddr_in'
    struct sockaddr_in addr;
           ^
main.c:46:32: error: use of undeclared identifier 'INADDR_ANY'
        addr.sin_addr.s_addr = INADDR_ANY;
                               ^
main.c:152:24: error: variable has incomplete type 'struct sockaddr_in'
    struct sockaddr_in addr;
                       ^
main.c:152:12: note: forward declaration of 'struct sockaddr_in'
    struct sockaddr_in addr;
           ^
3 errors generated.
gmake: *** [<builtin>: main.o] Error 1
```

including `netinet/in.h` fixes the build

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

5 weeks agoAdd 3.3 and 3.2 branches to Coveralls builds
Tomas Mraz [Fri, 22 Mar 2024 15:00:15 +0000 (16:00 +0100)] 
Add 3.3 and 3.2 branches to Coveralls builds

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

5 weeks agoCorrect OSSL_sleep for NonStop PUT model by introducing sleep().
Randall S. Becker [Thu, 21 Mar 2024 21:16:11 +0000 (21:16 +0000)] 
Correct OSSL_sleep for NonStop PUT model by introducing sleep().

This fix also removes SPT model support as it was previously deprecated.
Upcoming threading models on the platform should be supportable without change
to this method.

Fixes: #23923
Fixes: #23927
Fixes: #23928
Signed-off-by: Randall S. Becker <randall.becker@nexbridge.ca>
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/23926)

5 weeks agoDon’t use the recvmmsg dgram method on Android <5
Yavor Georgiev [Tue, 5 Mar 2024 18:10:03 +0000 (19:10 +0100)] 
Don’t use the recvmmsg dgram method on Android <5

recvmmsg and sendmmsg were only added to Android’s C library in version 5, starting with API Level 21.

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

5 weeks agoFixed a typo and grammar in openssl-ts.pod
olszomal [Thu, 21 Mar 2024 10:10:04 +0000 (11:10 +0100)] 
Fixed a typo and grammar in openssl-ts.pod

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

5 weeks agofix uploading artifacts for paramertrized jobs
Dmitry Misharov [Fri, 22 Mar 2024 11:01:53 +0000 (12:01 +0100)] 
fix uploading artifacts for paramertrized jobs

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

5 weeks agoMake counters in rcu/rw threads torture test 64 bit
Neil Horman [Tue, 5 Mar 2024 19:22:28 +0000 (14:22 -0500)] 
Make counters in rcu/rw threads torture test 64 bit

Its possible in some conditions for the rw/rcu torture tests to wrap the
counter, leading to false positive failures, make them 64 bits to avoid
this

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

5 weeks agoAdd M1 macOS runner to some workflows
Dmitry Misharov [Fri, 1 Mar 2024 15:59:07 +0000 (16:59 +0100)] 
Add M1 macOS runner to some workflows

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

5 weeks agoriscv: Fix remaining asm checks
Jakov Smolić [Tue, 5 Mar 2024 15:43:11 +0000 (16:43 +0100)] 
riscv: Fix remaining asm checks

There are additional asm checks which don't check for OPENSSL_CPUID_OBJ
causing the build to still fail on riscv [1], so fix them in the same
manner as ff279597692f9f19dca5b147944d3d96f2e109f8

[1] https://bugs.gentoo.org/923956
Fixes: https://github.com/openssl/openssl/issues/22871
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23752)

(cherry picked from commit daf1f8d64fff4a395ee7cf032484dc022a27e748)

5 weeks agoUpdate FIPS hmac key documentation
Matt Hauck [Fri, 15 Mar 2024 01:25:11 +0000 (18:25 -0700)] 
Update FIPS hmac key documentation

The documentation is slightly incorrect about the FIPS hmac key.

CLA: trivial

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23846)

5 weeks agoMove artifact upload code into the shell script
Hugo Landau [Mon, 12 Feb 2024 13:17:01 +0000 (13:17 +0000)] 
Move artifact upload code into the shell script

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

5 weeks agoExperimental support for uploading qlog artifacts
Hugo Landau [Mon, 12 Feb 2024 11:29:14 +0000 (11:29 +0000)] 
Experimental support for uploading qlog artifacts

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

6 weeks agoFix unbounded memory growth when using no-cached-fetch
Matt Caswell [Wed, 13 Mar 2024 15:19:43 +0000 (15:19 +0000)] 
Fix unbounded memory growth when using no-cached-fetch

When OpenSSL has been compiled with no-cached-fetch we do not cache
algorithms fetched from a provider. When we export an EVP_PKEY to a
provider we cache the details of that export in the operation cache for
that EVP_PKEY. Amoung the details we cache is the EVP_KEYMGMT that we used
for the export. When we come to reuse the key in the same provider that
we have previously exported the key to, we check the operation cache for
the cached key data. However because the EVP_KEYMGMT instance was not
cached then instance will be different every time and we were not
recognising that we had already exported the key to the provider.

This causes us to re-export the key to the same provider everytime the key
is used. Since this consumes memory we end up with unbounded memory growth.

The fix is to be more intelligent about recognising that we have already
exported key data to a given provider even if the EVP_KEYMGMT instance is
different.

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

6 weeks agoTry to fix intermittent CI failures in quic_multistream test
Bernd Edlinger [Sun, 10 Mar 2024 12:15:55 +0000 (13:15 +0100)] 
Try to fix intermittent CI failures in quic_multistream test

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

6 weeks agoplug potential memory leak in error code path
Alexandr Nedvedicky [Thu, 14 Mar 2024 08:53:56 +0000 (09:53 +0100)] 
plug potential memory leak in error code path

Function `module_add()` may leak stack of modules when
it fails to initialize newly added module.

Fixes #23835

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

6 weeks agoRaise the AFL_MAP_SIZE to accommodate future growth
Tomas Mraz [Fri, 15 Mar 2024 10:28:42 +0000 (11:28 +0100)] 
Raise the AFL_MAP_SIZE to accommodate future growth

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

6 weeks ago82-test_ocsp_cert_chain.t: Just ignore unrecognized lines in server output
Tomas Mraz [Fri, 15 Mar 2024 10:27:41 +0000 (11:27 +0100)] 
82-test_ocsp_cert_chain.t: Just ignore unrecognized lines in server output

There might be warnings from AFL fuzz checker
or other warnings that we do not care about.

For success it is just required that cert_status: ocsp response sent:
is present.

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