Add metadata tests intertwining truncated and at-least-length algos
Signed-off-by: Steven Cooreman <steven.cooreman@silabs.com>
This commit is contained in:
parent
947bb0b06f
commit
16a05f5881
1 changed files with 56 additions and 0 deletions
|
@ -263,6 +263,20 @@ void mac_algorithm( int alg_arg, int classification_flags,
|
|||
PSA_ALG_TRUNCATED_MAC( alg, length - 1) );
|
||||
TEST_EQUAL( PSA_ALG_TRUNCATED_MAC( truncated_alg, length ),
|
||||
PSA_ALG_TRUNCATED_MAC( alg, length ) );
|
||||
|
||||
/* Check that calling PSA_ALG_TRUNCATED_MAC on an algorithm
|
||||
* earlier constructed with PSA_ALG_AT_LEAST_THIS_LENGTH_MAC gives the
|
||||
* length of the outer truncation (even if the outer length is smaller
|
||||
* than the inner length). */
|
||||
TEST_EQUAL( PSA_ALG_TRUNCATED_MAC(
|
||||
PSA_ALG_AT_LEAST_THIS_LENGTH_MAC( truncated_alg, n ), 1 ),
|
||||
PSA_ALG_TRUNCATED_MAC( alg, 1 ) );
|
||||
TEST_EQUAL( PSA_ALG_TRUNCATED_MAC(
|
||||
PSA_ALG_AT_LEAST_THIS_LENGTH_MAC( truncated_alg, n ), length - 1 ),
|
||||
PSA_ALG_TRUNCATED_MAC( alg, length - 1) );
|
||||
TEST_EQUAL( PSA_ALG_TRUNCATED_MAC(
|
||||
PSA_ALG_AT_LEAST_THIS_LENGTH_MAC( truncated_alg, n ), length ),
|
||||
PSA_ALG_TRUNCATED_MAC( alg, length ) );
|
||||
}
|
||||
|
||||
/* At-leat-this-length versions */
|
||||
|
@ -281,6 +295,20 @@ void mac_algorithm( int alg_arg, int classification_flags,
|
|||
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 ) );
|
||||
|
||||
/* Check that calling PSA_ALG_AT_LEAST_THIS_LENGTH_MAC on an algorithm
|
||||
* earlier constructed with PSA_ALG_TRUNCATED_MAC 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(
|
||||
PSA_ALG_TRUNCATED_MAC( policy_alg, n ), 1),
|
||||
PSA_ALG_AT_LEAST_THIS_LENGTH_MAC( alg, 1 ) );
|
||||
TEST_EQUAL( PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(
|
||||
PSA_ALG_TRUNCATED_MAC( policy_alg, n ), length - 1 ),
|
||||
PSA_ALG_AT_LEAST_THIS_LENGTH_MAC( alg, length - 1) );
|
||||
TEST_EQUAL( PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(
|
||||
PSA_ALG_TRUNCATED_MAC( policy_alg, n ), length ),
|
||||
PSA_ALG_AT_LEAST_THIS_LENGTH_MAC( alg, length ) );
|
||||
}
|
||||
}
|
||||
/* END_CASE */
|
||||
|
@ -356,6 +384,20 @@ void aead_algorithm( int alg_arg, int classification_flags,
|
|||
PSA_ALG_AEAD_WITH_SHORTENED_TAG( alg, tag_length - 1) );
|
||||
TEST_EQUAL( PSA_ALG_AEAD_WITH_SHORTENED_TAG( truncated_alg, tag_length ),
|
||||
PSA_ALG_AEAD_WITH_SHORTENED_TAG( alg, tag_length ) );
|
||||
|
||||
/* Check that calling PSA_ALG_AEAD_WITH_SHORTENED_TAG on an algorithm
|
||||
* earlier constructed with PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG
|
||||
* gives the length of the outer truncation (even if the outer length is
|
||||
* smaller than the inner length). */
|
||||
TEST_EQUAL( PSA_ALG_AEAD_WITH_SHORTENED_TAG(
|
||||
PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG( truncated_alg, n ), 1 ),
|
||||
PSA_ALG_AEAD_WITH_SHORTENED_TAG( alg, 1 ) );
|
||||
TEST_EQUAL( PSA_ALG_AEAD_WITH_SHORTENED_TAG(
|
||||
PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG( truncated_alg, n ), tag_length - 1 ),
|
||||
PSA_ALG_AEAD_WITH_SHORTENED_TAG( alg, tag_length - 1) );
|
||||
TEST_EQUAL( PSA_ALG_AEAD_WITH_SHORTENED_TAG(
|
||||
PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG( truncated_alg, n ), tag_length ),
|
||||
PSA_ALG_AEAD_WITH_SHORTENED_TAG( alg, tag_length ) );
|
||||
}
|
||||
|
||||
/* At-leat-this-length versions */
|
||||
|
@ -374,6 +416,20 @@ void aead_algorithm( int alg_arg, int classification_flags,
|
|||
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 ) );
|
||||
|
||||
/* Check that calling PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG on an
|
||||
* algorithm earlier constructed with PSA_ALG_AEAD_WITH_SHORTENED_TAG
|
||||
* 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(
|
||||
PSA_ALG_AEAD_WITH_SHORTENED_TAG( policy_alg, n ), 1),
|
||||
PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG( alg, 1 ) );
|
||||
TEST_EQUAL( PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(
|
||||
PSA_ALG_AEAD_WITH_SHORTENED_TAG( policy_alg, n ), 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(
|
||||
PSA_ALG_AEAD_WITH_SHORTENED_TAG( policy_alg, n ), tag_length ),
|
||||
PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG( alg, tag_length ) );
|
||||
}
|
||||
}
|
||||
/* END_CASE */
|
||||
|
|
Loading…
Reference in a new issue