Commit Graph

38426 Commits

Author SHA1 Message Date
Simo Sorce 5b761751b6 Disable buggy markdownlint rule MD032
The markdownlint rule MD032, which checks for blank lines surrounding lists,
is disabled because it is buggy and produces false positives. This change
prevents unnecessary build failures caused by incorrect linting.

Signed-off-by: Simo Sorce <simo@redhat.com>

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/29004)
2025-11-26 08:50:25 +11:00
Simo Sorce 7962a7ec98 Clarify and expand FIPS deferred tests design
Add a new "Examples" section to the design document to illustrate the intended
behavior of the self-test mechanism. These examples cover simple tests,
composite algorithms, and the specific semantics of the `also_satisfies` and
`depends_on` lists.

This change also clarifies several key points:
- The `also_satisfies` list is not processed recursively, while `depends_on`
is.
- The entire FIPS module will enter a failure state if any individual self-
test fails.

Finally, the document is updated with various grammatical fixes and improved
wording for better readability.

Signed-off-by: Simo Sorce <simo@redhat.com>

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/29004)
2025-11-26 08:50:25 +11:00
Simo Sorce 35396be7ab Describe FIPS deferred tests implementation
Add a "Current Implementation" section to the FIPS deferred tests design
document.

This section details the mechanism used to execute on-demand self-tests in a
thread-safe manner. It explains the roles of the core functions, the use of a
global lock to serialize test execution, and the thread-local storage strategy
to prevent deadlocks during nested test calls.

Signed-off-by: Simo Sorce <simo@redhat.com>

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/29004)
2025-11-26 08:50:25 +11:00
Simo Sorce 7c61af8ae3 Add design for deferred FIPS self-tests
This commit introduces a design document for a new FIPS self-test execution
model.

The proposed design moves from the current model, where all Known Answer Tests
(KATs) run at provider load time, to a deferred model. In this new approach,
each algorithm's self-test is executed on-demand, the first time that
algorithm is requested for use.

The primary motivation is to reduce the noticeable startup latency caused by
running all FIPS self-tests unconditionally. This change will benefit
applications that only use a small subset of the available cryptographic
algorithms. The document details requirements for on-demand execution, failure
handling, dependency management, and thread safety, while maintaining FIPS
140-3 compliance.

Signed-off-by: Simo Sorce <simo@redhat.com>

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/29004)
2025-11-26 08:50:25 +11:00
Dimitri John Ledkov 71ed0fc8b3 pbkdf2: enable setting minimum password length at build time
This is required for FIPS, allow to customize minimum password length,
allow opting in doing the same for the default provider too.

Set FIPS provider default to minimum length of 8, and default provider
to 0. Controlled by -no_pbkdf2_lower_bound_check and indicated with
fips-approved indicator.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/25621)
2025-11-26 08:48:02 +11:00
Tomas Mraz abcf402a6c Update the ssl trace reference for test_sslapi
Fixes ec114826

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29211)
2025-11-25 09:29:57 +01:00
David von Oheimb ec11482675 Remove extra leading '00:' when printing key material with highest byte >= 0x80
Removed pseudo-DER encoding of (unsigned) BNs from output of ASN1_bn_print() and
print_labeled_bignum() in providers/implementations/encode_decode/encode_key2text.c
Also adapt test output reference files where needed.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8136)
2025-11-25 09:09:33 +01:00
David Benjamin 069181d7f3 doc: Discuss calling X509_verify_cert in cert_verify_callback
Using SSL_CTX_set_cert_verify_callback but still calling
X509_verify_cert is useful if applications want to dynamically
configure the X509_STORE_CTX, or postprocess the result, in a way that
does not quite fit the somewhat unpredictable behavior of the
SSL_CTX_set_verify callback. (In my experience, applications rarely
realize it is called multiple times. It's also too late at that point to
reconfigure the X509_STORE_CTX as verification has already started.)

There is one note in the docs that the callback needs to stash the
verify result with X509_STORE_CTX_set_error, but it is not immediately
obvious that X509_verify_cert will do so, or that it is the built-in
behavior. Add a paragraph discussing this.

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28960)
2025-11-24 19:22:20 +01:00
Bob Beck aa0be384d8 Removed ASN1_STRING_data()
This has been deprecated since 1.1.0 and is in the way for
improvements that could make ASN1_STRING opaque. (#29177)

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29149)
2025-11-24 19:18:18 +01:00
Joshua Rogers 7f015c909e asn1: clear error mark on success in asn1_d2i_read_bio
Balance ERR_set_mark by calling ERR_clear_last_mark on the success path.
Prevents a stale mark from skewing later error handling.

