|
|
1ac26c |
From a325a23bc83f4efd60130001c417ca5b96bdbff1 Mon Sep 17 00:00:00 2001
|
|
|
1ac26c |
From: Clemens Lang <cllang@redhat.com>
|
|
|
1ac26c |
Date: Thu, 17 Nov 2022 19:33:02 +0100
|
|
|
1ac26c |
Subject: [PATCH 1/3] signature: Add indicator for PSS salt length
|
|
|
1ac26c |
MIME-Version: 1.0
|
|
|
1ac26c |
Content-Type: text/plain; charset=UTF-8
|
|
|
1ac26c |
Content-Transfer-Encoding: 8bit
|
|
|
1ac26c |
|
|
|
1ac26c |
FIPS 186-4 section 5 "The RSA Digital Signature Algorithm", subsection
|
|
|
1ac26c |
5.5 "PKCS #1" says: "For RSASSA-PSS […] the length (in bytes) of the
|
|
|
1ac26c |
salt (sLen) shall satisfy 0 ≤ sLen ≤ hLen, where hLen is the length of
|
|
|
1ac26c |
the hash function output block (in bytes)."
|
|
|
1ac26c |
|
|
|
1ac26c |
It is not exactly clear from this text whether hLen refers to the
|
|
|
1ac26c |
message digest or the hash function used for the mask generation
|
|
|
1ac26c |
function MGF1. PKCS#1 v2.1 suggests it is the former:
|
|
|
1ac26c |
|
|
|
1ac26c |
| Typical salt lengths in octets are hLen (the length of the output of
|
|
|
1ac26c |
| the hash function Hash) and 0. In both cases the security of
|
|
|
1ac26c |
| RSASSA-PSS can be closely related to the hardness of inverting RSAVP1.
|
|
|
1ac26c |
| Bellare and Rogaway [4] give a tight lower bound for the security of
|
|
|
1ac26c |
| the original RSA-PSS scheme, which corresponds roughly to the former
|
|
|
1ac26c |
| case, while Coron [12] gives a lower bound for the related Full Domain
|
|
|
1ac26c |
| Hashing scheme, which corresponds roughly to the latter case. In [13]
|
|
|
1ac26c |
| Coron provides a general treatment with various salt lengths ranging
|
|
|
1ac26c |
| from 0 to hLen; see [27] for discussion. See also [31], which adapts
|
|
|
1ac26c |
| the security proofs in [4][13] to address the differences between the
|
|
|
1ac26c |
| original and the present version of RSA-PSS as listed in Note 1 above.
|
|
|
1ac26c |
|
|
|
1ac26c |
Since OpenSSL defaults to creating signatures with the maximum salt
|
|
|
1ac26c |
length, blocking the use of longer salts would probably lead to
|
|
|
1ac26c |
significant problems in practice. Instead, introduce an explicit
|
|
|
1ac26c |
indicator that can be obtained from the EVP_PKEY_CTX object using
|
|
|
1ac26c |
EVP_PKEY_CTX_get_params() with the
|
|
|
1ac26c |
OSSL_SIGNATURE_PARAM_REDHAT_FIPS_INDICATOR
|
|
|
1ac26c |
parameter.
|
|
|
1ac26c |
|
|
|
1ac26c |
Signed-off-by: Clemens Lang <cllang@redhat.com>
|
|
|
1ac26c |
---
|
|
|
1ac26c |
include/openssl/core_names.h | 1 +
|
|
|
1ac26c |
include/openssl/evp.h | 4 ++++
|
|
|
1ac26c |
providers/implementations/signature/rsa_sig.c | 18 ++++++++++++++++++
|
|
|
1ac26c |
3 files changed, 23 insertions(+)
|
|
|
1ac26c |
|
|
|
1ac26c |
diff --git a/include/openssl/core_names.h b/include/openssl/core_names.h
|
|
|
1ac26c |
index 94fab83193..69c59f0b46 100644
|
|
|
1ac26c |
--- a/include/openssl/core_names.h
|
|
|
1ac26c |
+++ b/include/openssl/core_names.h
|
|
|
1ac26c |
@@ -453,6 +453,7 @@ extern "C" {
|
|
|
1ac26c |
#define OSSL_SIGNATURE_PARAM_MGF1_PROPERTIES \
|
|
|
1ac26c |
OSSL_PKEY_PARAM_MGF1_PROPERTIES
|
|
|
1ac26c |
#define OSSL_SIGNATURE_PARAM_DIGEST_SIZE OSSL_PKEY_PARAM_DIGEST_SIZE
|
|
|
1ac26c |
+#define OSSL_SIGNATURE_PARAM_REDHAT_FIPS_INDICATOR "redhat-fips-indicator"
|
|
|
1ac26c |
|
|
|
1ac26c |
/* Asym cipher parameters */
|
|
|
1ac26c |
#define OSSL_ASYM_CIPHER_PARAM_DIGEST OSSL_PKEY_PARAM_DIGEST
|
|
|
1ac26c |
diff --git a/include/openssl/evp.h b/include/openssl/evp.h
|
|
|
1ac26c |
index a5e78efd6e..f239200465 100644
|
|
|
1ac26c |
--- a/include/openssl/evp.h
|
|
|
1ac26c |
+++ b/include/openssl/evp.h
|
|
|
1ac26c |
@@ -797,6 +797,10 @@ __owur int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm,
|
|
|
1ac26c |
__owur int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm,
|
|
|
1ac26c |
int *outl);
|
|
|
1ac26c |
|
|
|
1ac26c |
+# define EVP_SIGNATURE_REDHAT_FIPS_INDICATOR_UNDETERMINED 0
|
|
|
1ac26c |
+# define EVP_SIGNATURE_REDHAT_FIPS_INDICATOR_APPROVED 1
|
|
|
1ac26c |
+# define EVP_SIGNATURE_REDHAT_FIPS_INDICATOR_NOT_APPROVED 2
|
|
|
1ac26c |
+
|
|
|
1ac26c |
__owur int EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s,
|
|
|
1ac26c |
EVP_PKEY *pkey);
|
|
|
1ac26c |
__owur int EVP_SignFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s,
|
|
|
1ac26c |
diff --git a/providers/implementations/signature/rsa_sig.c b/providers/implementations/signature/rsa_sig.c
|
|
|
1ac26c |
index 49e7f9158a..0c45008a00 100644
|
|
|
1ac26c |
--- a/providers/implementations/signature/rsa_sig.c
|
|
|
1ac26c |
+++ b/providers/implementations/signature/rsa_sig.c
|
|
|
1ac26c |
@@ -1127,6 +1127,21 @@ static int rsa_get_ctx_params(void *vprsactx, OSSL_PARAM *params)
|
|
|
1ac26c |
}
|
|
|
1ac26c |
}
|
|
|
1ac26c |
|
|
|
1ac26c |
+#ifdef FIPS_MODULE
|
|
|
1ac26c |
+ p = OSSL_PARAM_locate(params, OSSL_SIGNATURE_PARAM_REDHAT_FIPS_INDICATOR);
|
|
|
1ac26c |
+ if (p != NULL) {
|
|
|
1ac26c |
+ int fips_indicator = EVP_SIGNATURE_REDHAT_FIPS_INDICATOR_APPROVED;
|
|
|
1ac26c |
+ if (prsactx->pad_mode == RSA_PKCS1_PSS_PADDING) {
|
|
|
1ac26c |
+ if (prsactx->md == NULL) {
|
|
|
1ac26c |
+ fips_indicator = EVP_SIGNATURE_REDHAT_FIPS_INDICATOR_UNDETERMINED;
|
|
|
1ac26c |
+ } else if (rsa_pss_compute_saltlen(prsactx) > EVP_MD_get_size(prsactx->md)) {
|
|
|
1ac26c |
+ fips_indicator = EVP_SIGNATURE_REDHAT_FIPS_INDICATOR_NOT_APPROVED;
|
|
|
1ac26c |
+ }
|
|
|
1ac26c |
+ }
|
|
|
1ac26c |
+ return OSSL_PARAM_set_int(p, fips_indicator);
|
|
|
1ac26c |
+ }
|
|
|
1ac26c |
+#endif
|
|
|
1ac26c |
+
|
|
|
1ac26c |
return 1;
|
|
|
1ac26c |
}
|
|
|
1ac26c |
|
|
|
1ac26c |
@@ -1136,6 +1151,9 @@ static const OSSL_PARAM known_gettable_ctx_params[] = {
|
|
|
1ac26c |
OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_DIGEST, NULL, 0),
|
|
|
1ac26c |
OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_MGF1_DIGEST, NULL, 0),
|
|
|
1ac26c |
OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_PSS_SALTLEN, NULL, 0),
|
|
|
1ac26c |
+#ifdef FIPS_MODULE
|
|
|
1ac26c |
+ OSSL_PARAM_int(OSSL_SIGNATURE_PARAM_REDHAT_FIPS_INDICATOR, NULL),
|
|
|
1ac26c |
+#endif
|
|
|
1ac26c |
OSSL_PARAM_END
|
|
|
1ac26c |
};
|
|
|
1ac26c |
|
|
|
1ac26c |
--
|
|
|
1ac26c |
2.38.1
|
|
|
1ac26c |
|