Skip to content

Commit 63d0f58

Browse files
authored
Merge pull request #18 from gardenlinux/feat/fips/patches
feat: various fips patches
2 parents aab0324 + 77895f2 commit 63d0f58

5 files changed

Lines changed: 198 additions & 0 deletions
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
From ba4c73c0665a7cb40e1dbab64f778edaa4c19bfd Mon Sep 17 00:00:00 2001
2+
From: nkraetzschmar <9020053+nkraetzschmar@users.noreply.github.com>
3+
Date: Mon, 29 Jun 2026 12:12:09 +0000
4+
Subject: [PATCH] providers: flag RSA decrypt with no padding as unapproved
5+
6+
FIPS 140-3 IG 2.4.B treats raw RSA primitives as component algorithms
7+
that must not be used standalone. Patch 0032 already gates the encrypt
8+
path against pad_mode == RSA_NO_PADDING; mirror that behaviour in
9+
rsa_decrypt() so a decrypt call with no padding goes through
10+
OSSL_FIPS_IND_ON_UNAPPROVED and reuses the existing
11+
rsa_no_padding_disabled config flag.
12+
---
13+
providers/fips/self_test_kats.c | 2 +-
14+
providers/implementations/asymciphers/rsa_enc.c | 8 ++++++++
15+
2 files changed, 9 insertions(+), 1 deletion(-)
16+
17+
diff --git a/providers/fips/self_test_kats.c b/providers/fips/self_test_kats.c
18+
index e17cd2cd8e..e96aba1613 100644
19+
--- a/providers/fips/self_test_kats.c
20+
+++ b/providers/fips/self_test_kats.c
21+
@@ -880,7 +880,7 @@ static int self_test_asym_cipher(const ST_KAT_ASYM_CIPHER *t, OSSL_SELF_TEST *st
22+
23+
OSSL_SELF_TEST_onbegin(st, OSSL_SELF_TEST_TYPE_KAT_ASYM_CIPHER, t->desc);
24+
25+
- if (t->encrypt && strcmp(t->algorithm, "RSA") == 0)
26+
+ if (strcmp(t->algorithm, "RSA") == 0)
27+
extra_postinit_params = rsa_encrypt_fips_params;
28+
29+
bnctx = BN_CTX_new_ex(libctx);
30+
diff --git a/providers/implementations/asymciphers/rsa_enc.c b/providers/implementations/asymciphers/rsa_enc.c
31+
index 330fc71f7b..fa5181c99e 100644
32+
--- a/providers/implementations/asymciphers/rsa_enc.c
33+
+++ b/providers/implementations/asymciphers/rsa_enc.c
34+
@@ -259,6 +259,14 @@ static int rsa_decrypt(void *vprsactx, unsigned char *out, size_t *outlen,
35+
ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_PADDING_MODE);
36+
return 0;
37+
}
38+
+ if (prsactx->pad_mode == RSA_NO_PADDING
39+
+ && !OSSL_FIPS_IND_ON_UNAPPROVED(prsactx, OSSL_FIPS_IND_SETTABLE2,
40+
+ prsactx->libctx, "RSA Decrypt",
41+
+ "No padding",
42+
+ ossl_fips_config_rsa_no_padding_disabled)) {
43+
+ ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_PADDING_MODE);
44+
+ return 0;
45+
+ }
46+
#endif
47+
48+
if (prsactx->pad_mode == RSA_PKCS1_WITH_TLS_PADDING) {
49+
--
50+
2.47.3
51+
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
From 4dbdc399da1c996d6aaaa85cf6d40ea91ca81695 Mon Sep 17 00:00:00 2001
2+
From: nkraetzschmar <9020053+nkraetzschmar@users.noreply.github.com>
3+
Date: Mon, 29 Jun 2026 12:51:47 +0000
4+
Subject: [PATCH] providers: flag ECDSA standalone-component signing as
5+
unapproved
6+
7+
FIPS 140-3 IG 2.4.B treats raw asymmetric primitives as component
8+
algorithms that may only be claimed as approved in the context of a
9+
higher-level approved operation. Patch 0034 already gates ECDSA verify
10+
with verify_message == 0; mirror that on the sign side by gating
11+
ecdsa_sign_directly() when operation == EVP_PKEY_OP_SIGN (i.e.
12+
EVP_PKEY_sign() rather than EVP_PKEY_sign_message()) through
13+
OSSL_FIPS_IND_ON_UNAPPROVED, behind a new
14+
ecdsa_sign_component_disallowed config flag.
15+
---
16+
providers/fips/include/fips_indicator_params.inc | 1 +
17+
providers/implementations/signature/ecdsa_sig.c | 8 ++++++++
18+
util/perl/OpenSSL/paramnames.pm | 1 +
19+
3 files changed, 10 insertions(+)
20+
21+
diff --git a/providers/fips/include/fips_indicator_params.inc b/providers/fips/include/fips_indicator_params.inc
22+
index 6e2a2dc845..45cd3463bc 100644
23+
--- a/providers/fips/include/fips_indicator_params.inc
24+
+++ b/providers/fips/include/fips_indicator_params.inc
25+
@@ -38,3 +38,4 @@ OSSL_FIPS_PARAM(slh_dsa_sign_entropy_check, SLH_DSA_SIGN_ENTROPY_CHECK, 1)
26+
OSSL_FIPS_PARAM(slh_dsa_seed_check, SLH_DSA_SEED_CHECK, 1)
27+
OSSL_FIPS_PARAM(rsa_verify_min_modulus_disallowed, RSA_VERIFY_MIN_MODULUS_DISABLED, 1)
28+
OSSL_FIPS_PARAM(ecdsa_p192_verify_disallowed, ECDSA_P192_VERIFY_DISABLED, 1)
29+
+OSSL_FIPS_PARAM(ecdsa_sign_component_disallowed, ECDSA_SIGN_COMPONENT_DISABLED, 1)
30+
diff --git a/providers/implementations/signature/ecdsa_sig.c b/providers/implementations/signature/ecdsa_sig.c
31+
index 08f8ee828e..25709b6fa0 100644
32+
--- a/providers/implementations/signature/ecdsa_sig.c
33+
+++ b/providers/implementations/signature/ecdsa_sig.c
34+
@@ -331,6 +331,14 @@ static int ecdsa_sign_directly(void *vctx,
35+
if (!ossl_prov_is_running())
36+
return 0;
37+
38+
+#ifdef FIPS_MODULE
39+
+ if (ctx->operation == EVP_PKEY_OP_SIGN
40+
+ && !OSSL_FIPS_IND_ON_UNAPPROVED(ctx, OSSL_FIPS_IND_SETTABLE4,
41+
+ ctx->libctx, "ECDSA Sign", "Component signing",
42+
+ ossl_fips_config_ecdsa_sign_component_disallowed))
43+
+ return 0;
44+
+#endif
45+
+
46+
if (sig == NULL) {
47+
*siglen = ecsize;
48+
return 1;
49+
diff --git a/util/perl/OpenSSL/paramnames.pm b/util/perl/OpenSSL/paramnames.pm
50+
index 7f3859aa90..cf3b28b09a 100644
51+
--- a/util/perl/OpenSSL/paramnames.pm
52+
+++ b/util/perl/OpenSSL/paramnames.pm
53+
@@ -54,6 +54,7 @@ my %params = (
54+
'PROV_PARAM_RSA_NO_PAD_DISABLED' => "rsa-no-pad-disabled", # uint
55+
'PROV_PARAM_RSA_VERIFY_MIN_MODULUS_DISABLED' => "rsa-verify-min-modulus-disabled", # uint
56+
'PROV_PARAM_ECDSA_P192_VERIFY_DISABLED' => "ecdsa-p192-verify-disabled", # uint
57+
+ 'PROV_PARAM_ECDSA_SIGN_COMPONENT_DISABLED' => "ecdsa-sign-component-disabled", # uint
58+
'PROV_PARAM_HKDF_KEY_CHECK' => "hkdf-key-check", # uint
59+
'PROV_PARAM_KBKDF_KEY_CHECK' => "kbkdf-key-check", # uint
60+
'PROV_PARAM_TLS13_KDF_KEY_CHECK' => "tls13-kdf-key-check", # uint
61+
--
62+
2.47.3
63+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
From f2b2545d228c209994d6cacd00e6844722b18ab7 Mon Sep 17 00:00:00 2001
2+
From: nkraetzschmar <9020053+nkraetzschmar@users.noreply.github.com>
3+
Date: Mon, 29 Jun 2026 13:12:06 +0000
4+
Subject: [PATCH] providers: flag RSA verify with no padding as unapproved
5+
6+
FIPS 140-3 IG 2.4.B does not list the RSA signature verification
7+
primitive among the components that may be validated; running
8+
EVP_PKEY_verify() against a raw RSA modular exponentiation with
9+
RSA_NO_PADDING therefore must not be reported as an approved service.
10+
Patch 0039 already gates the equivalent sign-side path; add the
11+
matching hook in rsa_verify_directly() reusing the existing
12+
rsa_no_padding_disabled config flag.
13+
---
14+
providers/implementations/signature/rsa_sig.c | 7 +++++++
15+
1 file changed, 7 insertions(+)
16+
17+
diff --git a/providers/implementations/signature/rsa_sig.c b/providers/implementations/signature/rsa_sig.c
18+
index a6b7123709..cfe2a2381c 100644
19+
--- a/providers/implementations/signature/rsa_sig.c
20+
+++ b/providers/implementations/signature/rsa_sig.c
21+
@@ -1074,6 +1074,13 @@ static int rsa_verify_directly(PROV_RSA_CTX *prsactx,
22+
ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY_LENGTH);
23+
return 0;
24+
}
25+
+ if (prsactx->pad_mode == RSA_NO_PADDING
26+
+ && !OSSL_FIPS_IND_ON_UNAPPROVED(prsactx, OSSL_FIPS_IND_SETTABLE7,
27+
+ prsactx->libctx, "RSA Verify", "No padding",
28+
+ ossl_fips_config_rsa_no_padding_disabled)) {
29+
+ ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_PADDING_MODE);
30+
+ return 0;
31+
+ }
32+
#endif
33+
34+
if (prsactx->md != NULL) {
35+
--
36+
2.47.3
37+
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
From 5c7d0f954e55c04c1f7ae22d6219e02b69b6e06b Mon Sep 17 00:00:00 2001
2+
From: nkraetzschmar <9020053+nkraetzschmar@users.noreply.github.com>
3+
Date: Mon, 29 Jun 2026 15:15:56 +0000
4+
Subject: [PATCH] providers: flag hybrid ML-KEM keygen and check as unapproved
5+
6+
Patch 0046 marked the X25519MLKEM768, X448MLKEM1024, SecP256r1MLKEM768
7+
and SecP384r1MLKEM1024 hybrid schemes as unapproved in the FIPS
8+
provider's KEM dispatch table, which makes encapsulation and
9+
decapsulation report non-approved. The keymgmt dispatch table for the
10+
same schemes was left at FIPS_DEFAULT_PROPERTIES, so EVP_PKEY_keygen
11+
and EVP_PKEY_check still report approved. Flip those four entries to
12+
FIPS_UNAPPROVED_PROPERTIES as well.
13+
---
14+
providers/fips/fipsprov.c | 8 ++++----
15+
1 file changed, 4 insertions(+), 4 deletions(-)
16+
17+
diff --git a/providers/fips/fipsprov.c b/providers/fips/fipsprov.c
18+
index 54de206b17..c03f240219 100644
19+
--- a/providers/fips/fipsprov.c
20+
+++ b/providers/fips/fipsprov.c
21+
@@ -623,15 +623,15 @@ static const OSSL_ALGORITHM fips_keymgmt[] = {
22+
{ PROV_NAMES_ML_KEM_1024, FIPS_DEFAULT_PROPERTIES, ossl_ml_kem_1024_keymgmt_functions,
23+
PROV_DESCS_ML_KEM_1024 },
24+
#if !defined(OPENSSL_NO_ECX)
25+
- { PROV_NAMES_X25519MLKEM768, FIPS_DEFAULT_PROPERTIES, ossl_mlx_x25519_kem_kmgmt_functions,
26+
+ { PROV_NAMES_X25519MLKEM768, FIPS_UNAPPROVED_PROPERTIES, ossl_mlx_x25519_kem_kmgmt_functions,
27+
PROV_DESCS_X25519MLKEM768 },
28+
- { PROV_NAMES_X448MLKEM1024, FIPS_DEFAULT_PROPERTIES, ossl_mlx_x448_kem_kmgmt_functions,
29+
+ { PROV_NAMES_X448MLKEM1024, FIPS_UNAPPROVED_PROPERTIES, ossl_mlx_x448_kem_kmgmt_functions,
30+
PROV_DESCS_X448MLKEM1024 },
31+
#endif
32+
#if !defined(OPENSSL_NO_EC)
33+
- { PROV_NAMES_SecP256r1MLKEM768, FIPS_DEFAULT_PROPERTIES, ossl_mlx_p256_kem_kmgmt_functions,
34+
+ { PROV_NAMES_SecP256r1MLKEM768, FIPS_UNAPPROVED_PROPERTIES, ossl_mlx_p256_kem_kmgmt_functions,
35+
PROV_DESCS_SecP256r1MLKEM768 },
36+
- { PROV_NAMES_SecP384r1MLKEM1024, FIPS_DEFAULT_PROPERTIES, ossl_mlx_p384_kem_kmgmt_functions,
37+
+ { PROV_NAMES_SecP384r1MLKEM1024, FIPS_UNAPPROVED_PROPERTIES, ossl_mlx_p384_kem_kmgmt_functions,
38+
PROV_DESCS_SecP384r1MLKEM1024 },
39+
#endif
40+
#endif
41+
--
42+
2.47.3
43+

upstream_patches/series

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,7 @@ rsa_kem-test-RSA_public_encrypt-result-in-RSASVE.patch
4747
0044-FIPS-ML-KEM-encap-key-check.patch
4848
0045-FIPS-ML-KEM-decap-key-check.patch
4949
0046-disable-hybrid-MLKEM-in-FIPS-mode.patch
50+
0047-FIPS-RSA-no-padding-decrypt-indicator.patch
51+
0048-FIPS-ECDSA-sign-component-indicator.patch
52+
0049-FIPS-RSA-no-padding-verify-indicator.patch
53+
0050-disable-hybrid-MLKEM-keygen-and-check.patch

0 commit comments

Comments
 (0)