Skip to content

Commit e6d54dd

Browse files
Ron EldorRon Eldor
Ron Eldor
authored and
Ron Eldor
committed
Enforce plaintext to be on stack
Use lccal buffer for plaintext, to support different platforms, that can't access Flash, but only RAM.
1 parent 7dd22b6 commit e6d54dd

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

library/cmac.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,7 @@ static int cmac_test_wth_cipher( int verbose,
880880
const mbedtls_cipher_info_t *cipher_info;
881881
int i, ret = 0;
882882
unsigned char output[MBEDTLS_CIPHER_BLKSIZE_MAX];
883+
unsigned char plaintext[64];
883884

884885
cipher_info = mbedtls_cipher_info_from_type( cipher_type );
885886
if( cipher_info == NULL )
@@ -894,7 +895,9 @@ static int cmac_test_wth_cipher( int verbose,
894895
if( verbose != 0 )
895896
mbedtls_printf( " %s CMAC #%u: ", testname, i + 1 );
896897

897-
if( ( ret = mbedtls_cipher_cmac( cipher_info, key, keybits, messages,
898+
memset( plaintext, 0, sizeof( plaintext ) );
899+
memcpy( plaintext, messages, message_lengths[i] );
900+
if( ( ret = mbedtls_cipher_cmac( cipher_info, key, keybits, plaintext,
898901
message_lengths[i], output ) ) != 0 )
899902
{
900903
if( ret == MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED )

0 commit comments

Comments
 (0)