diff --git a/include/mbedtls/timing.h b/include/mbedtls/timing.h index 2d4a19c01a..830dcee635 100644 --- a/include/mbedtls/timing.h +++ b/include/mbedtls/timing.h @@ -39,7 +39,7 @@ extern "C" { * \brief timer structure */ struct mbedtls_timing_hr_time { - unsigned char MBEDTLS_PRIVATE(opaque)[32]; + uint64_t MBEDTLS_PRIVATE(opaque)[4]; }; /** diff --git a/tests/suites/test_suite_timing.function b/tests/suites/test_suite_timing.function index 821ebd6783..4143a1c511 100644 --- a/tests/suites/test_suite_timing.function +++ b/tests/suites/test_suite_timing.function @@ -20,8 +20,20 @@ void timing_get_timer() { struct mbedtls_timing_hr_time time; + + memset(&time, 0, sizeof(time)); + (void) mbedtls_timing_get_timer(&time, 1); + + /* Check that a non-zero time was written back */ + int all_zero = 1; + for (size_t i = 0; i < sizeof(time); i++) { + all_zero &= ((unsigned char *) &time)[i] == 0; + } + TEST_ASSERT(!all_zero); + (void) mbedtls_timing_get_timer(&time, 0); + /* This goto is added to avoid warnings from the generated code. */ goto exit; }