psa_sign_hash() function
Sign a hash or short message with a private key. Note that to perform a hash-and-sign signature algorithm, you must first calculate the hash by calling psa_hash_setup(), psa_hash_update() and psa_hash_finish(), or alternatively by calling psa_hash_compute(). Then pass the resulting hash as the \p hash parameter to this function. You can use #PSA_ALG_SIGN_GET_HASH(\p alg) to determine the hash algorithm to use.
Arguments
key
Identifier of the key to use for the operation. It must be an asymmetric key pair. The key must allow the usage #PSA_KEY_USAGE_SIGN_HASH.
alg
A signature algorithm (PSA_ALG_XXX value such that #PSA_ALG_IS_SIGN_HASH(\p alg) is true), that is compatible with the type of \p key.
hash
The hash or message to sign.
hash_length
Size of the \p hash buffer in bytes.
signature
Buffer where the signature is to be written.
signature_size
Size of the \p signature buffer in bytes.
signature_length
On success, the number of bytes that make up the returned signature value.
Return value
#PSA_SUCCESS \emptydescription #PSA_ERROR_INVALID_HANDLE \emptydescription #PSA_ERROR_NOT_PERMITTED \emptydescription #PSA_ERROR_BUFFER_TOO_SMALL The size of the \p signature buffer is too small. You can determine a sufficient buffer size by calling #PSA_SIGN_OUTPUT_SIZE(\c key_type, \c key_bits, \p alg) where \c key_type and \c key_bits are the type and bit-size respectively of \p key. #PSA_ERROR_NOT_SUPPORTED \emptydescription #PSA_ERROR_INVALID_ARGUMENT \emptydescription #PSA_ERROR_INSUFFICIENT_MEMORY \emptydescription #PSA_ERROR_COMMUNICATION_FAILURE \emptydescription #PSA_ERROR_HARDWARE_FAILURE \emptydescription #PSA_ERROR_CORRUPTION_DETECTED \emptydescription #PSA_ERROR_STORAGE_FAILURE \emptydescription #PSA_ERROR_INSUFFICIENT_ENTROPY \emptydescription #PSA_ERROR_BAD_STATE The library has not been previously initialized by psa_crypto_init(). It is implementation-dependent whether a failure to initialize results in this error code.