openssl/util
Viktor Dukhovni d2136d9e73 Multi-variant ML-KEM
This introduces support for ML-KEM-512 and ML-KEM-1024 using the same
underlying implementation parameterised by a few macros for the
associated types and constants.

KAT tests are added for ML-KEM 512 and 1024, to complement the previous
tests for ML-KEM-768.

MLKEM{512,768,1024} TLS "group" codepoints are updated to match the
final IANA assigments and to make the additional KEMs known to the TLS
layer.

The pure-QC MLKEMs are not in the default list of supported groups, and
need to be explicitly enabled by the application.  Future work will
introduce support for hybrids, and for more fine-grained policy of
which keyshares a client should send by default, and when a server
should request (HRR) a new mutually-supported group that was not
sent.

Tests for ML-KEM key exchange added to sslapitest to make sure that our
TLS client MLKEM{512,768,1024} implementations interoperate with our TLS
server, and that MLKEM* are not negotiated in TLS 1.2.

Tests also added to excercise non-derandomised ML-KEM APIs, both
directly (bypassing the provider layer), and through the generic EVP KEM
API (exercising the provider).  These make sure that RNG input is used
correctly (KAT tests bypass the RNG by specifying seeds).

The API interface to the provider takes an "const ML_KEM_VINFO" pointer,
(obtained from ossl_ml_kem_get_vinfo()).  This checks input and output
buffer sizes before passing control to internal code that assumes
correctly sized (for each variant) buffers.

The original BoringSSL API was refactored to eliminate the opaque
public/private key structure wrappers, since these structures are an
internal detail between libcrypto and the provider, they are not part of
the public (EVP) API.

New "clangover" counter-measures added, refined with much appreciated
input from David Benjamin (Chromium).

The internal steps of "encrypt_cpa" were reordered to reduce the
working-set size of the algorithm, now needs space for just two
temporary "vectors" rather than three.  The "decap" function now process
the decrypted message in one call, rather than three separate calls to
scalar_decode_1, scalar_decompress and scalar_add.

Some loops were unrolled, improving performance of en/decapsulate
(pre-expanded vectors and matrix) by around 5%.

To handle, however unlikely, the SHA3 primitives not behaving like
"pure" functions and failing, the implementation of `decap` was modifed:

- To use the KDF to compute the Fujisaki-Okamoto (FO) failure secret
  first thing, and if that fails, bail out returning an error, a shared
  secret is still returned at random from the RNG, but it is OK for the
  caller to not use it.

- If any of the subsequently used hash primitives fail, use the computed
  FO failure secret (OK, despite no longer constant-time) and return
  success (otherwise the RNG would replace the result).

- We quite reasonably assume that chosen-ciphertext attacks (of the
  correct length) cannot cause hash functions to fail in a manner the
  depends on the private key content.

Support for ML-KEM-512 required adding a centered binomial distribution
helper function to deal with η_1 == 3 in just that variant.

