Commit graph

36976 commits

Author SHA1 Message Date
Neil Horman
1636ae1a90 Free hashtable prior to freeing atomic worker_lock
lhash_test uses a hashtable that may not be empty at the end of the test

Given that the free function frees the elements in the list and uses the
atomic worker_lock to do so, we need to free the hash table prior to
freeing the working lock to avoid the use of unallocated memory.

Fixes #26798

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26800)
2025-02-18 16:40:24 +01:00
Frederik Wedel-Heinen
00fbc96988 Adds missing checks of return from XXX_up_ref().
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26294)
2025-02-18 16:32:59 +01:00
Tomas Mraz
e9aac2c2f3 Do not call BIO_printf() from FIPS_MODULE
Fixes #26743

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26744)
2025-02-18 16:31:45 +01:00
Dr. David von Oheimb
5cba362909 OSSL_CMP_MSG_http_perform(): support using BIO from OSSL_CMP_CTX_set_transfer_cb_arg()
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26628)
2025-02-18 12:19:26 +01:00
Neil Horman
75bc132dec Initial slh-dsa fuzzer
Current preforms the following operations

1) Generates arbitrary key pairs
2) Generates key pairs with parameters (both correct and incorrect)
   based on fuzzer input buffer
3) Exports and re-imports keys, confirming validity
4) Preforms Sign and Verify operations with optional parameters based on
   fuzzer input buffer

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26708)
2025-02-18 10:24:02 +01:00
slontis
0e43652489 SLH-DSA: Add EVP_PKEY_CTX_dup() support.
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/26701)
2025-02-18 10:17:29 +01:00
slontis
3fcefd51a1 SLH_DSA: Make apps.c do_X509_REQ_verify() call work correctly.
- Added sigid_algs for SLH_DSA such that OBJ_find_sigid_algs() works.
- OBJ_sn2nid() was also being called, so the SN form of SLH_DSA
  algorithms needed to be added to the provider dispatch tables.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26625)
2025-02-18 10:17:29 +01:00
slontis
7389cca079 SLH_DSA: Add support for generating X509 certs via the openssl
command line app.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26625)
2025-02-18 10:17:29 +01:00
slontis
67d52a555e SLH-DSA cleanups
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25882)
2025-02-18 10:17:29 +01:00
slontis
0f0a836abd SLH-DSA More fixups
Also added slh_dsa_key_dup()

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25882)
2025-02-18 10:17:29 +01:00
slontis
8f86a75fcf SLH-DSA: Remove legacy ASN1 method tables for SLH-DSA. Update to use
custom encoders for SLH_DSA decode_der2key.

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25882)
2025-02-18 10:17:29 +01:00
slontis
79e7c83711 SLH-DSA cleanups
Addressed some review comments.
- Ref counting has been removed from SLH_DSA_KEY (EVP_PKEY is responsible
for the keys ref counting).
- Moved constants and prefetched objects into SLH_DSA_KEY.
- The SLH_DSA_HASH_CTX is still required since there are multiple
  contexts that need to propagate to a lot of functions, but it no
  longer contains the constants. Note that it also holds a pointer to
  the SLH_DSA_KEY.

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25882)
2025-02-18 10:17:29 +01:00
slontis
eba0e11c39 Add SLH_DSA key validation.
The pairwise test requires that the computed PK_ROOT key matches the
keys PK_ROOT value. The public and private key tests just require the
key elements to exist.

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25882)
2025-02-18 10:17:29 +01:00
slontis
b8b67b1907 Add SLH-DSA FIPS self tests
This requires a keygen test, as well as Sign/Verify tests for at least 1
sha2 algorithm and 1 shake related algorithm.

A pairwise consistency test has also been added to the key generation.

