1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-12-24 17:41:01 +03:00

Don't directly access key_bitlen

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
This commit is contained in:
Dave Rodgman
2023-06-24 11:03:04 +01:00
parent 3319ae9679
commit 9282d4f13a
5 changed files with 8 additions and 8 deletions

View File

@@ -1143,10 +1143,10 @@ int mbedtls_test_ssl_build_transforms(mbedtls_ssl_transform *t_in,
cipher_info = mbedtls_cipher_info_from_type(cipher_type);
CHK(cipher_info != NULL);
CHK(cipher_info->iv_size <= 16);
CHK(cipher_info->key_bitlen % 8 == 0);
CHK(mbedtls_cipher_info_get_key_bitlen(cipher_info) % 8 == 0);
/* Pick keys */
keylen = cipher_info->key_bitlen / 8;
keylen = mbedtls_cipher_info_get_key_bitlen(cipher_info) / 8;
/* Allocate `keylen + 1` bytes to ensure that we get
* a non-NULL pointers from `mbedtls_calloc` even if
* `keylen == 0` in the case of the NULL cipher. */

View File

@@ -586,12 +586,12 @@ void dec_empty_buf(int cipher,
ASSERT_ALLOC(iv, iv_len);
memset(iv, 0, iv_len);
TEST_ASSERT(sizeof(key) * 8 >= cipher_info->key_bitlen);
TEST_ASSERT(sizeof(key) * 8 >= mbedtls_cipher_info_get_key_bitlen(cipher_info));
TEST_ASSERT(0 == mbedtls_cipher_setup(&ctx_dec, cipher_info));
TEST_ASSERT(0 == mbedtls_cipher_setkey(&ctx_dec,
key, cipher_info->key_bitlen,
key, mbedtls_cipher_info_get_key_bitlen(cipher_info),
MBEDTLS_DECRYPT));
TEST_ASSERT(0 == mbedtls_cipher_set_iv(&ctx_dec, iv, iv_len));