1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-08-08 17:42:09 +03:00

Merge pull request #7825 from daverodgman/cipher_wrap_size

Cipher wrap size improvement
This commit is contained in:
Dave Rodgman
2023-07-05 15:45:48 +01:00
committed by GitHub
15 changed files with 765 additions and 610 deletions

View File

@@ -1142,11 +1142,11 @@ int mbedtls_test_ssl_build_transforms(mbedtls_ssl_transform *t_in,
/* Pick cipher */
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_iv_size(cipher_info) <= 16);
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. */
@@ -1273,7 +1273,7 @@ int mbedtls_test_ssl_build_transforms(mbedtls_ssl_transform *t_in,
/* Pick IV's (regardless of whether they
* are being used by the transform). */
ivlen = cipher_info->iv_size;
ivlen = mbedtls_cipher_info_get_iv_size(cipher_info);
memset(iv_enc, 0x3, sizeof(iv_enc));
memset(iv_dec, 0x4, sizeof(iv_dec));

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));