From: Joachim Vandersmissen Date: Fri, 18 Apr 2025 16:07:53 +0000 (-0500) Subject: Move to error state if ML-DSA / SLH-DSA PCT fails X-Git-Tag: openssl-3.5.1~150 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=17eb8a94f49ff1e8972b0171052e72aea469afa5;p=thirdparty%2Fopenssl.git Move to error state if ML-DSA / SLH-DSA PCT fails As required by FIPS 140-3 AS10.07, if the module fails a self-test, it shall enter an error state. Reviewed-by: Matt Caswell Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/27436) (cherry picked from commit 17cacc1a1c85b65ba94f76890810d2ada6243f38) --- diff --git a/providers/implementations/keymgmt/ml_dsa_kmgmt.c b/providers/implementations/keymgmt/ml_dsa_kmgmt.c index ee5463caec8..5e9023e3339 100644 --- a/providers/implementations/keymgmt/ml_dsa_kmgmt.c +++ b/providers/implementations/keymgmt/ml_dsa_kmgmt.c @@ -474,8 +474,10 @@ static void *ml_dsa_gen(void *genctx, int evp_type) goto err; } #ifdef FIPS_MODULE - if (!ml_dsa_pairwise_test(key)) + if (!ml_dsa_pairwise_test(key)) { + ossl_set_error_state(OSSL_SELF_TEST_TYPE_PCT); goto err; + } #endif return key; err: diff --git a/providers/implementations/keymgmt/slh_dsa_kmgmt.c b/providers/implementations/keymgmt/slh_dsa_kmgmt.c index b67367b449c..1b89b75ef5a 100644 --- a/providers/implementations/keymgmt/slh_dsa_kmgmt.c +++ b/providers/implementations/keymgmt/slh_dsa_kmgmt.c @@ -346,8 +346,10 @@ static void *slh_dsa_gen(void *genctx, const char *alg) gctx->entropy, gctx->entropy_len)) goto err; #ifdef FIPS_MODULE - if (!slh_dsa_fips140_pairwise_test(ctx, key, gctx->libctx)) + if (!slh_dsa_fips140_pairwise_test(ctx, key, gctx->libctx)) { + ossl_set_error_state(OSSL_SELF_TEST_TYPE_PCT); goto err; + } #endif /* FIPS_MODULE */ ossl_slh_dsa_hash_ctx_free(ctx); return key;