Conversation
|
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! |
|
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 */ |
308efaf to
f83bffa
Compare
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., |
There was a problem hiding this comment.
This directory should just be called mlkem. The bssl reference is no longer relevant.
crypto/bsslmlkem/mlkem768.c
Outdated
| static const int kDU1024 = 11; | ||
| static const int kDV1024 = 5; | ||
|
|
||
| static size_t compressed_vector_size(int rank) |
There was a problem hiding this comment.
Perhaps this and the other *_size functions should be ossl_inline?
crypto/bsslmlkem/mlkem768.c
Outdated
| 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); |
There was a problem hiding this comment.
These global caches become problematic in the case where the provider that supplied them gets unloaded.
There was a problem hiding this comment.
This problem is gone with baentsch#2 merged.
There was a problem hiding this comment.
Please check the resolution, @mattcaswell -- ascertained by your test code from #25403
crypto/bsslmlkem/mlkem768.c
Outdated
|
|
||
| if (msg) | ||
| printf("%s: \n", msg); | ||
| for (i = 0; i < len; i++) { |
There was a problem hiding this comment.
This is basically reimplementing BIO_dump_fp
There was a problem hiding this comment.
Thanks for the pointer! So changed in 467e70f
crypto/bsslmlkem/mlkem768.c
Outdated
| { | ||
| uint8_t seed[MLKEM_SEED_BYTES]; | ||
|
|
||
| RAND_bytes(seed, sizeof(seed)); |
There was a problem hiding this comment.
Probably this should be RAND_priv_bytes_ex...and this function can fail.
| { 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 |
test/mlkem_internal_test.c
Outdated
|
|
||
| int main(void) | ||
| { | ||
| #ifndef OPENSSL_NO_MLKEM |
There was a problem hiding this comment.
Better to just not build this test at all in the case of no-mlkem, i.e. detect this in the build.info file.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
this should be implemented as a standard test, i.e. using the test framework with a setup_tests() function etc
There was a problem hiding this comment.
AFAIK @andrewkdinh already has that in the works, so leaving as-is for now.
| return 6; | ||
| #endif | ||
| return 0; | ||
| } |
There was a problem hiding this comment.
This needs a test recipe in test/recipes to run this test
There was a problem hiding this comment.
As per above -- rely on @andrewkdinh's change on this one.
test/mlkem_internal_test.c
Outdated
| /* 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); |
There was a problem hiding this comment.
This function can fail so we should check the return code
There was a problem hiding this comment.
Thanks for the catch. So changed in 7b7cdfb
crypto/mlkem/mlkem768.c
Outdated
| } matrix; | ||
|
|
||
| typedef struct public_key_RANK768 | ||
| { |
There was a problem hiding this comment.
nit: Put the { on the end of the previous line
crypto/mlkem/mlkem768.c
Outdated
| } public_key_RANK768; | ||
|
|
||
| typedef struct private_key_RANK768 | ||
| { |
There was a problem hiding this comment.
nit: Placement of { as above
crypto/mlkem/mlkem768.c
Outdated
| return 0; | ||
|
|
||
| /* TODO(ML-KEM): Review requested randomness strength */ | ||
| if (RAND_bytes_ex(mlkem_ctx->libctx, seed, sizeof(seed), 256) == 1) { |
providers/common/capabilities.c
Outdated
| 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), |
There was a problem hiding this comment.
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)). |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
|
|
||
| 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); |
|
@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. |
|
I may be missing something, but there's no support for writing the private and public keys to a file included? |
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. |
|
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. |
crypto/mlkem/mlkem768.c
Outdated
| nctx->sha3_512_cache = EVP_MD_fetch(libctx, "SHA3-512", properties); | ||
| nctx->libctx = libctx; | ||
| if (properties != NULL) | ||
| nctx->properties = OPENSSL_strdup(properties); |
There was a problem hiding this comment.
| nctx->properties = OPENSSL_strdup(properties); | |
| if ((nctx->properties = OPENSSL_strdup(properties)) == NULL) | |
| goto err; |
crypto/mlkem/mlkem768.c
Outdated
| 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); |
There was a problem hiding this comment.
Please remove all the checks for !=NULL EVP_MDs. All the free functions handle NULL parameter gracefully.
crypto/mlkem/mlkem768.c
Outdated
| 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); |
There was a problem hiding this comment.
The return value must be checked and returned.
crypto/mlkem/mlkem768.c
Outdated
| 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); |
There was a problem hiding this comment.
The return value must be checked and returned.
crypto/mlkem/mlkem768.c
Outdated
| 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); |
There was a problem hiding this comment.
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 */ |
| &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, |
| 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); |
| 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?? */ |
There was a problem hiding this comment.
Perhaps the pubkey value from the duplicated key is not really used?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|
@t8m Thanks for the thorough check on retval functions. Is there no automated check that could find such problems ( |
t8m
left a comment
There was a problem hiding this comment.
Just nits to fix and I'll approve
crypto/mlkem/mlkem768.c
Outdated
| 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, |
There was a problem hiding this comment.
Nit: please remove the extraneous parentheses.
crypto/mlkem/mlkem768.c
Outdated
| 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))) |
There was a problem hiding this comment.
Nit: please remove the extraneous parentheses
crypto/mlkem/mlkem768.c
Outdated
|
|
||
| /* 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) |
There was a problem hiding this comment.
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
|
Thanks for review and approvals, @t8m @mattcaswell ! Anything else missing to / Who can now merge this into the feature branch? |
|
Just waiting on the 24 hour timer which expires very soon. |
|
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. |
|
Pushed to the feature/ml-kem branch!! |
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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.