Signed-off-by: Joshua Rogers <MegaManSec@users.noreply.github.com>

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28882)
2025-11-24 19:10:25 +01:00
bleeqer d3463971bc CRYPTO_secure_used(), CRYPTO_secure_actual_size(): Check for NULL rwlock
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28749)
2025-11-24 19:08:06 +01:00
Joshua Rogers 1c4f7b1035 crypto/bio/bss_acpt: reset accept_sock and b->num after close in ACPT_S_LISTEN failures
On BIO_listen or BIO_sock_info failure we close the socket but leave
accept_sock and b->num pointing at the old fd. Later cleanup can double
close.

Set both to INVALID_SOCKET immediately after BIO_closesocket.

Signed-off-by: Joshua Rogers <MegaManSec@users.noreply.github.com>

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28904)
2025-11-24 09:03:43 -05:00
Viktor Dukhovni fb43a0ac5a Expand and clarify SSL_CTX_config(3) docs.
- Document significant limitations in CONF_module_load_file() in OpenSSL 3.x

- Given the limitations, deëmphasise the use of CONF_module_load_file()
  in SSL_CTX_config(3) documentation, showing an example with the default
  config file instead.

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28650)
2025-11-21 15:13:09 +01:00
Viktor Dukhovni 98e8800e70 Editorial: future proofing -> future-proofing
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28650)
2025-11-21 15:13:02 +01:00
Igor Ustinov 2a7b058429 Correct information about the default value of the -md parameter
of the openssl cms command.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29175)
2025-11-21 08:45:50 -05:00
Eugene Syromiatnikov 768468f40e doc/man3/OPENSSL_malloc.pod: mention rationale for OPENSSL_cleanse()
It was not entirely clear from the sole description, what is  the reason
for preferring OPENSSL_cleanse() over memset().  Add a note about situations
in which OPENSSL_cleanse() should be chosen.

Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29174)
2025-11-21 14:36:24 +01:00
Shohei YOSHIDA 978cb1f9d1 DOC: fix description of '-self_test_oninstall'
CLA: trivial

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29168)
2025-11-21 14:32:37 +01:00
Neil Horman 3d7f4eb35b Add test for recordpadding
Just run the quicapitest (which attempts to create quic connections)
while using a config that specifies recordpadding, which quic should
ignore

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28992)
2025-11-21 14:28:32 +01:00
Neil Horman 4d33baf565 Ignore RecordPadding option in config file for QUIC objects
QUIC connections always pad data at the packet level during packet
encryption, and so have no ability to do padding at the record level.

We want to be able to inform the user of this condition when
applications call SSL_set_block_padding_ex directly by returning an
error, we have no idea of what kind of SSL objects are created when the
config file is written.

As such, silently ignore this config file option when QUIC objects are created.

Fixes #28953

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28992)
2025-11-21 14:28:15 +01:00
Neil Horman 771814bee7 Add SSL_CTX_is_quic API
Like SSL_is_quic, it would be helpful to know if SSL_CTX objects create
QUIC SSL's or not.

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28992)
2025-11-21 14:28:15 +01:00
Teshan Kannangara e7251fa1a9 rand_lib.c: Use ERR_LIB_RAND with RAND_R errors
Use ERR_LIB_RAND when reporting RAND_R_ALREADY_INSTANTIATED from
RAND_set_DRBG_type() and RAND_set_seed_source_type() so the error
message references the RAND subsystem instead of CRYPTO.

Fixes #29039

CLA: trivial

Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29109)
2025-11-21 14:15:07 +01:00
Daniel Kubec 3f0fb59095 CHANGES.md: CRL Certificate Issuer and IDP extensions
Updated CHANGES.md for commit e2990825a2

Co-authored-by: Viktor Dukhovni <viktor1ghub@dukhovni.org>

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29136)
2025-11-21 14:13:10 +01:00
zhoulu 7b3810847e sm4-riscv64-zvksed.pl: Code comment corrections
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29134)
2025-11-21 14:10:15 +01:00
Dr. David von Oheimb 399781ef78 OCSP_request_set1_name(): make use of GENERAL_NAME_set1_X509_NAME()
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28031)
2025-11-20 15:09:30 +01:00
Tomas Mraz 00b112c024 cms_sd.c: Code style cleanup and removed redundant check
The `md == NULL` check is redundant as ossl_cms_adjust_md()
never returns success with `md == NULL`.

