diff --git a/crypto/fipsmodule/curve25519/curve25519.c b/crypto/fipsmodule/curve25519/curve25519.c index 1bbf164ddf..5717984a61 100644 --- a/crypto/fipsmodule/curve25519/curve25519.c +++ b/crypto/fipsmodule/curve25519/curve25519.c @@ -112,6 +112,8 @@ void ED25519_keypair(uint8_t out_public_key[ED25519_PUBLIC_KEY_LEN], // description why this is useful. ED25519_keypair_from_seed(out_public_key, out_private_key, seed); OPENSSL_cleanse(seed, ED25519_SEED_LEN); + + FIPS_service_indicator_update_state(); } int ED25519_sign(uint8_t out_sig[ED25519_SIGNATURE_LEN], @@ -155,6 +157,8 @@ int ED25519_sign(uint8_t out_sig[ED25519_SIGNATURE_LEN], // The signature is computed from the private key, but is public. CONSTTIME_DECLASSIFY(out_sig, 64); + + FIPS_service_indicator_update_state(); return 1; } @@ -212,8 +216,12 @@ int ED25519_verify(const uint8_t *message, size_t message_len, #endif // Comparison [S]B - [k]A' =? R_expected. Short-circuits if decoding failed. - return (res == 1) && - CRYPTO_memcmp(R_computed_encoded, R_expected, sizeof(R_computed_encoded)) == 0; + res = (res == 1) && CRYPTO_memcmp(R_computed_encoded, R_expected, + sizeof(R_computed_encoded)) == 0; + if(res) { + FIPS_service_indicator_update_state(); + } + return res; } diff --git a/crypto/fipsmodule/evp/digestsign.c b/crypto/fipsmodule/evp/digestsign.c index e2bedf0c42..39914db92a 100644 --- a/crypto/fipsmodule/evp/digestsign.c +++ b/crypto/fipsmodule/evp/digestsign.c @@ -292,7 +292,9 @@ int EVP_DigestSign(EVP_MD_CTX *ctx, uint8_t *out_sig, size_t *out_sig_len, data_len); end: FIPS_service_indicator_unlock_state(); - if (ret > 0) { + if (ret > 0 && out_sig != NULL) { + // Indicator should only be set if we performed crypto, don't set if we only + // performed a size check. EVP_DigestSign_verify_service_indicator(ctx); } return ret; diff --git a/crypto/fipsmodule/evp/evp_ctx.c b/crypto/fipsmodule/evp/evp_ctx.c index e659e317dc..e827c39caf 100644 --- a/crypto/fipsmodule/evp/evp_ctx.c +++ b/crypto/fipsmodule/evp/evp_ctx.c @@ -591,30 +591,56 @@ int EVP_PKEY_encapsulate_deterministic(EVP_PKEY_CTX *ctx, seed, seed_len); } -int EVP_PKEY_encapsulate(EVP_PKEY_CTX *ctx, - uint8_t *ciphertext, size_t *ciphertext_len, - uint8_t *shared_secret, size_t *shared_secret_len) { +int EVP_PKEY_encapsulate(EVP_PKEY_CTX *ctx, uint8_t *ciphertext, + size_t *ciphertext_len, uint8_t *shared_secret, + size_t *shared_secret_len) { + // We have to avoid potential underlying services updating the indicator + // state, so we lock the state here. + FIPS_service_indicator_lock_state(); SET_DIT_AUTO_DISABLE; + int ret = 0; if (ctx == NULL || ctx->pmeth == NULL || ctx->pmeth->encapsulate == NULL) { - OPENSSL_PUT_ERROR(EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); - return 0; + OPENSSL_PUT_ERROR(EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); + goto end; } - return ctx->pmeth->encapsulate(ctx, ciphertext, ciphertext_len, - shared_secret, shared_secret_len); + if (!ctx->pmeth->encapsulate(ctx, ciphertext, ciphertext_len, shared_secret, + shared_secret_len)) { + goto end; + } + ret = 1; +end: + FIPS_service_indicator_unlock_state(); + if (ret && ciphertext != NULL && shared_secret != NULL) { + EVP_PKEY_encapsulate_verify_service_indicator(ctx); + } + return ret; } -int EVP_PKEY_decapsulate(EVP_PKEY_CTX *ctx, - uint8_t *shared_secret, size_t *shared_secret_len, - const uint8_t *ciphertext, size_t ciphertext_len) { +int EVP_PKEY_decapsulate(EVP_PKEY_CTX *ctx, uint8_t *shared_secret, + size_t *shared_secret_len, const uint8_t *ciphertext, + size_t ciphertext_len) { + // We have to avoid potential underlying services updating the indicator + // state, so we lock the state here. + FIPS_service_indicator_lock_state(); SET_DIT_AUTO_DISABLE; + int ret = 0; if (ctx == NULL || ctx->pmeth == NULL || ctx->pmeth->decapsulate == NULL) { - OPENSSL_PUT_ERROR(EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); - return 0; + OPENSSL_PUT_ERROR(EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); + goto end; } - return ctx->pmeth->decapsulate(ctx, shared_secret, shared_secret_len, - ciphertext, ciphertext_len); + if (!ctx->pmeth->decapsulate(ctx, shared_secret, shared_secret_len, + ciphertext, ciphertext_len)) { + goto end; + } + ret = 1; +end: + FIPS_service_indicator_unlock_state(); + if (ret && shared_secret != NULL) { + EVP_PKEY_decapsulate_verify_service_indicator(ctx); + } + return ret; } // Deprecated keygen NO-OP functions diff --git a/crypto/fipsmodule/evp/p_kem.c b/crypto/fipsmodule/evp/p_kem.c index c5c310e122..64a96693fd 100644 --- a/crypto/fipsmodule/evp/p_kem.c +++ b/crypto/fipsmodule/evp/p_kem.c @@ -95,10 +95,11 @@ static int pkey_kem_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey) { if (key == NULL || !KEM_KEY_init(key, kem) || !kem->method->keygen(key->public_key, key->secret_key) || - !EVP_PKEY_assign(pkey, EVP_PKEY_KEM, key)) { + !EVP_PKEY_set_type(pkey, EVP_PKEY_KEM)) { KEM_KEY_free(key); return 0; } + pkey->pkey.kem_key = key; return 1; } diff --git a/crypto/fipsmodule/ml_kem/ml_kem.c b/crypto/fipsmodule/ml_kem/ml_kem.c index 736983d820..1da7350e4b 100644 --- a/crypto/fipsmodule/ml_kem/ml_kem.c +++ b/crypto/fipsmodule/ml_kem/ml_kem.c @@ -16,6 +16,7 @@ #include "./ml_kem_ref/reduce.c" #include "./ml_kem_ref/symmetric-shake.c" #include "./ml_kem_ref/verify.c" +#include "../../internal.h" // Note: These methods currently default to using the reference code for ML_KEM. // In a future where AWS-LC has optimized options available, those can be @@ -25,6 +26,13 @@ int ml_kem_512_keypair_deterministic(uint8_t *public_key /* OUT */, uint8_t *secret_key /* OUT */, const uint8_t *seed /* IN */) { + boringssl_ensure_ml_kem_self_test(); + return ml_kem_512_keypair_deterministic_no_self_test(public_key, secret_key, seed); +} + +int ml_kem_512_keypair_deterministic_no_self_test(uint8_t *public_key /* OUT */, + uint8_t *secret_key /* OUT */, + const uint8_t *seed /* IN */) { ml_kem_params params; ml_kem_512_params_init(¶ms); return ml_kem_keypair_derand_ref(¶ms, public_key, secret_key, seed); @@ -32,6 +40,7 @@ int ml_kem_512_keypair_deterministic(uint8_t *public_key /* OUT */, int ml_kem_512_keypair(uint8_t *public_key /* OUT */, uint8_t *secret_key /* OUT */) { + boringssl_ensure_ml_kem_self_test(); ml_kem_params params; ml_kem_512_params_init(¶ms); return ml_kem_keypair_ref(¶ms, public_key, secret_key); @@ -41,14 +50,24 @@ int ml_kem_512_encapsulate_deterministic(uint8_t *ciphertext /* OUT */, uint8_t *shared_secret /* OUT */, const uint8_t *public_key /* IN */, const uint8_t *seed /* IN */) { + boringssl_ensure_ml_kem_self_test(); + return ml_kem_512_encapsulate_deterministic_no_self_test(ciphertext, shared_secret, public_key, seed); +} + +int ml_kem_512_encapsulate_deterministic_no_self_test(uint8_t *ciphertext /* OUT */, + uint8_t *shared_secret /* OUT */, + const uint8_t *public_key /* IN */, + const uint8_t *seed /* IN */) { ml_kem_params params; ml_kem_512_params_init(¶ms); - return ml_kem_enc_derand_ref(¶ms, ciphertext, shared_secret, public_key, seed); + return ml_kem_enc_derand_ref(¶ms, ciphertext, shared_secret, public_key, + seed); } int ml_kem_512_encapsulate(uint8_t *ciphertext /* OUT */, uint8_t *shared_secret /* OUT */, const uint8_t *public_key /* IN */) { + boringssl_ensure_ml_kem_self_test(); ml_kem_params params; ml_kem_512_params_init(¶ms); return ml_kem_enc_ref(¶ms, ciphertext, shared_secret, public_key); @@ -57,14 +76,23 @@ int ml_kem_512_encapsulate(uint8_t *ciphertext /* OUT */, int ml_kem_512_decapsulate(uint8_t *shared_secret /* OUT */, const uint8_t *ciphertext /* IN */, const uint8_t *secret_key /* IN */) { + boringssl_ensure_ml_kem_self_test(); + return ml_kem_512_decapsulate_no_self_test(shared_secret, ciphertext, secret_key); +} + +int ml_kem_512_decapsulate_no_self_test(uint8_t *shared_secret /* OUT */, + const uint8_t *ciphertext /* IN */, + const uint8_t *secret_key /* IN */) { ml_kem_params params; ml_kem_512_params_init(¶ms); return ml_kem_dec_ref(¶ms, shared_secret, ciphertext, secret_key); } + int ml_kem_768_keypair_deterministic(uint8_t *public_key /* OUT */, uint8_t *secret_key /* OUT */, const uint8_t *seed /* IN */) { + boringssl_ensure_ml_kem_self_test(); ml_kem_params params; ml_kem_768_params_init(¶ms); return ml_kem_keypair_derand_ref(¶ms, public_key, secret_key, seed); @@ -72,6 +100,7 @@ int ml_kem_768_keypair_deterministic(uint8_t *public_key /* OUT */, int ml_kem_768_keypair(uint8_t *public_key /* OUT */, uint8_t *secret_key /* OUT */) { + boringssl_ensure_ml_kem_self_test(); ml_kem_params params; ml_kem_768_params_init(¶ms); return ml_kem_keypair_ref(¶ms, public_key, secret_key); @@ -81,6 +110,7 @@ int ml_kem_768_encapsulate_deterministic(uint8_t *ciphertext /* OUT */, uint8_t *shared_secret /* OUT */, const uint8_t *public_key /* IN */, const uint8_t *seed /* IN */) { + boringssl_ensure_ml_kem_self_test(); ml_kem_params params; ml_kem_768_params_init(¶ms); return ml_kem_enc_derand_ref(¶ms, ciphertext, shared_secret, public_key, seed); @@ -89,6 +119,7 @@ int ml_kem_768_encapsulate_deterministic(uint8_t *ciphertext /* OUT */, int ml_kem_768_encapsulate(uint8_t *ciphertext /* OUT */, uint8_t *shared_secret /* OUT */, const uint8_t *public_key /* IN */) { + boringssl_ensure_ml_kem_self_test(); ml_kem_params params; ml_kem_768_params_init(¶ms); return ml_kem_enc_ref(¶ms, ciphertext, shared_secret, public_key); @@ -97,6 +128,7 @@ int ml_kem_768_encapsulate(uint8_t *ciphertext /* OUT */, int ml_kem_768_decapsulate(uint8_t *shared_secret /* OUT */, const uint8_t *ciphertext /* IN */, const uint8_t *secret_key /* IN */) { + boringssl_ensure_ml_kem_self_test(); ml_kem_params params; ml_kem_768_params_init(¶ms); return ml_kem_dec_ref(¶ms, shared_secret, ciphertext, secret_key); @@ -105,6 +137,7 @@ int ml_kem_768_decapsulate(uint8_t *shared_secret /* OUT */, int ml_kem_1024_keypair_deterministic(uint8_t *public_key /* OUT */, uint8_t *secret_key /* OUT */, const uint8_t *seed /* IN */) { + boringssl_ensure_ml_kem_self_test(); ml_kem_params params; ml_kem_1024_params_init(¶ms); return ml_kem_keypair_derand_ref(¶ms, public_key, secret_key, seed); @@ -112,6 +145,7 @@ int ml_kem_1024_keypair_deterministic(uint8_t *public_key /* OUT */, int ml_kem_1024_keypair(uint8_t *public_key /* OUT */, uint8_t *secret_key /* OUT */) { + boringssl_ensure_ml_kem_self_test(); ml_kem_params params; ml_kem_1024_params_init(¶ms); return ml_kem_keypair_ref(¶ms, public_key, secret_key); @@ -121,6 +155,7 @@ int ml_kem_1024_encapsulate_deterministic(uint8_t *ciphertext /* OUT */, uint8_t *shared_secret /* OUT */, const uint8_t *public_key /* IN */, const uint8_t *seed /* IN */) { + boringssl_ensure_ml_kem_self_test(); ml_kem_params params; ml_kem_1024_params_init(¶ms); return ml_kem_enc_derand_ref(¶ms, ciphertext, shared_secret, public_key, seed); @@ -129,6 +164,7 @@ int ml_kem_1024_encapsulate_deterministic(uint8_t *ciphertext /* OUT */, int ml_kem_1024_encapsulate(uint8_t *ciphertext /* OUT */, uint8_t *shared_secret /* OUT */, const uint8_t *public_key /* IN */) { + boringssl_ensure_ml_kem_self_test(); ml_kem_params params; ml_kem_1024_params_init(¶ms); return ml_kem_enc_ref(¶ms, ciphertext, shared_secret, public_key); @@ -137,6 +173,7 @@ int ml_kem_1024_encapsulate(uint8_t *ciphertext /* OUT */, int ml_kem_1024_decapsulate(uint8_t *shared_secret /* OUT */, const uint8_t *ciphertext /* IN */, const uint8_t *secret_key /* IN */) { + boringssl_ensure_ml_kem_self_test(); ml_kem_params params; ml_kem_1024_params_init(¶ms); return ml_kem_dec_ref(¶ms, shared_secret, ciphertext, secret_key); diff --git a/crypto/fipsmodule/ml_kem/ml_kem.h b/crypto/fipsmodule/ml_kem/ml_kem.h index a4c0af01c7..752855764f 100644 --- a/crypto/fipsmodule/ml_kem/ml_kem.h +++ b/crypto/fipsmodule/ml_kem/ml_kem.h @@ -32,6 +32,10 @@ int ml_kem_512_keypair_deterministic(uint8_t *public_key /* OUT */, uint8_t *secret_key /* OUT */, const uint8_t *seed /* IN */); +int ml_kem_512_keypair_deterministic_no_self_test(uint8_t *public_key /* OUT */, + uint8_t *secret_key /* OUT */, + const uint8_t *seed /* IN */); + int ml_kem_512_keypair(uint8_t *public_key /* OUT */, uint8_t *secret_key /* OUT */); @@ -40,6 +44,11 @@ int ml_kem_512_encapsulate_deterministic(uint8_t *ciphertext /* OUT */, const uint8_t *public_key /* IN */, const uint8_t *seed /* IN */); +int ml_kem_512_encapsulate_deterministic_no_self_test(uint8_t *ciphertext /* OUT */, + uint8_t *shared_secret /* OUT */, + const uint8_t *public_key /* IN */, + const uint8_t *seed /* IN */); + int ml_kem_512_encapsulate(uint8_t *ciphertext /* OUT */, uint8_t *shared_secret /* OUT */, const uint8_t *public_key /* IN */); @@ -48,6 +57,10 @@ int ml_kem_512_decapsulate(uint8_t *shared_secret /* OUT */, const uint8_t *ciphertext /* IN */, const uint8_t *secret_key /* IN */); +int ml_kem_512_decapsulate_no_self_test(uint8_t *shared_secret /* OUT */, + const uint8_t *ciphertext /* IN */, + const uint8_t *secret_key /* IN */); + int ml_kem_768_keypair_deterministic(uint8_t *public_key /* OUT */, uint8_t *secret_key /* OUT */, const uint8_t *seed /* IN */); diff --git a/crypto/fipsmodule/rsa/rsa_impl.c b/crypto/fipsmodule/rsa/rsa_impl.c index eab5729bb5..38f26d6df0 100644 --- a/crypto/fipsmodule/rsa/rsa_impl.c +++ b/crypto/fipsmodule/rsa/rsa_impl.c @@ -1270,11 +1270,12 @@ int RSA_generate_key_ex(RSA *rsa, int bits, const BIGNUM *e_value, } int RSA_generate_key_fips(RSA *rsa, int bits, BN_GENCB *cb) { - // FIPS 186-4 allows 2048-bit and 3072-bit RSA keys (1024-bit and 1536-bit - // primes, respectively) with the prime generation method we use. - // Subsequently, IG A.14 stated that larger modulus sizes can be used and ACVP - // testing supports 4096 bits. - if (bits != 2048 && bits != 3072 && bits != 4096) { + // FIPS 186-5 Section 5.1: + // This standard specifies the use of a modulus whose bit length is an even + // integer and greater than or equal to 2048 bits. Furthermore, this standard + // specifies that p and q be of the same bit length – namely, half the bit + // length of n + if (bits < 2048 || bits % 128 != 0) { OPENSSL_PUT_ERROR(RSA, RSA_R_BAD_RSA_PARAMETERS); return 0; } diff --git a/crypto/fipsmodule/self_check/self_check.c b/crypto/fipsmodule/self_check/self_check.c index 26bc2f0928..a0e9218f74 100644 --- a/crypto/fipsmodule/self_check/self_check.c +++ b/crypto/fipsmodule/self_check/self_check.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -38,6 +39,7 @@ #include "../dh/internal.h" #include "../ec/internal.h" #include "../ecdsa/internal.h" +#include "../ml_kem/ml_kem.h" #include "../rand/internal.h" #include "../rsa/internal.h" @@ -792,6 +794,682 @@ static int boringssl_self_test_ffdh(void) { return ret; } +static int boringssl_self_test_ml_kem(void) { + int ret = 0; + + const uint8_t kKeyGenSeed[MLKEM512_KEYGEN_SEED_LEN] = { + 0xec, 0xdb, 0x97, 0x62, 0xf4, 0x78, 0xb2, 0xfa, 0x26, 0x3d, 0xf4, + 0x6d, 0xe4, 0x47, 0xf3, 0xd1, 0x52, 0xa1, 0xbc, 0x0e, 0x02, 0xee, + 0x95, 0x36, 0x77, 0x30, 0x11, 0x64, 0xd1, 0x5d, 0x20, 0xd7, 0x1b, + 0x07, 0x4b, 0xff, 0x80, 0x44, 0x44, 0x5e, 0x11, 0x66, 0x0b, 0x1b, + 0x6b, 0x26, 0xdf, 0x24, 0x2b, 0x8f, 0xc0, 0x2b, 0x9e, 0x8d, 0xf5, + 0x38, 0xdb, 0x17, 0xa6, 0x39, 0xd7, 0xc4, 0x61, 0x32 + }; + const uint8_t kKeyGenEK[MLKEM512_PUBLIC_KEY_BYTES] = { + 0xe9, 0xe0, 0x22, 0x0a, 0x69, 0x45, 0x56, 0xbc, 0x0a, 0x4b, 0x5a, 0xad, + 0xe0, 0x32, 0xb2, 0xaa, 0x87, 0x7c, 0x0d, 0xa8, 0x16, 0xef, 0x32, 0xa8, + 0x4d, 0x77, 0xbb, 0xff, 0x46, 0x56, 0xe6, 0x80, 0x85, 0x4e, 0x69, 0x61, + 0xa4, 0x17, 0x08, 0x2b, 0xd4, 0x6f, 0x50, 0x23, 0xc4, 0x7c, 0xea, 0x09, + 0xbb, 0xa2, 0x14, 0x5d, 0x41, 0x51, 0x88, 0xe1, 0x38, 0x03, 0xbb, 0x5e, + 0x7f, 0xc1, 0x9d, 0x39, 0x81, 0x9e, 0x59, 0xca, 0x7f, 0xdc, 0x38, 0x05, + 0x1d, 0x96, 0x94, 0x01, 0xd4, 0xc4, 0x11, 0xda, 0xc0, 0x0a, 0x47, 0xab, + 0x57, 0x52, 0x7d, 0xaa, 0x89, 0x7a, 0x37, 0x75, 0x93, 0x51, 0xb4, 0xb1, + 0x18, 0x5b, 0x14, 0x96, 0xd7, 0x9a, 0xa3, 0x32, 0x29, 0xbe, 0xa3, 0xc0, + 0xe8, 0xdb, 0xcf, 0x1d, 0x7a, 0x64, 0x73, 0x09, 0x28, 0x77, 0x5c, 0x74, + 0xc9, 0x46, 0x18, 0x1b, 0xb8, 0x8e, 0x0a, 0x38, 0xa1, 0x65, 0xeb, 0xbd, + 0xc7, 0x86, 0x0b, 0x01, 0x4c, 0x59, 0x89, 0x4c, 0x72, 0x11, 0xbc, 0x23, + 0xd3, 0x90, 0x77, 0xe6, 0x29, 0x44, 0xd3, 0xc4, 0x8c, 0x43, 0x4b, 0x73, + 0x7b, 0x1a, 0x64, 0xb5, 0xf9, 0xa1, 0x64, 0x6a, 0x18, 0xa5, 0x19, 0x5a, + 0x54, 0x60, 0x3f, 0xfc, 0x28, 0x0b, 0xf5, 0xea, 0x1b, 0xf3, 0xd8, 0xcb, + 0x41, 0x12, 0xaa, 0x82, 0xfa, 0xb8, 0x9e, 0x26, 0x33, 0x66, 0x55, 0x97, + 0xbe, 0xd3, 0x0d, 0xe6, 0xc8, 0x89, 0x7a, 0x96, 0x13, 0xea, 0x8c, 0x11, + 0x73, 0x65, 0x24, 0xa7, 0x08, 0x62, 0x66, 0x52, 0x3f, 0xba, 0xb8, 0x87, + 0x46, 0x54, 0x94, 0xeb, 0xfc, 0x96, 0xfb, 0xe4, 0x46, 0x67, 0x75, 0xbc, + 0x0d, 0x70, 0x7e, 0x62, 0x4b, 0xb3, 0xde, 0x70, 0x0e, 0xaa, 0xc9, 0xb3, + 0x7c, 0x2b, 0xc1, 0x2b, 0x52, 0xaa, 0x2d, 0xfb, 0x73, 0xb7, 0x00, 0x6b, + 0xd9, 0x56, 0xc0, 0xb9, 0x32, 0x4c, 0x47, 0x29, 0x5e, 0x4e, 0x4c, 0x4c, + 0xc4, 0x7b, 0xa9, 0xb5, 0xa8, 0x99, 0x69, 0x4b, 0x38, 0xa6, 0x4a, 0x29, + 0x12, 0x06, 0x84, 0xbf, 0x64, 0xc6, 0x48, 0x21, 0x1b, 0x18, 0xd0, 0x17, + 0xce, 0x34, 0x84, 0x9c, 0x4a, 0x09, 0x2b, 0x24, 0xbc, 0xb8, 0x96, 0x0d, + 0x87, 0x04, 0x22, 0xeb, 0xd9, 0x54, 0xbc, 0x72, 0x64, 0xba, 0x95, 0xa7, + 0x27, 0xa3, 0x19, 0x26, 0xf3, 0x1c, 0x12, 0x38, 0x1d, 0x0d, 0x05, 0x1e, + 0x1e, 0x04, 0x19, 0x0b, 0x94, 0x93, 0x22, 0x44, 0x28, 0x45, 0xf3, 0xaa, + 0x6f, 0xb1, 0x79, 0x40, 0x44, 0x2a, 0x9c, 0x1a, 0x18, 0x3b, 0x23, 0x97, + 0xdc, 0xc0, 0x77, 0x0c, 0xb2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e, 0xa8, 0x16, + 0x0a, 0x5b, 0xa7, 0x22, 0x27, 0xc1, 0x5b, 0xec, 0x5d, 0xf1, 0x71, 0x14, + 0x01, 0x98, 0x89, 0x6d, 0x31, 0x73, 0x2a, 0x24, 0x1f, 0x5b, 0x93, 0x8f, + 0xf2, 0x33, 0xcb, 0xa2, 0xdc, 0x82, 0xde, 0x91, 0xc6, 0xb4, 0x93, 0x78, + 0x2b, 0x61, 0x63, 0xbc, 0x12, 0x82, 0xdf, 0x85, 0x5e, 0xe6, 0xa6, 0xa6, + 0x59, 0x75, 0xb3, 0x3c, 0xb6, 0xa2, 0x7d, 0x25, 0x8b, 0xd3, 0x17, 0xd0, + 0x4c, 0xef, 0x8e, 0xb5, 0x57, 0xba, 0x02, 0xd4, 0x94, 0x71, 0x92, 0x3c, + 0xd6, 0x0e, 0x99, 0x17, 0x96, 0x6b, 0xe9, 0x0f}; + const uint8_t kKeyGenDK[MLKEM512_SECRET_KEY_BYTES] = { + 0x88, 0xc1, 0x2c, 0xea, 0xa6, 0xcb, 0x91, 0xf5, 0x89, 0xac, 0xb8, 0x6d, + 0x91, 0x3c, 0x7a, 0x60, 0xf7, 0xcd, 0xab, 0xe3, 0xb7, 0xb5, 0x90, 0x09, + 0x1d, 0x00, 0x84, 0xe2, 0x9a, 0x04, 0x9b, 0x43, 0x68, 0x41, 0xf2, 0x47, + 0x3b, 0x03, 0x16, 0x5a, 0xe9, 0xc6, 0xa9, 0x82, 0x6d, 0x6c, 0x65, 0x0d, + 0x04, 0xb3, 0x88, 0xef, 0xf5, 0x94, 0x50, 0x5b, 0x7e, 0x54, 0x70, 0x95, + 0x30, 0x54, 0x68, 0x25, 0xa0, 0x70, 0xa6, 0x25, 0xb0, 0xe5, 0xfa, 0x86, + 0x6e, 0x6a, 0xaf, 0x40, 0xc2, 0x41, 0x42, 0x46, 0x24, 0x09, 0x73, 0xc7, + 0x59, 0x8a, 0xae, 0x7c, 0x36, 0x3e, 0x43, 0x03, 0xab, 0xb7, 0xa1, 0x11, + 0x31, 0xb4, 0x64, 0xa9, 0x43, 0x99, 0x6d, 0xe7, 0x59, 0x2c, 0xa0, 0x49, + 0x22, 0xea, 0x8a, 0x4d, 0x73, 0xb4, 0x43, 0xea, 0x04, 0x8c, 0x06, 0xac, + 0xc4, 0xe5, 0x5a, 0x8f, 0x25, 0x4b, 0xf6, 0xd2, 0x71, 0xfd, 0x82, 0x71, + 0x19, 0xec, 0x5b, 0x55, 0x80, 0x49, 0x8b, 0xfc, 0xc0, 0x9e, 0xb0, 0x26, + 0x6f, 0x8c, 0x2b, 0x45, 0x98, 0x8a, 0xe9, 0x8c, 0x1e, 0x54, 0x02, 0xb7, + 0x00, 0x34, 0x63, 0xf2, 0x03, 0x59, 0x47, 0x01, 0x59, 0xc0, 0x50, 0x9f, + 0xa9, 0x71, 0x15, 0x34, 0x43, 0xce, 0x25, 0x80, 0xc0, 0xb2, 0x44, 0x3f, + 0x8a, 0xc2, 0xb0, 0x81, 0x04, 0x01, 0xe7, 0x30, 0x52, 0xd6, 0x26, 0xbf, + 0x58, 0xc6, 0x74, 0xee, 0x48, 0x88, 0x0c, 0x40, 0x8d, 0x1f, 0x31, 0x3a, + 0x94, 0xb1, 0x66, 0x7f, 0x89, 0x76, 0x28, 0xc5, 0x5a, 0x83, 0xe2, 0x86, + 0x34, 0xa2, 0x07, 0x10, 0xd2, 0x5d, 0xa8, 0x8b, 0x2a, 0xc9, 0x0c, 0x0f, + 0x5d, 0x6b, 0x0e, 0xd6, 0xe0, 0x80, 0xfd, 0x2c, 0x24, 0xbb, 0x11, 0x81, + 0x6b, 0x5c, 0x60, 0x79, 0x57, 0x78, 0x1d, 0xb2, 0x28, 0x79, 0x66, 0x71, + 0x7f, 0xfa, 0x50, 0x0a, 0x03, 0x02, 0x58, 0x39, 0x16, 0x41, 0x15, 0xba, + 0x5e, 0xa7, 0xb7, 0x17, 0x34, 0x45, 0x88, 0x16, 0x9e, 0x8a, 0x85, 0xa9, + 0xe8, 0x3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, 0x33, 0x82, 0x02, 0x07, 0x1e, 0x11, 0x66, 0x5f, + 0x13, 0x42, 0x73, 0xbd, 0xaa, 0xcb, 0xc9, 0x52, 0xb9, 0x94, 0xba, 0x94, + 0x62, 0x67, 0x12, 0x26, 0x51, 0x4b, 0x44, 0x61, 0x13, 0xe7, 0xab, 0x7e, + 0xdb, 0x9c, 0x54, 0xc3, 0x11, 0xc4, 0xda, 0x94, 0x10, 0x4d, 0x26, 0x2a, + 0x80, 0x28, 0x0e, 0x39, 0x20, 0x1e, 0x75, 0x51, 0x91, 0x76, 0x39, 0x83, + 0xc4, 0x39, 0xa9, 0x5a, 0xea, 0xaf, 0xa7, 0x67, 0xc2, 0xcb, 0x59, 0x48, + 0x29, 0xe6, 0x31, 0x3e, 0x38, 0x69, 0x82, 0xd6, 0x62, 0x1a, 0xcc, 0x4b, + 0xb0, 0x99, 0x1a, 0x60, 0x79, 0x0a, 0x2b, 0x0c, 0x5f, 0x31, 0x39, 0xaa, + 0xdd, 0x70, 0x45, 0xf7, 0xd8, 0x49, 0xaa, 0x20, 0x9b, 0xf6, 0x0b, 0xc1, + 0x5e, 0xd8, 0x26, 0x67, 0x41, 0x4b, 0x70, 0xb7, 0x1a, 0x7e, 0x18, 0x4e, + 0x16, 0x42, 0x80, 0xaf, 0x00, 0xbf, 0x95, 0xa9, 0xad, 0x3d, 0xe4, 0x1d, + 0xcf, 0x19, 0x62, 0x36, 0x10, 0xcf, 0xb3, 0x06, 0x87, 0xa5, 0xa0, 0x82, + 0xa2, 0x45, 0x88, 0x70, 0xeb, 0x33, 0xd6, 0x49, 0xb3, 0xfc, 0xe3, 0x31, + 0x7e, 0x03, 0x62, 0xee, 0x61, 0x75, 0xfb, 0x81, 0x1c, 0x7f, 0xe3, 0x64, + 0x7c, 0xa2, 0x10, 0x20, 0x67, 0x3a, 0xed, 0xd2, 0x3b, 0xf0, 0x47, 0x0c, + 0xd8, 0x73, 0x5c, 0xe5, 0x3a, 0x78, 0x08, 0x26, 0x68, 0xe4, 0x9a, 0x51, + 0x32, 0xd1, 0x33, 0x6a, 0x08, 0x43, 0x60, 0x18, 0x7f, 0xcf, 0xf9, 0x22, + 0x7c, 0xdc, 0x0d, 0x7f, 0x20, 0x5b, 0x2a, 0xf2, 0xc8, 0x8d, 0xc6, 0xbc, + 0x9a, 0x04, 0xb4, 0x1f, 0x42, 0x9f, 0xa9, 0xa3, 0x86, 0xf5, 0x8b, 0x8f, + 0x21, 0x6c, 0xbf, 0x67, 0x14, 0xa6, 0x19, 0x59, 0x7c, 0xaa, 0x5a, 0x9b, + 0xf6, 0x68, 0x04, 0x8d, 0x71, 0x35, 0x10, 0x5a, 0x94, 0x25, 0xcb, 0x46, + 0xfe, 0x80, 0x7a, 0x40, 0x64, 0x59, 0xb0, 0x67, 0xb7, 0x16, 0xf5, 0xa4, + 0x77, 0x30, 0x97, 0x4b, 0x20, 0x78, 0x26, 0x71, 0x6f, 0xe3, 0xf7, 0x47, + 0xfd, 0x74, 0xcd, 0x8c, 0x02, 0x57, 0x20, 0xb1, 0x00, 0x3f, 0x27, 0xb2, + 0xde, 0xa6, 0x95, 0xf2, 0x21, 0x97, 0x1c, 0xd5, 0xaf, 0x81, 0xa1, 0xa7, + 0x95, 0x00, 0x1f, 0x12, 0x5c, 0x28, 0x5c, 0x15, 0x0d, 0xdc, 0x99, 0x59, + 0xe9, 0xe0, 0x22, 0x0a, 0x69, 0x45, 0x56, 0xbc, 0x0a, 0x4b, 0x5a, 0xad, + 0xe0, 0x32, 0xb2, 0xaa, 0x87, 0x7c, 0x0d, 0xa8, 0x16, 0xef, 0x32, 0xa8, + 0x4d, 0x77, 0xbb, 0xff, 0x46, 0x56, 0xe6, 0x80, 0x85, 0x4e, 0x69, 0x61, + 0xa4, 0x17, 0x08, 0x2b, 0xd4, 0x6f, 0x50, 0x23, 0xc4, 0x7c, 0xea, 0x09, + 0xbb, 0xa2, 0x14, 0x5d, 0x41, 0x51, 0x88, 0xe1, 0x38, 0x03, 0xbb, 0x5e, + 0x7f, 0xc1, 0x9d, 0x39, 0x81, 0x9e, 0x59, 0xca, 0x7f, 0xdc, 0x38, 0x05, + 0x1d, 0x96, 0x94, 0x01, 0xd4, 0xc4, 0x11, 0xda, 0xc0, 0x0a, 0x47, 0xab, + 0x57, 0x52, 0x7d, 0xaa, 0x89, 0x7a, 0x37, 0x75, 0x93, 0x51, 0xb4, 0xb1, + 0x18, 0x5b, 0x14, 0x96, 0xd7, 0x9a, 0xa3, 0x32, 0x29, 0xbe, 0xa3, 0xc0, + 0xe8, 0xdb, 0xcf, 0x1d, 0x7a, 0x64, 0x73, 0x09, 0x28, 0x77, 0x5c, 0x74, + 0xc9, 0x46, 0x18, 0x1b, 0xb8, 0x8e, 0x0a, 0x38, 0xa1, 0x65, 0xeb, 0xbd, + 0xc7, 0x86, 0x0b, 0x01, 0x4c, 0x59, 0x89, 0x4c, 0x72, 0x11, 0xbc, 0x23, + 0xd3, 0x90, 0x77, 0xe6, 0x29, 0x44, 0xd3, 0xc4, 0x8c, 0x43, 0x4b, 0x73, + 0x7b, 0x1a, 0x64, 0xb5, 0xf9, 0xa1, 0x64, 0x6a, 0x18, 0xa5, 0x19, 0x5a, + 0x54, 0x60, 0x3f, 0xfc, 0x28, 0x0b, 0xf5, 0xea, 0x1b, 0xf3, 0xd8, 0xcb, + 0x41, 0x12, 0xaa, 0x82, 0xfa, 0xb8, 0x9e, 0x26, 0x33, 0x66, 0x55, 0x97, + 0xbe, 0xd3, 0x0d, 0xe6, 0xc8, 0x89, 0x7a, 0x96, 0x13, 0xea, 0x8c, 0x11, + 0x73, 0x65, 0x24, 0xa7, 0x08, 0x62, 0x66, 0x52, 0x3f, 0xba, 0xb8, 0x87, + 0x46, 0x54, 0x94, 0xeb, 0xfc, 0x96, 0xfb, 0xe4, 0x46, 0x67, 0x75, 0xbc, + 0x0d, 0x70, 0x7e, 0x62, 0x4b, 0xb3, 0xde, 0x70, 0x0e, 0xaa, 0xc9, 0xb3, + 0x7c, 0x2b,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bc, 0xc5, 0x3b, 0x31, 0xf2, 0x52, 0x5a, 0xb5, 0x3f, + 0x95, 0xa3, 0xb0, 0x02, 0x42, 0xc1, 0x1c, 0x49, 0x4e, 0x25, 0x54, 0x43, + 0x8b, 0x0a, 0x4f, 0x68, 0x19, 0x40, 0x19, 0x18, 0x1b, 0xbd, 0xb1, 0x94, + 0x91, 0x03, 0x07, 0xbc, 0x19, 0xaf, 0xae, 0x55, 0x3d, 0xd6, 0x66, 0x56, + 0x43, 0x32, 0xc0, 0x78, 0x60, 0x4f, 0xbd, 0x8b, 0xc4, 0xfd, 0xc9, 0x2f, + 0x92, 0x01, 0x80, 0x9a, 0xb4, 0x95, 0xc1, 0xb5, 0x35, 0x53, 0x0b, 0xad, + 0x2e, 0xb3, 0x57, 0x53, 0xf9, 0x19, 0x56, 0xb5, 0x8b, 0xfb, 0xf6, 0x2d, + 0x1e, 0x33, 0xc8, 0x61, 0xf7, 0x38, 0x46, 0x33, 0x4c, 0x4a, 0x2a, 0xc5, + 0x57, 0x69, 0x84, 0xef, 0x11, 0x63, 0xa5, 0x04, 0x54, 0xa3, 0xe4, 0xce, + 0x83, 0x88, 0x98, 0xf2, 0x25, 0x86, 0x81, 0x89, 0xbd, 0xae, 0x5a, 0x03, + 0xef, 0xd8, 0x00, 0x1d, 0x2a, 0x9f, 0x55, 0x7c, 0xb6, 0xcd, 0x93, 0xa4, + 0x6f, 0xbb, 0x13, 0x79, 0xd8, 0x16, 0x45, 0xb8, 0x53, 0xcb, 0x98, 0xb4, + 0x7b, 0xa8, 0x7a, 0x66, 0xfc, 0xbc, 0x0a, 0xda, 0x76, 0x50, 0x6b, 0x8d, + 0xcd, 0x65, 0x90, 0x42, 0x64, 0x0e, 0xf6, 0x16, 0x82, 0x0f, 0xf2, 0x0b, + 0x26, 0x43, 0x33, 0x99, 0x37, 0x1d, 0xc4, 0xc5, 0x02, 0x87, 0x34, 0x9c, + 0xa2, 0x76, 0x3e, 0x30, 0x73, 0x86, 0x5c, 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71, 0x92, 0x3c, + 0xd6, 0x0e, 0x99, 0x17, 0x96, 0x6b, 0xe9, 0x0f, 0x56, 0xd2, 0xd5, 0x3f, + 0xa3, 0xbc, 0x26, 0x29, 0x74, 0x0a, 0xbb, 0xd1, 0x67, 0x20, 0xa9, 0xa7, + 0x06, 0x9a, 0x64, 0xde, 0x7a, 0x26, 0x32, 0x88, 0x17, 0xd7, 0x4a, 0x7c, + 0x2f, 0x55, 0xa2, 0x46, 0x1b, 0x07, 0x4b, 0xff, 0x80, 0x44, 0x44, 0x5e, + 0x11, 0x66, 0x0b, 0x1b, 0x6b, 0x26, 0xdf, 0x24, 0x2b, 0x8f, 0xc0, 0x2b, + 0x9e, 0x8d, 0xf5, 0x38, 0xdb, 0x17, 0xa6, 0x39, 0xd7, 0xc4, 0x61, 0x32}; + + uint8_t keygen_decaps[MLKEM512_SECRET_KEY_BYTES] = {0}; + uint8_t keygen_encaps[MLKEM512_PUBLIC_KEY_BYTES] = {0}; + + if (ml_kem_512_keypair_deterministic_no_self_test( + keygen_encaps, keygen_decaps, kKeyGenSeed) || + !check_test(kKeyGenDK, keygen_decaps, sizeof(keygen_decaps), + "ML-KEM keyGen decaps") || + !check_test(kKeyGenEK, keygen_encaps, sizeof(keygen_encaps), + "ML-KEM keyGen encaps")) { + goto err; + } + + const uint8_t kEncapEK[MLKEM512_PUBLIC_KEY_BYTES] = { + 0x57, 0xc3, 0xba, 0x4c, 0xd7, 0x81, 0xd8, 0x69, 0x0b, 0x4c, 0x39, 0x0d, + 0x9a, 0x58, 0xb3, 0x5d, 0x69, 0xa5, 0x2d, 0x52, 0xcd, 0x19, 0x01, 0x2a, + 0x25, 0xe1, 0x58, 0xa2, 0xc1, 0x9b, 0x75, 0x47, 0x0a, 0x03, 0x9a, 0x05, + 0xc5, 0x98, 0x33, 0xc5, 0xd2, 0xa8, 0x28, 0x0b, 0x33, 0xde, 0x95, 0xb6, + 0x0c, 0x1b, 0xb5, 0xc6, 0x33, 0xaf, 0x71, 0x13, 0x8f, 0xb0, 0x64, 0x28, + 0x14, 0x37, 0x12, 0xb7, 0xa0, 0x33, 0xeb, 0xaa, 0x3c, 0x0d, 0x6a, 0x84, + 0x12, 0x11, 0x20, 0x4c, 0x67, 0x56, 0x4b, 0xc5, 0x16, 0xf3, 0x43, 0x73, + 0xb3, 0x04, 0x70, 0xa1, 0xa5, 0x03, 0x3b, 0x85, 0x2a, 0x2c, 0x3a, 0x80, + 0xad, 0xfc, 0x8f, 0x8c, 0x17, 0x62, 0xfb, 0x06, 0x29, 0x0e, 0x55, 0x75, + 0x9d, 0x46, 0x6d, 0x67, 0xd2, 0x7e, 0xfd, 0x3b, 0xb8, 0xf6, 0x5c, 0x7f, + 0x1a, 0xd0, 0x11, 0xb9, 0x9a, 0xc6, 0x96, 0xe0, 0xba, 0x78, 0xf4, 0x56, + 0xc1, 0x91, 0x03, 0x30, 0x43, 0x0d, 0xa6, 0xcc, 0x91, 0x86, 0xcb, 0x21, + 0x9e, 0x47, 0xa8, 0xce, 0xfb, 0xc2, 0xbe, 0x58, 0x05, 0x52, 0xc3, 0x0a, + 0xf1, 0xe8, 0x73, 0x4c, 0x57, 0x2f, 0x48, 0x90, 0xc1, 0xec, 0x14, 0x22, + 0x5b, 0x2a, 0xc6, 0x41, 0xe6, 0xc2, 0x3c, 0x94, 0x94, 0x29, 0x84, 0x32, + 0x3f, 0xc5, 0x4a, 0xf9, 0x29, 0x9a, 0x72, 0xe9, 0x2d, 0x05, 0x68, 0x37, + 0xc4, 0x50, 0x54, 0x5a, 0x88, 0x49, 0x41, 0x7b, 0x40, 0xa3, 0x23, 0x68, + 0x62, 0xb4, 0x07, 0xd0, 0x9a, 0x70, 0x22, 0xdc, 0x54, 0x47, 0x55, 0x15, + 0x5b, 0x23, 0xaf, 0x0f, 0x30, 0x6d, 0xac, 0x83, 0x37, 0x34, 0x78, 0x03, + 0x41, 0x2c, 0xcd, 0x57, 0xdb, 0x4b, 0xeb, 0xf9, 0x78, 0x70, 0xd5, 0xb8, + 0x61, 0xdb, 0xac, 0x6c, 0x4a, 0x8d, 0x7f, 0xdb, 0xc9, 0x26, 0x92, 0x3f, + 0xae, 0xa1, 0x71, 0xbe, 0x17, 0x23, 0x54, 0xf5, 0x4c, 0x11, 0xb6, 0x8c, + 0x9f, 0xf6, 0xc0, 0xfe, 0x05, 0x86, 0x93, 0x24, 0x61, 0x16, 0x8b, 0xa9, + 0x01, 0x88, 0xc8, 0x6c, 0xba, 0xce, 0x80, 0x49, 0x82, 0xe1, 0x88, 0x12, + 0x16, 0x40, 0x11, 0x66, 0xc6, 0x5a, 0x55, 0x64, 0x25, 0xab, 0x21, 0x45, + 0x51, 0x6c, 0x76, 0x99, 0x03, 0x1d, 0xf5, 0x6b, 0x14, 0x78, 0x1b, 0xa2, + 0x44, 0x57, 0x29, 0x47, 0xf6, 0x3f, 0x7c, 0xe9, 0x35, 0x62, 0xb1, 0x09, + 0x01, 0x78, 0x04, 0x01, 0xe2, 0x44, 0x17, 0x47, 0x97, 0xcf, 0xe6, 0xab, + 0x5d, 0x5a, 0xca, 0xfd, 0x07, 0x48, 0x6d, 0x13, 0x36, 0x30, 0x63, 0x1e, + 0x3e, 0x00, 0x9f, 0xda, 0x23, 0xc4, 0x27, 0xf5, 0xb4, 0xc2, 0x05, 0x64, + 0x31, 0x47, 0xc0, 0xef, 0x17, 0xcc, 0x4a, 0x67, 0x4c, 0x96, 0x91, 0x77, + 0xb5, 0x0a, 0x37, 0x24, 0x25, 0xad, 0xbe, 0x65, 0x4a, 0x74, 0xca, 0xa8, + 0x87, 0xf8, 0x7c, 0xdd, 0xe4, 0x92, 0xec, 0x50, 0x27, 0x05, 0x60, 0x9b, + 0x9e, 0x31, 0x8a, 0xe6, 0xbb, 0x5c, 0xe4, 0xa9, 0xa2, 0x82, 0xf1, 0x24, + 0x44, 0x77, 0x9b, 0xba, 0xe0, 0x32, 0x0d, 0x12, 0x97, 0xd9, 0xcb, 0xbb, + 0x87, 0x61, 0x00, 0x03, 0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x9e, 0x40, 0xcd, 0xe8, 0x71, 0x76, + 0x75, 0x29, 0x14, 0x4d, 0xa3, 0x29, 0x79, 0x47, 0x55, 0x56, 0x45, 0x33, + 0x3e, 0xf0, 0x58, 0x37, 0x70, 0x98, 0xb2, 0xa1, 0x51, 0xd5, 0x11, 0x0f, + 0xce, 0x09, 0x21, 0x7d, 0x5a, 0x00, 0x55, 0xa2, 0x08, 0xf3, 0xb5, 0x83, + 0xe2, 0xc7, 0x13, 0x67, 0x72, 0x24, 0x1b, 0x85, 0xb5, 0xbb, 0x36, 0x7d, + 0xb4, 0x3c, 0x07, 0xe5, 0x48, 0x09, 0xb7, 0xa3, 0x0c, 0x82, 0xd9, 0xaf, + 0x74, 0x79, 0xab, 0x37, 0xd8, 0x49, 0xd7, 0x78, 0x91, 0x39, 0xd6, 0xbc, + 0xfa, 0xf8, 0x31, 0x46, 0x77, 0x5f, 0x6f, 0x1a, 0x63, 0x2d, 0x17, 0x91, + 0x0f, 0x0a, 0x49, 0xf6, 0x74, 0x72, 0xc1, 0x8a, 0x34, 0x39, 0xcc, 0x03, + 0x7c, 0xa4, 0x2d, 0x7e, 0xb8, 0x61, 0x09, 0xe3, 0xc4, 0x7b, 0xd9, 0x4e, + 0xc7, 0xbc, 0x99, 0xd5, 0xb8, 0x2a, 0x8f, 0x4c, 0x4d, 0x1d, 0x72, 0x47, + 0xc8, 0x47, 0x99, 0xa9, 0x05, 0x8d, 0x01, 0x84, 0x2f, 0xed, 0x69, 0x57, + 0xce, 0xb4, 0x8d, 0xd2, 0x02, 0x91, 0x22, 0xaa, 0x8f, 0xf4, 0x38, 0x84, + 0x10, 0xe1, 0xb3, 0xbb, 0xa2, 0x76, 0xc2, 0xaa, 0x54, 0x4e, 0xf9, 0x91, + 0x97, 0x3f, 0x15, 0xe7, 0xc5, 0x9b, 0x89, 0x4a, 0xab, 0x27, 0xf5, 0xce, + 0xad, 0xdd, 0xe8, 0x25, 0x33, 0x3f, 0x44, 0x03, 0x9b, 0x02, 0xe7, 0xbd, + 0xec, 0x21, 0xfc, 0x0d, 0x8f, 0x9b, 0x3a, 0x22}; + const uint8_t kEncapM[MLKEM512_ENCAPS_SEED_LEN] = { + 0x2c, 0x87, 0xaa, 0x8b, 0x11, 0x76, 0x75, 0x54, 0x74, 0xdf, 0x76, + 0x3b, 0x2a, 0xe0, 0x46, 0x35, 0x39, 0xe9, 0x53, 0xe0, 0x04, 0xc4, + 0x6a, 0x11, 0x83, 0xfd, 0x53, 0xcf, 0x84, 0xef, 0x81, 0x03}; + const uint8_t kEncapCiphertext[MLKEM512_CIPHERTEXT_BYTES] = { + 0x43, 0x1a, 0x4f, 0x1b, 0x2d, 0x2c, 0x6c, 0x00, 0xf1, 0x69, 0x0b, 0xbe, + 0x48, 0x25, 0x41, 0xef, 0x3d, 0x56, 0x37, 0x74, 0xda, 0xff, 0x83, 0x20, + 0x7f, 0x96, 0xde, 0x7e, 0x5e, 0x4a, 0x59, 0xd5, 0xd9, 0x36, 0xd9, 0x44, + 0x3a, 0xd4, 0x22, 0xe6, 0x45, 0x79, 0x3e, 0x7a, 0x60, 0xa9, 0xb0, 0xa7, + 0x6c, 0xd6, 0x72, 0xd2, 0x0c, 0x69, 0xb8, 0x2a, 0x55, 0x63, 0xdf, 0x52, + 0xd9, 0x6f, 0x9a, 0x6c, 0xdf, 0xc5, 0x6f, 0xbd, 0x4f, 0xd8, 0xd5, 0xa8, + 0xaf, 0xeb, 0x2a, 0x09, 0xd9, 0x2e, 0xc8, 0x54, 0x09, 0x47, 0x94, 0xb4, + 0xed, 0x2d, 0xb3, 0x81, 0xf0, 0x4c, 0x68, 0x43, 0x96, 0x08, 0xaa, 0x99, + 0x02, 0xa4, 0xd1, 0x68, 0x9e, 0x2e, 0xb1, 0xe5, 0xf0, 0x7a, 0x4a, 0x1c, + 0x70, 0x92, 0x62, 0xd7, 0xc2, 0xff, 0x2f, 0x81, 0xf6, 0xee, 0xaa, 0xb2, + 0xa8, 0x6a, 0x41, 0xba, 0x21, 0x0e, 0xb1, 0xbf, 0x8e, 0x75, 0xfe, 0xbc, + 0xcd, 0x1a, 0x15, 0xb4, 0xd7, 0xa7, 0xb6, 0x02, 0x57, 0xc8, 0x9d, 0x00, + 0xbd, 0x81, 0xd3, 0x9f, 0xcb, 0x8d, 0x1c, 0xe3, 0x27, 0x81, 0x02, 0x59, + 0x5d, 0xd6, 0x52, 0xf7, 0xfb, 0x7d, 0x55, 0x84, 0x87, 0x4f, 0x33, 0x27, + 0xb1, 0x74, 0x04, 0x3b, 0x35, 0x0e, 0xbd, 0x4d, 0x41, 0xfe, 0x08, 0xbd, + 0x0e, 0x85, 0x4d, 0x41, 0xcb, 0xb0, 0x27, 0xc4, 0x81, 0xda, 0x64, 0xdc, + 0x61, 0x51, 0xb8, 0x8d, 0xec, 0xec, 0xcf, 0x02, 0x2d, 0xda, 0xc2, 0xe2, + 0x27, 0x36, 0xc1, 0x47, 0xe0, 0x77, 0x32, 0x94, 0x23, 0x1c, 0x05, 0x89, + 0x96, 0x71, 0x54, 0xc5, 0x26, 0xb0, 0xb7, 0xcd, 0xd5, 0x95, 0x68, 0xee, + 0xff, 0x57, 0x49, 0xa4, 0x0c, 0xb1, 0x00, 0xc6, 0x0c, 0x64, 0x80, 0x89, + 0x76, 0x55, 0xd9, 0x6e, 0x9f, 0x64, 0xd6, 0x16, 0x84, 0xc0, 0xb3, 0x15, + 0x06, 0x46, 0x73, 0x2c, 0x19, 0x40, 0x9f, 0xe5, 0x65, 0x54, 0x0a, 0x31, + 0x89, 0x47, 0x03, 0xcf, 0x01, 0x79, 0xca, 0xe8, 0x5b, 0xc8, 0xc1, 0xa5, + 0x73, 0x26, 0x49, 0x83, 0x6e, 0x48, 0xe6, 0x76, 0x40, 0x5b, 0x95, 0x91, + 0xb6, 0x5b, 0xa2, 0x5f, 0x9b, 0x48, 0x9b, 0x9e, 0x57, 0x72, 0xaa, 0x1e, + 0xd5, 0xa0, 0x01, 0x43, 0xcb, 0x9f, 0x54, 0x49, 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6, 0x22, 0x50, 0x5f, + 0x28, 0x88, 0x21, 0x38, 0x84, 0xc0, 0xb5, 0x25, 0x22, 0x89, 0xb1, 0x1f, + 0xce, 0x5b, 0xfe, 0xeb, 0xfb, 0xef, 0x0a, 0x32, 0xce, 0xaf, 0x9c, 0x14, + 0xc6, 0x25, 0x00, 0x90, 0x02, 0x84, 0x63, 0xdb, 0x6f, 0x8d, 0x19, 0x68, + 0x4f, 0x54, 0x11, 0x08, 0xfe, 0x93, 0x4d, 0x88, 0xe7, 0xef, 0x5c, 0xce, + 0x9d, 0xae, 0xbb, 0x32, 0x70, 0x0b, 0x93, 0x97, 0x69, 0x1a, 0x68, 0x42, + 0x98, 0xc9, 0xbf, 0x1b, 0x7c, 0x22, 0xd1, 0xbc, 0xec, 0x3f, 0xca, 0xcf, + 0xbb, 0x17, 0xf2, 0xed, 0x2b, 0x98, 0xb8, 0x5e, 0x6a, 0x8f, 0xe2, 0x48, + 0x29, 0x96, 0xb5, 0xe0, 0x99, 0xe9, 0xd0, 0x21, 0x1c, 0xb9, 0x41, 0x26, + 0x14, 0xde, 0x87, 0xdc, 0x18, 0xd2, 0x36, 0x13, 0xed, 0x7f, 0x6c, 0x29, + 0xcc, 0x37, 0xb7, 0x27, 0x11, 0x6d, 0xd9, 0x01, 0xc2, 0x81, 0x79, 0x38, + 0xc2, 0x9f, 0xcd, 0x02, 0x60, 0x89, 0x33, 0x6a, 0xdd, 0xc0, 0x9e, 0xca, + 0x90, 0xde, 0x9a, 0x25, 0xa6, 0x37, 0x4f, 0xee, 0x86, 0xbc, 0xdd, 0x06, + 0xae, 0x3d, 0xaa, 0xf0, 0xb1, 0xbc, 0x5b, 0x3b, 0x27, 0x90, 0xd4, 0xd9, + 0xf7, 0x59, 0xbe, 0xf8, 0xac, 0x74, 0x36, 0x12, 0xa2, 0xbb, 0xf6, 0xe4, + 0x5d, 0xe8, 0xb2, 0x2e, 0xfa, 0x61, 0x22, 0x66, 0x25, 0xd4, 0xc3, 0x9f, + 0x34, 0x6b, 0x84, 0x4c, 0x5e, 0xbe, 0xc5, 0x35, 0x58, 0x66, 0xc0, 0x0b, + 0x72, 0x6c, 0xc1, 0x64, 0x0c, 0xb2, 0x37, 0xc3, 0x4a, 0x20, 0xa7, 0xc6, + 0x03, 0xd2, 0x51, 0xf4, 0x6e, 0x6b, 0x3b, 0x0f, 0xa7, 0x1b, 0x32, 0x76, + 0x83, 0x5e, 0x3e, 0x9d, 0xa5, 0xb9, 0x48, 0x5e, 0x78, 0x96, 0x14, 0xaf, + 0x49, 0xf1, 0xe9, 0x50, 0x4d, 0xb2, 0x52, 0x86, 0x31, 0xfb, 0xe1, 0xcd, + 0x7d, 0xbe, 0xe8, 0x51, 0x64, 0xe4, 0xc0, 0x99, 0xa2, 0x7a, 0x45, 0x83, + 0xe9, 0x24, 0x7d, 0x07, 0x8f, 0x88, 0x30, 0xb4, 0x68, 0x74, 0xc1, 0xb0, + 0x10, 0xbf, 0x3c, 0xd9, 0x0e, 0xb0, 0x77, 0x49, 0x61, 0xf2, 0x39, 0xba}; + const uint8_t kEncapSharedSecret[MLKEM512_SHARED_SECRET_LEN] = { + 0xa7, 0x72, 0xdf, 0x2d, 0xe2, 0x50, 0xac, 0x7d, 0x89, 0x6b, 0xbb, + 0x82, 0x0b, 0x57, 0xf2, 0xae, 0x05, 0xf9, 0xa4, 0x12, 0xab, 0x55, + 0xba, 0xa4, 0x21, 0xd4, 0xaf, 0x6d, 0xac, 0x62, 0x66, 0x2a}; + + uint8_t ciphertext[MLKEM512_CIPHERTEXT_BYTES] = {0}; + uint8_t shared_secret[MLKEM512_SHARED_SECRET_LEN] = {0}; + + if (ml_kem_512_encapsulate_deterministic_no_self_test( + ciphertext, shared_secret, kEncapEK, kEncapM) || + !check_test(kEncapCiphertext, ciphertext, sizeof(kEncapCiphertext), + "ML-KEM encapsulate ciphertext") || + !check_test(kEncapSharedSecret, shared_secret, sizeof(kEncapSharedSecret), + "ML-KEM encapsulate shared secret")) { + goto err; + } + + const uint8_t kDecapDK[MLKEM512_SECRET_KEY_BYTES] = { + 0x73, 0x9b, 0x8b, 0x1f, 0x6a, 0x57, 0x66, 0x31, 0x0b, 0x06, 0x19, 0x04, + 0x02, 0x14, 0x38, 0xbb, 0xd6, 0x1a, 0x14, 0xf0, 0x85, 0xfd, 0xe0, 0x29, + 0xb5, 0x33, 0x86, 0xec, 0x37, 0x61, 0xaa, 0xe7, 0x78, 0x28, 0xfb, 0x19, + 0xde, 0xdc, 0x50, 0xdd, 0xc1, 0xc3, 0x2d, 0x3a, 0x44, 0x4a, 0x15, 0x4b, + 0xf8, 0x33, 0xa8, 0x25, 0x71, 0x31, 0x5a, 0x56, 0x55, 0xfd, 0x3b, 0x06, + 0x65, 0x1c, 0x20, 0xf7, 0xb0, 0x37, 0x8d, 0x78, 0x24, 0x72, 0x68, 0x0c, + 0xfb, 0xb9, 0x1d, 0x07, 0xd2, 0x31, 0x10, 0xd8, 0xb1, 0x58, 0xe3, 0xa8, + 0xf3, 0x29, 0x5d, 0x92, 0x97, 0x64, 0x6d, 0xe5, 0x81, 0x4c, 0xe8, 0x2a, + 0xe8, 0x74, 0xa6, 0x45, 0x4c, 0x61, 0xf6, 0x5b, 0x0b, 0xed, 0x79, 0x77, + 0xce, 0x01, 0xc7, 0x69, 0x99, 0xce, 0x86, 0x75, 0x6d, 0xa2, 0x6a, 0x2f, + 0x5a, 0x09, 0x3c, 0x05, 0x70, 0x73, 0x16, 0xd9, 0x2a, 0xc2, 0xb2, 0x5e, + 0x72, 0xc2, 0x16, 0x0e, 0x60, 0x4c, 0x90, 0xc3, 0x39, 0xd8, 0xd0, 0x3f, + 0xa8, 0x45, 0x4d, 0x40, 0xc7, 0x07, 0x81, 0x33, 0x05, 0xe6, 0x0a, 0x48, + 0x89, 0x2c, 0x6d, 0x48, 0xfb, 0x18, 0x19, 0xf8, 0xa0, 0x92, 0x18, 0x62, + 0x49, 0xe5, 0x02, 0x1d, 0x83, 0x8b, 0xac, 0xe8, 0x19,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x7b, 0x34, + 0xf2, 0xe1, 0xcc, 0x95, 0xcb, 0x81, 0x85, 0xbb, 0x5e, 0x35, 0x60, 0x67, + 0x6f, 0x30, 0x27, 0x52, 0xc3, 0x82, 0x4e, 0x90, 0xbd, 0x84, 0x08, 0x1b, + 0x28, 0x89, 0x1f, 0xcd, 0xda, 0x31, 0x3f, 0x06, 0x37, 0x65, 0x59, 0x4e, + 0x41, 0xe0, 0x85, 0x2a, 0x65, 0x55, 0x1f, 0xf2, 0x50, 0xb3, 0x18, 0x8a, + 0x2a, 0x61, 0xbc, 0x5f, 0x76, 0x50, 0x3b, 0x39, 0x16, 0xf0, 0x64, 0x61, + 0xca, 0x01, 0x1f, 0xe1, 0xd1, 0x91, 0x53, 0xe2, 0x64, 0x29, 0xb0, 0x37, + 0x3a, 0x45, 0x39, 0xdf, 0x32, 0x47, 0x47, 0x76, 0xbe, 0xcb, 0xec, 0xa6, + 0x08, 0xe9, 0x70, 0x6f, 0x65, 0xad, 0x92, 0x42, 0x2b, 0xbb, 0x28, 0xb6, + 0xb9, 0xc9, 0x6c, 0xa0, 0x2b, 0x61, 0x3d, 0x5c, 0x06, 0xee, 0xe3, 0x1f, + 0x9f, 0x32, 0x22, 0x33, 0x00, 0xb2, 0x22, 0xe3, 0x95, 0x5c, 0xb0, 0x5a, + 0x1b, 0xab, 0xac, 0x60, 0x2a, 0xb3, 0x1e, 0x18, 0x74, 0x15, 0x4a, 0x83, + 0xd4, 0xbc, 0x54, 0xdc, 0xdc, 0x94, 0xd6, 0xd0, 0x5a, 0xdf, 0xbc, 0x6f, + 0x46, 0x61, 0x3d, 0x85, 0x81, 0x45, 0xed, 0xeb, 0x63, 0xf9, 0x20, 0x44, + 0x55, 0x1b, 0xb9, 0xe8, 0xbb, 0x63, 0x07, 0x10, 0x1b, 0xef, 0x5b, 0xc2, + 0x68, 0x5b, 0xcb, 0x04, 0x35, 0x3c, 0x94, 0x84, 0x3e, 0xc9, 0x94, 0x28, + 0x69, 0x89, 0x99, 0xf9, 0x95, 0x80, 0x33, 0x6a, 0x90, 0x3e, 0xb3, 0x08, + 0x08, 0xe3, 0x01, 0xa1, 0x88, 0x79, 0xb0, 0x9b, 0x8b, 0x20, 0x59, 0x68, + 0xe6, 0x24, 0x7f, 0x3a, 0x14, 0xb9, 0x00, 0x93, 0x5d, 0x80, 0x8a, 0x7c, + 0xf8, 0x21, 0x85, 0x15, 0xf3, 0xb8, 0xc1, 0x3b, 0x54, 0x07, 0x29, 0xaa, + 0x74, 0x1b, 0x42, 0x46, 0x0b, 0x41, 0x17, 0xe0, 0x55, 0x56, 0x19, 0x46, + 0x0a, 0x5a, 0x48, 0x4c, 0x52, 0x15, 0x0f, 0x3b, 0x1b, 0x60, 0x00, 0x95, + 0xd2, 0x25, 0x9f, 0x45, 0x56, 0x7a, 0x3e, 0x03, 0x4e, 0x14, 0x39, 0xaf, + 0x5e, 0xd3, 0xbc, 0x41, 0x61, 0x93, 0x52, 0x77, 0x53, 0x05, 0x29, 0x24, + 0x26, 0x18, 0x49, 0x13, 0xc2, 0x53, 0xd9, 0x54, 0x46, 0xfc, 0x45, 0x33, + 0xfe, 0x12, 0x79, 0xf5, 0x5a, 0x04, 0x9b, 0xcc, 0x70, 0xad, 0x50, 0x86, + 0xad, 0x72, 0xc7, 0x40, 0xd5, 0x3d, 0x58, 0x5b, 0x4b, 0x93, 0x20, 0x42, + 0xa2, 0x84, 0x3b, 0x69, 0x5c, 0x21, 0x9f, 0xb1, 0x3c, 0xa3, 0xc0, 0xcf, + 0x62, 0x56, 0xca, 0x82, 0xe5, 0x8a, 0x98, 0xfb, 0x79, 0x88, 0x06, 0x91, + 0x27, 0x1c, 0x1a, 0xc5, 0x30, 0x38, 0x95, 0x3c, 0x0e, 0xc6, 0x07, 0x92, + 0x06, 0xc5, 0x0c, 0x5d, 0x24, 0xcd, 0xfe, 0x80, 0x23, 0x43, 0x91, 0xba, + 0x17, 0x62, 0x19, 0x7d, 0xf1, 0x2c, 0xcd, 0x01, 0x04, 0x7b, 0x74, 0x3b, + 0x9c, 0xab, 0x2d, 0xc8, 0xab, 0xb8, 0x61, 0x19, 0x0f, 0xfc, 0x92, 0xc6, + 0xa2, 0x6b, 0x86, 0x50, 0xf6, 0xa0, 0x0d, 0xf4, 0x40, 0x4d, 0xb2, 0x54, + 0x24, 0x68, 0x6a, 0x34, 0x55, 0xc6, 0x45, 0x90, 0x51, 0x1a, 0x34, 0x3a, + 0x8c, 0x73, 0x4c, 0x55, 0x8b, 0x42, 0x74, 0xb4, 0x39, 0x77, 0x12, 0x13, + 0xed, 0x5b, 0xc6, 0x28, 0x58, 0x5f, 0x75, 0x0b, 0x67, 0xd3, 0xc0, 0x42, + 0x96, 0xdc, 0x4b, 0xda, 0x56, 0x44, 0xec, 0xd5, 0x84, 0xee, 0x87, 0x0b, + 0x46, 0xa7, 0x04, 0xe5, 0xd1, 0x9f, 0xa1, 0x37, 0x6e, 0x66, 0x88, 0x09, + 0x73, 0xab, 0x56, 0xa5, 0x16, 0x0d, 0x8b, 0x99, 0xc2, 0xb4, 0xba, 0x4e, + 0x17, 0x7c, 0x25, 0xb2, 0x4a, 0x9b, 0xdf, 0x80, 0xba, 0x1b, 0x48, 0xc2, + 0x7c, 0x88, 0xbd, 0x2c, 0xab, 0xbd, 0x98, 0x80, 0x34, 0xf3, 0x5c, 0xa7, + 0x92, 0x54, 0x9e, 0x4d, 0x57, 0x9b, 0x20, 0xa5, 0x07, 0x45, 0x47, 0x43, + 0x11, 0x97, 0xa3, 0x62, 0x7b, 0x5d, 0x7c, 0x75, 0x73, 0xfa, 0x93, 0x06, + 0x52, 0xfa, 0x99, 0x9a, 0x12, 0x89, 0x15, 0xcc, 0x01, 0x73, 0x7a, 0x08, + 0x70, 0xa3, 0x02, 0xa1, 0x51, 0x38, 0xb3, 0x85, 0x48, 0xb5, 0x9a, 0x65, + 0xd3, 0x97, 0xb6, 0xa0, 0xfc, 0xb6, 0x61, 0x23, 0xad, 0x93, 0x47, 0xc8, + 0x9c, 0xf5, 0xbe, 0x90, 0xa9, 0xac, 0xcf, 0x4a, 0x61, 0x6f, 0x42, 0x36, + 0x9a, 0x83, 0x99, 0xcf, 0xc4, 0x6e, 0x9c, 0xc6, 0xa1, 0x01, 0xfc, 0x35, + 0x3f, 0xf2, 0x27, 0xc6, 0xf2, 0x62, 0xb7, 0x95, 0xa2, 0x15, 0x70, 0x49, + 0x7a, 0x9b, 0xad, 0x2d, 0x7c, 0xbf, 0x2e, 0x87, 0x7a, 0xde, 0x82, 0xc8, + 0x37, 0xea, 0x68, 0xbc, 0x42, 0x43, 0x8d, 0xf7, 0x9e, 0xc5, 0x96, 0x31, + 0x8b, 0x57, 0x98, 0x1c, 0x35, 0x96, 0x87, 0x15, 0xa7, 0x59, 0xf4, 0x53, + 0x83, 0x5c, 0xbc, 0x27, 0xd7, 0x59, 0x4c, 0xb8, 0x65, 0xdd, 0x51, 0x15, + 0x21, 0x72, 0xb0, 0xa1, 0x36, 0xbe, 0x2a, 0x4a, 0x95, 0xed, 0x0a, 0x80, + 0x27, 0xe1, 0x5f, 0xca, 0x37, 0x35, 0x13, 0xe9, 0x8a, 0x2a, 0x32, 0xc8, + 0xe2, 0x24, 0x62, 0xff, 0xb4, 0x46, 0x43, 0x54, 0x1e, 0x8c, 0x45, 0x83, + 0x5e, 0x67, 0x81, 0xd1, 0x99, 0x8e, 0x97, 0xa9, 0x4e, 0xf4, 0x98, 0xcf, + 0x41, 0xa0, 0x80, 0x20, 0xb0, 0x9f, 0x9c, 0xac, 0x36, 0xac, 0x42, 0x28, + 0x89, 0x45, 0x58, 0xf3, 0x29, 0x61, 0x0d, 0x52, 0x88, 0x20, 0x8a, 0x9b, + 0x44, 0xf6, 0x14, 0xd8, 0x26, 0x44, 0x0a, 0x87, 0xb9, 0x20, 0xe0, 0x7c, + 0x54, 0x70, 0xc1, 0x01, 0x24, 0x5a, 0xd7, 0x78, 0x5b, 0x30, 0xa4, 0xc5, + 0x4c, 0xd3, 0xa0, 0xec, 0x08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xe0, 0xa1, 0x9f, 0x11, 0x51, + 0x07, 0x33, 0xaa, 0x07, 0xf6, 0x16, 0x02, 0xda, 0x8d, 0xbd, 0x20, 0x6a, + 0x62, 0xb6, 0xa9, 0xe1, 0x90, 0xad, 0x8d, 0xd9, 0xc1, 0x91, 0x52, 0x6d, + 0x26, 0xd7, 0x27, 0xfd, 0x15, 0x95, 0x46, 0x54, 0x71, 0xd2, 0xf0, 0x55, + 0xb1, 0x41, 0x74, 0xe7, 0x02, 0x1c, 0x84, 0x0a, 0x62, 0x17, 0x22, 0xac, + 0x0b, 0x76, 0xc3, 0xf0, 0xe4, 0x1e, 0x24, 0x9c, 0x8a, 0xa1, 0x06, 0x9c, + 0x52, 0x55, 0x38, 0x8d, 0xbb, 0xc8, 0xa9, 0xd6, 0xbd, 0xcb, 0x3b, 0x8a, + 0x2c, 0x19, 0x08, 0xf5, 0x40, 0x74, 0x54, 0x51, 0x70, 0x6d, 0x08, 0xbe, + 0xc0, 0x90, 0x2d, 0xbe, 0xca, 0x2e, 0xe9, 0x89, 0x0c, 0x2a, 0x24, 0x1d, + 0xde, 0x47, 0xc3, 0x62, 0x66, 0x16, 0xb4, 0x3c, 0x7d, 0x39, 0xf6, 0x3f, + 0x98, 0x9c, 0x62, 0x77, 0xc3, 0x0f, 0x70, 0xf9, 0x7b, 0xad, 0x09, 0x89, + 0xcb, 0x64, 0xac, 0xbe, 0xb4, 0xa4, 0x03, 0xd2, 0xa4, 0xb6, 0x57, 0x06, + 0x33, 0x89, 0x86, 0xc9, 0xa0, 0x79, 0xb1, 0x8b, 0x7d, 0x43, 0xf1, 0x19, + 0xa5, 0x14, 0xaa, 0x59, 0x06, 0x6c, 0xdc, 0x39, 0x11, 0xcc, 0x3c, 0xc4, + 0x8b, 0xec, 0x56, 0x45, 0x92, 0x7b, 0x25, 0x63, 0xa6, 0x51, 0x37, 0xb5, + 0x02, 0x56, 0xb0, 0xf3, 0xda, 0x25, 0xd5, 0xe4, 0x10, 0x92, 0x00, 0x9d, + 0x0c, 0x7b, 0xc5, 0x39, 0x8b, 0xb7, 0xcf, 0x15, 0x3c, 0xcb, 0x85, 0x4e, + 0xaf, 0xb2, 0x14, 0x40, 0x93, 0x73, 0x9b, 0x7a, 0x7c, 0xcd, 0x03, 0xc8, + 0xcb, 0xa8, 0xb2, 0xc2, 0x89, 0x2e, 0x57, 0xf9, 0x9c, 0xbd, 0x03, 0x23, + 0x4f, 0x09, 0x97, 0x52, 0xd7, 0xb1, 0x05, 0xec, 0x45, 0xc1, 0xa1, 0x53, + 0xbb, 0x30, 0x0d, 0xb7, 0x75, 0x3b, 0x3e, 0xb3, 0x0b, 0x76, 0x59, 0x56, + 0xe8, 0x37, 0xbb, 0xaa, 0x8c, 0x51, 0xab, 0xd8, 0xbe, 0x54, 0xeb, 0x64, + 0xab, 0x52, 0x29, 0x61, 0x1b, 0x4b, 0x8c, 0xee, 0xd4, 0xd7, 0x7a, 0xe3, + 0xb3, 0x93, 0x35, 0xa4, 0xa4, 0x7a, 0x68, 0xaa, 0x38, 0x50, 0x42, 0x50, + 0x82, 0x98, 0x74, 0xd0, 0xec, 0xc6, 0xdf, 0xf4, 0x98, 0x6d, 0x1a, 0xe5, + 0x8c, 0xfe, 0x53, 0x7a, 0xfd, 0x2e, 0x02, 0xb2, 0xc4, 0x4b, 0xa0, 0x88, + 0xe7, 0xf3, 0xdb, 0xd2, 0x1f, 0x9d, 0x1c, 0x02, 0x37, 0x17, 0x85, 0x74, + 0x6e, 0x66, 0x72, 0x63, 0xb5, 0x0d, 0x48, 0xc4, 0x85, 0x5a, 0xe2, 0x49, + 0xab, 0x4c, 0x80, 0xc9, 0xb4, 0x93, 0xd2, 0x2b, 0xf9, 0x59, 0xcd, 0x6e, + 0x85, 0xfd, 0x28, 0xc0, 0xcd, 0x9f, 0xae, 0xce, 0xd7, 0x0f, 0xa7, 0x90}; + const uint8_t kDecapCiphertext[MLKEM512_CIPHERTEXT_BYTES] = { + 0xaf, 0x4a, 0x00, 0x68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, 0xac, 0x20, + 0x5c, 0x61, 0x38, 0x04, 0xaf, 0x15, 0xac, 0x2c, 0x65, 0x55, 0x3b, 0x69, + 0xd5, 0xd0, 0x12, 0xcd, 0x90, 0xe5, 0x0a, 0x40, 0xfd, 0xdb, 0x8e, 0xda, + 0xa8, 0x33, 0x13, 0xb0, 0x08, 0x9b, 0x5d, 0x69, 0x97, 0x19, 0x3f, 0x21}; + const uint8_t kDecapSharedSecret[MLKEM512_SHARED_SECRET_LEN] = { + 0xbe, 0x41, 0xc0, 0x7a, 0xd0, 0x59, 0x67, 0xab, 0xf7, 0x00, 0xb8, + 0xb2, 0xe6, 0x97, 0x5e, 0x3c, 0x1e, 0x87, 0x50, 0x3c, 0xa0, 0xb5, + 0x83, 0xe1, 0xd7, 0x30, 0x46, 0x23, 0x0e, 0x26, 0x5e, 0x5a}; + const uint8_t kDecapCiphertextRejection[MLKEM512_CIPHERTEXT_BYTES] = { + 0x18, 0x1a, 0xf9, 0xb9, 0xf1, 0x63, 0xa3, 0x04, 0x9d, 0x97, 0xd8, 0x19, + 0x4b, 0x5c, 0x26, 0x35, 0x5f, 0xc9, 0xf9, 0xdc, 0xbf, 0x12, 0x05, 0x76, + 0xab, 0xe4, 0x4d, 0x71, 0xa0, 0xd9, 0x91, 0x06, 0xd5, 0x57, 0x5d, 0xb4, + 0xd1, 0x11, 0x89, 0xc0, 0xeb, 0xbd, 0x3b, 0x30, 0x9e, 0x2b, 0x7f, 0xb8, + 0x6b, 0xb2, 0x51, 0xfe, 0xbd, 0x0c, 0xb5, 0x1b, 0x34, 0x72, 0x89, 0x52, + 0xde, 0x93, 0xad, 0xf1, 0x52, 0xb9, 0xb2, 0x39, 0x27, 0x79, 0x04, 0x93, + 0x93, 0x74, 0xcd, 0x63, 0x89, 0xc9, 0x9e, 0xd2, 0x6d, 0xc9, 0xb7, 0xd7, + 0xa4, 0x82, 0x82, 0xe9, 0x1c, 0x8f, 0x51, 0x75, 0xca, 0xd4, 0xcb, 0x0c, + 0x49, 0xfb, 0x5b, 0x1d, 0x5b, 0x32, 0xfa, 0x89, 0x04, 0xd4, 0x84, 0x49, + 0xe1, 0x0a, 0x18, 0xa3, 0x99, 0x60, 0x25, 0xb1, 0x4e, 0xc7, 0x13, 0x7c, + 0x10, 0x49, 0xe8, 0x6f, 0xa0, 0xd1, 0x25, 0xb2, 0xb5, 0xe1, 0xa6, 0xd1, + 0xe8, 0xfa, 0x8d, 0x6d, 0xc1, 0xdb, 0x67, 0x25, 0x3c, 0xba, 0x44, 0xb2, + 0xa6, 0xb5, 0xf1, 0xa5, 0xe8, 0x7f, 0x05, 0x29, 0x1a, 0x03, 0xdb, 0xd2, + 0x75, 0x70, 0x70, 0x2c, 0xb7, 0x0c, 0x46, 0xe3, 0xe2, 0xd2, 0x60, 0x98, + 0x40, 0x65, 0xc9, 0x69, 0x18, 0x84, 0xd8, 0x86, 0x62, 0x32, 0x68, 0x8b, + 0x77, 0x43, 0xf2, 0x7f, 0x46, 0x92, 0xc9, 0x3e, 0x94, 0xe1, 0x05, 0x67, + 0xf6, 0x22, 0x6c, 0xef, 0xe8, 0x20, 0x30, 0xfd, 0x0a, 0x83, 0x54, 0x7a, + 0x8c, 0x0a, 0x1f, 0xf7, 0xca, 0x81, 0x26, 0x08, 0x76, 0x05, 0x68, 0xec, + 0x69, 0x28, 0xe0, 0xe6, 0x30, 0xd7, 0xe9, 0x37, 0xa9, 0x66, 0x99, 0x14, + 0x7e, 0x34, 0xbe, 0x04, 0xbb, 0xb7, 0xeb, 0xb5, 0x55, 0x07, 0xeb, 0x51, + 0x61, 0xd0, 0xe9, 0xdb, 0x13, 0xbe, 0x22, 0x15, 0xb7, 0x21, 0xe5, 0x47, + 0x41, 0xc7, 0x53, 0xe5, 0x0a, 0x50, 0xb6, 0x9c, 0x15, 0x97, 0x0c, 0xb1, + 0x2c, 0x92, 0xc4, 0x05, 0xa5, 0x08, 0xae, 0xa3, 0xce, 0x17, 0xb3, 0xa8, + 0x4e, 0x25, 0x36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x04, 0x48, 0x17, 0xec, 0x03, 0x83, + 0x2f, 0x6c, 0x0a, 0x76, 0xe2, 0xb6, 0x16, 0xbb, 0x40, 0xb2, 0xe7, 0x62, + 0x11, 0xb9, 0x1f, 0xf9, 0x69, 0xdc, 0xe0, 0xad, 0x06, 0x9f, 0xb7, 0x29, + 0x47, 0x1e, 0x95, 0xba, 0xce, 0x35, 0x8e, 0x1b, 0xbf, 0xf2, 0xbd, 0xab, + 0xd7, 0x42, 0x98, 0x57, 0xdb, 0xab, 0x72, 0x21, 0x45, 0x47, 0xaf, 0x1a, + 0xbc, 0xdb, 0x08, 0x89, 0x6e, 0xe7, 0x7f, 0x13, 0xf2, 0xd7, 0x5b, 0x17, + 0x17, 0x44, 0x6f, 0xca, 0x7d, 0xf3, 0x2e, 0xfe, 0x1c, 0x2d, 0x09, 0xdc, + 0xfd, 0x5b, 0xfa, 0xff, 0xd1, 0x9e, 0xde, 0x7e, 0x50, 0x2b, 0x63, 0x64, + 0xab, 0xe3, 0x2e, 0x84, 0x49, 0x99, 0xb4, 0x47, 0x7c, 0x99, 0x8a, 0x9f, + 0xb3, 0xc9, 0xba, 0xbb, 0xe8, 0x3c, 0x6e, 0xc6, 0x13, 0x74, 0x0c, 0x2b, + 0x04, 0x75, 0xec, 0xb7, 0x32, 0xde, 0x51, 0x64, 0x38, 0x68, 0xeb, 0xb7}; + const uint8_t kDecapSharedSecretRejection[MLKEM512_SHARED_SECRET_LEN] = { + 0x98, 0xed, 0x60, 0x0f, 0xfd, 0x9e, 0x01, 0x9f, 0x35, 0x0e, 0x0a, + 0x15, 0xd4, 0x69, 0x5b, 0xa0, 0x96, 0xce, 0x2b, 0x32, 0xc3, 0x75, + 0x24, 0x4f, 0x79, 0xa5, 0x74, 0xda, 0x06, 0xb4, 0xb1, 0xbd}; + + if (ml_kem_512_decapsulate_no_self_test(shared_secret, kDecapCiphertext, + kDecapDK) || + !check_test(kDecapSharedSecret, shared_secret, sizeof(kDecapSharedSecret), + "ML-KEM decapsulate non-rejection") || + ml_kem_512_decapsulate_no_self_test( + shared_secret, kDecapCiphertextRejection, kDecapDK) || + !check_test(kDecapSharedSecretRejection, shared_secret, + sizeof(kDecapSharedSecretRejection), + "ML-KEM decapsulate implicit rejection")) { + goto err; + } + + ret = 1; +err: + return ret; +} + #if defined(BORINGSSL_FIPS) static void run_self_test_rsa(void) { @@ -830,6 +1508,18 @@ void boringssl_ensure_ffdh_self_test(void) { CRYPTO_once(g_self_test_once_ffdh_bss_get(), run_self_test_ffdh); } +static void run_self_test_ml_kem(void) { + if (!boringssl_self_test_ml_kem()) { + BORINGSSL_FIPS_abort(); + } +} + +DEFINE_STATIC_ONCE(g_self_test_once_ml_kem); + +void boringssl_ensure_ml_kem_self_test(void) { + CRYPTO_once(g_self_test_once_ml_kem_bss_get(), run_self_test_ml_kem); +} + #endif // BORINGSSL_FIPS @@ -1306,7 +1996,8 @@ int BORINGSSL_self_test(void) { // When requested to run self tests, also run the lazy tests. !boringssl_self_test_rsa() || !boringssl_self_test_ecc() || - !boringssl_self_test_ffdh()) { + !boringssl_self_test_ffdh() || + !boringssl_self_test_ml_kem()) { return 0; } diff --git a/crypto/fipsmodule/service_indicator/internal.h b/crypto/fipsmodule/service_indicator/internal.h index b051ff62af..0f8881132b 100644 --- a/crypto/fipsmodule/service_indicator/internal.h +++ b/crypto/fipsmodule/service_indicator/internal.h @@ -56,6 +56,8 @@ void TLSKDF_verify_service_indicator(const EVP_MD *dgst, const char *label, void SSKDF_digest_verify_service_indicator(const EVP_MD *dgst); void SSKDF_hmac_verify_service_indicator(const EVP_MD *dgst); void KBKDF_ctr_hmac_verify_service_indicator(const EVP_MD *dgst); +void EVP_PKEY_encapsulate_verify_service_indicator(const EVP_PKEY_CTX* ctx); +void EVP_PKEY_decapsulate_verify_service_indicator(const EVP_PKEY_CTX* ctx); #else @@ -127,6 +129,10 @@ OPENSSL_INLINE void SSKDF_hmac_verify_service_indicator( OPENSSL_INLINE void KBKDF_ctr_hmac_verify_service_indicator(OPENSSL_UNUSED const EVP_MD *dgst) {} +OPENSSL_INLINE void EVP_PKEY_encapsulate_verify_service_indicator(OPENSSL_UNUSED const EVP_PKEY_CTX* ctx) {} + +OPENSSL_INLINE void EVP_PKEY_decapsulate_verify_service_indicator(OPENSSL_UNUSED const EVP_PKEY_CTX* ctx) {} + #endif // AWSLC_FIPS // is_fips_build is similar to |FIPS_mode| but returns 1 including in the case diff --git a/crypto/fipsmodule/service_indicator/service_indicator.c b/crypto/fipsmodule/service_indicator/service_indicator.c index 791038e071..5f02536f5a 100644 --- a/crypto/fipsmodule/service_indicator/service_indicator.c +++ b/crypto/fipsmodule/service_indicator/service_indicator.c @@ -222,7 +222,14 @@ static void evp_md_ctx_verify_service_indicator(const EVP_MD_CTX *ctx, int (*md_ok)(int md_type, int pkey_type)) { if (EVP_MD_CTX_md(ctx) == NULL) { - // Signature schemes without a prehash are currently never FIPS approved. + if(ctx->pctx->pkey->type == EVP_PKEY_ED25519) { + // FIPS 186-5: + //. 7.6 EdDSA Signature Generation + // 7.7 EdDSA Signature Verification + FIPS_service_indicator_update_state(); + return; + } + // All other signature schemes without a prehash are currently never FIPS approved. goto err; } @@ -260,14 +267,12 @@ static void evp_md_ctx_verify_service_indicator(const EVP_MD_CTX *ctx, } } - // The approved RSA key sizes for signing are 2048, 3072 and 4096 bits. - // Note: |EVP_PKEY_size| returns the size in bytes. - size_t pkey_size = EVP_PKEY_size(ctx->pctx->pkey); + // The approved RSA key sizes for signing are key sizes >= 2048 bits and bits % 2 == 0. + size_t n_bits = RSA_bits(ctx->pctx->pkey->pkey.rsa); // Check if the MD type and the RSA key size are approved. if (md_ok(md_type, pkey_type) && - ((rsa_1024_ok && pkey_size == 128) || pkey_size == 256 || - pkey_size == 384 || pkey_size == 512)) { + ((rsa_1024_ok && n_bits == 1024) || (n_bits >= 2048 && n_bits % 2 == 0))) { FIPS_service_indicator_update_state(); } } else if (pkey_type == EVP_PKEY_EC) { @@ -299,18 +304,12 @@ void ECDH_verify_service_indicator(const EC_KEY *ec_key) { void EVP_PKEY_keygen_verify_service_indicator(const EVP_PKEY *pkey) { if (pkey->type == EVP_PKEY_RSA || pkey->type == EVP_PKEY_RSA_PSS) { - // 2048, 3072 and 4096 bit keys are approved for RSA key generation. - // EVP_PKEY_size returns the size of the key in bytes. - // Note: |EVP_PKEY_size| returns the length in bytes. - size_t key_size = EVP_PKEY_size(pkey); - switch (key_size) { - case 256: - case 384: - case 512: - FIPS_service_indicator_update_state(); - break; - default: - break; + // The approved RSA key sizes for signing are key sizes >= 2048 bits and + // bits % 2 == 0, though we check bits % 128 == 0 for consistency with + // our RSA key generation. + size_t n_bits = RSA_bits(pkey->pkey.rsa); + if (n_bits >= 2048 && n_bits % 128 == 0) { + FIPS_service_indicator_update_state(); } } else if (pkey->type == EVP_PKEY_EC) { // Note: even though the function is called |EC_GROUP_get_curve_name| @@ -319,6 +318,19 @@ void EVP_PKEY_keygen_verify_service_indicator(const EVP_PKEY *pkey) { if (is_ec_fips_approved(curve_nid)) { FIPS_service_indicator_update_state(); } + } else if (pkey->type == EVP_PKEY_KEM) { + const KEM *kem = KEM_KEY_get0_kem(pkey->pkey.kem_key); + switch (kem->nid) { + case NID_MLKEM512: + case NID_MLKEM768: + case NID_MLKEM1024: + FIPS_service_indicator_update_state(); + break; + default: + break; + } + } else if (pkey->type == EVP_PKEY_ED25519) { + FIPS_service_indicator_update_state(); } } @@ -571,6 +583,36 @@ void KBKDF_ctr_hmac_verify_service_indicator(const EVP_MD *dgst) { } } +void EVP_PKEY_encapsulate_verify_service_indicator(const EVP_PKEY_CTX* ctx) { + if (ctx->pkey->type == EVP_PKEY_KEM) { + const KEM *kem = KEM_KEY_get0_kem(ctx->pkey->pkey.kem_key); + switch (kem->nid) { + case NID_MLKEM512: + case NID_MLKEM768: + case NID_MLKEM1024: + FIPS_service_indicator_update_state(); + break; + default: + break; + } + } +} + +void EVP_PKEY_decapsulate_verify_service_indicator(const EVP_PKEY_CTX* ctx) { + if (ctx->pkey->type == EVP_PKEY_KEM) { + const KEM *kem = KEM_KEY_get0_kem(ctx->pkey->pkey.kem_key); + switch (kem->nid) { + case NID_MLKEM512: + case NID_MLKEM768: + case NID_MLKEM1024: + FIPS_service_indicator_update_state(); + break; + default: + break; + } + } +} + #else uint64_t FIPS_service_indicator_before_call(void) { return 0; } diff --git a/crypto/fipsmodule/service_indicator/service_indicator_test.cc b/crypto/fipsmodule/service_indicator/service_indicator_test.cc index 6495aa795f..49bece44c5 100644 --- a/crypto/fipsmodule/service_indicator/service_indicator_test.cc +++ b/crypto/fipsmodule/service_indicator/service_indicator_test.cc @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -2012,9 +2013,8 @@ TEST(ServiceIndicatorTest, RSAKeyGen) { bssl::UniquePtr rsa(RSA_new()); ASSERT_TRUE(rsa); - // |RSA_generate_key_fips| may only be used for 2048-, 3072-, and 4096-bit - // keys. - for (const size_t bits : {512, 1024, 3071, 4095}) { + // |RSA_generate_key_fips| may only be used for bits >= 2048 && bits % 128 == 0 + for (const size_t bits : {512, 1024, 2520, 3071}) { SCOPED_TRACE(bits); rsa.reset(RSA_new()); @@ -2023,8 +2023,9 @@ TEST(ServiceIndicatorTest, RSAKeyGen) { EXPECT_EQ(approved, AWSLC_NOT_APPROVED); } - // Test that we can generate keys of the supported lengths: - for (const size_t bits : {2048, 3072, 4096}) { + // Test that we can generate keys with supported lengths, + // larger key sizes are supported but are omitted for time. + for (const size_t bits : {2048, 3072, 4096, 6144, 8192}) { SCOPED_TRACE(bits); rsa.reset(RSA_new()); @@ -2044,7 +2045,7 @@ TEST(ServiceIndicatorTest, RSAKeyGen) { ASSERT_TRUE(ctx); if (kEVPKeyGenShouldCallFIPSFunctions) { - // Test unapproved key sizes of RSA. + // Test various unapproved key sizes of RSA. for (const size_t bits : {512, 1024, 3071, 4095}) { SCOPED_TRACE(bits); CALL_SERVICE_AND_CHECK_APPROVED( @@ -2058,8 +2059,8 @@ TEST(ServiceIndicatorTest, RSAKeyGen) { raw = nullptr; } - // Test approved key sizes of RSA. - for (const size_t bits : {2048, 3072, 4096}) { + // Test various approved key sizes of RSA. + for (const size_t bits : {2048, 3072, 4096, 6144, 8192}) { SCOPED_TRACE(bits); CALL_SERVICE_AND_CHECK_APPROVED( approved, ASSERT_TRUE(EVP_PKEY_keygen_init(ctx.get()))); @@ -2094,9 +2095,6 @@ struct RSATestVector kRSATestVectors[] = { { 1536, &EVP_sha256, false, AWSLC_NOT_APPROVED, AWSLC_NOT_APPROVED }, { 1536, &EVP_sha512, true, AWSLC_NOT_APPROVED, AWSLC_NOT_APPROVED }, { 2048, &EVP_md5, false, AWSLC_NOT_APPROVED, AWSLC_NOT_APPROVED }, - { 3071, &EVP_md5, true, AWSLC_NOT_APPROVED, AWSLC_NOT_APPROVED }, - { 3071, &EVP_sha256, false, AWSLC_NOT_APPROVED, AWSLC_NOT_APPROVED }, - { 3071, &EVP_sha512, true, AWSLC_NOT_APPROVED, AWSLC_NOT_APPROVED }, { 4096, &EVP_md5, false, AWSLC_NOT_APPROVED, AWSLC_NOT_APPROVED }, // RSA test cases that are approved. @@ -2194,6 +2192,54 @@ struct RSATestVector kRSATestVectors[] = { { 4096, &EVP_sha3_256, true, AWSLC_APPROVED, AWSLC_APPROVED }, { 4096, &EVP_sha3_384, true, AWSLC_APPROVED, AWSLC_APPROVED }, { 4096, &EVP_sha3_512, true, AWSLC_APPROVED, AWSLC_APPROVED }, + + { 6144, &EVP_sha1, false, AWSLC_NOT_APPROVED, AWSLC_APPROVED }, + { 6144, &EVP_sha224, false, AWSLC_APPROVED, AWSLC_APPROVED }, + { 6144, &EVP_sha256, false, AWSLC_APPROVED, AWSLC_APPROVED }, + { 6144, &EVP_sha384, false, AWSLC_APPROVED, AWSLC_APPROVED }, + { 6144, &EVP_sha512, false, AWSLC_APPROVED, AWSLC_APPROVED }, + { 6144, &EVP_sha512_224, false, AWSLC_APPROVED, AWSLC_APPROVED }, + { 6144, &EVP_sha512_256, false, AWSLC_APPROVED, AWSLC_APPROVED }, + { 6144, &EVP_sha3_224, false, AWSLC_APPROVED, AWSLC_APPROVED }, + { 6144, &EVP_sha3_256, false, AWSLC_APPROVED, AWSLC_APPROVED }, + { 6144, &EVP_sha3_384, false, AWSLC_APPROVED, AWSLC_APPROVED }, + { 6144, &EVP_sha3_512, false, AWSLC_APPROVED, AWSLC_APPROVED }, + + { 6144, &EVP_sha1, true, AWSLC_NOT_APPROVED, AWSLC_APPROVED }, + { 6144, &EVP_sha224, true, AWSLC_APPROVED, AWSLC_APPROVED }, + { 6144, &EVP_sha256, true, AWSLC_APPROVED, AWSLC_APPROVED }, + { 6144, &EVP_sha384, true, AWSLC_APPROVED, AWSLC_APPROVED }, + { 6144, &EVP_sha512, true, AWSLC_APPROVED, AWSLC_APPROVED }, + { 6144, &EVP_sha512_224, true, AWSLC_APPROVED, AWSLC_APPROVED }, + { 6144, &EVP_sha512_256, true, AWSLC_APPROVED, AWSLC_APPROVED }, + { 6144, &EVP_sha3_224, true, AWSLC_APPROVED, AWSLC_APPROVED }, + { 6144, &EVP_sha3_256, true, AWSLC_APPROVED, AWSLC_APPROVED }, + { 6144, &EVP_sha3_384, true, AWSLC_APPROVED, AWSLC_APPROVED }, + { 6144, &EVP_sha3_512, true, AWSLC_APPROVED, AWSLC_APPROVED }, + + { 8192, &EVP_sha1, false, AWSLC_NOT_APPROVED, AWSLC_APPROVED }, + { 8192, &EVP_sha224, false, AWSLC_APPROVED, AWSLC_APPROVED }, + { 8192, &EVP_sha256, false, AWSLC_APPROVED, AWSLC_APPROVED }, + { 8192, &EVP_sha384, false, AWSLC_APPROVED, AWSLC_APPROVED }, + { 8192, &EVP_sha512, false, AWSLC_APPROVED, AWSLC_APPROVED }, + { 8192, &EVP_sha512_224, false, AWSLC_APPROVED, AWSLC_APPROVED }, + { 8192, &EVP_sha512_256, false, AWSLC_APPROVED, AWSLC_APPROVED }, + { 8192, &EVP_sha3_224, false, AWSLC_APPROVED, AWSLC_APPROVED }, + { 8192, &EVP_sha3_256, false, AWSLC_APPROVED, AWSLC_APPROVED }, + { 8192, &EVP_sha3_384, false, AWSLC_APPROVED, AWSLC_APPROVED }, + { 8192, &EVP_sha3_512, false, AWSLC_APPROVED, AWSLC_APPROVED }, + + { 8192, &EVP_sha1, true, AWSLC_NOT_APPROVED, AWSLC_APPROVED }, + { 8192, &EVP_sha224, true, AWSLC_APPROVED, AWSLC_APPROVED }, + { 8192, &EVP_sha256, true, AWSLC_APPROVED, AWSLC_APPROVED }, + { 8192, &EVP_sha384, true, AWSLC_APPROVED, AWSLC_APPROVED }, + { 8192, &EVP_sha512, true, AWSLC_APPROVED, AWSLC_APPROVED }, + { 8192, &EVP_sha512_224, true, AWSLC_APPROVED, AWSLC_APPROVED }, + { 8192, &EVP_sha512_256, true, AWSLC_APPROVED, AWSLC_APPROVED }, + { 8192, &EVP_sha3_224, true, AWSLC_APPROVED, AWSLC_APPROVED }, + { 8192, &EVP_sha3_256, true, AWSLC_APPROVED, AWSLC_APPROVED }, + { 8192, &EVP_sha3_384, true, AWSLC_APPROVED, AWSLC_APPROVED }, + { 8192, &EVP_sha3_512, true, AWSLC_APPROVED, AWSLC_APPROVED }, }; class RSAServiceIndicatorTest : public TestWithNoErrors {}; @@ -2228,20 +2274,20 @@ static RSA *GetRSAKey(unsigned bits) { return ret; } -// When using |EVP_PKEY_assign| to assign |RSA| to |EVP_PKEY|, the pointer will -// get assigned to |EVP_PKEY| and get freed along with it. -static RSA *GetRSAPSSKey(unsigned bits) { - bssl::UniquePtr e(BN_new()); - if (!e || !BN_set_word(e.get(), RSA_F4)) { +static void AssignRSAPSSKey(EVP_PKEY *pkey, unsigned bits) { + RSA *rsa = GetRSAKey(bits); + if (rsa == NULL || pkey == NULL) { abort(); } - RSA *key = RSA_new(); - if (!key || !RSA_generate_key_ex(key, bits, e.get(), nullptr)) { + // When using |EVP_PKEY_assign| to assign |RSA| to |EVP_PKEY|, the pointer + // will get assigned to |EVP_PKEY| and get freed along with it. This will not + // up the reference to RSA unlike |EVP_PKEY_assign_RSA|! So we do that after. + if (!EVP_PKEY_assign(pkey, EVP_PKEY_RSA_PSS, rsa)) { abort(); } - return key; + RSA_up_ref(rsa); } TEST_P(RSAServiceIndicatorTest, RSASigGen) { @@ -2252,8 +2298,7 @@ TEST_P(RSAServiceIndicatorTest, RSASigGen) { ASSERT_TRUE(pkey); RSA *rsa = nullptr; if(test.use_pss) { - rsa = GetRSAPSSKey(test.key_size); - ASSERT_TRUE(EVP_PKEY_assign(pkey.get(), EVP_PKEY_RSA_PSS, rsa)); + AssignRSAPSSKey(pkey.get(), test.key_size); } else { rsa = GetRSAKey(test.key_size); ASSERT_TRUE(EVP_PKEY_set1_RSA(pkey.get(), rsa)); @@ -2297,21 +2342,31 @@ TEST_P(RSAServiceIndicatorTest, RSASigGen) { &sig_len))); EXPECT_EQ(approved, test.sig_gen_expect_approved); - // Test using the one-shot |EVP_DigestSign| function for approval. md_ctx.Reset(); std::vector oneshot_output(sig_len); CALL_SERVICE_AND_CHECK_APPROVED( approved, ASSERT_TRUE(EVP_DigestSignInit(md_ctx.get(), &pctx, test.func(), nullptr, pkey.get()))); EXPECT_EQ(approved, AWSLC_NOT_APPROVED); + if (test.use_pss) { - CALL_SERVICE_AND_CHECK_APPROVED(approved, - ASSERT_TRUE(EVP_PKEY_CTX_set_rsa_padding(pctx, RSA_PKCS1_PSS_PADDING))); + CALL_SERVICE_AND_CHECK_APPROVED( + approved, + ASSERT_TRUE(EVP_PKEY_CTX_set_rsa_padding(pctx, RSA_PKCS1_PSS_PADDING))); EXPECT_EQ(approved, AWSLC_NOT_APPROVED); CALL_SERVICE_AND_CHECK_APPROVED( approved, ASSERT_TRUE(EVP_PKEY_CTX_set_rsa_pss_saltlen(pctx, -1))); EXPECT_EQ(approved, AWSLC_NOT_APPROVED); } + + // Test the one-shot |EVP_DigestSign| function to determine size. + // This should not set the indicator. + CALL_SERVICE_AND_CHECK_APPROVED( + approved, + ASSERT_TRUE(EVP_DigestSign(md_ctx.get(), nullptr, &sig_len, nullptr, 0))); + EXPECT_EQ(approved, AWSLC_NOT_APPROVED); + + // Now test using the one-shot |EVP_DigestSign| function for approval. CALL_SERVICE_AND_CHECK_APPROVED(approved, ASSERT_TRUE(EVP_DigestSign(md_ctx.get(), oneshot_output.data(), &sig_len, kPlaintext, sizeof(kPlaintext)))); @@ -2340,8 +2395,7 @@ TEST_P(RSAServiceIndicatorTest, RSASigVer) { RSA *rsa = nullptr; if(test.use_pss) { - rsa = GetRSAPSSKey(test.key_size); - ASSERT_TRUE(EVP_PKEY_assign(pkey.get(), EVP_PKEY_RSA_PSS, rsa)); + AssignRSAPSSKey(pkey.get(), test.key_size); } else { rsa = GetRSAKey(test.key_size); ASSERT_TRUE(EVP_PKEY_set1_RSA(pkey.get(), rsa)); @@ -2422,8 +2476,7 @@ TEST_P(RSAServiceIndicatorTest, ManualRSASignVerify) { RSA *rsa = nullptr; if(test.use_pss) { - rsa = GetRSAPSSKey(test.key_size); - ASSERT_TRUE(EVP_PKEY_assign(pkey.get(), EVP_PKEY_RSA_PSS, rsa)); + AssignRSAPSSKey(pkey.get(), test.key_size); } else { rsa = GetRSAKey(test.key_size); ASSERT_TRUE(EVP_PKEY_set1_RSA(pkey.get(), rsa)); @@ -4557,6 +4610,127 @@ TEST_P(KBKDFCtrHmacIndicatorTest, KBKDF) { ASSERT_EQ(vector.expectation, approved); } +TEST(ServiceIndicatorTest, ML_KEM) { + for (int nid : {NID_MLKEM512, NID_MLKEM768, NID_MLKEM1024}) { + bssl::UniquePtr ctx( + EVP_PKEY_CTX_new_id(EVP_PKEY_KEM, nullptr)); + ASSERT_TRUE(EVP_PKEY_CTX_kem_set_params(ctx.get(), nid)); + ASSERT_TRUE(EVP_PKEY_keygen_init(ctx.get())); + + FIPSStatus approved = AWSLC_NOT_APPROVED; + EVP_PKEY *raw = nullptr; + // keygen for ML-KEM algorithms should be approved + CALL_SERVICE_AND_CHECK_APPROVED(approved, EVP_PKEY_keygen(ctx.get(), &raw)); + bssl::UniquePtr pkey(raw); + ASSERT_EQ(approved, AWSLC_APPROVED); + + size_t ciphertext_len = 0; + size_t shared_secret_len = 0; + + ctx.reset(EVP_PKEY_CTX_new(pkey.get(), nullptr)); + + approved = AWSLC_NOT_APPROVED; + // encapsulate size check should not set indicator + CALL_SERVICE_AND_CHECK_APPROVED( + approved, EVP_PKEY_encapsulate(ctx.get(), nullptr, &ciphertext_len, + nullptr, &shared_secret_len)); + ASSERT_EQ(approved, AWSLC_NOT_APPROVED); + + std::vector ciphertext(ciphertext_len); + std::vector encap_shared_secret(shared_secret_len); + + // encapsulate should set indicator + CALL_SERVICE_AND_CHECK_APPROVED( + approved, + EVP_PKEY_encapsulate(ctx.get(), ciphertext.data(), &ciphertext_len, + encap_shared_secret.data(), &shared_secret_len)); + ASSERT_EQ(approved, AWSLC_APPROVED); + + shared_secret_len = 0; + approved = AWSLC_NOT_APPROVED; + // decapsulate size check should not set indicator + CALL_SERVICE_AND_CHECK_APPROVED( + approved, EVP_PKEY_decapsulate(ctx.get(), nullptr, &shared_secret_len, + ciphertext.data(), ciphertext.size())); + ASSERT_EQ(approved, AWSLC_NOT_APPROVED); + + std::vector decap_shared_secret(shared_secret_len); + // decapsulate should set indicator + CALL_SERVICE_AND_CHECK_APPROVED( + approved, EVP_PKEY_decapsulate(ctx.get(), decap_shared_secret.data(), + &shared_secret_len, ciphertext.data(), + ciphertext.size())); + ASSERT_EQ(approved, AWSLC_APPROVED); + ASSERT_EQ(encap_shared_secret, decap_shared_secret); + } +} + +TEST(ServiceIndicatorTest, ED25519KeyGen) { + FIPSStatus approved = AWSLC_NOT_APPROVED; + uint8_t private_key[ED25519_PRIVATE_KEY_LEN] = {0}; + uint8_t public_key[ED25519_PUBLIC_KEY_LEN] = {0}; + CALL_SERVICE_AND_CHECK_APPROVED(approved, + ED25519_keypair(public_key, private_key)); + ASSERT_EQ(AWSLC_APPROVED, approved); + + approved = AWSLC_NOT_APPROVED; + + bssl::UniquePtr ctx( + EVP_PKEY_CTX_new_id(EVP_PKEY_ED25519, nullptr)); + EVP_PKEY *raw = nullptr; + bssl::UniquePtr pkey(raw); + ASSERT_TRUE(EVP_PKEY_keygen_init(ctx.get())); + CALL_SERVICE_AND_CHECK_APPROVED( + approved, ASSERT_TRUE(EVP_PKEY_keygen(ctx.get(), &raw))); + ASSERT_EQ(AWSLC_APPROVED, approved); + pkey.reset(raw); +} + +TEST(ServiceIndicatorTest, ED25519SigGenVerify) { + const uint8_t MESSAGE[15] = {'E', 'D', '2', '5', '5', '1', '9', ' ', + 'M', 'E', 'S', 'S', 'A', 'G', 'E'}; + uint8_t private_key[ED25519_PRIVATE_KEY_LEN] = {0}; + uint8_t public_key[ED25519_PUBLIC_KEY_LEN] = {0}; + uint8_t signature[ED25519_SIGNATURE_LEN] = {0}; + ED25519_keypair(public_key, private_key); + + FIPSStatus approved = AWSLC_NOT_APPROVED; + CALL_SERVICE_AND_CHECK_APPROVED( + approved, ASSERT_TRUE(ED25519_sign(&signature[0], &MESSAGE[0], + sizeof(MESSAGE), private_key))); + ASSERT_EQ(AWSLC_APPROVED, approved); + + approved = AWSLC_NOT_APPROVED; + CALL_SERVICE_AND_CHECK_APPROVED( + approved, ASSERT_TRUE(ED25519_verify(&MESSAGE[0], sizeof(MESSAGE), + signature, public_key))); + ASSERT_EQ(AWSLC_APPROVED, approved); + + bssl::UniquePtr pkey(EVP_PKEY_new_raw_private_key( + EVP_PKEY_ED25519, NULL, &private_key[0], ED25519_PRIVATE_KEY_SEED_LEN)); + + bssl::UniquePtr mdctx(EVP_MD_CTX_new()); + CALL_SERVICE_AND_CHECK_APPROVED( + approved, EVP_DigestSignInit(mdctx.get(), NULL, NULL, NULL, pkey.get())); + ASSERT_EQ(AWSLC_NOT_APPROVED, approved); + size_t sig_out_len = sizeof(signature); + CALL_SERVICE_AND_CHECK_APPROVED( + approved, + ASSERT_TRUE(EVP_DigestSign(mdctx.get(), &signature[0], &sig_out_len, + &MESSAGE[0], sizeof(MESSAGE)))); + ASSERT_EQ(AWSLC_APPROVED, approved); + ASSERT_EQ(sizeof(signature), sig_out_len); + + mdctx.reset(EVP_MD_CTX_new()); + ASSERT_TRUE(EVP_DigestVerifyInit(mdctx.get(), NULL, NULL, NULL, pkey.get())); + approved = AWSLC_NOT_APPROVED; + CALL_SERVICE_AND_CHECK_APPROVED( + approved, ASSERT_TRUE(EVP_DigestVerify(mdctx.get(), &signature[0], + sizeof(signature), &MESSAGE[0], + sizeof(MESSAGE)))); + ASSERT_EQ(AWSLC_APPROVED, approved); +} + // Verifies that the awslc_version_string is as expected. // Since this is running in FIPS mode it should end in FIPS // Update this when the AWS-LC version number is modified diff --git a/crypto/internal.h b/crypto/internal.h index 70bff348ac..a9ae95f521 100644 --- a/crypto/internal.h +++ b/crypto/internal.h @@ -1296,6 +1296,11 @@ void boringssl_ensure_ecc_self_test(void); // if unsuccessful. void boringssl_ensure_ffdh_self_test(void); +// boringssl_ensure_ml_kem_self_test checks whether the ML-KEM self-test +// has been run in this address space. If not, it runs it and crashes the +// address space if unsuccessful. +void boringssl_ensure_ml_kem_self_test(void); + #else // Outside of FIPS mode, the lazy tests are no-ops. @@ -1303,6 +1308,7 @@ void boringssl_ensure_ffdh_self_test(void); OPENSSL_INLINE void boringssl_ensure_rsa_self_test(void) {} OPENSSL_INLINE void boringssl_ensure_ecc_self_test(void) {} OPENSSL_INLINE void boringssl_ensure_ffdh_self_test(void) {} +OPENSSL_INLINE void boringssl_ensure_ml_kem_self_test(void) {} #endif // FIPS diff --git a/include/openssl/rsa.h b/include/openssl/rsa.h index 726f19d4ac..f684987070 100644 --- a/include/openssl/rsa.h +++ b/include/openssl/rsa.h @@ -313,6 +313,11 @@ OPENSSL_EXPORT int RSA_meth_set_sign(RSA_METHOD *meth, // is called with event=2 when the n'th prime is rejected as unsuitable and // with event=3 when a suitable value for |p| is found. // +// Note: |bits| is expected to be divisible by 128, and if not will be rounded +// down to the nearest valid value. For example, requesting 3071 bits will +// provide a key that is 2944 bits. |RSA_bits| can be used to verify the +// RSA modulus size of the returned key. +// // It returns one on success or zero on error. OPENSSL_EXPORT int RSA_generate_key_ex(RSA *rsa, int bits, const BIGNUM *e, BN_GENCB *cb); diff --git a/util/fipstools/acvp/acvptool/test/expected/RSA.bz2 b/util/fipstools/acvp/acvptool/test/expected/RSA.bz2 index 9a71e2a352..78a65f6b6e 100644 Binary files a/util/fipstools/acvp/acvptool/test/expected/RSA.bz2 and b/util/fipstools/acvp/acvptool/test/expected/RSA.bz2 differ diff --git a/util/fipstools/acvp/acvptool/test/tests.json b/util/fipstools/acvp/acvptool/test/tests.json index ee530fffa9..06ab78558e 100644 --- a/util/fipstools/acvp/acvptool/test/tests.json +++ b/util/fipstools/acvp/acvptool/test/tests.json @@ -29,6 +29,7 @@ {"Wrapper": "modulewrapper", "In": "vectors/kdf-components.bz2", "Out": "expected/kdf-components.bz2"}, {"Wrapper": "modulewrapper", "In": "vectors/RSA.bz2", "Out": "expected/RSA.bz2"}, {"Wrapper": "modulewrapper", "In": "vectors/RSA-SigGen.bz2"}, +{"Wrapper": "modulewrapper", "In": "vectors/RSA-KeyGen.bz2"}, {"Wrapper": "modulewrapper", "In": "vectors/TLS-1.2-KDF.bz2", "Out": "expected/TLS-1.2-KDF.bz2"}, {"Wrapper": "modulewrapper", "In": "vectors/PBKDF.bz2", "Out": "expected/PBKDF.bz2"}, {"Wrapper": "modulewrapper", "In": "vectors/KDA-HKDF.bz2", "Out": "expected/KDA-HKDF.bz2"}, diff --git a/util/fipstools/acvp/acvptool/test/vectors/RSA-KeyGen.bz2 b/util/fipstools/acvp/acvptool/test/vectors/RSA-KeyGen.bz2 new file mode 100644 index 0000000000..5e0b2bebfd Binary files /dev/null and b/util/fipstools/acvp/acvptool/test/vectors/RSA-KeyGen.bz2 differ diff --git a/util/fipstools/acvp/acvptool/test/vectors/RSA-SigGen.bz2 b/util/fipstools/acvp/acvptool/test/vectors/RSA-SigGen.bz2 index 01b698a402..0f8c151d8b 100644 Binary files a/util/fipstools/acvp/acvptool/test/vectors/RSA-SigGen.bz2 and b/util/fipstools/acvp/acvptool/test/vectors/RSA-SigGen.bz2 differ diff --git a/util/fipstools/acvp/acvptool/test/vectors/RSA.bz2 b/util/fipstools/acvp/acvptool/test/vectors/RSA.bz2 index 4898469cad..3212fdb979 100644 Binary files a/util/fipstools/acvp/acvptool/test/vectors/RSA.bz2 and b/util/fipstools/acvp/acvptool/test/vectors/RSA.bz2 differ diff --git a/util/fipstools/acvp/modulewrapper/modulewrapper.cc b/util/fipstools/acvp/modulewrapper/modulewrapper.cc index 61dcf0843f..6fe7c29d5e 100644 --- a/util/fipstools/acvp/modulewrapper/modulewrapper.cc +++ b/util/fipstools/acvp/modulewrapper/modulewrapper.cc @@ -636,223 +636,224 @@ static bool GetConfig(const Span args[], "capabilities": [{ "randPQ": "probable", "properties": [{ - "modulo": 2048, - "primeTest": [ - "2powSecStr" - ], - "pMod8": 0, - "qMod8": 0 - },{ - "modulo": 3072, - "primeTest": [ - "2powSecStr" - ], - "pMod8": 0, - "qMod8": 0 - },{ - "modulo": 4096, - "primeTest": [ - "2powSecStr" - ], - "pMod8": 0, - "qMod8": 0 + "modulo": 2048, + "primeTest": [ + "2powSecStr" + ], + "pMod8": 0, + "qMod8": 0 + },{ + "modulo": 3072, + "primeTest": [ + "2powSecStr" + ], + "pMod8": 0, + "qMod8": 0 + },{ + "modulo": 4096, + "primeTest": [ + "2powSecStr" + ], + "pMod8": 0, + "qMod8": 0 + },{ + "modulo": 6144, + "primeTest": [ + "2powSecStr" + ], + "pMod8": 0, + "qMod8": 0 + },{ + "modulo": 8192, + "primeTest": [ + "2powSecStr" + ], + "pMod8": 0, + "qMod8": 0 }] }] - }, - { + },)" + R"({ "algorithm": "RSA", "mode": "sigGen", "revision": "FIPS186-5", "capabilities": [{ "sigType": "pkcs1v1.5", "properties": [{ - "modulo": 2048, - "hashPair": [{ - "hashAlg": "SHA2-224" - }, { - "hashAlg": "SHA2-256" - }, { - "hashAlg": "SHA2-384" - }, { - "hashAlg": "SHA2-512" - }, { - "hashAlg": "SHA2-512/224" - }, { - "hashAlg": "SHA2-512/256" - }, { - "hashAlg": "SHA3-224" - }, { - "hashAlg": "SHA3-256" - }, { - "hashAlg": "SHA3-384" - }, { - "hashAlg": "SHA3-512" - }] - }] - },{ - "sigType": "pkcs1v1.5", - "properties": [{ - "modulo": 3072, - "hashPair": [{ - "hashAlg": "SHA2-224" - }, { - "hashAlg": "SHA2-256" - }, { - "hashAlg": "SHA2-384" - }, { - "hashAlg": "SHA2-512" - }, { - "hashAlg": "SHA2-512/224" - }, { - "hashAlg": "SHA2-512/256" - }, { - "hashAlg": "SHA3-224" - }, { - "hashAlg": "SHA3-256" - }, { - "hashAlg": "SHA3-384" - }, { - "hashAlg": "SHA3-512" - }] - }] - },{ - "sigType": "pkcs1v1.5", - "properties": [{ - "modulo": 4096, - "hashPair": [{ - "hashAlg": "SHA2-224" - }, { - "hashAlg": "SHA2-256" - }, { - "hashAlg": "SHA2-384" - }, { - "hashAlg": "SHA2-512" - }, { - "hashAlg": "SHA2-512/224" - }, { - "hashAlg": "SHA2-512/256" - }, { - "hashAlg": "SHA3-224" - }, { - "hashAlg": "SHA3-256" - }, { - "hashAlg": "SHA3-384" - }, { - "hashAlg": "SHA3-512" + "modulo": 2048, + "hashPair": [{ + "hashAlg": "SHA2-224" + },{ + "hashAlg": "SHA2-256" + },{ + "hashAlg": "SHA2-384" + },{ + "hashAlg": "SHA2-512" + },{ + "hashAlg": "SHA2-512/224" + },{ + "hashAlg": "SHA2-512/256" + },{ + "hashAlg": "SHA3-224" + },{ + "hashAlg": "SHA3-256" + },{ + "hashAlg": "SHA3-384" + },{ + "hashAlg": "SHA3-512" + }] + },{ + "modulo": 3072, + "hashPair": [{ + "hashAlg": "SHA2-224" + },{ + "hashAlg": "SHA2-256" + },{ + "hashAlg": "SHA2-384" + },{ + "hashAlg": "SHA2-512" + },{ + "hashAlg": "SHA2-512/224" + },{ + "hashAlg": "SHA2-512/256" + },{ + "hashAlg": "SHA3-224" + },{ + "hashAlg": "SHA3-256" + },{ + "hashAlg": "SHA3-384" + },{ + "hashAlg": "SHA3-512" + }] + },{ + "modulo": 4096, + "hashPair": [{ + "hashAlg": "SHA2-224" + },{ + "hashAlg": "SHA2-256" + },{ + "hashAlg": "SHA2-384" + },{ + "hashAlg": "SHA2-512" + },{ + "hashAlg": "SHA2-512/224" + },{ + "hashAlg": "SHA2-512/256" + },{ + "hashAlg": "SHA3-224" + },{ + "hashAlg": "SHA3-256" + },{ + "hashAlg": "SHA3-384" + },{ + "hashAlg": "SHA3-512" + }] }] - }] - },)" - R"({ - "sigType": "pss", - "properties": [{ - "modulo": 2048, - "maskFunction": ["mgf1"], - "hashPair": [{ - "hashAlg": "SHA2-224", - "saltLen": 28 - }, { - "hashAlg": "SHA2-256", - "saltLen": 32 - }, { - "hashAlg": "SHA2-384", - "saltLen": 48 - }, { - "hashAlg": "SHA2-512", - "saltLen": 64 - }, { - "hashAlg": "SHA2-512/224", - "saltLen": 28 - }, { - "hashAlg": "SHA2-512/256", - "saltLen": 32 - }, { - "hashAlg": "SHA3-224", - "saltLen": 28 - }, { - "hashAlg": "SHA3-256", - "saltLen": 32 - }, { - "hashAlg": "SHA3-384", - "saltLen": 48 - }, { - "hashAlg": "SHA3-512", - "saltLen": 64 - }] - }] - },{ - "sigType": "pss", - "properties": [{ - "modulo": 3072, - "maskFunction": ["mgf1"], - "hashPair": [{ - "hashAlg": "SHA2-224", - "saltLen": 28 - }, { - "hashAlg": "SHA2-256", - "saltLen": 32 - }, { - "hashAlg": "SHA2-384", - "saltLen": 48 - }, { - "hashAlg": "SHA2-512", - "saltLen": 64 - }, { - "hashAlg": "SHA2-512/224", - "saltLen": 28 - }, { - "hashAlg": "SHA2-512/256", - "saltLen": 32 - }, { - "hashAlg": "SHA3-224", - "saltLen": 28 - }, { - "hashAlg": "SHA3-256", - "saltLen": 32 - }, { - "hashAlg": "SHA3-384", - "saltLen": 48 - }, { - "hashAlg": "SHA3-512", - "saltLen": 64 - }] - }] - },{ - "sigType": "pss", - "properties": [{ - "modulo": 4096, - "maskFunction": ["mgf1"], - "hashPair": [{ - "hashAlg": "SHA2-224", - "saltLen": 28 - }, { - "hashAlg": "SHA2-256", - "saltLen": 32 - }, { - "hashAlg": "SHA2-384", - "saltLen": 48 - }, { - "hashAlg": "SHA2-512", - "saltLen": 64 - }, { - "hashAlg": "SHA2-512/224", - "saltLen": 28 - }, { - "hashAlg": "SHA2-512/256", - "saltLen": 32 - }, { - "hashAlg": "SHA3-224", - "saltLen": 28 - }, { - "hashAlg": "SHA3-256", - "saltLen": 32 - }, { - "hashAlg": "SHA3-384", - "saltLen": 48 - }, { - "hashAlg": "SHA3-512", - "saltLen": 64 + },{ + "sigType": "pss", + "properties": [{ + "modulo": 2048, + "maskFunction": ["mgf1"], + "hashPair": [{ + "hashAlg": "SHA2-224", + "saltLen": 28 + },{ + "hashAlg": "SHA2-256", + "saltLen": 32 + },{ + "hashAlg": "SHA2-384", + "saltLen": 48 + },{ + "hashAlg": "SHA2-512", + "saltLen": 64 + },{ + "hashAlg": "SHA2-512/224", + "saltLen": 28 + },{ + "hashAlg": "SHA2-512/256", + "saltLen": 32 + },{ + "hashAlg": "SHA3-224", + "saltLen": 28 + },{ + "hashAlg": "SHA3-256", + "saltLen": 32 + },{ + "hashAlg": "SHA3-384", + "saltLen": 48 + },{ + "hashAlg": "SHA3-512", + "saltLen": 64 + }] + },{ + "modulo": 3072, + "maskFunction": ["mgf1"], + "hashPair": [{ + "hashAlg": "SHA2-224", + "saltLen": 28 + },{ + "hashAlg": "SHA2-256", + "saltLen": 32 + },{ + "hashAlg": "SHA2-384", + "saltLen": 48 + },{ + "hashAlg": "SHA2-512", + "saltLen": 64 + },{ + "hashAlg": "SHA2-512/224", + "saltLen": 28 + },{ + "hashAlg": "SHA2-512/256", + "saltLen": 32 + },{ + "hashAlg": "SHA3-224", + "saltLen": 28 + },{ + "hashAlg": "SHA3-256", + "saltLen": 32 + },{ + "hashAlg": "SHA3-384", + "saltLen": 48 + },{ + "hashAlg": "SHA3-512", + "saltLen": 64 + }] + },{ + "modulo": 4096, + "maskFunction": ["mgf1"], + "hashPair": [{ + "hashAlg": "SHA2-224", + "saltLen": 28 + },{ + "hashAlg": "SHA2-256", + "saltLen": 32 + },{ + "hashAlg": "SHA2-384", + "saltLen": 48 + },{ + "hashAlg": "SHA2-512", + "saltLen": 64 + },{ + "hashAlg": "SHA2-512/224", + "saltLen": 28 + },{ + "hashAlg": "SHA2-512/256", + "saltLen": 32 + },{ + "hashAlg": "SHA3-224", + "saltLen": 28 + },{ + "hashAlg": "SHA3-256", + "saltLen": 32 + },{ + "hashAlg": "SHA3-384", + "saltLen": 48 + },{ + "hashAlg": "SHA3-512", + "saltLen": 64 + }] }] - }] }] },)" R"({ @@ -862,256 +863,270 @@ static bool GetConfig(const Span args[], "pubExpMode": "fixed", "fixedPubExp": "010001", "capabilities": [{ - "sigType": "pkcs1v1.5", - "properties": [{ - "modulo": 1024, - "hashPair": [{ - "hashAlg": "SHA-1" - }] - }, { - "modulo": 2048, - "hashPair": [{ - "hashAlg": "SHA-1" - }] - }, { - "modulo": 3072, - "hashPair": [{ - "hashAlg": "SHA-1" - }] - }, { - "modulo": 4096, - "hashPair": [{ - "hashAlg": "SHA-1" - }] - }] - },{ - "sigType": "pss", - "properties": [{ - "modulo": 1024, - "hashPair": [{ - "hashAlg": "SHA-1", - "saltLen": 20 - }] - }, { - "modulo": 2048, - "hashPair": [{ - "hashAlg": "SHA-1", - "saltLen": 20 + "sigType": "pkcs1v1.5", + "properties": [{ + "modulo": 1024, + "hashPair": [{ + "hashAlg": "SHA-1" + },{ + "hashAlg": "SHA2-224" + },{ + "hashAlg": "SHA2-256" + },{ + "hashAlg": "SHA2-384" + },{ + "hashAlg": "SHA2-512" + },{ + "hashAlg": "SHA2-512/224" + },{ + "hashAlg": "SHA2-512/256" + }] + },{ + "modulo": 2048, + "hashPair": [{ + "hashAlg": "SHA-1" + }] + },{ + "modulo": 3072, + "hashPair": [{ + "hashAlg": "SHA-1" + }] + },{ + "modulo": 4096, + "hashPair": [{ + "hashAlg": "SHA-1" + }] }] - }, { - "modulo": 3072, - "hashPair": [{ - "hashAlg": "SHA-1", - "saltLen": 20 - }] - }, { - "modulo": 4096, - "hashPair": [{ - "hashAlg": "SHA-1", - "saltLen": 20 + },{ + "sigType": "pss", + "properties": [{ + "modulo": 1024, + "hashPair": [{ + "hashAlg": "SHA-1", + "saltLen": 20 + },{ + "hashAlg": "SHA2-224", + "saltLen": 28 + },{ + "hashAlg": "SHA2-256", + "saltLen": 32 + },{ + "hashAlg": "SHA2-384", + "saltLen": 48 + },{ + "hashAlg": "SHA2-512/224", + "saltLen": 28 + },{ + "hashAlg": "SHA2-512/256", + "saltLen": 32 + }] + },{ + "modulo": 2048, + "hashPair": [{ + "hashAlg": "SHA-1", + "saltLen": 20 + }] + },{ + "modulo": 3072, + "hashPair": [{ + "hashAlg": "SHA-1", + "saltLen": 20 + }] + },{ + "modulo": 4096, + "hashPair": [{ + "hashAlg": "SHA-1", + "saltLen": 20 + }] }] - }] }] - }, - { + },)" + R"({ "algorithm": "RSA", "mode": "sigVer", "revision": "FIPS186-5", "pubExpMode": "fixed", "fixedPubExp": "010001", "capabilities": [{ - "sigType": "pkcs1v1.5", - "properties": [{ - "modulo": 2048, - "hashPair": [{ - "hashAlg": "SHA2-224" - }, { - "hashAlg": "SHA2-256" - }, { - "hashAlg": "SHA2-384" - }, { - "hashAlg": "SHA2-512" - }, { - "hashAlg": "SHA2-512/224" - }, { - "hashAlg": "SHA2-512/256" - }, { - "hashAlg": "SHA3-224" - }, { - "hashAlg": "SHA3-256" - }, { - "hashAlg": "SHA3-384" - }, { - "hashAlg": "SHA3-512" - }] - }] - },{ - "sigType": "pkcs1v1.5", - "properties": [{ - "modulo": 3072, - "hashPair": [{ - "hashAlg": "SHA2-224" - }, { - "hashAlg": "SHA2-256" - }, { - "hashAlg": "SHA2-384" - }, { - "hashAlg": "SHA2-512" - }, { - "hashAlg": "SHA2-512/224" - }, { - "hashAlg": "SHA2-512/256" - }, { - "hashAlg": "SHA3-224" - }, { - "hashAlg": "SHA3-256" - }, { - "hashAlg": "SHA3-384" - }, { - "hashAlg": "SHA3-512" + "sigType": "pkcs1v1.5", + "properties": [{ + "modulo": 2048, + "hashPair": [{ + "hashAlg": "SHA2-224" + },{ + "hashAlg": "SHA2-256" + },{ + "hashAlg": "SHA2-384" + },{ + "hashAlg": "SHA2-512" + },{ + "hashAlg": "SHA2-512/224" + },{ + "hashAlg": "SHA2-512/256" + },{ + "hashAlg": "SHA3-224" + },{ + "hashAlg": "SHA3-256" + },{ + "hashAlg": "SHA3-384" + },{ + "hashAlg": "SHA3-512" + }] + },{ + "modulo": 3072, + "hashPair": [{ + "hashAlg": "SHA2-224" + },{ + "hashAlg": "SHA2-256" + },{ + "hashAlg": "SHA2-384" + },{ + "hashAlg": "SHA2-512" + },{ + "hashAlg": "SHA2-512/224" + },{ + "hashAlg": "SHA2-512/256" + },{ + "hashAlg": "SHA3-224" + },{ + "hashAlg": "SHA3-256" + },{ + "hashAlg": "SHA3-384" + },{ + "hashAlg": "SHA3-512" + }] + },{ + "modulo": 4096, + "hashPair": [{ + "hashAlg": "SHA2-224" + },{ + "hashAlg": "SHA2-256" + },{ + "hashAlg": "SHA2-384" + },{ + "hashAlg": "SHA2-512" + },{ + "hashAlg": "SHA2-512/224" + },{ + "hashAlg": "SHA2-512/256" + },{ + "hashAlg": "SHA3-224" + },{ + "hashAlg": "SHA3-256" + },{ + "hashAlg": "SHA3-384" + },{ + "hashAlg": "SHA3-512" + }] }] - }] - },{ - "sigType": "pkcs1v1.5", - "properties": [{ - "modulo": 4096, - "hashPair": [{ - "hashAlg": "SHA2-224" - }, { - "hashAlg": "SHA2-256" - }, { - "hashAlg": "SHA2-384" - }, { - "hashAlg": "SHA2-512" - }, { - "hashAlg": "SHA2-512/224" - }, { - "hashAlg": "SHA2-512/256" - }, { - "hashAlg": "SHA3-224" - }, { - "hashAlg": "SHA3-256" - }, { - "hashAlg": "SHA3-384" - }, { - "hashAlg": "SHA3-512" - }] - }] - },)" - R"({ - "sigType": "pss", - "properties": [{ - "modulo": 2048, - "maskFunction": ["mgf1"], - "hashPair": [{ - "hashAlg": "SHA2-224", - "saltLen": 28 - }, { - "hashAlg": "SHA2-256", - "saltLen": 32 - }, { - "hashAlg": "SHA2-384", - "saltLen": 48 - }, { - "hashAlg": "SHA2-512", - "saltLen": 64 - }, { - "hashAlg": "SHA2-512/224", - "saltLen": 28 - }, { - "hashAlg": "SHA2-512/256", - "saltLen": 32 - }, { - "hashAlg": "SHA3-224", - "saltLen": 28 - }, { - "hashAlg": "SHA3-256", - "saltLen": 32 - }, { - "hashAlg": "SHA3-384", - "saltLen": 48 - }, { - "hashAlg": "SHA3-512", - "saltLen": 64 - }] - }] - },{ - "sigType": "pss", - "properties": [{ - "modulo": 3072, - "maskFunction": ["mgf1"], - "hashPair": [{ - "hashAlg": "SHA2-224", - "saltLen": 28 - }, { - "hashAlg": "SHA2-256", - "saltLen": 32 - }, { - "hashAlg": "SHA2-384", - "saltLen": 48 - }, { - "hashAlg": "SHA2-512", - "saltLen": 64 - }, { - "hashAlg": "SHA2-512/224", - "saltLen": 28 - }, { - "hashAlg": "SHA2-512/256", - "saltLen": 32 - }, { - "hashAlg": "SHA3-224", - "saltLen": 28 - }, { - "hashAlg": "SHA3-256", - "saltLen": 32 - }, { - "hashAlg": "SHA3-384", - "saltLen": 48 - }, { - "hashAlg": "SHA3-512", - "saltLen": 64 - }] - }] - },{ - "sigType": "pss", - "properties": [{ - "modulo": 4096, - "maskFunction": ["mgf1"], - "hashPair": [{ - "hashAlg": "SHA2-224", - "saltLen": 28 - }, { - "hashAlg": "SHA2-256", - "saltLen": 32 - }, { - "hashAlg": "SHA2-384", - "saltLen": 48 - }, { - "hashAlg": "SHA2-512", - "saltLen": 64 - }, { - "hashAlg": "SHA2-512/224", - "saltLen": 28 - }, { - "hashAlg": "SHA2-512/256", - "saltLen": 32 - }, { - "hashAlg": "SHA3-224", - "saltLen": 28 - }, { - "hashAlg": "SHA3-256", - "saltLen": 32 - }, { - "hashAlg": "SHA3-384", - "saltLen": 48 - }, { - "hashAlg": "SHA3-512", - "saltLen": 64 + },{ + "sigType": "pss", + "properties": [{ + "modulo": 2048, + "maskFunction": ["mgf1"], + "hashPair": [{ + "hashAlg": "SHA2-224", + "saltLen": 28 + },{ + "hashAlg": "SHA2-256", + "saltLen": 32 + },{ + "hashAlg": "SHA2-384", + "saltLen": 48 + },{ + "hashAlg": "SHA2-512", + "saltLen": 64 + },{ + "hashAlg": "SHA2-512/224", + "saltLen": 28 + },{ + "hashAlg": "SHA2-512/256", + "saltLen": 32 + },{ + "hashAlg": "SHA3-224", + "saltLen": 28 + },{ + "hashAlg": "SHA3-256", + "saltLen": 32 + },{ + "hashAlg": "SHA3-384", + "saltLen": 48 + },{ + "hashAlg": "SHA3-512", + "saltLen": 64 + }] + },{ + "modulo": 3072, + "maskFunction": ["mgf1"], + "hashPair": [{ + "hashAlg": "SHA2-224", + "saltLen": 28 + },{ + "hashAlg": "SHA2-256", + "saltLen": 32 + },{ + "hashAlg": "SHA2-384", + "saltLen": 48 + },{ + "hashAlg": "SHA2-512", + "saltLen": 64 + },{ + "hashAlg": "SHA2-512/224", + "saltLen": 28 + },{ + "hashAlg": "SHA2-512/256", + "saltLen": 32 + },{ + "hashAlg": "SHA3-224", + "saltLen": 28 + },{ + "hashAlg": "SHA3-256", + "saltLen": 32 + },{ + "hashAlg": "SHA3-384", + "saltLen": 48 + },{ + "hashAlg": "SHA3-512", + "saltLen": 64 + }] + },{ + "modulo": 4096, + "maskFunction": ["mgf1"], + "hashPair": [{ + "hashAlg": "SHA2-224", + "saltLen": 28 + },{ + "hashAlg": "SHA2-256", + "saltLen": 32 + },{ + "hashAlg": "SHA2-384", + "saltLen": 48 + },{ + "hashAlg": "SHA2-512", + "saltLen": 64 + },{ + "hashAlg": "SHA2-512/224", + "saltLen": 28 + },{ + "hashAlg": "SHA2-512/256", + "saltLen": 32 + },{ + "hashAlg": "SHA3-224", + "saltLen": 28 + },{ + "hashAlg": "SHA3-256", + "saltLen": 32 + },{ + "hashAlg": "SHA3-384", + "saltLen": 48 + },{ + "hashAlg": "SHA3-512", + "saltLen": 64 + }] }] - }] }] - }, - { + },)" + R"({ "algorithm": "CMAC-AES", "acvptoolTestOnly": true, "revision": "1.0",