Note that self test datat for the signature is currently stored as a
sha256 digest in order to reduce the memory footprint.
(Since the signature size for sha2/shake using 128s = ~8K, and for 128f = ~17K)

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25882)
2025-02-18 10:17:29 +01:00
slontis
a25bcde26a Add SLH-DSA encoder/decoder support.
This required adding additional EVP_PKEY_ASN1_METHOD methods.

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25882)
2025-02-18 10:17:29 +01:00
slontis
db5846a7e0 Address style check nits for SLH-DSA
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25882)
2025-02-18 10:17:29 +01:00
slontis
148f4d23e1 Update SLH-DSA code to use PACKET and WPACKET.
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25882)
2025-02-18 10:17:29 +01:00
slontis
ed77201a26 Update SLH-DSAto use EVP_PKEY_sign_message_init() instead of using the
prehashed variant.

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25882)
2025-02-18 10:17:29 +01:00
slontis
acdd2c8bff Add SLH-DSA design document
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25882)
2025-02-18 10:17:26 +01:00
slontis
6de411963f Add SLH-DSA documentation
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25882)
2025-02-18 10:16:04 +01:00
slontis
5c2b404241 SLH-DSA clean ups
- Make slh_dsa_sign() return the siglen when sig is NULL.
- Remove the ability in fromdata to generate the public key root
  given the private key and public key seed. This was messy and can
  be done by key generation instead.
- Add common EVP_PKEY gettablesto SLH_DSA keys
  (OSSL_PKEY_PARAM_BITS, OSSL_PKEY_PARAM_SECURITY_BITS, and
   OSSL_PKEY_PARAM_MAX_SIZE).
- Update tests based on the above changes.

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25882)
2025-02-18 10:13:53 +01:00
slontis
ce3acbd07e Zeorize some secret values in SLH_DSA
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25882)
2025-02-18 10:13:53 +01:00
slontis
30a55b0cf1 Added return code checks to SLH_DSA Hash functions and propogated the
values thru the calling functions.

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25882)
2025-02-18 10:13:53 +01:00
slontis
5901ca87ba Add SLH_DSA to the FIPS provider.
The keygen tests required "entropy" to be added via an additional
parameter for ACVP testing. This is required because TEST_RAND cant be
used to pass entropy to the FIPS provider, due to it not knowing the
lib ctx of the FIPS provider.

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25882)
2025-02-18 10:13:53 +01:00
slontis
e8457ce077 Add support for all 12 SLH-DSA parameter sets.
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25882)
2025-02-18 10:13:53 +01:00
slontis
e240d39c6c Add SLH-DSA signing.
Also updated function comments.

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25882)
2025-02-18 10:13:53 +01:00
slontis
8f53b9b59d Add SLH-DSA key generation
Also made fromdata able to generate the public root key if the private
key seed + prf as well as the public key seed are passed to from data.

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25882)
2025-02-18 10:13:53 +01:00
slontis
2f9e152d86 Add SLH_DSA signature verification.
This uses a SLH_DSA_CTX that is passed to most functions.
It contains information related to a parameter set (such as constants,
hash functions, prefetched EVP_MD/EVP_MAC objects, as well as ADDRESS
functions). This context is seperated from the SLH_DSA_KEY since
multiple signature operations could be performed using the same keys.
This only implements functions required for SLH-DSA-SHA2-128s

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25882)
2025-02-18 10:13:53 +01:00
slontis
34f4cacc8f Add base code to load a SLH_DSA public key.
This loads a SLH_DSA public key from data.
A simple SLH_DSA keymanager imports this key.

