Test consistency of cipher max-size macros

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine 2023-06-14 17:34:31 +02:00
parent f07612d02e
commit 4f4d4b2c40
2 changed files with 5 additions and 0 deletions

View file

@ -63,6 +63,9 @@ static int check_cipher_info(mbedtls_cipher_type_t type,
key_bitlen == 192 ||
key_bitlen == 256);
}
TEST_LE_U(key_bitlen, MBEDTLS_MAX_KEY_LENGTH * 8);
TEST_LE_U(block_size, MBEDTLS_MAX_BLOCK_LENGTH);
TEST_LE_U(iv_size, MBEDTLS_MAX_IV_LENGTH);
if (strstr(info->name, "-ECB") != NULL) {
TEST_ASSERT(iv_size == 0);

View file

@ -111,6 +111,8 @@ void mbedtls_cmac_setkey(int cipher_type, int key_size, int result)
TEST_ASSERT((cipher_info = mbedtls_cipher_info_from_type(cipher_type))
!= NULL);
TEST_LE_U(mbedtls_cipher_info_get_block_size(cipher_info),
MBEDTLS_CIPHER_BLKSIZE_MAX);
memset(buf, 0x2A, sizeof(buf));
TEST_ASSERT((result == mbedtls_cipher_cmac(cipher_info, key, key_size,