Check truncation length explicitly
Comparing algorithm with its FULL_LENGTH_MAC version doesn't work in
cases where algorithm is a wildcard. Wildcard input is not specified in
the documentation of the function, but in order to test the function
using the same test as PSA_MAC_LENGTH we're mimicking that behaviour here.
Signed-off-by: Steven Cooreman <steven.cooreman@silabs.com>
diff --git a/library/psa_crypto.c b/library/psa_crypto.c
index a112ff4..13a0835 100644
--- a/library/psa_crypto.c
+++ b/library/psa_crypto.c
@@ -583,8 +583,9 @@
return( PSA_ERROR_INVALID_ARGUMENT );
/* Output the expected (potentially truncated) length as long as it can
- * actually be output by the algorithm */
- if( PSA_ALG_FULL_LENGTH_MAC( algorithm ) == algorithm )
+ * actually be output by the algorithm. Truncation length of '0' means
+ * default output length of the keytype-algorithm combination. */
+ if( PSA_MAC_TRUNCATED_LENGTH( algorithm ) == 0 )
{
*length = default_length;
return( PSA_SUCCESS );