PSA_ALG_ANY_HASH macro
In a hash-and-sign algorithm policy, allow any hash algorithm. This value may be used to form the algorithm usage field of a policy for a signature algorithm that is parametrized by a hash. The key may then be used to perform operations using the same signature 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_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: ``` psa_set_key_usage_flags(&attributes, PSA_KEY_USAGE_SIGN_HASH); // or VERIFY psa_set_key_algorithm(&attributes, PSA_xxx_SIGNATURE(PSA_ALG_ANY_HASH)); ``` - Import or generate key material. - Call psa_sign_hash() or psa_verify_hash(), passing an algorithm built from `PSA_xxx_SIGNATURE` and a specific hash. Each call to sign or verify a message may use a different hash. ``` psa_sign_hash(key, PSA_xxx_SIGNATURE(PSA_ALG_SHA_256), ...); psa_sign_hash(key, PSA_xxx_SIGNATURE(PSA_ALG_SHA_512), ...); psa_sign_hash(key, PSA_xxx_SIGNATURE(PSA_ALG_SHA3_256), ...); ``` This value may not be used to build other algorithms that are parametrized over a hash. For any valid use of this macro to build an algorithm \c alg, #PSA_ALG_IS_HASH_AND_SIGN(\c alg) is true. This value may not be used to build an algorithm specification to perform an operation. It is only valid to build policies.
![]()
(alg) == PSA_ALG_ANY_HASH)