]> git.ipfire.org Git - thirdparty/openssl.git/log
thirdparty/openssl.git
2 years agocrypto/initthread.c: fix misspelled OSSL_provider_init() in comment
Matthias St. Pierre [Fri, 22 Sep 2023 15:43:19 +0000 (17:43 +0200)] 
crypto/initthread.c: fix misspelled OSSL_provider_init() in comment

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22450)

2 years agossl_lib: added pointer SSL_CONNECTION check to NULL before dereferencing it in ossl_c...
atishkov [Tue, 24 Oct 2023 11:59:00 +0000 (14:59 +0300)] 
ssl_lib: added pointer SSL_CONNECTION check to NULL before dereferencing it in ossl_ctrl_internal()

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

2 years agossl_lib: added pointer SSL and SSL_CONNECTION check to NULL before dereferencing...
atishkov [Tue, 24 Oct 2023 10:25:13 +0000 (13:25 +0300)] 
ssl_lib: added pointer SSL and SSL_CONNECTION check to NULL before dereferencing it in ossl_ctrl_internal()

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

2 years agossl_lib: added pointer SSL and SSL_CONNECTION check to NULL before dereferencing...
atishkov [Tue, 24 Oct 2023 09:30:22 +0000 (12:30 +0300)] 
ssl_lib: added pointer SSL and SSL_CONNECTION check to NULL before dereferencing it in ossl_ctrl_internal()

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

2 years agossl_lib: added pointer SSL_CONNECTION check to NULL before dereferencing it in ossl_c...
atishkov [Mon, 23 Oct 2023 10:50:44 +0000 (13:50 +0300)] 
ssl_lib: added pointer SSL_CONNECTION check to NULL before dereferencing it in ossl_ctrl_internal()

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

2 years agoFix potential NULL deref in ssl_old_test.c
Todd Short [Fri, 13 Oct 2023 14:18:52 +0000 (10:18 -0400)] 
Fix potential NULL deref in ssl_old_test.c

Fix #22367

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

2 years agoaes-gcm-avx512.pl: fix non-reproducibility issue
trigpolynom [Wed, 18 Oct 2023 02:44:45 +0000 (22:44 -0400)] 
aes-gcm-avx512.pl: fix non-reproducibility issue

Replace the random suffix with a counter, to make the
build reproducible.

Fixes #20954

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22415)

2 years agobn: Properly error out if aliasing return value with modulus
Tomas Mraz [Wed, 18 Oct 2023 13:50:30 +0000 (15:50 +0200)] 
bn: Properly error out if aliasing return value with modulus

Test case amended from code initially written by Bernd Edlinger.

Fixes #21110

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22421)

2 years agodoc: change "certifictes" to "certificates"
James Muir [Fri, 20 Oct 2023 04:40:29 +0000 (00:40 -0400)] 
doc: change "certifictes" to "certificates"

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22446)

2 years agoLink libatomic on riscv32
Khem Raj [Sat, 21 Oct 2023 20:03:52 +0000 (13:03 -0700)] 
Link libatomic on riscv32

GCC toolchains on linux are not able to build libcrypto without linking
to libatomic as it does not have all needed atomics implemented as
intrinsics

Fixes errors like