Initially this only has a parameter set for
SLH-DSA-SHA2-128s

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25882)
2025-02-18 10:13:53 +01:00
slontis
16395ee9cc Add SLH_DSA configuration option
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25882)
2025-02-18 10:13:53 +01:00
Viktor Dukhovni
d5a4665a21 Case-insensitive sigalgs
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/26767)
2025-02-18 14:24:57 +11:00
Pauli
2b7679b16d fips: omit PCT on key import
Our lab thinks the IG 10.3.A additional comment 1 is a mistake and that
a PCT on import is not required.

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26785)
2025-02-18 10:11:42 +11:00
Neil Horman
a903be9cae Fixup error ennumeration
The merge gives us a conflict on SSL_R_MISSING_QUIC_TLS_FUNCTIONS
which conflicted with SSL_R_LISTENER_USE_ONLY.  Move the former to
ordinal 423

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26762)
2025-02-17 11:27:34 -05:00
Neil Horman
b684545e73 Fix ssltrace test
It seems something changed during the merge leading to a slightly longer
frame

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26762)
2025-02-17 11:27:34 -05:00
Neil Horman
8b0fbe224a Add ssl_unwrap.h to quic_tls_api.c
Needed after the macro re-arranging performed on the quic-server branch

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26762)
2025-02-17 11:27:34 -05:00
Neil Horman
b360611ad6 Readd the inclusion of quic_record_util.h to quic_tls.c
Some refactoring on master removed the inclusion of quic_local.h from
ssl_local.h, which quic_tls.c needed on the server branch to pull in the
QRL_SUITE_AES128GCM and simmilar definitions.  Fix it by specifcially
adding quic_record_util.h into quic_tls.c, as we only need a few defines
from that header.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26762)
2025-02-17 11:27:34 -05:00
Neil Horman
473e6bcb2c Fixup conflict between 3rd party quic-tls api and quic-server
Build.info changes between quic-server and master occured here, resolve
them.  Can't do it as a fixup as the conficting changes have already
been merged to master

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26762)
2025-02-17 11:27:34 -05:00
Alexandr Nedvedicky
9eee58cce4 Backout validation of initial packet done by port_default_packet_handler()
QUIC interoperability tests discovered bugs in my earlier commit #59e7c2313b.
This change reverts everything out.

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/26748)
2025-02-17 11:27:34 -05:00
Alexandr Nedvedicky
c82c1dbbbb Perform initial AEAD validation before creating a channel
We let port to create qrx object and use it for
packet validation. If packet validates, we then
create channel and pass pre-created qrx to channel's
constructor.

Co-authored-by: Andrew Dinh <andrewd@openssl.org>

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26610)
2025-02-17 11:27:34 -05:00
Andrew Dinh
029d85869f Add quic-server fuzz test. Also update fuzz corpora submodule.
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26514)
2025-02-17 11:27:34 -05:00
Neil Horman
5177484f19 Fix ossl_quic_trace to fetch connection short conn id len
ossl_quic_trace currently fails to get the connection id when parsing a
short header.  now that we have an api to get the known length, go ahead
and use that to parse the header properly

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26592)
2025-02-17 11:27:34 -05:00
Neil Horman
164d3a6b59 Use the recorded short conn id len in pktsplitbio
Do the same thing in our pktsplit bio

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26592)
2025-02-17 11:27:34 -05:00
Neil Horman
a55b689499 Use reported short conn id len in qtestlib
Use the new short conn id internal api to record and use the connections
short conn id len when decoding packets in qtestlib

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26592)
2025-02-17 11:27:34 -05:00
Neil Horman
5b808e1d80 Add api to fetch short conn id len from a given channel/tserver
Need an api to fetch the configured conn id len for short headers, add
that in here

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26592)
2025-02-17 11:27:34 -05:00
Neil Horman
7d5426c703 Move handling of connection close frames to QUIC FUTURE
There is a corner case in handling connection close frames for which RFC
guidance is unclear.  Given that, move addressing it to QUIC FUTURE

Fixes openssl/project#1075

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26593)
2025-02-17 11:27:34 -05:00
Neil Horman
3f06ebcfe3 Eliminate SSL_LISTENER_FLAG_NO_ACCEPT flag in QUIC
We've not implemented it yet, and don't need it for MVP, so move the
TODO's to QUIC FUTURE and remove the docs for it.

Fixes openssl/project#1074

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26593)
2025-02-17 11:27:34 -05:00
Neil Horman
a6f3110318 Move EAGAIN handling of QUIC retry/verneg frames to QUIC FUTURE
Fixes openssl/project#1072
Fixes openssl/project#1073

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26593)
2025-02-17 11:27:34 -05:00
Neil Horman
a08e9aec1d Move implementation of RETIRE CONN ID frames to QUIC FUTURE
Fixes openssl/project#1071

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26593)
2025-02-17 11:27:34 -05:00
Neil Horman
05ea15261c Move quictestlib TODO to QUIC FUTURE
Improving handling of packets in tserver doesn't currently make sense,
as we're planning on eliminating it soon.  Move this TODO to QUIC FUTURE

Fixes openssl/project#1070

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26593)
2025-02-17 11:27:34 -05:00
Neil Horman
c536754fd0 move token store definition to quic_predef.h
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26517)
2025-02-17 11:27:34 -05:00