Skip to content

Comments

ML-KEM768#25848

Closed
baentsch wants to merge 1 commit intoopenssl:feature/ml-kemfrom
baentsch:bsslmlkem768
Closed

ML-KEM768#25848
baentsch wants to merge 1 commit intoopenssl:feature/ml-kemfrom
baentsch:bsslmlkem768

Conversation

@baentsch
Copy link
Contributor

@baentsch baentsch commented Nov 1, 2024

First cut integrating ML-KEM768 based on the boringssl implementation.

Lots of work required to complete this -- will add issues for those so that more people can contribute in case of interest.

For now, all this code does is make ML-KEM768 available for simple initial testing, e.g., openssl s_client -brief -groups MLKEM-768 -connect test.openquantumsafe.org:6020.

Thanks to @andrewkdinh @t8m @mattcaswell @paulidale @slontis for help and guidance preparing this PR.

@mattcaswell
Copy link
Member

Not looked at this yet, but we should acknowledge the original source of the code in the first commit message.

@baentsch
Copy link
Contributor Author

baentsch commented Nov 1, 2024

Not looked at this yet, but we should acknowledge the original source of the code in the first commit message.

Lots of references -- most referencing only generally to "bssl", though. Any suggestion as to how to make it explicit welcome!

@mattcaswell
Copy link
Member

Something simple like this would do it:

Based on code from BoringSSL covered under Google CLA (insert link to original source code here)

int maxtls; /* Maximum TLS version (or 0 for undefined) */
int mindtls; /* Minimum DTLS version, -1 unsupported */
int maxdtls; /* Maximum DTLS version (or 0 for undefined) */
int is_kem; /* Indicates utility as KEM */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be a bit flag?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's IMO premature optimization.

@baentsch
Copy link
Contributor Author

baentsch commented Nov 2, 2024

Something simple like this would do it:

Based on code from BoringSSL covered under Google CLA (insert link to original source code here)

See latest change to first commit message: OK?

@github-actions github-actions bot added the severity: fips change The pull request changes FIPS provider sources label Nov 2, 2024
@t8m
Copy link
Member

t8m commented Nov 4, 2024

Something simple like this would do it:
Based on code from BoringSSL covered under Google CLA (insert link to original source code here)

See latest change to first commit message: OK?

I would put the link into the commit message body. Also to keep the formatting of the commit message titles aligned with most of the other commits in the repository, you should use uppercase for the beginning of the title message - i.e., Initial transfer of boringssl mlkem code under CCLA. Then in the body you can add the link, preferably with the git commit ID that was used for the initial transfer so we know when the code was exactly forked.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This directory should just be called mlkem. The bssl reference is no longer relevant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So changed in 467e70f

static const int kDU1024 = 11;
static const int kDV1024 = 5;

static size_t compressed_vector_size(int rank)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this and the other *_size functions should be ossl_inline?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So changed in 467e70f

shake128_cache = EVP_MD_fetch(NULL, "SHAKE128", NULL);
shake256_cache = EVP_MD_fetch(NULL, "SHAKE256", NULL);
sha3_256_cache = EVP_MD_fetch(NULL, "SHA3-256", NULL);
sha3_512_cache = EVP_MD_fetch(NULL, "SHA3-512", NULL);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These global caches become problematic in the case where the provider that supplied them gets unloaded.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This problem is gone with baentsch#2 merged.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the resolution, @mattcaswell -- ascertained by your test code from #25403


