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 <andrzej.kurek@arm.com>
diff --git a/library/timing.c b/library/timing.c
index d4f9554..47e34f9 100644
--- a/library/timing.c
+++ b/library/timing.c
@@ -352,9 +352,9 @@
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 @@
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 @@
}
#endif /* MBEDTLS_SELF_TEST */
-#endif /* !MBEDTLS_TIMING_ALT */
#endif /* MBEDTLS_TIMING_C */