Fixes Coverity issue 1675014
Fixes #29170

Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/29171)
2025-11-20 15:07:47 +01:00
Samaresh Kumar Singh 6b4ad7f8d8 doc: Add HISTORY entry for message signing functions in provider-signature(7)
The OSSL_FUNC_signature_{sign,verify}_message_* functions were added
in OpenSSL 3.4 but weren't documented in the HISTORY section of
provider-signature(7), while the corresponding EVP_PKEY_sign_message_*
functions are properly documented in EVP_PKEY_sign(3).

This adds the missing HISTORY entry to document when these provider
functions were introduced.

Fixes #29088

CLA: trivial

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/29130)
2025-11-20 10:21:26 +11:00
Joshua Rogers cb95203379 apps/s_time: enable peer verification when -verify is used
s_time loaded CA material but never turned verification on, so
-verify only changed the depth while handshakes skipped verification.

Signed-off-by: Joshua Rogers <MegaManSec@users.noreply.github.com>

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28857)
2025-11-19 18:51:48 +01:00
Lars Erik Wik 8da3d5dd9f bio_ok.c: Fixed undefined identifier 'SIZE_MAX'
This fixes the following compilation error on HP-UX:
```
11:07:19 crypto/evp/bio_ok.c: In function 'block_in':
11:07:19 crypto/evp/bio_ok.c:579: error: 'SIZE_MAX' undeclared (first use in this function)
11:07:19 crypto/evp/bio_ok.c:579: error: (Each undeclared identifier is reported only once
11:07:19 crypto/evp/bio_ok.c:579: error: for each function it appears in.)
```

Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
CLA: trivial

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28793)

(cherry picked from commit 695a5aaf0b)
2025-11-19 16:00:23 +01:00
Anton Moryakov 34d3d2e308 dsaparam.c: Check return value of PEM_write_bio_PrivateKey()
The result of PEM_write_bio_PrivateKey was not checked, which could lead
to silent failure when writing a generated DSA private key to output.

Now verify the return value and report an error if the write fails,
matching the error handling pattern used for other write operations.

Signed-off-by: Anton Moryakov <ant.v.moryakov@gmail.com>

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29075)
2025-11-19 15:55:46 +01:00
Tom Cosgrove 9b810d9256 Enable AES and SHA3 optimisations on Apple Silicon M5-based macOS systems
ARMV8_UNROLL8_EOR3 gives a performance improvement of 6-35%.

ARMV8_HAVE_SHA3_AND_WORTH_USING gives 3-4% improvement.

Still no performance gain from ARMV8_UNROLL12_EOR3.

Change-Id: I692ad5711e7ff728cd59baba64830cd3f69c3687

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29053)
2025-11-19 15:54:00 +01:00
Neil Horman 0b803c2adc merge x509 and handshake memfail test
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28736)
2025-11-19 15:53:01 +01:00
Neil Horman 7916bccc77 Add x509 memfail test to run_checker_daily
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28736)
2025-11-19 15:52:44 +01:00
Neil Horman 2d6d0831d2 add a memfail test for x509 operations
Much like our handshake test, x509 has several operations that can be
tested easily in such a way that we ensure memory failures don't cause
cascading asan failures, and increase our test coverage.

Add a test to exercise some X509 apis to do so.

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Norbert Pocs <norbertp@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28736)
2025-11-19 15:52:44 +01:00
Dr. David von Oheimb d46fca3263 CMP doc: update RFC 4210 -> 9810, RFC 6712 -> 9811
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Alicja Kario <hkario@redhat.com>
(Merged from https://github.com/openssl/openssl/pull/28017)
2025-11-19 14:31:42 +01:00
Tomas Mraz 7ec28bfe45 80-test_cms.t: Fix regression in provider compatibility CI
Fixes de83e65580

Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29172)
2025-11-19 14:27:44 +01:00
Leon Timmermans fc563b4d48 Allow get_params to return length of the AES-GCM tag parameter
Previously, EVP_CIPHER_CTX_get_params would not report the length of the
tag parameter when called with a NULL data pointer. This change makes the
function behave as documented.

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28232)
2025-11-19 14:19:20 +01:00
Leon Timmermans ab60626253 Allow get_params to return length of AES-GCM IV parameters
Previously, EVP_CIPHER_CTX_get_params would not report the length of the
IV parameters when called with a NULL data pointer. This change makes the
function behave as documented.

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28232)
2025-11-19 14:19:20 +01:00
Dmitry Misharov 793a744f2b add CI job for linux-x86 platform
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29123)
2025-11-19 14:16:37 +01:00
Igor Ustinov 747cfae9f1 Removed ossl_assert() calls from public OSSL_EN/DECODER_CTX_*() functions
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29120)
2025-11-18 19:36:22 +01:00
Igor Ustinov f480a73610 Added finalized flag to the OSSL_ENCODER/DECODER_CTX structures
After this flag is set, the generic OSSL_ENCODER/DECODER_CTX_set_*()
functions shouldn't be called anymore, so they return error in this case.

