From cf4e9999bca2229e031a27955550019aa1b46a8c Mon Sep 17 00:00:00 2001 From: Andrzej Kurek Date: Fri, 13 Jan 2023 19:01:51 -0500 Subject: [PATCH] Enable the timing.c selftest with MBEDTLS_TIMING_ALT This caused trouble for users that were using the selftest feature along with an alternative implementation. They were forced to provide their own version of a selftest. Since it was not mentioned in the define description, it should not be required, and is provided roughly as it was before breaking changes in 77daaad198 were introduced. Signed-off-by: Andrzej Kurek --- library/timing.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/library/timing.c b/library/timing.c index d4f9554ee..47e34f922 100644 --- a/library/timing.c +++ b/library/timing.c @@ -352,9 +352,9 @@ int mbedtls_timing_get_delay(void *data) return 0; } +#endif /* !MBEDTLS_TIMING_ALT */ #if defined(MBEDTLS_SELF_TEST) - /* * Busy-waits for the given number of milliseconds. * Used for testing mbedtls_timing_hardclock. @@ -383,9 +383,8 @@ static void busy_msleep(unsigned long msec) mbedtls_printf(" cycles=%lu ratio=%lu millisecs=%lu secs=%lu hardfail=%d a=%lu b=%lu\n", \ cycles, ratio, millisecs, secs, hardfail, \ (unsigned long) a, (unsigned long) b); \ - mbedtls_printf(" elapsed(hires)=%lu elapsed(ctx)=%lu status(ctx)=%d\n", \ + mbedtls_printf(" elapsed(hires)=%lu status(ctx)=%d\n", \ mbedtls_timing_get_timer(&hires, 0), \ - mbedtls_timing_get_timer(&ctx.timer, 0), \ mbedtls_timing_get_delay(&ctx)); \ } \ return 1; \ @@ -526,5 +525,4 @@ hard_test_done: } #endif /* MBEDTLS_SELF_TEST */ -#endif /* !MBEDTLS_TIMING_ALT */ #endif /* MBEDTLS_TIMING_C */