mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-27 04:34:14 +01:00
Test _AT_LEAST_THIS_LENGTH macros in the PSA Crypto metadata test suite
Signed-off-by: Steven Cooreman <steven.cooreman@silabs.com>
This commit is contained in:
parent
2c2efa488b
commit
a96e2410e7
@ -264,6 +264,24 @@ void mac_algorithm( int alg_arg, int classification_flags,
|
||||
TEST_EQUAL( PSA_ALG_TRUNCATED_MAC( truncated_alg, length ),
|
||||
PSA_ALG_TRUNCATED_MAC( alg, length ) );
|
||||
}
|
||||
|
||||
/* At-leat-this-length versions */
|
||||
for( n = 1; n <= length; n++ )
|
||||
{
|
||||
psa_algorithm_t policy_alg = PSA_ALG_AT_LEAST_THIS_LENGTH_MAC( alg, n );
|
||||
mac_algorithm_core( policy_alg, classification_flags | ALG_IS_WILDCARD,
|
||||
key_type, key_bits, n );
|
||||
TEST_EQUAL( PSA_ALG_FULL_LENGTH_MAC( policy_alg ), alg );
|
||||
/* Check that calling PSA_ALG_TRUNCATED_MAC twice gives the length
|
||||
* of the outer truncation (even if the outer length is smaller than
|
||||
* the inner length). */
|
||||
TEST_EQUAL( PSA_ALG_AT_LEAST_THIS_LENGTH_MAC( policy_alg, 1 ),
|
||||
PSA_ALG_AT_LEAST_THIS_LENGTH_MAC( alg, 1 ) );
|
||||
TEST_EQUAL( PSA_ALG_AT_LEAST_THIS_LENGTH_MAC( policy_alg, length - 1 ),
|
||||
PSA_ALG_AT_LEAST_THIS_LENGTH_MAC( alg, length - 1) );
|
||||
TEST_EQUAL( PSA_ALG_AT_LEAST_THIS_LENGTH_MAC( policy_alg, length ),
|
||||
PSA_ALG_AT_LEAST_THIS_LENGTH_MAC( alg, length ) );
|
||||
}
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
@ -339,6 +357,24 @@ void aead_algorithm( int alg_arg, int classification_flags,
|
||||
TEST_EQUAL( PSA_ALG_AEAD_WITH_SHORTENED_TAG( truncated_alg, tag_length ),
|
||||
PSA_ALG_AEAD_WITH_SHORTENED_TAG( alg, tag_length ) );
|
||||
}
|
||||
|
||||
/* At-leat-this-length versions */
|
||||
for( n = 1; n <= tag_length; n++ )
|
||||
{
|
||||
psa_algorithm_t policy_alg = PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG( alg, n );
|
||||
aead_algorithm_core( policy_alg, classification_flags | ALG_IS_WILDCARD, n );
|
||||
TEST_EQUAL( PSA_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG( policy_alg ),
|
||||
alg );
|
||||
/* Check that calling PSA_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG twice gives
|
||||
* the length of the outer truncation (even if the outer length is
|
||||
* smaller than the inner length). */
|
||||
TEST_EQUAL( PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG( policy_alg, 1 ),
|
||||
PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG( alg, 1 ) );
|
||||
TEST_EQUAL( PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG( policy_alg, tag_length - 1 ),
|
||||
PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG( alg, tag_length - 1) );
|
||||
TEST_EQUAL( PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG( policy_alg, tag_length ),
|
||||
PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG( alg, tag_length ) );
|
||||
}
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user