mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-28 00:21:48 +03:00
Merge pull request #5010 from gilles-peskine-arm/psa-rsa-pss_any_salt
PSA: fix salt length for PSS verification
This commit is contained in:
@ -56,6 +56,12 @@ extern "C" {
|
||||
#define PSA_WANT_ALG_RSA_PKCS1V15_SIGN_RAW PSA_WANT_ALG_RSA_PKCS1V15_SIGN
|
||||
#endif
|
||||
|
||||
#if defined(PSA_WANT_ALG_RSA_PSS_ANY_SALT) && !defined(PSA_WANT_ALG_RSA_PSS)
|
||||
#define PSA_WANT_ALG_RSA_PSS PSA_WANT_ALG_RSA_PSS_ANY_SALT
|
||||
#elif !defined(PSA_WANT_ALG_RSA_PSS_ANY_SALT) && defined(PSA_WANT_ALG_RSA_PSS)
|
||||
#define PSA_WANT_ALG_RSA_PSS_ANY_SALT PSA_WANT_ALG_RSA_PSS
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/****************************************************************/
|
||||
|
@ -890,7 +890,7 @@
|
||||
* algorithm parametrized with any supported hash.
|
||||
*
|
||||
* That is, suppose that `PSA_xxx_SIGNATURE` is one of the following macros:
|
||||
* - #PSA_ALG_RSA_PKCS1V15_SIGN, #PSA_ALG_RSA_PSS,
|
||||
* - #PSA_ALG_RSA_PKCS1V15_SIGN, #PSA_ALG_RSA_PSS, #PSA_ALG_RSA_PSS_ANY_SALT,
|
||||
* - #PSA_ALG_ECDSA, #PSA_ALG_DETERMINISTIC_ECDSA.
|
||||
* Then you may create and use a key as follows:
|
||||
* - Set the key usage field using #PSA_ALG_ANY_HASH, for example:
|
||||
@ -1345,6 +1345,7 @@
|
||||
(((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_RSA_PKCS1V15_SIGN_BASE)
|
||||
|
||||
#define PSA_ALG_RSA_PSS_BASE ((psa_algorithm_t)0x06000300)
|
||||
#define PSA_ALG_RSA_PSS_ANY_SALT_BASE ((psa_algorithm_t)0x06001300)
|
||||
/** RSA PSS signature with hashing.
|
||||
*
|
||||
* This is the signature scheme defined by RFC 8017
|
||||
@ -1365,9 +1366,72 @@
|
||||
*/
|
||||
#define PSA_ALG_RSA_PSS(hash_alg) \
|
||||
(PSA_ALG_RSA_PSS_BASE | ((hash_alg) & PSA_ALG_HASH_MASK))
|
||||
#define PSA_ALG_IS_RSA_PSS(alg) \
|
||||
|
||||
/** RSA PSS signature with hashing with relaxed verification.
|
||||
*
|
||||
* This algorithm has the same behavior as #PSA_ALG_RSA_PSS when signing,
|
||||
* but allows an arbitrary salt length (including \c 0) when verifying a
|
||||
* signature.
|
||||
*
|
||||
* \param hash_alg A hash algorithm (\c PSA_ALG_XXX value such that
|
||||
* #PSA_ALG_IS_HASH(\p hash_alg) is true).
|
||||
* This includes #PSA_ALG_ANY_HASH
|
||||
* when specifying the algorithm in a usage policy.
|
||||
*
|
||||
* \return The corresponding RSA PSS signature algorithm.
|
||||
* \return Unspecified if \p hash_alg is not a supported
|
||||
* hash algorithm.
|
||||
*/
|
||||
#define PSA_ALG_RSA_PSS_ANY_SALT(hash_alg) \
|
||||
(PSA_ALG_RSA_PSS_ANY_SALT_BASE | ((hash_alg) & PSA_ALG_HASH_MASK))
|
||||
|
||||
/** Whether the specified algorithm is RSA PSS with standard salt.
|
||||
*
|
||||
* \param alg An algorithm value or an algorithm policy wildcard.
|
||||
*
|
||||
* \return 1 if \p alg is of the form
|
||||
* #PSA_ALG_RSA_PSS(\c hash_alg),
|
||||
* where \c hash_alg is a hash algorithm or
|
||||
* #PSA_ALG_ANY_HASH. 0 otherwise.
|
||||
* This macro may return either 0 or 1 if \p alg is not
|
||||
* a supported algorithm identifier or policy.
|
||||
*/
|
||||
#define PSA_ALG_IS_RSA_PSS_STANDARD_SALT(alg) \
|
||||
(((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_RSA_PSS_BASE)
|
||||
|
||||
/** Whether the specified algorithm is RSA PSS with any salt.
|
||||
*
|
||||
* \param alg An algorithm value or an algorithm policy wildcard.
|
||||
*
|
||||
* \return 1 if \p alg is of the form
|
||||
* #PSA_ALG_RSA_PSS_ANY_SALT_BASE(\c hash_alg),
|
||||
* where \c hash_alg is a hash algorithm or
|
||||
* #PSA_ALG_ANY_HASH. 0 otherwise.
|
||||
* This macro may return either 0 or 1 if \p alg is not
|
||||
* a supported algorithm identifier or policy.
|
||||
*/
|
||||
#define PSA_ALG_IS_RSA_PSS_ANY_SALT(alg) \
|
||||
(((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_RSA_PSS_ANY_SALT_BASE)
|
||||
|
||||
/** Whether the specified algorithm is RSA PSS.
|
||||
*
|
||||
* This includes any of the RSA PSS algorithm variants, regardless of the
|
||||
* constraints on salt length.
|
||||
*
|
||||
* \param alg An algorithm value or an algorithm policy wildcard.
|
||||
*
|
||||
* \return 1 if \p alg is of the form
|
||||
* #PSA_ALG_RSA_PSS(\c hash_alg) or
|
||||
* #PSA_ALG_RSA_PSS_ANY_SALT_BASE(\c hash_alg),
|
||||
* where \c hash_alg is a hash algorithm or
|
||||
* #PSA_ALG_ANY_HASH. 0 otherwise.
|
||||
* This macro may return either 0 or 1 if \p alg is not
|
||||
* a supported algorithm identifier or policy.
|
||||
*/
|
||||
#define PSA_ALG_IS_RSA_PSS(alg) \
|
||||
(PSA_ALG_IS_RSA_PSS_STANDARD_SALT(alg) || \
|
||||
PSA_ALG_IS_RSA_PSS_ANY_SALT(alg))
|
||||
|
||||
#define PSA_ALG_ECDSA_BASE ((psa_algorithm_t)0x06000600)
|
||||
/** ECDSA signature with hashing.
|
||||
*
|
||||
|
Reference in New Issue
Block a user