if (msg)
printf("%s: \n", msg);
for (i = 0; i < len; i++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is basically reimplementing BIO_dump_fp

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pointer! So changed in 467e70f

{
uint8_t seed[MLKEM_SEED_BYTES];

RAND_bytes(seed, sizeof(seed));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably this should be RAND_priv_bytes_ex...and this function can fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good catch!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So changed in 467e70f

{ OSSL_FUNC_KEYMGMT_GEN_CLEANUP, (void (*)(void))mlkem_gen_cleanup },
{ OSSL_FUNC_KEYMGMT_DUP, (void (*)(void))mlkem_dup },
/*
* don't do for now, see https://github.com/openssl/private/issues/698
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add TODO(ML-KEM)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added


int main(void)
{
#ifndef OPENSSL_NO_MLKEM
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to just not build this test at all in the case of no-mlkem, i.e. detect this in the build.info file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo there's many other tests not carrying such enable check (e.g., everything EC). But whatever, let me try to find out how to do this....

#include "testutil.h"
#include "testutil/output.h"

int main(void)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be implemented as a standard test, i.e. using the test framework with a setup_tests() function etc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK @andrewkdinh already has that in the works, so leaving as-is for now.

return 6;
#endif
return 0;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a test recipe in test/recipes to run this test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per above -- rely on @andrewkdinh's change on this one.

/* public key component to be created from private key */
ossl_mlkem768_public_from_private(&public_key, &private_key);
/* try to re-create public key structure from encoded public key */
ossl_mlkem768_recreate_public_key(out_encoded_public_key, &recreated_public_key);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function can fail so we should check the return code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the catch. So changed in 7b7cdfb

} matrix;

typedef struct public_key_RANK768
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Put the { on the end of the previous line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so changed.

} public_key_RANK768;

typedef struct private_key_RANK768
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Placement of { as above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so changed.

return 0;

/* TODO(ML-KEM): Review requested randomness strength */
if (RAND_bytes_ex(mlkem_ctx->libctx, seed, sizeof(seed), 256) == 1) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RAND_priv_bytes_ex?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so changed in 7b7cdfb

TLS_GROUP_ENTRY("ffdhe8192", "ffdhe8192", "DH", 37),
# endif
/* TODO(ML-KEM): Decide final name, e.g., ML-KEM768 or MLKEM768 */
TLS_GROUP_ENTRY("MLKEM-768", "MLKEM-768", "MLKEM-768", 38),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. The alg name now matches - but the group name still differs from the IANA name.

/*
* ideally, this is a one-time allocation and ctx that should be within the
* provider context: OK to move it there to improve performance?? It would be
* the first algorithmspecific context stored: Feels weird (TODO(ML-KEM)).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving it there has implications. It brings back some problems which were present previously but are now no longer present. E.g. if providers get loaded/unloaded after the default provider then the cache might reference the wrong instances. Also if the global property query setting gets changed.

It might be a good idea to assess the performance impact of this, so we can understand whether it is worth it or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Captured in #25879, so consider this dealt with for now.

return 0;
if (privkeylen != MLKEM768_SECRETKEYBYTES) {
printf("sec key len mismatch in import: %ld vs %d: HOWCAN?\n",
privkeylen, MLKEM768_SECRETKEYBYTES);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debug_print?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so changed in 7b7cdfb


if ((param_pub_key != NULL && pubkeylen != ossl_mlkem768_PUBLIC_KEY_BYTES)) {
printf("sec key len mismatch in import: %ld vs %d: HOWCAN?\n",
pubkeylen, ossl_mlkem768_PUBLIC_KEY_BYTES);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debug_print?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so changed in 7b7cdfb

@baentsch
Copy link
Contributor Author

baentsch commented Nov 5, 2024

@mattcaswell I think I addressed all your comments with the latest commit. Thus, I'd like to consider at least the API "settled" for now, will not touch it unnecessarily and thus invite @andrewkdinh to use/improve on it as discussed.

@tomato42
Copy link
Contributor

tomato42 commented Nov 5, 2024

I may be missing something, but there's no support for writing the private and public keys to a file included?
if so, may I ask for a follow up issue for it?

@baentsch
Copy link
Contributor Author

baentsch commented Nov 5, 2024

may I ask for a follow up issue for it?

There's lots of issues waiting to be published. I waited raising all "further improvement" issues so the community can lend hands with them until this code is ready to go onto the feature branch as the basis for other contributions -- which seems to be getting close now.

@t8m t8m added triaged: feature The issue/pr requests/adds a feature tests: deferred Tests will be added in a subsequent PR (label should be removed when the PR with tests is merged) approval: review pending This pull request needs review by a committer labels Nov 5, 2024
@slontis
Copy link
Member

slontis commented Nov 6, 2024

Not sure if this is useful to you or not, but here is a python3 file I use to convert hex strings into byte arrays

e.g.

python3 str2hex.py -columns 8 -b BEEFCAFE
import argparse
from hashlib import sha256

parser = argparse.ArgumentParser(description="")
parser.add_argument('-b', type=str)
parser.add_argument("-columns", type=int, default=8)
parser.add_argument("-spacing", type=int, default=1)
parser.add_argument("-indent", type=int, default=4)
parser.add_argument("-sha256", action="store_true")
args = parser.parse_args()

hx = bytes.fromhex(args.b);
if args.sha256:
    hx = sha256(hx).digest();

print("static const unsigned char bytes[] = {", end='')
i = 0
for b in hx:
    if i % args.columns == 0:
        print("\n{indent}".format(indent=' ' * args.indent), end='')
    else:
        print(' ' * args.spacing, end='')
    print('0x{:02x},'.format(b), end='')
    i += 1
print("\n};")

nctx->sha3_512_cache = EVP_MD_fetch(libctx, "SHA3-512", properties);
nctx->libctx = libctx;
if (properties != NULL)
nctx->properties = OPENSSL_strdup(properties);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
nctx->properties = OPENSSL_strdup(properties);
if ((nctx->properties = OPENSSL_strdup(properties)) == NULL)
goto err;

Comment on lines 150 to 157
if (ctx->shake128_cache != NULL)
EVP_MD_free(ctx->shake128_cache);
if (ctx->shake256_cache != NULL)
EVP_MD_free(ctx->shake256_cache);
if (ctx->sha3_256_cache != NULL)
EVP_MD_free(ctx->sha3_256_cache);
if (ctx->sha3_512_cache != NULL)
EVP_MD_free(ctx->sha3_512_cache);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove all the checks for !=NULL EVP_MDs. All the free functions handle NULL parameter gracefully.

static void prf(uint8_t *out, size_t out_len, const uint8_t in[33],
ossl_mlkem_ctx *mlkem_ctx)
{
single_keccak(out, out_len, in, 33, mlkem_ctx->shake256_cache);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return value must be checked and returned.

static void hash_h(uint8_t *out, const uint8_t *in, size_t len,
ossl_mlkem_ctx *mlkem_ctx)
{
single_keccak(out, 32, in, len, mlkem_ctx->sha3_256_cache);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return value must be checked and returned.

static void hash_g(uint8_t *out, const uint8_t *in, size_t len,
ossl_mlkem_ctx *mlkem_ctx)
{
single_keccak(out, 64, in, len, mlkem_ctx->sha3_512_cache);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return value must be checked and returned.

int maxtls; /* Maximum TLS version (or 0 for undefined) */
int mindtls; /* Minimum DTLS version, -1 unsupported */
int maxdtls; /* Maximum DTLS version (or 0 for undefined) */
int is_kem; /* Indicates utility as KEM */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's IMO premature optimization.

&len_stored))
return 0;
debug_print("encoded pub key successfully stored with %ld bytes\n", len_stored);
ossl_mlkem768_recreate_public_key(mkey->encoded_pubkey, &mkey->pubkey,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return value must be checked here

Comment on lines 510 to 513
ossl_mlkem768_generate_key(mkey->encoded_pubkey, NULL, &mkey->seckey,
mkey->mlkem_ctx);
mkey->seckey_initialized = 1;
ossl_mlkem768_public_from_private(&mkey->pubkey, &mkey->seckey);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return values must be checked here.

dstkey->keytype = srckey->keytype;
if (srckey->pubkey_initialized == 1
&& (selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0) {
/* TODO(ML-KEM)/TBC: By commenting out these, the EVP level test still passes: WHY?? */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps the pubkey value from the duplicated key is not really used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As well as the private key value. It indeed does not seem like the duplicated key is operated at all. Why is it then created in the first place?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The duplication is done during the EVP_PKEY_copy_parameters() call. That call does not set OSSL_KEYMGMT_SELECT_PUBLIC_KEY. So the current test does not exercise this code at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK -- that explains it then, thanks. Will remove this comment then when squashing all into one commit after the last PR review comment is resolved.

@baentsch
Copy link
Contributor Author

baentsch commented Nov 9, 2024

@t8m Thanks for the thorough check on retval functions. Is there no automated check that could find such problems (./config -pedantic didn't help)? Anyway, now added return value checks in all places I could find.

Copy link
Member

@t8m t8m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just nits to fix and I'll approve

hash_h(priv->pub.public_key_hash, out_encoded_public_key,
encoded_public_key_size(RANK768), mlkem_ctx);
if (!mlkem_marshal_public_key(out_encoded_public_key, &priv->pub)
|| (!hash_h(priv->pub.public_key_hash, out_encoded_public_key,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: please remove the extraneous parentheses.

hash_g(key_and_randomness, input, sizeof(input), mlkem_ctx);
encrypt_cpa(out_ciphertext, pub, entropy, key_and_randomness + 32, mlkem_ctx);
if (!hash_g(key_and_randomness, input, sizeof(input), mlkem_ctx)
|| (!encrypt_cpa(out_ciphertext, pub, entropy, key_and_randomness + 32, mlkem_ctx)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: please remove the extraneous parentheses


/* TODO(ML-KEM): Review requested randomness strength */
if (RAND_bytes_ex(mlkem_ctx->libctx, entropy, MLKEM_ENCAP_ENTROPY, 256) != 1)
if ((RAND_bytes_ex(mlkem_ctx->libctx, entropy, MLKEM_ENCAP_ENTROPY, 256) != 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: please remove the extraneous parentheses

Based on code from BoringSSL covered under Google CCLA

Original code at https://boringssl.googlesource.com/boringssl/+/HEAD/crypto/mlkem

VSCode automatic formatting ([email protected])

Just do some basic formatting to make diffs easier to read later: convert from 2 to 4 spaces, add newlines after function declarations, and move function open curly brace to new line ([email protected])

Move variable init to beginning of each function ([email protected])

replace CBB API

fixing up constants and parameter lists

replace BORINGSSL_keccac calls with EVP calls

added library symbols and low-level test case

switch boringssl constant time routines for OpenSSL ones

data type assertion and negative test added

moved mlkem.h to include/crypto

changed function naming to be in line with ossl convention

remove Google license terms based on CCLA

add constant_time_lt_32

convert asserts to ossl_asserts where possible

add bssl keccak, pubK recreation, formatting

add provider interface to utilize mlkem768 code enabling TLS1.3 use

revert to OpenSSL DigestXOF

use EVP_MD_xof() to determine digest finalisation ([email protected])

change APIs to return error codes; reference new IANA number; move static asserts to one place

remove boringssl keccak for good

fix coding style and return value checks

ANSI C compatibility changes

remove static cache objects

all internal retval functions used leading to some new retval functions
@mattcaswell mattcaswell added the approval: done This pull request has the required number of approvals label Nov 12, 2024
@baentsch
Copy link
Contributor Author

Thanks for review and approvals, @t8m @mattcaswell ! Anything else missing to / Who can now merge this into the feature branch?

@mattcaswell
Copy link
Member

Just waiting on the 24 hour timer which expires very soon.

@openssl-machine
Copy link
Collaborator

24 hours has passed since 'approval: done' was set, but as this PR has been updated in that time the label 'approval: ready to merge' is not being automatically set. Please review the updates and set the label manually.

@mattcaswell mattcaswell added approval: ready to merge The 24 hour grace period has passed, ready to merge and removed approval: done This pull request has the required number of approvals labels Nov 13, 2024
@mattcaswell
Copy link
Member

Pushed to the feature/ml-kem branch!!

openssl-machine pushed a commit that referenced this pull request Nov 13, 2024
Based on code from BoringSSL covered under Google CCLA

Original code at https://boringssl.googlesource.com/boringssl/+/HEAD/crypto/mlkem

VSCode automatic formatting ([email protected])

Just do some basic formatting to make diffs easier to read later: convert from 2 to 4 spaces, add newlines after function declarations, and move function open curly brace to new line ([email protected])

Move variable init to beginning of each function ([email protected])

replace CBB API

fixing up constants and parameter lists

replace BORINGSSL_keccac calls with EVP calls

added library symbols and low-level test case

switch boringssl constant time routines for OpenSSL ones

data type assertion and negative test added

moved mlkem.h to include/crypto

changed function naming to be in line with ossl convention

remove Google license terms based on CCLA

add constant_time_lt_32

convert asserts to ossl_asserts where possible

add bssl keccak, pubK recreation, formatting

add provider interface to utilize mlkem768 code enabling TLS1.3 use

revert to OpenSSL DigestXOF

use EVP_MD_xof() to determine digest finalisation ([email protected])

change APIs to return error codes; reference new IANA number; move static asserts to one place

remove boringssl keccak for good

fix coding style and return value checks

ANSI C compatibility changes

remove static cache objects

all internal retval functions used leading to some new retval functions

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from #25848)
vdukhovni pushed a commit to vdukhovni/openssl that referenced this pull request Jan 7, 2025
Based on code from BoringSSL covered under Google CCLA

Original code at https://boringssl.googlesource.com/boringssl/+/HEAD/crypto/mlkem

VSCode automatic formatting ([email protected])

Just do some basic formatting to make diffs easier to read later: convert from 2 to 4 spaces, add newlines after function declarations, and move function open curly brace to new line ([email protected])

Move variable init to beginning of each function ([email protected])

replace CBB API

fixing up constants and parameter lists

replace BORINGSSL_keccac calls with EVP calls

added library symbols and low-level test case

switch boringssl constant time routines for OpenSSL ones

data type assertion and negative test added

moved mlkem.h to include/crypto

changed function naming to be in line with ossl convention

remove Google license terms based on CCLA

add constant_time_lt_32

convert asserts to ossl_asserts where possible

add bssl keccak, pubK recreation, formatting

add provider interface to utilize mlkem768 code enabling TLS1.3 use

revert to OpenSSL DigestXOF

use EVP_MD_xof() to determine digest finalisation ([email protected])

change APIs to return error codes; reference new IANA number; move static asserts to one place

remove boringssl keccak for good

fix coding style and return value checks

ANSI C compatibility changes

remove static cache objects

all internal retval functions used leading to some new retval functions

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from openssl#25848)
t8m pushed a commit to t8m/openssl that referenced this pull request Jan 7, 2025
Based on code from BoringSSL covered under Google CCLA

Original code at https://boringssl.googlesource.com/boringssl/+/HEAD/crypto/mlkem

VSCode automatic formatting ([email protected])

Just do some basic formatting to make diffs easier to read later: convert from 2 to 4 spaces, add newlines after function declarations, and move function open curly brace to new line ([email protected])

Move variable init to beginning of each function ([email protected])

replace CBB API

fixing up constants and parameter lists

replace BORINGSSL_keccac calls with EVP calls

added library symbols and low-level test case

switch boringssl constant time routines for OpenSSL ones

data type assertion and negative test added

moved mlkem.h to include/crypto

changed function naming to be in line with ossl convention

remove Google license terms based on CCLA

add constant_time_lt_32

convert asserts to ossl_asserts where possible

add bssl keccak, pubK recreation, formatting

add provider interface to utilize mlkem768 code enabling TLS1.3 use

revert to OpenSSL DigestXOF

use EVP_MD_xof() to determine digest finalisation ([email protected])

change APIs to return error codes; reference new IANA number; move static asserts to one place

remove boringssl keccak for good

fix coding style and return value checks

ANSI C compatibility changes

remove static cache objects

all internal retval functions used leading to some new retval functions

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from openssl#25848)
vdukhovni pushed a commit to vdukhovni/openssl that referenced this pull request Jan 8, 2025
Based on code from BoringSSL covered under Google CCLA

Original code at https://boringssl.googlesource.com/boringssl/+/HEAD/crypto/mlkem

VSCode automatic formatting ([email protected])

Just do some basic formatting to make diffs easier to read later: convert from 2 to 4 spaces, add newlines after function declarations, and move function open curly brace to new line ([email protected])

Move variable init to beginning of each function ([email protected])

replace CBB API

fixing up constants and parameter lists

replace BORINGSSL_keccac calls with EVP calls

added library symbols and low-level test case

switch boringssl constant time routines for OpenSSL ones

data type assertion and negative test added

moved mlkem.h to include/crypto

changed function naming to be in line with ossl convention

remove Google license terms based on CCLA

add constant_time_lt_32

convert asserts to ossl_asserts where possible

add bssl keccak, pubK recreation, formatting

add provider interface to utilize mlkem768 code enabling TLS1.3 use

revert to OpenSSL DigestXOF

use EVP_MD_xof() to determine digest finalisation ([email protected])

change APIs to return error codes; reference new IANA number; move static asserts to one place

remove boringssl keccak for good

fix coding style and return value checks

ANSI C compatibility changes

remove static cache objects

all internal retval functions used leading to some new retval functions

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from openssl#25848)
vdukhovni pushed a commit to vdukhovni/openssl that referenced this pull request Jan 14, 2025
Based on code from BoringSSL covered under Google CCLA

Original code at https://boringssl.googlesource.com/boringssl/+/HEAD/crypto/mlkem

VSCode automatic formatting ([email protected])

Just do some basic formatting to make diffs easier to read later: convert from 2 to 4 spaces, add newlines after function declarations, and move function open curly brace to new line ([email protected])

Move variable init to beginning of each function ([email protected])

replace CBB API

fixing up constants and parameter lists

replace BORINGSSL_keccac calls with EVP calls

added library symbols and low-level test case

switch boringssl constant time routines for OpenSSL ones

data type assertion and negative test added

moved mlkem.h to include/crypto

changed function naming to be in line with ossl convention

remove Google license terms based on CCLA

add constant_time_lt_32

convert asserts to ossl_asserts where possible

add bssl keccak, pubK recreation, formatting

add provider interface to utilize mlkem768 code enabling TLS1.3 use

revert to OpenSSL DigestXOF

use EVP_MD_xof() to determine digest finalisation ([email protected])

change APIs to return error codes; reference new IANA number; move static asserts to one place

remove boringssl keccak for good

fix coding style and return value checks

ANSI C compatibility changes

remove static cache objects

all internal retval functions used leading to some new retval functions

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from openssl#25848)
vdukhovni pushed a commit to vdukhovni/openssl that referenced this pull request Jan 14, 2025
Based on code from BoringSSL covered under Google CCLA

Original code at https://boringssl.googlesource.com/boringssl/+/HEAD/crypto/mlkem

VSCode automatic formatting ([email protected])

Just do some basic formatting to make diffs easier to read later: convert from 2 to 4 spaces, add newlines after function declarations, and move function open curly brace to new line ([email protected])

Move variable init to beginning of each function ([email protected])

replace CBB API

fixing up constants and parameter lists

replace BORINGSSL_keccac calls with EVP calls

added library symbols and low-level test case

switch boringssl constant time routines for OpenSSL ones

data type assertion and negative test added

moved mlkem.h to include/crypto

changed function naming to be in line with ossl convention

remove Google license terms based on CCLA

add constant_time_lt_32

convert asserts to ossl_asserts where possible

add bssl keccak, pubK recreation, formatting

add provider interface to utilize mlkem768 code enabling TLS1.3 use

revert to OpenSSL DigestXOF

use EVP_MD_xof() to determine digest finalisation ([email protected])

change APIs to return error codes; reference new IANA number; move static asserts to one place

remove boringssl keccak for good

fix coding style and return value checks

ANSI C compatibility changes

remove static cache objects

all internal retval functions used leading to some new retval functions

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from openssl#25848)
openssl-machine pushed a commit that referenced this pull request Jan 17, 2025
Based on code from BoringSSL covered under Google CCLA

Original code at https://boringssl.googlesource.com/boringssl/+/HEAD/crypto/mlkem

VSCode automatic formatting ([email protected])

Just do some basic formatting to make diffs easier to read later: convert from 2 to 4 spaces, add newlines after function declarations, and move function open curly brace to new line ([email protected])

Move variable init to beginning of each function ([email protected])

replace CBB API

fixing up constants and parameter lists

replace BORINGSSL_keccac calls with EVP calls

added library symbols and low-level test case

switch boringssl constant time routines for OpenSSL ones

data type assertion and negative test added

moved mlkem.h to include/crypto

changed function naming to be in line with ossl convention

remove Google license terms based on CCLA

add constant_time_lt_32

convert asserts to ossl_asserts where possible

add bssl keccak, pubK recreation, formatting

add provider interface to utilize mlkem768 code enabling TLS1.3 use

revert to OpenSSL DigestXOF

use EVP_MD_xof() to determine digest finalisation ([email protected])

change APIs to return error codes; reference new IANA number; move static asserts to one place

remove boringssl keccak for good

fix coding style and return value checks

ANSI C compatibility changes

remove static cache objects

all internal retval functions used leading to some new retval functions

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from #25848)
openssl-machine pushed a commit that referenced this pull request Jan 19, 2025
Based on code from BoringSSL covered under Google CCLA

Original code at https://boringssl.googlesource.com/boringssl/+/HEAD/crypto/mlkem

VSCode automatic formatting ([email protected])

Just do some basic formatting to make diffs easier to read later: convert from 2 to 4 spaces, add newlines after function declarations, and move function open curly brace to new line ([email protected])

Move variable init to beginning of each function ([email protected])

replace CBB API

fixing up constants and parameter lists

replace BORINGSSL_keccac calls with EVP calls

added library symbols and low-level test case

switch boringssl constant time routines for OpenSSL ones

data type assertion and negative test added

moved mlkem.h to include/crypto

changed function naming to be in line with ossl convention

remove Google license terms based on CCLA

add constant_time_lt_32

convert asserts to ossl_asserts where possible

add bssl keccak, pubK recreation, formatting

add provider interface to utilize mlkem768 code enabling TLS1.3 use

revert to OpenSSL DigestXOF

use EVP_MD_xof() to determine digest finalisation ([email protected])

change APIs to return error codes; reference new IANA number; move static asserts to one place

remove boringssl keccak for good

fix coding style and return value checks

ANSI C compatibility changes

remove static cache objects

all internal retval functions used leading to some new retval functions

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from #25848)
openssl-machine pushed a commit that referenced this pull request Jan 21, 2025
Based on code from BoringSSL covered under Google CCLA

Original code at https://boringssl.googlesource.com/boringssl/+/HEAD/crypto/mlkem

VSCode automatic formatting ([email protected])

Just do some basic formatting to make diffs easier to read later: convert from 2 to 4 spaces, add newlines after function declarations, and move function open curly brace to new line ([email protected])

Move variable init to beginning of each function ([email protected])

replace CBB API

fixing up constants and parameter lists

replace BORINGSSL_keccac calls with EVP calls

added library symbols and low-level test case

switch boringssl constant time routines for OpenSSL ones

data type assertion and negative test added

moved mlkem.h to include/crypto

changed function naming to be in line with ossl convention

remove Google license terms based on CCLA

add constant_time_lt_32

convert asserts to ossl_asserts where possible

add bssl keccak, pubK recreation, formatting

add provider interface to utilize mlkem768 code enabling TLS1.3 use

revert to OpenSSL DigestXOF

use EVP_MD_xof() to determine digest finalisation ([email protected])

change APIs to return error codes; reference new IANA number; move static asserts to one place

remove boringssl keccak for good

fix coding style and return value checks

ANSI C compatibility changes

remove static cache objects

all internal retval functions used leading to some new retval functions

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from #25848)
openssl-machine pushed a commit that referenced this pull request Jan 22, 2025
Based on code from BoringSSL covered under Google CCLA

Original code at https://boringssl.googlesource.com/boringssl/+/HEAD/crypto/mlkem

VSCode automatic formatting ([email protected])

Just do some basic formatting to make diffs easier to read later: convert from 2 to 4 spaces, add newlines after function declarations, and move function open curly brace to new line ([email protected])

Move variable init to beginning of each function ([email protected])

replace CBB API

fixing up constants and parameter lists

replace BORINGSSL_keccac calls with EVP calls

added library symbols and low-level test case

switch boringssl constant time routines for OpenSSL ones

data type assertion and negative test added

moved mlkem.h to include/crypto

changed function naming to be in line with ossl convention

remove Google license terms based on CCLA

add constant_time_lt_32

convert asserts to ossl_asserts where possible

add bssl keccak, pubK recreation, formatting

add provider interface to utilize mlkem768 code enabling TLS1.3 use

revert to OpenSSL DigestXOF

use EVP_MD_xof() to determine digest finalisation ([email protected])

change APIs to return error codes; reference new IANA number; move static asserts to one place

remove boringssl keccak for good

fix coding style and return value checks

ANSI C compatibility changes

remove static cache objects

all internal retval functions used leading to some new retval functions

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from #25848)
openssl-machine pushed a commit that referenced this pull request Jan 25, 2025
Based on code from BoringSSL covered under Google CCLA

Original code at https://boringssl.googlesource.com/boringssl/+/HEAD/crypto/mlkem

VSCode automatic formatting ([email protected])

Just do some basic formatting to make diffs easier to read later: convert from 2 to 4 spaces, add newlines after function declarations, and move function open curly brace to new line ([email protected])

Move variable init to beginning of each function ([email protected])

replace CBB API

fixing up constants and parameter lists

replace BORINGSSL_keccac calls with EVP calls

added library symbols and low-level test case

switch boringssl constant time routines for OpenSSL ones

data type assertion and negative test added

moved mlkem.h to include/crypto

changed function naming to be in line with ossl convention

remove Google license terms based on CCLA

add constant_time_lt_32

convert asserts to ossl_asserts where possible

add bssl keccak, pubK recreation, formatting

add provider interface to utilize mlkem768 code enabling TLS1.3 use

revert to OpenSSL DigestXOF

use EVP_MD_xof() to determine digest finalisation ([email protected])

change APIs to return error codes; reference new IANA number; move static asserts to one place

remove boringssl keccak for good

fix coding style and return value checks

ANSI C compatibility changes

remove static cache objects

all internal retval functions used leading to some new retval functions

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from #25848)
openssl-machine pushed a commit that referenced this pull request Feb 5, 2025
Based on code from BoringSSL covered under Google CCLA

Original code at https://boringssl.googlesource.com/boringssl/+/HEAD/crypto/mlkem

VSCode automatic formatting ([email protected])

Just do some basic formatting to make diffs easier to read later: convert from 2 to 4 spaces, add newlines after function declarations, and move function open curly brace to new line ([email protected])

Move variable init to beginning of each function ([email protected])

replace CBB API

fixing up constants and parameter lists

replace BORINGSSL_keccac calls with EVP calls

added library symbols and low-level test case

switch boringssl constant time routines for OpenSSL ones

data type assertion and negative test added

moved mlkem.h to include/crypto

changed function naming to be in line with ossl convention

remove Google license terms based on CCLA

add constant_time_lt_32

convert asserts to ossl_asserts where possible

add bssl keccak, pubK recreation, formatting

add provider interface to utilize mlkem768 code enabling TLS1.3 use

revert to OpenSSL DigestXOF

use EVP_MD_xof() to determine digest finalisation ([email protected])

change APIs to return error codes; reference new IANA number; move static asserts to one place

remove boringssl keccak for good

fix coding style and return value checks

ANSI C compatibility changes

remove static cache objects

all internal retval functions used leading to some new retval functions

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from #25848)
openssl-machine pushed a commit that referenced this pull request Feb 7, 2025
Based on code from BoringSSL covered under Google CCLA

Original code at https://boringssl.googlesource.com/boringssl/+/HEAD/crypto/mlkem

VSCode automatic formatting ([email protected])

Just do some basic formatting to make diffs easier to read later: convert from 2 to 4 spaces, add newlines after function declarations, and move function open curly brace to new line ([email protected])

Move variable init to beginning of each function ([email protected])

replace CBB API

fixing up constants and parameter lists

replace BORINGSSL_keccac calls with EVP calls

added library symbols and low-level test case

switch boringssl constant time routines for OpenSSL ones

data type assertion and negative test added

moved mlkem.h to include/crypto

changed function naming to be in line with ossl convention

remove Google license terms based on CCLA

add constant_time_lt_32

convert asserts to ossl_asserts where possible

add bssl keccak, pubK recreation, formatting

add provider interface to utilize mlkem768 code enabling TLS1.3 use

revert to OpenSSL DigestXOF

use EVP_MD_xof() to determine digest finalisation ([email protected])

change APIs to return error codes; reference new IANA number; move static asserts to one place

remove boringssl keccak for good

fix coding style and return value checks

ANSI C compatibility changes

remove static cache objects

all internal retval functions used leading to some new retval functions

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from #25848)
vdukhovni pushed a commit to vdukhovni/openssl that referenced this pull request Feb 12, 2025
Based on code from BoringSSL covered under Google CCLA

Original code at https://boringssl.googlesource.com/boringssl/+/HEAD/crypto/mlkem

VSCode automatic formatting ([email protected])

Just do some basic formatting to make diffs easier to read later: convert from 2 to 4 spaces, add newlines after function declarations, and move function open curly brace to new line ([email protected])

Move variable init to beginning of each function ([email protected])

replace CBB API

fixing up constants and parameter lists

replace BORINGSSL_keccac calls with EVP calls

added library symbols and low-level test case

switch boringssl constant time routines for OpenSSL ones

data type assertion and negative test added

moved mlkem.h to include/crypto

changed function naming to be in line with ossl convention

remove Google license terms based on CCLA

add constant_time_lt_32

convert asserts to ossl_asserts where possible

add bssl keccak, pubK recreation, formatting

add provider interface to utilize mlkem768 code enabling TLS1.3 use

revert to OpenSSL DigestXOF

use EVP_MD_xof() to determine digest finalisation ([email protected])

change APIs to return error codes; reference new IANA number; move static asserts to one place

remove boringssl keccak for good

fix coding style and return value checks

ANSI C compatibility changes

remove static cache objects

all internal retval functions used leading to some new retval functions

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from openssl#25848)
openssl-machine pushed a commit that referenced this pull request Feb 14, 2025
Based on code from BoringSSL covered under Google CCLA
Original code at https://boringssl.googlesource.com/boringssl/+/HEAD/crypto/mlkem

- VSCode automatic formatting ([email protected])
- Just do some basic formatting to make diffs easier to read later: convert
  from 2 to 4 spaces, add newlines after function declarations, and move
  function open curly brace to new line ([email protected])
- Move variable init to beginning of each function ([email protected])
- Replace CBB API
- Fixing up constants and parameter lists
- Replace BORINGSSL_keccak calls with EVP calls
- Added library symbols and low-level test case
- Switch boringssl constant time routines for OpenSSL ones
- Data type assertion and negative test added
- Moved mlkem.h to include/crypto
- Changed function naming to be in line with ossl convention
- Remove Google license terms based on CCLA
- Add constant_time_lt_32
- Convert asserts to ossl_asserts where possible
- Add bssl keccak, pubK recreation, formatting
- Add provider interface to utilize mlkem768 code enabling TLS1.3 use
- Revert to OpenSSL DigestXOF
- Use EVP_MD_xof() to determine digest finalisation ([email protected])
- Change APIs to return error codes; reference new IANA number; move static asserts
  to one place
- Remove boringssl keccak for good
- Fix coding style and return value checks
- ANSI C compatibility changes
- Remove static cache objects
- All internal retval functions used leading to some new retval functions

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from #25848)
definability pushed a commit to definability/openssl that referenced this pull request Feb 25, 2025
Based on code from BoringSSL covered under Google CCLA
Original code at https://boringssl.googlesource.com/boringssl/+/HEAD/crypto/mlkem

- VSCode automatic formatting ([email protected])
- Just do some basic formatting to make diffs easier to read later: convert
  from 2 to 4 spaces, add newlines after function declarations, and move
  function open curly brace to new line ([email protected])
- Move variable init to beginning of each function ([email protected])
- Replace CBB API
- Fixing up constants and parameter lists
- Replace BORINGSSL_keccak calls with EVP calls
- Added library symbols and low-level test case
- Switch boringssl constant time routines for OpenSSL ones
- Data type assertion and negative test added
- Moved mlkem.h to include/crypto
- Changed function naming to be in line with ossl convention
- Remove Google license terms based on CCLA
- Add constant_time_lt_32
- Convert asserts to ossl_asserts where possible
- Add bssl keccak, pubK recreation, formatting
- Add provider interface to utilize mlkem768 code enabling TLS1.3 use
- Revert to OpenSSL DigestXOF
- Use EVP_MD_xof() to determine digest finalisation ([email protected])
- Change APIs to return error codes; reference new IANA number; move static asserts
  to one place
- Remove boringssl keccak for good
- Fix coding style and return value checks
- ANSI C compatibility changes
- Remove static cache objects
- All internal retval functions used leading to some new retval functions

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from openssl#25848)
quarckster pushed a commit to quarckster/openssl-fork that referenced this pull request Feb 27, 2025
Based on code from BoringSSL covered under Google CCLA
Original code at https://boringssl.googlesource.com/boringssl/+/HEAD/crypto/mlkem

- VSCode automatic formatting ([email protected])
- Just do some basic formatting to make diffs easier to read later: convert
  from 2 to 4 spaces, add newlines after function declarations, and move
  function open curly brace to new line ([email protected])
- Move variable init to beginning of each function ([email protected])
- Replace CBB API
- Fixing up constants and parameter lists
- Replace BORINGSSL_keccak calls with EVP calls
- Added library symbols and low-level test case
- Switch boringssl constant time routines for OpenSSL ones
- Data type assertion and negative test added
- Moved mlkem.h to include/crypto
- Changed function naming to be in line with ossl convention
- Remove Google license terms based on CCLA
- Add constant_time_lt_32
- Convert asserts to ossl_asserts where possible
- Add bssl keccak, pubK recreation, formatting
- Add provider interface to utilize mlkem768 code enabling TLS1.3 use
- Revert to OpenSSL DigestXOF
- Use EVP_MD_xof() to determine digest finalisation ([email protected])
- Change APIs to return error codes; reference new IANA number; move static asserts
  to one place
- Remove boringssl keccak for good
- Fix coding style and return value checks
- ANSI C compatibility changes
- Remove static cache objects
- All internal retval functions used leading to some new retval functions

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from openssl#25848)
DDvO pushed a commit to siemens/openssl that referenced this pull request Jun 16, 2025
Based on code from BoringSSL covered under Google CCLA
Original code at https://boringssl.googlesource.com/boringssl/+/HEAD/crypto/mlkem

- VSCode automatic formatting ([email protected])
- Just do some basic formatting to make diffs easier to read later: convert
  from 2 to 4 spaces, add newlines after function declarations, and move
  function open curly brace to new line ([email protected])
- Move variable init to beginning of each function ([email protected])
- Replace CBB API
- Fixing up constants and parameter lists
- Replace BORINGSSL_keccak calls with EVP calls
- Added library symbols and low-level test case
- Switch boringssl constant time routines for OpenSSL ones
- Data type assertion and negative test added
- Moved mlkem.h to include/crypto
- Changed function naming to be in line with ossl convention
- Remove Google license terms based on CCLA
- Add constant_time_lt_32
- Convert asserts to ossl_asserts where possible
- Add bssl keccak, pubK recreation, formatting
- Add provider interface to utilize mlkem768 code enabling TLS1.3 use
- Revert to OpenSSL DigestXOF
- Use EVP_MD_xof() to determine digest finalisation ([email protected])
- Change APIs to return error codes; reference new IANA number; move static asserts
  to one place
- Remove boringssl keccak for good
- Fix coding style and return value checks
- ANSI C compatibility changes
- Remove static cache objects
- All internal retval functions used leading to some new retval functions

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from openssl#25848)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approval: ready to merge The 24 hour grace period has passed, ready to merge severity: fips change The pull request changes FIPS provider sources tests: deferred Tests will be added in a subsequent PR (label should be removed when the PR with tests is merged) triaged: feature The issue/pr requests/adds a feature

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

8 participants