Add a test for calloc zeroization
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
This commit is contained in:
parent
b9f8974c6c
commit
c08ccd00f3
3 changed files with 18 additions and 1 deletions
|
@ -3680,7 +3680,7 @@
|
|||
|
||||
/* Platform options */
|
||||
//#define MBEDTLS_PLATFORM_STD_MEM_HDR <stdlib.h> /**< Header to include if MBEDTLS_PLATFORM_NO_STD_FUNCTIONS is defined. Don't define if no header is needed. */
|
||||
//#define MBEDTLS_PLATFORM_STD_CALLOC calloc /**< Default allocator to use, can be undefined. Please note that it should zeroize the buffer after allocation. */
|
||||
//#define MBEDTLS_PLATFORM_STD_CALLOC calloc /**< Default allocator to use, can be undefined. Please note that it should zeroize the allocated buffer. */
|
||||
//#define MBEDTLS_PLATFORM_STD_FREE free /**< Default free to use, can be undefined */
|
||||
//#define MBEDTLS_PLATFORM_STD_SETBUF setbuf /**< Default setbuf to use, can be undefined */
|
||||
//#define MBEDTLS_PLATFORM_STD_EXIT exit /**< Default exit to use, can be undefined */
|
||||
|
|
|
@ -4,3 +4,6 @@ time_get_milliseconds:
|
|||
|
||||
Time: get seconds
|
||||
time_get_seconds:
|
||||
|
||||
Check mbedtls_calloc zeroization
|
||||
check_mbedtls_calloc_zeroization:
|
|
@ -120,3 +120,17 @@ void time_delay_seconds(int delay_secs)
|
|||
goto exit;
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void check_mbedtls_calloc_zeroization()
|
||||
{
|
||||
unsigned int buf_size = 256;
|
||||
unsigned char *buf;
|
||||
buf = mbedtls_calloc(buf_size, sizeof(unsigned char));
|
||||
for (unsigned int i = 0; i < buf_size; i++) {
|
||||
TEST_EQUAL(buf[i], 0);
|
||||
}
|
||||
exit:
|
||||
mbedtls_free(buf);
|
||||
}
|
||||
/* END_CASE */
|
Loading…
Reference in a new issue