Fixes #28249

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29120)
2025-11-18 19:35:01 +01:00
Soumik Sarker de89ca9347 apps/enc.c: Moved -pass, -k, -kfile to encryption options
Signed-off-by: Soumik Sarker <ronodhirsoumik@gmail.com>

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/29110)
2025-11-18 19:31:43 +01:00
Joshua Rogers 9eb6922c59 asn1: raise NOT_ENOUGH_DATA on header EOF
If BIO_read returns 0 with no buffered data, raise ASN1_R_NOT_ENOUGH_DATA
so callers see a specific error instead of a generic -1.

Signed-off-by: Joshua Rogers <MegaManSec@users.noreply.github.com>

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28883)
2025-11-18 19:29:31 +01:00
Anton Moryakov 87a4607668 Prevent NULL deref in BN_is_zero when cofactor is missing
In ossl_ec_curve_nid_from_params, EC_GROUP_get0_cofactor may return NULL,
but BN_is_zero was called on it unconditionally, leading to a potential
segmentation fault.

Now check that cofactor != NULL before calling BN_is_zero or BN_is_word,
aligning with safe practices used elsewhere in the codebase.

This fixes a critical NULL pointer dereference vulnerability that could
be triggered by EC groups with unset cofactor, preventing DoS via segfault.

Signed-off-by: Anton Moryakov <ant.v.moryakov@gmail.com>

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Paul Yang <paulyang.inf@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29069)
2025-11-18 19:07:52 +01:00
Igor Ustinov c9248e19dd ML_KEM init refactoring, unconditional entropy cleanup
Fixes #27746

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29062)
2025-11-18 18:11:54 +01:00
KubaBoi ecf3ac3b10 asn1_gen: add ASN1_object_size() return check and fix else braces
Fixes: #6570

CLA: trivial

Reviewed-by: Norbert Pocs <norbertp@openssl.org>
Reviewed-by: Paul Yang <paulyang.inf@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29022)
2025-11-18 18:08:26 +01:00
Tomas Mraz 376f7ee4d1 CRYPTO_R_ cannot be used with ERR_LIB_OSSL_STORE
Use ERR_R_PASSED_NULL_PARAMETER instead.

Fixes e9e643bc58

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29006)
2025-11-18 18:05:44 +01:00
Stefan Berger 28a9d0e52d Implement EVP_SIGNATURE_hash_message_update() and use it
Implement EVP_SIGNATURE_hash_message_update() to check for support
of EVP_PKEY_sign_message_update() and EVP_PKEY_verify_message_update() and
use this function to replace the has_msg_update column in CMS.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28923)
2025-11-18 18:03:24 +01:00
Stefan Berger de83e65580 tests: Add CMS tests for no-attribute signing for ML/SLH-DSA and EdDSA
Add CMS test cases for no-attribute signing for ML-DSA, SLH-DSA
amd EdDSA (Ed448 and Ed25519 keys).

Fixes: #11915

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28923)
2025-11-18 18:03:24 +01:00
Stefan Berger 266fb55eb8 cms: Enable signature verification for no-attribute case (hashless signing)
Enable signature verification for hashless signing schemes, such as ML-DSA
and EdDSA, for the non-attribute case of CMS. Also in this case the BIO
with the plain input data needs to be passed through to the signature
verification function so that the pure-mode signature verification method
can hash the plain data itself.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28923)
2025-11-18 18:03:24 +01:00
Stefan Berger 3ee16555ee cms: Enable signing with hashless signing for no-attributes case
Enable the ability to sign with a hashless signing schemes, such as ML-DSA
in pure mode, in case no attributes are used in CMS. To support this, pass
the BIO with the plain data through to the signing function so that key's
pure mode signing scheme can hash the data itself.

The current implementation relies on a seek'able BIO so that the data
stream can be read multiple times for support of multiple keys.

Some signing schemes, such as ML-DSA, support the message_update function
when signing data, others, such as EdDSA keys do not support it. The former
allows for reading data in smaller chunks and calling
EVP_PKEY_sign_message_update with the data, while the latter requires that
all data are all read into memory and then passed for signing. This latter
method could run into out-of-memory issue when signing very large files.

Fixes: #28279

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28923)
2025-11-18 18:03:24 +01:00