Documentation and entropy self test changes (#610)
Ensure that the entropy self test always fails whenever
MBEDTLS_TEST_NULL_ENTROPY is defined. This is because the option is
meant to be for testing and development purposes rather than production
quality software. Also, this patch enhances the documentation for
mbedtls_entropy_source_self_test() and mbedtls_entropy_self_test().
diff --git a/library/entropy.c b/library/entropy.c
index 42ace55..8da5256 100644
--- a/library/entropy.c
+++ b/library/entropy.c
@@ -575,7 +575,7 @@
*/
int mbedtls_entropy_self_test( int verbose )
{
- int ret = 0;
+ int ret = 1;
mbedtls_entropy_context ctx;
unsigned char buf[MBEDTLS_ENTROPY_BLOCK_SIZE] = { 0 };
unsigned char acc[MBEDTLS_ENTROPY_BLOCK_SIZE] = { 0 };
@@ -584,6 +584,7 @@
if( verbose != 0 )
mbedtls_printf( " ENTROPY test: " );
+#if !defined(MBEDTLS_TEST_NULL_ENTROPY)
mbedtls_entropy_init( &ctx );
/* First do a gather to make sure we have default sources */
@@ -631,6 +632,7 @@
cleanup:
mbedtls_entropy_free( &ctx );
+#endif /* !MBEDTLS_TEST_NULL_ENTROPY */
if( verbose != 0 )
{