mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-01-30 17:31:03 +00:00
Move flag indicating presence of strong entropy to test code
This commit is contained in:
parent
c6deafc0d4
commit
47deec488f
|
@ -55,16 +55,6 @@
|
||||||
#define MBEDTLS_ERR_ENTROPY_NO_STRONG_SOURCE -0x003D /**< No strong sources have been added to poll. */
|
#define MBEDTLS_ERR_ENTROPY_NO_STRONG_SOURCE -0x003D /**< No strong sources have been added to poll. */
|
||||||
#define MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR -0x003F /**< Read/write error in file. */
|
#define MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR -0x003F /**< Read/write error in file. */
|
||||||
|
|
||||||
/* Indicates whether at least one standard strong entropy source is enabled. */
|
|
||||||
#if defined(MBEDTLS_TEST_NULL_ENTROPY) || \
|
|
||||||
( !defined(MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES) && \
|
|
||||||
( !defined(MBEDTLS_NO_PLATFORM_ENTROPY) || \
|
|
||||||
defined(MBEDTLS_HAVEGE_C) || \
|
|
||||||
defined(MBEDTLS_ENTROPY_HARDWARE_ALT) || \
|
|
||||||
defined(ENTROPY_NV_SEED) ) )
|
|
||||||
#define MBEDTLS_ENTROPY_HAVE_STRONG
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \name SECTION: Module settings
|
* \name SECTION: Module settings
|
||||||
*
|
*
|
||||||
|
|
|
@ -83,8 +83,8 @@ void mbedtls_entropy_init( mbedtls_entropy_context *ctx )
|
||||||
mbedtls_havege_init( &ctx->havege_data );
|
mbedtls_havege_init( &ctx->havege_data );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Reminder: Update MBEDTLS_ENTROPY_HAVE_STRONG when
|
/* Reminder: Update MBEDTLS_ENTROPY_HAVE_STRONG in the test files
|
||||||
* adding more strong entropy sources here. */
|
* when adding more strong entropy sources here. */
|
||||||
|
|
||||||
#if defined(MBEDTLS_TEST_NULL_ENTROPY)
|
#if defined(MBEDTLS_TEST_NULL_ENTROPY)
|
||||||
mbedtls_entropy_add_source( ctx, mbedtls_null_entropy_poll, NULL,
|
mbedtls_entropy_add_source( ctx, mbedtls_null_entropy_poll, NULL,
|
||||||
|
|
|
@ -102,6 +102,21 @@ typedef UINT32 uint32_t;
|
||||||
static int test_errors = 0;
|
static int test_errors = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------------*/
|
||||||
|
/* Helper flags for complex dependencies */
|
||||||
|
|
||||||
|
/* Indicates whether we expect mbedtls_entropy_init
|
||||||
|
* to initialize some strong entropy source. */
|
||||||
|
#if defined(MBEDTLS_TEST_NULL_ENTROPY) || \
|
||||||
|
( !defined(MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES) && \
|
||||||
|
( !defined(MBEDTLS_NO_PLATFORM_ENTROPY) || \
|
||||||
|
defined(MBEDTLS_HAVEGE_C) || \
|
||||||
|
defined(MBEDTLS_ENTROPY_HARDWARE_ALT) || \
|
||||||
|
defined(ENTROPY_NV_SEED) ) )
|
||||||
|
#define MBEDTLS_ENTROPY_HAVE_STRONG
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* Helper Functions */
|
/* Helper Functions */
|
||||||
|
|
||||||
|
@ -401,4 +416,3 @@ static void test_fail( const char *test, int line_no, const char* filename )
|
||||||
mbedtls_fprintf( stdout, " %s\n at line %d, %s\n", test, line_no,
|
mbedtls_fprintf( stdout, " %s\n at line %d, %s\n", test, line_no,
|
||||||
filename );
|
filename );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,14 +52,10 @@ entropy_nv_seed:"000000000000000000000000000000000000000000000000000000000000000
|
||||||
Check NV seed manually #3
|
Check NV seed manually #3
|
||||||
entropy_nv_seed:"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
|
entropy_nv_seed:"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
|
||||||
|
|
||||||
Entropy self test (with strong entropy)
|
Entropy self test
|
||||||
depends_on:!MBEDTLS_TEST_NULL_ENTROPY:MBEDTLS_ENTROPY_HAVE_STRONG
|
depends_on:!MBEDTLS_TEST_NULL_ENTROPY
|
||||||
entropy_selftest:0
|
entropy_selftest:0
|
||||||
|
|
||||||
Entropy self test (without strong entropy)
|
|
||||||
depends_on:!MBEDTLS_TEST_NULL_ENTROPY:!MBEDTLS_ENTROPY_HAVE_STRONG
|
|
||||||
entropy_selftest:1
|
|
||||||
|
|
||||||
Entropy self test (MBEDTLS_TEST_NULL_ENTROPY)
|
Entropy self test (MBEDTLS_TEST_NULL_ENTROPY)
|
||||||
depends_on:MBEDTLS_TEST_NULL_ENTROPY
|
depends_on:MBEDTLS_TEST_NULL_ENTROPY
|
||||||
entropy_selftest:1
|
entropy_selftest:1
|
||||||
|
|
|
@ -163,7 +163,7 @@ exit:
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
/* BEGIN_CASE */
|
/* BEGIN_CASE depends_on:MBEDTLS_ENTROPY_HAVE_STRONG */
|
||||||
void entropy_func_len( int len, int ret )
|
void entropy_func_len( int len, int ret )
|
||||||
{
|
{
|
||||||
mbedtls_entropy_context ctx;
|
mbedtls_entropy_context ctx;
|
||||||
|
@ -224,7 +224,7 @@ exit:
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
/* BEGIN_CASE */
|
/* BEGIN_CASE depends_on:MBEDTLS_ENTROPY_HAVE_STRONG */
|
||||||
void entropy_threshold( int threshold, int chunk_size, int result )
|
void entropy_threshold( int threshold, int chunk_size, int result )
|
||||||
{
|
{
|
||||||
mbedtls_entropy_context ctx;
|
mbedtls_entropy_context ctx;
|
||||||
|
@ -377,7 +377,7 @@ void entropy_nv_seed( char *read_seed_str )
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
/* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */
|
/* BEGIN_CASE depends_on:MBEDTLS_ENTROPY_HAVE_STRONG:MBEDTLS_SELF_TEST */
|
||||||
void entropy_selftest( int result )
|
void entropy_selftest( int result )
|
||||||
{
|
{
|
||||||
TEST_ASSERT( mbedtls_entropy_self_test( 1 ) == result );
|
TEST_ASSERT( mbedtls_entropy_self_test( 1 ) == result );
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "mbedtls/sha512.h"
|
#include "mbedtls/sha512.h"
|
||||||
#include "mbedtls/entropy.h"
|
#include "mbedtls/entropy.h"
|
||||||
#include "mbedtls/ctr_drbg.h"
|
#include "mbedtls/ctr_drbg.h"
|
||||||
|
|
||||||
/* END_HEADER */
|
/* END_HEADER */
|
||||||
|
|
||||||
/* BEGIN_DEPENDENCIES
|
/* BEGIN_DEPENDENCIES
|
||||||
|
|
Loading…
Reference in a new issue