|
| 1 | +From c88b5029780cb2e4354dbd276e3d3fa02e33e4a4 Mon Sep 17 00:00:00 2001 |
| 2 | +From: nkraetzschmar <9020053+nkraetzschmar@users.noreply.github.com> |
| 3 | +Date: Thu, 11 Jun 2026 23:00:27 +0000 |
| 4 | +Subject: [PATCH] providers: add FIPS SLH-DSA keygen seed indicator |
| 5 | + |
| 6 | +Mark SLH-DSA key pair generation using OSSL_PKEY_PARAM_SLH_DSA_SEED |
| 7 | +(caller-provided entropy) as unapproved in FIPS mode unless tolerated |
| 8 | +via indicator. Section 3.1 of FIPS 205 requires the SK.seed, SK.prf |
| 9 | +and PK.seed values to be retrieved from an approved RBG inside the |
| 10 | +module and explicitly forbids passing them in from outside. |
| 11 | + |
| 12 | +Wire the corresponding KAT to opt out of strict mode so the |
| 13 | +deterministic SLH-DSA keygen self-test still passes. |
| 14 | +--- |
| 15 | + .../fips/include/fips_indicator_params.inc | 1 + |
| 16 | + providers/fips/self_test_kats.c | 6 +++++ |
| 17 | + .../implementations/keymgmt/slh_dsa_kmgmt.c | 27 +++++++++++++++++++ |
| 18 | + util/perl/OpenSSL/paramnames.pm | 2 ++ |
| 19 | + 4 files changed, 36 insertions(+) |
| 20 | + |
| 21 | +diff --git a/providers/fips/include/fips_indicator_params.inc b/providers/fips/include/fips_indicator_params.inc |
| 22 | +index 168dd6c968..de0e372548 100644 |
| 23 | +--- a/providers/fips/include/fips_indicator_params.inc |
| 24 | ++++ b/providers/fips/include/fips_indicator_params.inc |
| 25 | +@@ -34,3 +34,4 @@ OSSL_FIPS_PARAM(ml_kem_ikme_check, ML_KEM_IKME_CHECK, 1) |
| 26 | + OSSL_FIPS_PARAM(ml_kem_seed_check, ML_KEM_SEED_CHECK, 1) |
| 27 | + OSSL_FIPS_PARAM(ml_dsa_seed_check, ML_DSA_SEED_CHECK, 1) |
| 28 | + OSSL_FIPS_PARAM(slh_dsa_sign_entropy_check, SLH_DSA_SIGN_ENTROPY_CHECK, 1) |
| 29 | ++OSSL_FIPS_PARAM(slh_dsa_seed_check, SLH_DSA_SEED_CHECK, 1) |
| 30 | +diff --git a/providers/fips/self_test_kats.c b/providers/fips/self_test_kats.c |
| 31 | +index f856c7ffab..e17cd2cd8e 100644 |
| 32 | +--- a/providers/fips/self_test_kats.c |
| 33 | ++++ b/providers/fips/self_test_kats.c |
| 34 | +@@ -644,6 +644,10 @@ static int self_test_asym_keygen(const ST_KAT_ASYM_KEYGEN *t, OSSL_SELF_TEST *st |
| 35 | + ST_KAT_PARAM_INT(OSSL_PKEY_PARAM_FIPS_ML_DSA_SEED_CHECK, seed_check), |
| 36 | + ST_KAT_PARAM_END() |
| 37 | + }; |
| 38 | ++ const ST_KAT_PARAM slh_dsa_keygen_fips_params[] = { |
| 39 | ++ ST_KAT_PARAM_INT(OSSL_PKEY_PARAM_FIPS_SLH_DSA_SEED_CHECK, seed_check), |
| 40 | ++ ST_KAT_PARAM_END() |
| 41 | ++ }; |
| 42 | + |
| 43 | + OSSL_SELF_TEST_onbegin(st, OSSL_SELF_TEST_TYPE_KAT_ASYM_KEYGEN, t->desc); |
| 44 | + |
| 45 | +@@ -655,6 +659,8 @@ static int self_test_asym_keygen(const ST_KAT_ASYM_KEYGEN *t, OSSL_SELF_TEST *st |
| 46 | + extra_keygen_params = ml_kem_keygen_fips_params; |
| 47 | + else if (strncmp(t->algorithm, "ML-DSA-", 7) == 0) |
| 48 | + extra_keygen_params = ml_dsa_keygen_fips_params; |
| 49 | ++ else if (strncmp(t->algorithm, "SLH-DSA-", 8) == 0) |
| 50 | ++ extra_keygen_params = slh_dsa_keygen_fips_params; |
| 51 | + key_params = kat_params_to_ossl_params(libctx, t->keygen_params, |
| 52 | + extra_keygen_params, NULL); |
| 53 | + if (key_params == NULL) |
| 54 | +diff --git a/providers/implementations/keymgmt/slh_dsa_kmgmt.c b/providers/implementations/keymgmt/slh_dsa_kmgmt.c |
| 55 | +index 8a67621390..88963e5c4d 100644 |
| 56 | +--- a/providers/implementations/keymgmt/slh_dsa_kmgmt.c |
| 57 | ++++ b/providers/implementations/keymgmt/slh_dsa_kmgmt.c |
| 58 | +@@ -18,6 +18,7 @@ |
| 59 | + #include "prov/implementations.h" |
| 60 | + #include "prov/providercommon.h" |
| 61 | + #include "prov/provider_ctx.h" |
| 62 | ++#include "prov/securitycheck.h" |
| 63 | + |
| 64 | + #ifdef FIPS_MODULE |
| 65 | + static int slh_dsa_fips140_pairwise_test(const SLH_DSA_KEY *key, |
| 66 | +@@ -49,6 +50,7 @@ struct slh_dsa_gen_ctx { |
| 67 | + char *propq; |
| 68 | + uint8_t entropy[SLH_DSA_MAX_N * 3]; |
| 69 | + size_t entropy_len; |
| 70 | ++ OSSL_FIPS_IND_DECLARE |
| 71 | + }; |
| 72 | + |
| 73 | + static void *slh_dsa_new_key(void *provctx, const char *alg) |
| 74 | +@@ -275,6 +277,7 @@ static void *slh_dsa_gen_init(void *provctx, int selection, |
| 75 | + |
| 76 | + if ((gctx = OPENSSL_zalloc(sizeof(*gctx))) != NULL) { |
| 77 | + gctx->libctx = libctx; |
| 78 | ++ OSSL_FIPS_IND_INIT(gctx) |
| 79 | + if (!slh_dsa_gen_set_params(gctx, params)) { |
| 80 | + OPENSSL_free(gctx); |
| 81 | + gctx = NULL; |
| 82 | +@@ -387,6 +390,16 @@ static int slh_dsa_gen_set_params(void *genctx, const OSSL_PARAM params[]) |
| 83 | + if (gctx == NULL) |
| 84 | + return 0; |
| 85 | + |
| 86 | ++#ifdef FIPS_MODULE |
| 87 | ++ if (!OSSL_FIPS_IND_SET_CTX_PARAM( |
| 88 | ++ gctx, |
| 89 | ++ OSSL_FIPS_IND_SETTABLE0, |
| 90 | ++ params, |
| 91 | ++ OSSL_PKEY_PARAM_FIPS_SLH_DSA_SEED_CHECK |
| 92 | ++ )) |
| 93 | ++ return 0; |
| 94 | ++#endif |
| 95 | ++ |
| 96 | + p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_SLH_DSA_SEED); |
| 97 | + if (p != NULL) { |
| 98 | + void *vp = gctx->entropy; |
| 99 | +@@ -396,6 +409,20 @@ static int slh_dsa_gen_set_params(void *genctx, const OSSL_PARAM params[]) |
| 100 | + gctx->entropy_len = 0; |
| 101 | + return 0; |
| 102 | + } |
| 103 | ++#ifdef FIPS_MODULE |
| 104 | ++ if (!OSSL_FIPS_IND_ON_UNAPPROVED( |
| 105 | ++ gctx, |
| 106 | ++ OSSL_FIPS_IND_SETTABLE0, |
| 107 | ++ gctx->libctx, |
| 108 | ++ "SLH-DSA", |
| 109 | ++ "Explicit key generation seed", |
| 110 | ++ ossl_fips_config_slh_dsa_seed_check |
| 111 | ++ )) { |
| 112 | ++ OPENSSL_cleanse(gctx->entropy, gctx->entropy_len); |
| 113 | ++ gctx->entropy_len = 0; |
| 114 | ++ return 0; |
| 115 | ++ } |
| 116 | ++#endif |
| 117 | + } |
| 118 | + |
| 119 | + p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_PROPERTIES); |
| 120 | +diff --git a/util/perl/OpenSSL/paramnames.pm b/util/perl/OpenSSL/paramnames.pm |
| 121 | +index 9f0d2009d7..240b29cba3 100644 |
| 122 | +--- a/util/perl/OpenSSL/paramnames.pm |
| 123 | ++++ b/util/perl/OpenSSL/paramnames.pm |
| 124 | +@@ -66,6 +66,7 @@ my %params = ( |
| 125 | + 'PROV_PARAM_ML_KEM_SEED_CHECK' => "ml-kem-seed-check", # uint |
| 126 | + 'PROV_PARAM_ML_DSA_SEED_CHECK' => "ml-dsa-seed-check", # uint |
| 127 | + 'PROV_PARAM_SLH_DSA_SIGN_ENTROPY_CHECK' => "slh-dsa-sign-entropy-check", # uint |
| 128 | ++ 'PROV_PARAM_SLH_DSA_SEED_CHECK' => "slh-dsa-seed-check", # uint |
| 129 | + |
| 130 | + # Self test callback parameters |
| 131 | + 'PROV_PARAM_SELF_TEST_PHASE' => "st-phase",# utf8_string |
| 132 | +@@ -458,6 +459,7 @@ my %params = ( |
| 133 | + |
| 134 | + # SLH_DSA Key generation parameters |
| 135 | + 'PKEY_PARAM_SLH_DSA_SEED' => "seed", |
| 136 | ++ 'PKEY_PARAM_FIPS_SLH_DSA_SEED_CHECK' => '*PROV_PARAM_SLH_DSA_SEED_CHECK', |
| 137 | + |
| 138 | + # Key Exchange parameters |
| 139 | + 'EXCHANGE_PARAM_PAD' => "pad",# uint |
| 140 | +-- |
| 141 | +2.47.3 |
| 142 | + |
0 commit comments