Change a generate_key test to exercise with PSS
This required tweaking exercise_signature_key to use a payload size
for the signature based on the algorithm, since our implementation of
PSS requires that the input size matches the hash size. This would
also be the case for PKCS#1 v1.5 with a specified hash.
diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function
index 8c8d41d..dbe306e 100644
--- a/tests/suites/test_suite_psa_crypto.function
+++ b/tests/suites/test_suite_psa_crypto.function
@@ -285,13 +285,19 @@
psa_key_usage_t usage,
psa_algorithm_t alg )
{
- unsigned char payload[16] = {1};
- size_t payload_length = sizeof( payload );
+ unsigned char payload[PSA_HASH_MAX_SIZE] = {1};
+ size_t payload_length = 16;
unsigned char signature[PSA_ASYMMETRIC_SIGNATURE_MAX_SIZE] = {0};
size_t signature_length = sizeof( signature );
if( usage & PSA_KEY_USAGE_SIGN )
{
+ /* Some algorithms require the payload to have the size of
+ * the hash encoded in the algorithm. Use this input size
+ * even for algorithms that allow other input sizes. */
+ psa_algorithm_t hash_alg = PSA_ALG_SIGN_GET_HASH( alg );
+ if( hash_alg != 0 )
+ payload_length = PSA_HASH_SIZE( hash_alg );
TEST_ASSERT( psa_asymmetric_sign( key, alg,
payload, payload_length,
signature, sizeof( signature ),