Some additional comments were added to highlight how the code relates to
the ML-KEM specification in FIPS 203.

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26172)
2025-02-14 10:50:57 +01:00
..
perl Multi-variant ML-KEM 2025-02-14 10:50:57 +01:00
platform_symbols atoi should be allowed 2025-01-17 15:04:35 +01:00
add-depends.pl Update copyright year 2022-05-03 13:34:51 +01:00
build.info Disable building quicserver utility when configured with no-apps option 2023-12-29 10:16:46 +01:00
c-compress-test.pl FIPS module checksums: add scripts and Makefile rule 2021-05-04 11:32:16 +02:00
cavs-to-evptest.pl
check-format-commit.sh fix: util/check-format-commit.sh - fix ending check 2024-10-30 11:41:55 +00:00
check-format-test-negatives.c Copyright year updates 2024-09-05 09:35:49 +02:00
check-format-test-positives.c check-format.pl: improve whitespace reporting on <op>= 2022-09-02 21:32:46 +02:00
check-format.pl check-format.pl: do checks regarding statement/block after for() also on {OSSL_,}LIST_FOREACH{,_*} 2024-09-24 22:19:12 +02:00
check-malloc-errs
checkplatformsyms.pl Create a rudimentary symbol scanning script 2023-11-01 16:32:26 +01:00
ck_errf.pl
copy.pl
ctags.sh Fix new typos found by codespell 2023-06-18 16:53:09 +10:00
dofile.pl configdata.pm.in, util/dofile.pl: Make a HERE document stricter. 2020-10-27 10:17:19 +01:00
echo.pl always use the same perl in $PATH 2021-09-02 12:55:39 +10:00
engines.num
err-to-raise Simplify util/err-to-raise 2020-11-18 11:40:52 +01:00
find-doc-nits Big and little-endian load and store support 2025-01-14 12:14:54 +00:00
find-unused-errs
fips-checksums.sh always use the same perl in $PATH 2021-09-02 12:55:39 +10:00
fix-deprecation always use the same perl in $PATH 2021-09-02 12:55:39 +10:00
fix-includes Update copyright year 2020-04-23 13:55:52 +01:00
fix-includes.sed CRYPTO: split cipher_platform.h into algorithm specific headers 2019-12-19 13:31:29 +01:00
help.pl Add "make help" option 2023-03-06 08:00:58 +11:00
indent.pro Removes record_queue struct which is no longer useful. 2024-02-16 16:33:14 +01:00
lang-compress.pl util: update FIPS checksumming script to be more aggressive with whitespace 2021-06-03 11:56:21 +10:00
libcrypto.num libcrypto.num: add RAND_set1_random_provider function 2025-02-05 07:20:22 +11:00
libssl.num Add an API for other QUIC stacks to use our TLS implementation 2025-02-11 17:17:10 +00:00
markdownlint.rb Adjust mdl configuration 2023-10-24 17:34:07 +01:00
merge-err-lines Add merge-err-lines script 2019-09-19 09:27:38 -04:00
missingcrypto-internal.txt STORE: Move the built-in 'file:' loader to become an engine module 2020-09-03 17:48:32 +02:00
missingcrypto.txt Make the provider context available to encoders 2025-01-21 17:19:07 +11:00
missingcrypto111.txt Implementation of the RFC 9579, PBMAC1 in PKCS#12 - documentation 2024-08-07 10:00:16 +02:00
missingmacro.txt BIO_s_dgram: add documentation and hazard warnings 2022-12-15 06:32:45 +00:00
missingmacro111.txt Document some SSL DH related functions/macros 2020-11-18 14:14:53 +00:00
missingssl-internal.txt Initialize files that declare internal symbols 2020-04-11 15:51:43 +02:00
missingssl.txt Document the SSL_set_session_secret_cb() function 2024-05-06 10:44:22 +02:00
missingssl111.txt Adjust all util/missing*.txt to include the section number 2019-12-21 22:53:54 +01:00
mk-fipsmodule-cnf.pl kdfs: implement key length check in X9.42 2024-09-30 20:03:49 +02:00
mkbuildinf.pl Fix buildinf.h generation for space and backslash 2025-01-10 11:56:38 +01:00
mkdef.pl Copyright year updates 2024-04-09 13:43:26 +02:00
mkdir-p.pl Update copyright year 2021-04-08 13:04:41 +01:00
mkerr.pl Copyright year updates 2024-09-05 09:35:49 +02:00
mkinstallvars.pl Copyright year updates 2024-09-05 09:35:49 +02:00
mknum.pl Ensure ordinals are created during release process 2021-06-29 09:51:30 +10:00
mkpod2html.pl Fix util/mkpod2html.pl to call pod2html with absolute paths 2021-09-21 11:05:53 +02:00
mkrc.pl util/mkrc.pl: Make sure FILEVERSION and PRODUCTVERSION have four numbers 2020-11-17 13:18:16 +01:00
mktar.sh Fix treatment of BUILD_METADATA 2022-12-08 07:01:33 +01:00
opensslwrap.sh
other-internal.syms Suppress errors about undocumented asn1_d2i_read_bio 2021-02-22 12:11:38 +00:00
other.syms Add documentation for the new third party QUIC stack API 2025-02-11 17:17:10 +00:00
providers.num
quicserver.c QUIC CHANNEL: Consolidate forward object declarations in a single header 2023-12-21 08:11:59 +00:00
shlib_wrap.sh.in Add explicit support in util/shlib_wrap.sh.in for NonStop DLL loading. 2021-03-30 19:08:32 +02:00
su-filter.pl
update_abi_check.sh Update ci and ABI xml files to validate function parameters 2023-11-15 11:08:17 +01:00
withlibctx.pl Perl util to do with_libctx renaming 2020-10-01 09:23:05 +01:00
wrap.pl.in jitter: add a new provider containing a jitter entropy source alone 2024-07-31 14:44:51 +10:00
write-man-symlinks write-man-symlinks: Write relative symlinks not absolute 2021-05-25 17:14:09 +02:00