Add a test case for MBEDTLS_ERR_ENTROPY_NO_SOURCES_DEFINED
diff --git a/tests/suites/test_suite_entropy.data b/tests/suites/test_suite_entropy.data
index 7460d74..abf36c0 100644
--- a/tests/suites/test_suite_entropy.data
+++ b/tests/suites/test_suite_entropy.data
@@ -7,6 +7,9 @@
Entropy write/update seed file: nonexistent
entropy_seed_file:"no_such_dir/file":MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR
+Entropy no sources
+entropy_no_sources:
+
Entropy too many sources
entropy_too_many_sources:
diff --git a/tests/suites/test_suite_entropy.function b/tests/suites/test_suite_entropy.function
index 8563b11..a125f62 100644
--- a/tests/suites/test_suite_entropy.function
+++ b/tests/suites/test_suite_entropy.function
@@ -45,7 +45,6 @@
return( 0 );
}
-#if defined(MBEDTLS_ENTROPY_NV_SEED)
/*
* Ability to clear entropy sources to allow testing with just predefined
* entropy sources. This function or tests depending on it might break if there
@@ -57,11 +56,12 @@
* This might break memory checks in the future if sources need 'free-ing' then
* as well.
*/
-void entropy_clear_sources( mbedtls_entropy_context *ctx )
+static void entropy_clear_sources( mbedtls_entropy_context *ctx )
{
ctx->source_count = 0;
}
+#if defined(MBEDTLS_ENTROPY_NV_SEED)
/*
* NV seed read/write functions that use a buffer instead of a file
*/
@@ -149,6 +149,22 @@
/* END_CASE */
/* BEGIN_CASE */
+void entropy_no_sources( )
+{
+ mbedtls_entropy_context ctx;
+ unsigned char buf[MBEDTLS_ENTROPY_BLOCK_SIZE];
+
+ mbedtls_entropy_init( &ctx );
+ entropy_clear_sources( &ctx );
+ TEST_EQUAL( mbedtls_entropy_func( &ctx, buf, sizeof( buf ) ),
+ MBEDTLS_ERR_ENTROPY_NO_SOURCES_DEFINED );
+
+exit:
+ mbedtls_entropy_free( &ctx );
+}
+/* END_CASE */
+
+/* BEGIN_CASE */
void entropy_too_many_sources( )
{
mbedtls_entropy_context ctx;