| ld: ./libcrypto.so: undefined reference to `__atomic_is_lock_free'

CLA: trivial
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22460)

2 years agoreturn 0 if an error occurred
Alexey Fofanov [Wed, 25 Oct 2023 11:29:06 +0000 (14:29 +0300)] 
return 0 if an error occurred

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

(cherry picked from commit f0d88b4d070426493749cfd6b657e42dc3c2f5dd)

2 years agoPreemptively reflect the changes in #22480
Hugo Landau [Tue, 24 Oct 2023 07:49:49 +0000 (08:49 +0100)] 
Preemptively reflect the changes in #22480

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

2 years agoBIO: Document BIO_sendmmsg and BIO_recvmmsg callbacks
Hugo Landau [Tue, 24 Oct 2023 07:43:49 +0000 (08:43 +0100)] 
BIO: Document BIO_sendmmsg and BIO_recvmmsg callbacks

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

2 years agoBlake2b: Use OSSL_DIGEST_PARAM_SIZE as settable instead of XOFLEN
Tomas Mraz [Tue, 24 Oct 2023 11:44:26 +0000 (13:44 +0200)] 
Blake2b: Use OSSL_DIGEST_PARAM_SIZE as settable instead of XOFLEN

BLAKE2 is not really an extensible output function unlike SHAKE
as the digest size must be set during the context initialization.
Thus it makes no sense to use OSSL_DIGEST_PARAM_XOFLEN.

We also need to adjust EVP_DigestFinal_ex() to query the
OSSL_DIGEST_PARAM_SIZE as gettable ctx param for the size.

Fixes #22488

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22491)

2 years agoQUIC CHANNEL: Handle ping deadlines differently
Hugo Landau [Tue, 24 Oct 2023 06:59:36 +0000 (07:59 +0100)] 
QUIC CHANNEL: Handle ping deadlines differently

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

2 years agoQUIC CHANNEL: Tweak crypto buffer sizes
Hugo Landau [Mon, 23 Oct 2023 14:44:26 +0000 (15:44 +0100)] 
QUIC CHANNEL: Tweak crypto buffer sizes

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

2 years agoQUIC CHANNEL: Correct timeout calculation for ACKs
Hugo Landau [Mon, 23 Oct 2023 14:38:16 +0000 (15:38 +0100)] 
QUIC CHANNEL: Correct timeout calculation for ACKs

ACKs are not restricted by CC so do not consider CC when determining
when we will emit an ACK.

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

2 years agoQUIC TLS: Ensure QUIC_TLS is ticked between each processed RX packet
Hugo Landau [Fri, 20 Oct 2023 15:52:40 +0000 (16:52 +0100)] 
QUIC TLS: Ensure QUIC_TLS is ticked between each processed RX packet

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

2 years agoQUIC: Test connection with large client and server cert chains
Tomas Mraz [Thu, 5 Oct 2023 17:48:15 +0000 (19:48 +0200)] 
QUIC: Test connection with large client and server cert chains

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

2 years agofuzz-checker.yml: Revert inadvertent change from fac61ea
Tomas Mraz [Wed, 25 Oct 2023 09:01:58 +0000 (11:01 +0200)] 
fuzz-checker.yml: Revert inadvertent change from fac61ea

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

2 years agoAvoid using gets as an argument name in a prototype
Tomas Mraz [Mon, 9 Oct 2023 08:32:44 +0000 (10:32 +0200)] 
Avoid using gets as an argument name in a prototype

This otherwise breaks compilation of applications using ssl.h on MingW.

Fixes #22296

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22316)

2 years agoquic: documentation and demo nits
James Muir [Tue, 24 Oct 2023 01:00:41 +0000 (21:00 -0400)] 
quic: documentation and demo nits

The code for the quic demos (from the openssl guide) is presented as
modifications of tls-client-block.c.  Make it so that the quic code
better matches the tls code (drop unneeded assignments to "ret", use
the same comment on SSL_connect(), add the same printf() statement).

Also fix some minor typos.

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

2 years agoQUIC MULTISTREAM TEST: Output connection closure reason info on failure
Hugo Landau [Tue, 24 Oct 2023 07:23:39 +0000 (08:23 +0100)] 
QUIC MULTISTREAM TEST: Output connection closure reason info on failure

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

2 years agoQUIC APL: Add support for querying frame type causing closure
Hugo Landau [Tue, 24 Oct 2023 07:15:18 +0000 (08:15 +0100)] 
QUIC APL: Add support for querying frame type causing closure

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

2 years agoDon't wait in select if we have data to write
Matt Caswell [Mon, 23 Oct 2023 17:11:06 +0000 (18:11 +0100)] 
Don't wait in select if we have data to write

In s_client, when using quic, if we have data from the user to write then we shouldn't
hang in "select" waiting for something to happen.

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

2 years agoMake s_client -quic -debug work
Matt Caswell [Fri, 13 Oct 2023 11:19:40 +0000 (12:19 +0100)] 
Make s_client -quic -debug work

The callback that makes -debug print the data sent/received needed extending
for the new QUIC callback codes.

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

2 years agoquic_multistream_test: Output info about connection close reason
Tomas Mraz [Mon, 23 Oct 2023 14:05:27 +0000 (16:05 +0200)] 
quic_multistream_test: Output info about connection close reason

In case the connection close error code is unexpected
print out the reason to help with diagnostics.

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

2 years agosslapitest: add cast to avoid compiler error
Pauli [Wed, 25 Oct 2023 07:30:39 +0000 (18:30 +1100)] 
sslapitest: add cast to avoid compiler error

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

2 years agoquic_tserver_test: Raise the initial timeout limit
Tomas Mraz [Mon, 23 Oct 2023 14:16:50 +0000 (16:16 +0200)] 
quic_tserver_test: Raise the initial timeout limit

There were intermitten failures on the test occasionally and
1s initial limit might be too short.

Fixes #22424

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22475)

2 years agorsa: Add SP800-56Br2 6.4.1.2.1 (3.c) check
Clemens Lang [Mon, 16 Oct 2023 13:30:26 +0000 (15:30 +0200)] 
rsa: Add SP800-56Br2 6.4.1.2.1 (3.c) check

The code did not yet check that the length of the RSA key is positive
and even.

Signed-off-by: Clemens Lang <cllang@redhat.com>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/22403)

2 years agospeed: Correct handling of async_jobs for KEM and signature algos
Ingo Franzki [Mon, 16 Oct 2023 12:07:05 +0000 (14:07 +0200)] 
speed: Correct handling of async_jobs for KEM and signature algos

Setup the loopargs array for all jobs, not only for the very first one.

It may fail with "Could not allocate 0 bytes for sig sign loop" and/or will
cause the loop functions to fail silently, because they operate on a NULL
PKEY context when "-async_jobs <n>" is specified.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/22399)

2 years agospeed: Fix memory leaks
Ingo Franzki [Mon, 16 Oct 2023 12:06:04 +0000 (14:06 +0200)] 
speed: Fix memory leaks

Free the PKEYs created for KEM and signature algorithms.
Free the encrypt/decrypt PKEY contexts for RSA.

Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/22399)

2 years agoCreate hierarchical demo Makefile.
slontis [Mon, 20 Mar 2023 05:08:38 +0000 (15:08 +1000)] 
Create hierarchical demo Makefile.

Adds a Makefile with all, clean, and test targets.
This has only been added for demos that already contain Makefiles.
For problematic tests that require inputs, the test target does nothing.

(Note: Demos should be self contained and not require unknown external
inputs. This PR does not attempt to fix this.)

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

2 years agoAdd a test for retries when sending app data
Matt Caswell [Mon, 23 Oct 2023 11:16:44 +0000 (12:16 +0100)] 
Add a test for retries when sending app data

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

2 years agoMake sure we remember how much data we sent in the event of a retry
Matt Caswell [Mon, 23 Oct 2023 08:54:16 +0000 (09:54 +0100)] 
Make sure we remember how much data we sent in the event of a retry

If a retry occurs we need to reset s->rlayer.wnum so that next time around
we remember how much data we already sent.

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

2 years agoWhen requeueing deferred URXEs retain the order
Matt Caswell [Fri, 20 Oct 2023 11:33:25 +0000 (12:33 +0100)] 
When requeueing deferred URXEs retain the order

If a URXE cannot be processed yet then we add it to the urx_deferred list.
Later, when they can be processed, we requeue them in the urx_pending list.

We must not reverse the order when doing so. We want to process the URXEs
in the order that they were received.

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22452)

2 years agoAdjust mdl configuration
Hugo Landau [Mon, 16 Oct 2023 14:50:30 +0000 (15:50 +0100)] 
Adjust mdl configuration

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

2 years agoAdd QUIC README file
Hugo Landau [Mon, 16 Oct 2023 14:50:25 +0000 (15:50 +0100)] 
Add QUIC README file

2 years agoAdd notes on use of strdup
Nate Karstens [Fri, 20 Oct 2023 16:24:33 +0000 (11:24 -0500)] 
Add notes on use of strdup

Added notes to OPENSSL_INIT_set_config_filename and
OPENSSL_INIT_set_config_appname explaining why strdup
is used instead of OPENSSL_strdup.

CLA: trivial

Co-authored-by: Jean Apolo <jean.apolo@garmin.com>
Signed-off-by: Jean Apolo <jean.apolo@garmin.com>
Signed-off-by: Nate Karstens <nate.karstens@garmin.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21742)

2 years agotest: add unit test for CVE-2023-5363
Pauli [Thu, 5 Oct 2023 23:32:20 +0000 (10:32 +1100)] 
test: add unit test for CVE-2023-5363

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
2 years agochanges and news entries for CVE-2023-5363
Pauli [Thu, 5 Oct 2023 23:43:46 +0000 (10:43 +1100)] 
changes and news entries for CVE-2023-5363

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
2 years agoevp: process key length and iv length early if present
Pauli [Thu, 5 Oct 2023 23:26:23 +0000 (10:26 +1100)] 
evp: process key length and iv length early if present

evp_cipher_init_internal() takes a params array argument and this is processed
late in the initialisation process for some ciphers (AEAD ones).

This means that changing the IV length as a parameter will either truncate the
IV (very bad if SP 800-38d section 8.2.1 is used) or grab extra uninitialised
bytes.

Truncation is very bad if SP 800-38d section 8.2.1 is being used to
contruct a deterministic IV.  This leads to an instant loss of confidentiality.

Grabbing extra bytes isn't so serious, it will most likely result in a bad
decryption.

Problem reported by Tony Battersby of Cybernetics.com but earlier discovered
and raised as issue #19822.

Fixes CVE-2023-5363
Fixes #19822

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
2 years agoFix Coverity 1547856: memset() uses only the lowest byte of c
Tomas Mraz [Thu, 19 Oct 2023 06:37:47 +0000 (08:37 +0200)] 
Fix Coverity 1547856: memset() uses only the lowest byte of c

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

2 years agorand: fix seeding from a weak entropy source
Matthias St. Pierre [Sun, 15 Oct 2023 23:35:48 +0000 (01:35 +0200)] 
rand: fix seeding from a weak entropy source

The 'rand_generate' method is not well suited for being used with
weak entropy sources in the 'get_entropy' callback, because the
caller needs to provide a preallocated buffer without knowing
how much bytes are actually needed to collect the required entropy.

Instead we use the 'rand_get_seed' and 'rand_clear_seed' methods
which were exactly designed for this purpose: it's the callee who
allocates and fills the buffer, and finally cleans it up again.

The 'rand_get_seed' and 'rand_clear_seed' methods are currently
optional for a provided random generator. We could fall back to
using 'rand_generate' if those methods are not implemented.
However, imo it would be better to simply make them an officially
documented requirement for seed sources.

Fixes #22332

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

2 years agorand: improve error message for rand pool overflows
Richard Levitte [Wed, 11 Oct 2023 01:19:23 +0000 (12:19 +1100)] 
rand: improve error message for rand pool overflows

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

2 years agoquic_record, quicapi, and quicfaults tests do not support fuzzing builds
Tomas Mraz [Mon, 23 Oct 2023 12:26:32 +0000 (14:26 +0200)] 
quic_record, quicapi, and quicfaults tests do not support fuzzing builds

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

2 years agorun-checker-daily.yml: If the openssl app is not built do not run it
Tomas Mraz [Thu, 19 Oct 2023 15:19:44 +0000 (17:19 +0200)] 
run-checker-daily.yml: If the openssl app is not built do not run it

Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22443)

2 years agoDon't run the QUIC client fuzzer if QUIC is disabled
Matt Caswell [Thu, 19 Oct 2023 13:54:58 +0000 (14:54 +0100)] 
Don't run the QUIC client fuzzer if QUIC is disabled

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

2 years agoUpdate the corpora files to include the new quic-client subdir
Matt Caswell [Thu, 19 Oct 2023 09:07:53 +0000 (10:07 +0100)] 
Update the corpora files to include the new quic-client subdir

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

2 years agoFurther tweaks to the CI runs for fuzzing
Matt Caswell [Mon, 16 Oct 2023 16:24:56 +0000 (17:24 +0100)] 
Further tweaks to the CI runs for fuzzing

Have a new job just to run the fuzz tests with fuzzing build mode enabled.

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

2 years agoTeach the quic-client fuzzer about time
Matt Caswell [Mon, 16 Oct 2023 12:10:33 +0000 (13:10 +0100)] 
Teach the quic-client fuzzer about time

We allow the fuzzer to influence the time between different packets using
the fake time capability.

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

2 years agoIf an error occurs constructing the quic record layer, free it properly
Matt Caswell [Fri, 13 Oct 2023 15:33:31 +0000 (16:33 +0100)] 
If an error occurs constructing the quic record layer, free it properly

We need to call quic_free() to free the record layer to ensure than any
BIO that was already set is also freed.

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

2 years agoDrop FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION for some builds
Matt Caswell [Fri, 13 Oct 2023 13:23:40 +0000 (14:23 +0100)] 
Drop FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION for some builds

Some builds that weren't doing fuzzing were defining this which makes no
sense and is not appropriate for non-fuzzing builds.

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

2 years agoSome cleanups in the quic-client fuzzer
Matt Caswell [Thu, 12 Oct 2023 15:56:00 +0000 (16:56 +0100)] 
Some cleanups in the quic-client fuzzer

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

2 years agoAdd a test for OSSL_ERR_STATE_save_to_mark()
Matt Caswell [Thu, 12 Oct 2023 15:10:12 +0000 (16:10 +0100)] 
Add a test for OSSL_ERR_STATE_save_to_mark()

Add a test for the recently added function OSSL_ERR_STATE_save_to_mark().
We can just modify the existing test_save_restore() to add this in.

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

2 years agoAdd a HISTORY section in the docs about the new ERR_STATE functions
Matt Caswell [Thu, 12 Oct 2023 14:55:48 +0000 (15:55 +0100)] 
Add a HISTORY section in the docs about the new ERR_STATE functions

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

2 years agoFix a use-after-free in qrx_proces_pkt
Matt Caswell [Thu, 12 Oct 2023 14:42:22 +0000 (15:42 +0100)] 
Fix a use-after-free in qrx_proces_pkt

When calling qrx_relocate_buffer, both the rxe and the pointer to the token
may be changing locations. We have to use a temporary copy of the token
pointer to avoid referencing the old location of the rxe.

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

2 years agoEnsure that the ERR_STATE is left in a consistent state
Matt Caswell [Thu, 12 Oct 2023 11:38:22 +0000 (12:38 +0100)] 
Ensure that the ERR_STATE is left in a consistent state

We shouldn't ever have the case where the data flags indicate that
err_data has been malloc'd, but the err_data field is NULL.

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

2 years agoAdd fuzz test recipe for the quic client fuzzer
Matt Caswell [Wed, 11 Oct 2023 16:35:33 +0000 (17:35 +0100)] 
Add fuzz test recipe for the quic client fuzzer

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

2 years agoUpdate the fuzz README to provide info about the stdc++ requirements
Matt Caswell [Wed, 11 Oct 2023 16:35:10 +0000 (17:35 +0100)] 
Update the fuzz README to provide info about the stdc++ requirements

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

2 years agoIgnore a bad signature in a CertificateVerify message while fuzzing
Matt Caswell [Wed, 11 Oct 2023 09:46:46 +0000 (10:46 +0100)] 
Ignore a bad signature in a CertificateVerify message while fuzzing

We ignore such a bad signature when fuzzing - it will never be correct.

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

2 years agoDon't fail on a bad dcid in the tranport params when fuzzing
Matt Caswell [Wed, 11 Oct 2023 09:45:14 +0000 (10:45 +0100)] 
Don't fail on a bad dcid in the tranport params when fuzzing

We accept a bad original destination connection id in the transport params
while we are fuzzing since this may change every time.

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

2 years agoUpdates to the quic client fuzzer
Matt Caswell [Wed, 11 Oct 2023 09:43:58 +0000 (10:43 +0100)] 
Updates to the quic client fuzzer

Handle retryable errors from SSL_read(). Also ensure the underlying BIO
handles the destination address capability.

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

2 years agoDon't encrypt/decrypt packet data during fuzzing
Matt Caswell [Fri, 6 Oct 2023 16:32:14 +0000 (17:32 +0100)] 
Don't encrypt/decrypt packet data during fuzzing

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

2 years agoAdd quic client fuzzer.
Kurt Roeckx [Wed, 23 Nov 2022 13:24:13 +0000 (14:24 +0100)] 
Add quic client fuzzer.

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

2 years agoReference the non-"legacy" provider names directly from EVP_md5(3) &c.
наб [Wed, 18 Oct 2023 13:35:55 +0000 (15:35 +0200)] 
Reference the non-"legacy" provider names directly from EVP_md5(3) &c.

Earlier today, it took me five manuals! to find what on earth the
"Performance"/"EVP_MD_fetch(3)" crosslinks actually mean:
  EVP_sha1(3)
  crypto(7)
  EVP_MD_fetch(3) (but not there! don't read that!)
  OSSL_PROVIDER-default(7)
  EVP_MD-SHA1(7)

If, instead, EVP_sha1(3) referenced EVP_MD-SHA1(7) at /all/,
which it should do, since it's supposed to be what you're replacing it
with, but it doesn't actually say that, maybe people would use it.
I know I didn't because it's basically just deadass buried

As found by git grep -l 'and should consider using'

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

2 years agoAdd a test for converting OSSL_TIME to struct timeval
Matt Caswell [Thu, 19 Oct 2023 10:37:28 +0000 (11:37 +0100)] 
Add a test for converting OSSL_TIME to struct timeval

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

2 years agoRound up nano secs when converting OSSL_TIME to struct timeval
Matt Caswell [Thu, 19 Oct 2023 10:00:39 +0000 (11:00 +0100)] 
Round up nano secs when converting OSSL_TIME to struct timeval

struct timeval doesn't support nanosecs but OSSL_TIME does. We round up
any nanosecs to ensure that a non-zero input always results in a non-zero
output.

This fixes a quic-client fuzzer hang.

Fixes #22437

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

2 years agoQUIC: Test handling of post-connection session tickets
Hugo Landau [Thu, 19 Oct 2023 10:58:26 +0000 (11:58 +0100)] 
QUIC: Test handling of post-connection session tickets

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

2 years agoQUIC: Prevent incoming oversize tokens
Hugo Landau [Thu, 19 Oct 2023 08:27:11 +0000 (09:27 +0100)] 
QUIC: Prevent incoming oversize tokens

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

2 years agoConvert jdkTrustedKeyUsage to be a pkcs12 cmd line option
Neil Horman [Wed, 18 Oct 2023 14:01:21 +0000 (10:01 -0400)] 
Convert jdkTrustedKeyUsage to be a pkcs12 cmd line option

Creating JDK compatible pkcs12 files requires a bit more than just
adding the Trusted Key Usage OID to a certbag in the pkcs12 file.
Additionally the JDK currently requires that pkcs12 files setting this
oid _not_ contain any additional keys, and in response will produce
unpredictable results.

This could be solved by implying --nokeys when the pkcs12 utility is run
and the config option is set, but thatcould confuse users who didn't
specify nokeys on the command line.  As such, remove the config file
setting for this feature, and replace it with a -jdktrust command line
option, that is documented to assert nokeys when a users specifies the
new command line option.

Fixes #22215

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

2 years agoQUIC: Add handling of SSL_get_shutdown()
Tomas Mraz [Tue, 17 Oct 2023 08:00:58 +0000 (10:00 +0200)] 
QUIC: Add handling of SSL_get_shutdown()

Return SSL_SENT_SHUTDOWN and SSL_RECEIVED_SHUTDOWN with semantics
similar to TLS connections.

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

2 years agoPostpone two TODO(QUIC) items appropriately
Tomas Mraz [Tue, 17 Oct 2023 06:58:22 +0000 (08:58 +0200)] 
Postpone two TODO(QUIC) items appropriately

The one in ch_rx_handle_packet() is a tuning thing -> QUIC FUTURE
The one in ossl_quic_tserver_shutdown() is a server thing -> QUIC SERVER

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

2 years agorand: add callbacks to cleanup the user entropy resp. nonce
Matthias St. Pierre [Mon, 16 Oct 2023 21:48:03 +0000 (23:48 +0200)] 
rand: add callbacks to cleanup the user entropy resp. nonce

The `get_user_{entropy,nonce}` callbacks were add recently to the
dispatch table in commit 4cde7585ce8e. Instead of adding corresponding
`cleanup_user_{entropy,nonce}` callbacks, the `cleanup_{entropy,nonce}`
callbacks were reused. This can cause a problem in the case where the
seed source is replaced by a provider: the buffer gets allocated by
the provider but cleared by the core.

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

2 years agoIgnore ping deadline when calculating tick deadline if we can't send
Matt Caswell [Tue, 17 Oct 2023 13:55:48 +0000 (14:55 +0100)] 
Ignore ping deadline when calculating tick deadline if we can't send

If the CC TX allowance is zero then we cannot send a PING frame at the
moment, so do not take into account the ping deadline when calculating the
tick deadline in that case.

This avoids the hang found by the fuzzer mentioned in
https://github.com/openssl/openssl/pull/22368#issuecomment-1765131727

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

2 years agoIgnore retry packets that arrive too late
Matt Caswell [Tue, 17 Oct 2023 15:26:13 +0000 (16:26 +0100)] 
Ignore retry packets that arrive too late

RFC 9000 s 17.2.5.2 says

> After the client has received and processed an Initial or Retry packet
> from the server, it MUST discard any subsequent Retry packets that it
> receives.

We were checking for multiple Retry packets, but not if we had already
processed an Initial packet.

Fixes the assertion failure noted in
https://github.com/openssl/openssl/pull/22368#issuecomment-1765618884

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

2 years agocms_enc.c: Include crypto/asn1.h for struct asn1_object_st
Tomas Mraz [Thu, 19 Oct 2023 07:23:43 +0000 (09:23 +0200)] 
cms_enc.c: Include crypto/asn1.h for struct asn1_object_st

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

2 years agoDo not include crypto/asn1.h from internal/cryptlib.h
Tomas Mraz [Thu, 19 Oct 2023 07:18:37 +0000 (09:18 +0200)] 
Do not include crypto/asn1.h from internal/cryptlib.h

This is unnecessary and conceptualy wrong as
headers from internal should not include headers from crypto

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

2 years agoapps.c: Remove a redundant error print-out
Tomas Mraz [Mon, 9 Oct 2023 09:39:12 +0000 (11:39 +0200)] 
apps.c: Remove a redundant error print-out

Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22318)

2 years agoapps: Print out a proper message when a store cannot be opened
Tomas Mraz [Mon, 9 Oct 2023 09:36:50 +0000 (11:36 +0200)] 
apps: Print out a proper message when a store cannot be opened

Fixes #22306

Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22318)

2 years agoFix markdown
Hugo Landau [Mon, 16 Oct 2023 14:02:10 +0000 (15:02 +0100)] 
Fix markdown

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

2 years agoAdd SNI
Hugo Landau [Mon, 16 Oct 2023 13:58:36 +0000 (14:58 +0100)] 
Add SNI

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

2 years agoRename
Hugo Landau [Mon, 16 Oct 2023 12:33:11 +0000 (13:33 +0100)] 
Rename

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

2 years agoAdd link to nghttp3
Hugo Landau [Mon, 16 Oct 2023 12:33:11 +0000 (13:33 +0100)] 
Add link to nghttp3

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

2 years agoAdd copyright headers
Hugo Landau [Mon, 16 Oct 2023 12:33:11 +0000 (13:33 +0100)] 
Add copyright headers

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

2 years agoQUIC: Add comments to HTTP/3 demo
Hugo Landau [Mon, 16 Oct 2023 12:33:11 +0000 (13:33 +0100)] 
QUIC: Add comments to HTTP/3 demo

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

2 years agoQUIC: Add HTTP/3 demo using nghttp3
Hugo Landau [Mon, 16 Oct 2023 12:33:11 +0000 (13:33 +0100)] 
QUIC: Add HTTP/3 demo using nghttp3

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

2 years agoAdd a test to confirm that legacy rsa keys work
Neil Horman [Wed, 11 Oct 2023 16:45:44 +0000 (12:45 -0400)] 
Add a test to confirm that legacy rsa keys work

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

2 years agoDont require CRT params on ossl_rsa_set0_all_params
Neil Horman [Tue, 10 Oct 2023 15:06:44 +0000 (11:06 -0400)] 
Dont require CRT params on ossl_rsa_set0_all_params

Its not required that crt params be available in an RSA key, so don't
perform an error check on them

Fixes #29135

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

2 years agoremove sanity check from ossl_rsa_todata
Neil Horman [Tue, 5 Sep 2023 16:08:19 +0000 (12:08 -0400)] 
remove sanity check from ossl_rsa_todata

Theres no reason we should gate ossl_rsa_todata on there being a minimum
set of parameters. EVP_PKEY_todata makes no guarantees about the
validity of a key, it only returns the parameters that are set in the
requested key, whatever they may be.  Remove the check.

Fixes #21935

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

2 years agoossl_param_build_set_multi_key_bn(): Do not set NULL BIGNUMs
Tomas Mraz [Mon, 4 Sep 2023 09:10:42 +0000 (11:10 +0200)] 
ossl_param_build_set_multi_key_bn(): Do not set NULL BIGNUMs

This makes them zeroes otherwise
where NULLs actually mean the values aren't present.

Fixes #21935

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

2 years agoensure that ossl_obj_nid_lock is allocated before use
Neil Horman [Wed, 11 Oct 2023 13:34:02 +0000 (09:34 -0400)] 
ensure that ossl_obj_nid_lock is allocated before use

external calls to OBJ_new_nid will fail on an attempt to lock the
ossl_obj_nid_lock as it won't have been initalized yet.

Bifurcate OBJ_new_nid into an external and internal variant, in which
the former calls ossl_obj_write_lock (ensuring that the nid_lock is
initalized), while OBJ_create (the sole internal caller) uses the latter
to avoid having to drop and re-acquire the lock

Fixes #22337

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

2 years agocms encrypt, better OBJ_nid2obj() return check
James Muir [Sat, 14 Oct 2023 23:36:57 +0000 (19:36 -0400)] 
cms encrypt, better OBJ_nid2obj() return check

Fixes #22225

In OBJ_nid2obj(), if the NID does not have an OID, then a pointer to
the special "undefined" ASN1_OBJECT is returned.  Check for the
undefined-ASN1_OBJECT and return an error.  Also, add a test for this
in 80-test_cms.t.

Testing:

  #!/bin/bash -x

  shopt -s expand_aliases

  alias openssl="LD_LIBRARY_PATH=~/git/openssl ~/git/openssl/apps/openssl"

  echo "This is a confidential message.  It should be encrypted." > msg.txt

  ## this should fail b/c there is no OID for aes-256-ctr
  openssl cms -encrypt -in msg.txt -aes-256-ctr -out msg.txt.cms -recip demos/cms/signer.pem
  echo $?

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

2 years agofix: LINEAR search doesn't work properly (if CHARSET_EBCDIC is defined)
Pavel Stetsuk [Thu, 14 Sep 2023 20:05:49 +0000 (23:05 +0300)] 
fix: LINEAR search doesn't work properly (if CHARSET_EBCDIC is defined)

CLA: trivial

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

2 years agorsa: Accept NULL OAEP label for backward compatibility
Daiki Ueno [Mon, 16 Oct 2023 05:42:12 +0000 (14:42 +0900)] 
rsa: Accept NULL OAEP label for backward compatibility

According to the manual page, EVP_PKEY_CTX_set0_rsa_oaep_label()
should accept NULL as the label argument, though the function
currently rejects it while setting the corresponding octet string
parameter with OSSL_PARAM_construct_octet_string, which expects
non-NULL input.  This adds a workaround to the caller for backward
compatibility.

Signed-off-by: Daiki Ueno <dueno@redhat.com>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22397)

2 years agoEVP shake_ctrl(): add missing NULL evp_ctx check
Dr. David von Oheimb [Fri, 13 Oct 2023 20:27:31 +0000 (22:27 +0200)] 
EVP shake_ctrl(): add missing NULL evp_ctx check

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

2 years agoCMS_add1_signer(): add missing ERR_raise() calls
Dr. David von Oheimb [Fri, 13 Oct 2023 20:12:22 +0000 (22:12 +0200)] 
CMS_add1_signer(): add missing ERR_raise() calls

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

2 years agoCMS_add1_signer.pod: add missing info on CMS_SignerInfo_sign() return values
Dr. David von Oheimb [Fri, 13 Oct 2023 20:39:25 +0000 (22:39 +0200)] 
CMS_add1_signer.pod: add missing info on CMS_SignerInfo_sign() return values

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

2 years agoPKCS7_SIGNER_INFO: point out confusing names of digest_enc_alg and enc_digest fields
Dr. David von Oheimb [Fri, 13 Oct 2023 20:30:31 +0000 (22:30 +0200)] 
PKCS7_SIGNER_INFO: point out confusing names of digest_enc_alg and enc_digest fields

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

2 years agoAvoid another copy of key schedule pointer in PROV_GCM_CTX
Tomas Mraz [Fri, 13 Oct 2023 14:22:59 +0000 (16:22 +0200)] 
Avoid another copy of key schedule pointer in PROV_GCM_CTX

This copy would need an update on dupctx but
rather than doing it just remove the copy.

This fixes failures of evp_test on Windows with
new CPUs.

Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22384)