Merge remote-tracking branch 'public/pr/2870' into baremetal

This commit is contained in:
Simon Butcher 2019-10-23 14:51:37 +01:00
commit a26fb4c64f
46 changed files with 699 additions and 0 deletions

View file

@ -164,6 +164,80 @@ MBEDTLS_DEPRECATED typedef int mbedtls_deprecated_numeric_constant_t;
*/
void mbedtls_platform_zeroize( void *buf, size_t len );
/**
* \brief Secure memset
*
* This is a constant-time version of memset(). If
* MBEDTLS_ENTROPY_HARDWARE_ALT is defined, the buffer is
* initialised with random data and the order is also
* randomised using the hardware RNG in order to further harden
* against side-channel attacks.
*
* \param ptr Buffer to be set.
* \param value Value to be used when setting the buffer.
* \param num The length of the buffer in bytes.
*
* \return The value of \p ptr.
*/
void *mbedtls_platform_memset( void *ptr, int value, size_t num );
/**
* \brief Secure memcpy
*
* This is a constant-time version of memcpy(). If
* MBEDTLS_ENTROPY_HARDWARE_ALT is defined, the buffer is
* initialised with random data and the order is also
* randomised using the hardware RNG in order to further harden
* against side-channel attacks.
*
* \param dst Destination buffer where the data is being copied to.
* \param src Source buffer where the data is being copied from.
* \param num The length of the buffers in bytes.
*
* \return The value of \p dst.
*/
void *mbedtls_platform_memcpy( void *dst, const void *src, size_t num );
/**
* \brief Secure memcmp
*
* This is a constant-time version of memcmp(). If
* MBEDTLS_ENTROPY_HARDWARE_ALT is defined, the order is also
* randomised using the hardware RNG in order to further harden
* against side-channel attacks.
*
* \param buf1 First buffer to compare.
* \param buf2 Second buffer to compare against.
* \param num The length of the buffers in bytes.
*
* \return 0 if the buffers were equal or an unspecified non-zero value
* otherwise.
*/
int mbedtls_platform_memcmp( const void *buf1, const void *buf2, size_t num );
/**
* \brief RNG-function for getting a random in given range.
*
* This function is meant to provide a global RNG to be used
* throughout Mbed TLS for hardening the library. It is used
* for generating a random delay, random data or random offset
* for utility functions. It is not meant to be a
* cryptographically secure RNG, but provide an RNG for utility
* functions.
*
* \note Currently the function is dependent of hardware providing an
* rng with MBEDTLS_ENTROPY_HARDWARE_ALT. By default, 0 is
* returned.
*
* \note If the given range is [0, 0), 0 is returned.
*
* \param num Max-value for the generated random number, exclusive.
* The generated number will be on range [0, num).
*
* \return The generated random number.
*/
uint32_t mbedtls_platform_random_in_range( size_t num );
#if defined(MBEDTLS_HAVE_TIME_DATE)
/**
* \brief Platform-specific implementation of gmtime_r()

View file

@ -38,6 +38,10 @@
#include "mbedtls/platform.h"
#include "mbedtls/threading.h"
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
#include "mbedtls/entropy_poll.h"
#endif
#include <stddef.h>
#include <string.h>
@ -79,6 +83,87 @@ void mbedtls_platform_zeroize( void *buf, size_t len )
}
#endif /* MBEDTLS_PLATFORM_ZEROIZE_ALT */
void *mbedtls_platform_memset( void *ptr, int value, size_t num )
{
/* Randomize start offset. */
size_t start_offset = (size_t) mbedtls_platform_random_in_range( num );
/* Randomize data */
uint32_t data = mbedtls_platform_random_in_range( 256 );
/* Perform a pair of memset operations from random locations with
* random data */
memset( (void *) ( (unsigned char *) ptr + start_offset ), data,
( num - start_offset ) );
memset( (void *) ptr, data, start_offset );
/* Perform the original memset */
return( memset( ptr, value, num ) );
}
void *mbedtls_platform_memcpy( void *dst, const void *src, size_t num )
{
/* Randomize start offset. */
size_t start_offset = (size_t) mbedtls_platform_random_in_range( num );
/* Randomize initial data to prevent leakage while copying */
uint32_t data = mbedtls_platform_random_in_range( 256 );
memset( (void *) dst, data, num );
memcpy( (void *) ( (unsigned char *) dst + start_offset ),
(void *) ( (unsigned char *) src + start_offset ),
( num - start_offset ) );
return( memcpy( (void *) dst, (void *) src, start_offset ) );
}
int mbedtls_platform_memcmp( const void *buf1, const void *buf2, size_t num )
{
volatile const unsigned char *A = (volatile const unsigned char *) buf1;
volatile const unsigned char *B = (volatile const unsigned char *) buf2;
volatile unsigned char diff = 0;
size_t i = num;
size_t start_offset = (size_t) mbedtls_platform_random_in_range( num );
for( i = start_offset; i < num; i++ )
{
unsigned char x = A[i], y = B[i];
diff |= x ^ y;
}
for( i = 0; i < start_offset; i++ )
{
unsigned char x = A[i], y = B[i];
diff |= x ^ y;
}
return( diff );
}
uint32_t mbedtls_platform_random_in_range( size_t num )
{
#if !defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
(void) num;
return 0;
#else
uint32_t result = 0;
size_t olen = 0;
mbedtls_hardware_poll( NULL, (unsigned char *) &result, sizeof( result ),
&olen );
if( num == 0 )
{
result = 0;
}
else
{
result %= num;
}
return( result );
#endif
}
#if defined(MBEDTLS_HAVE_TIME_DATE) && !defined(MBEDTLS_PLATFORM_GMTIME_R_ALT)
#include <time.h>
#if !defined(_WIN32) && (defined(unix) || \

View file

@ -80,6 +80,18 @@ int main( void )
}
#else
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
int main( int argc, char *argv[] )
{

View file

@ -82,6 +82,18 @@ int main( void )
}
#else
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
int main( int argc, char *argv[] )
{

View file

@ -52,6 +52,18 @@ int main( void )
}
#else
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
static int generic_wrapper( mbedtls_md_handle_t md_info, char *filename, unsigned char *sum )
{

View file

@ -48,6 +48,18 @@ int main( void )
}
#else
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
int main( void )
{

View file

@ -72,6 +72,18 @@ int main( void )
}
#else
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
int main( void )
{

View file

@ -69,6 +69,18 @@ int main( void )
*/
#define GENERATOR "4"
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
int main( int argc, char **argv )
{

View file

@ -72,6 +72,18 @@ int main( void )
}
#else
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
int main( void )
{

View file

@ -100,6 +100,18 @@ static void dump_pubkey( const char *title, mbedtls_ecdsa_context *key )
#define dump_pubkey( a, b )
#endif
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
int main( int argc, char *argv[] )
{

View file

@ -137,6 +137,18 @@ int main( void )
}
#else
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
/*
* global options

View file

@ -74,6 +74,18 @@ int main( void )
}
#else
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
/*
* global options

View file

@ -99,6 +99,18 @@ int main( void )
}
#else
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
/*
* global options

View file

@ -50,6 +50,18 @@ int main( void )
}
#else
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
int main( void )
{

View file

@ -60,6 +60,18 @@ int main( void )
}
#else
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
int main( int argc, char *argv[] )
{

View file

@ -61,6 +61,18 @@ int main( void )
}
#else
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
int main( int argc, char *argv[] )
{

View file

@ -61,6 +61,18 @@ int main( void )
#include <stdio.h>
#include <string.h>
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
/*
* For the currently used signature algorithms the buffer to store any signature

View file

@ -57,6 +57,18 @@ int main( void )
#include <stdio.h>
#include <string.h>
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
int main( int argc, char *argv[] )
{

View file

@ -59,6 +59,18 @@ int main( void )
}
#else
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
int main( int argc, char *argv[] )
{

View file

@ -59,6 +59,18 @@ int main( void )
}
#else
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
int main( int argc, char *argv[] )
{

View file

@ -64,6 +64,18 @@ int main( void )
}
#else
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
int main( void )
{

View file

@ -56,6 +56,18 @@ int main( void )
#include <stdio.h>
#include <string.h>
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
int main( int argc, char *argv[] )
{

View file

@ -60,6 +60,18 @@ int main( void )
#include <stdio.h>
#include <string.h>
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
int main( int argc, char *argv[] )
{

View file

@ -55,6 +55,18 @@ int main( void )
#include <stdio.h>
#include <string.h>
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
int main( int argc, char *argv[] )
{

View file

@ -60,6 +60,18 @@ int main( void )
#include <stdio.h>
#include <string.h>
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
int main( int argc, char *argv[] )
{

View file

@ -51,6 +51,18 @@ int main( void )
}
#else
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
int main( int argc, char *argv[] )
{

View file

@ -54,6 +54,18 @@ int main( void )
}
#else
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
int main( int argc, char *argv[] )
{

View file

@ -109,6 +109,19 @@ int rng_wrap( void *ctx, unsigned char *dst, size_t len )
}
#endif /* MBEDTLS_SSL_CONF_RNG */
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
int main( int argc, char *argv[] )
{
int ret, len;

View file

@ -118,6 +118,19 @@ int rng_wrap( void *ctx, unsigned char *dst, size_t len )
}
#endif /* MBEDTLS_SSL_CONF_RNG */
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
int main( void )
{
int ret, len;

View file

@ -180,6 +180,19 @@ int rng_wrap( void *ctx, unsigned char *dst, size_t len )
}
#endif /* MBEDTLS_SSL_CONF_RNG */
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
int main( void )
{
int ret = exit_ok;

View file

@ -99,6 +99,19 @@ int rng_wrap( void *ctx, unsigned char *dst, size_t len )
}
#endif /* MBEDTLS_SSL_CONF_RNG */
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
int main( void )
{
int ret = 1, len;

View file

@ -925,6 +925,19 @@ int rng_wrap( void *ctx, unsigned char *dst, size_t len )
}
#endif /* MBEDTLS_SSL_CONF_RNG */
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
int main( int argc, char *argv[] )
{
int ret = 0, len, tail_len, i, written, frags, retry_left;

View file

@ -116,6 +116,19 @@ int rng_wrap( void *ctx, unsigned char *dst, size_t len )
}
#endif /* MBEDTLS_SSL_CONF_RNG */
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
int main( void )
{
int ret = 1, len, cnt = 0, pid;

View file

@ -375,6 +375,19 @@ int rng_wrap( void *ctx, unsigned char *dst, size_t len )
}
#endif /* MBEDTLS_SSL_CONF_RNG */
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
int main( int argc, char *argv[] )
{
int ret = 1, len;

View file

@ -111,6 +111,19 @@ int rng_wrap( void *ctx, unsigned char *dst, size_t len )
}
#endif /* MBEDTLS_SSL_CONF_RNG */
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
int main( void )
{
int ret, len;

View file

@ -1536,6 +1536,19 @@ int rng_wrap( void *ctx, unsigned char *dst, size_t len )
}
#endif /* MBEDTLS_SSL_CONF_RNG */
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
int main( int argc, char *argv[] )
{
int ret = 0, len, written, frags, exchanges_left;

View file

@ -258,6 +258,18 @@ typedef struct {
rsa, dhm, ecdsa, ecdh;
} todo_list;
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
int main( int argc, char *argv[] )
{

View file

@ -279,6 +279,19 @@ const selftest_t selftests[] =
};
#endif /* MBEDTLS_SELF_TEST */
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
int main( int argc, char *argv[] )
{
#if defined(MBEDTLS_SELF_TEST)

View file

@ -99,3 +99,16 @@ int main( int argc, char** argv )
return( exit_code );
}
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif

View file

@ -165,6 +165,19 @@ int rng_wrap( void *ctx, unsigned char *dst, size_t len )
}
#endif /* MBEDTLS_SSL_CONF_RNG */
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
int main( int argc, char *argv[] )
{
int ret = 1;

View file

@ -154,6 +154,19 @@ int write_certificate_request( mbedtls_x509write_csr *req, const char *output_fi
return( 0 );
}
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
int main( int argc, char *argv[] )
{
int ret = 1;

View file

@ -214,6 +214,19 @@ int write_certificate( mbedtls_x509write_cert *crt, const char *output_file,
return( 0 );
}
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
int main( int argc, char *argv[] )
{
int ret = 1;

View file

@ -72,6 +72,19 @@ struct options
const char *filename; /* filename of the certificate file */
} opt;
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
int main( int argc, char *argv[] )
{
int ret = 1;

View file

@ -72,6 +72,19 @@ struct options
const char *filename; /* filename of the certificate request */
} opt;
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
size_t i;
(void) data;
for( i = 0; i < len; ++i )
output[i] = rand();
*olen = len;
return( 0 );
}
#endif
int main( int argc, char *argv[] )
{
int ret = 1;

View file

@ -1591,6 +1591,16 @@ component_test_baremetal () {
if_build_succeeded tests/ssl-opt.sh --filter "^Default, DTLS$"
}
component_test_hardware_entropy () {
msg "build: default config + MBEDTLS_ENTROPY_HARDWARE_ALT"
scripts/config.pl set MBEDTLS_ENTROPY_HARDWARE_ALT
make CFLAGS='-Werror -O1'
msg "test: default config + MBEDTLS_ENTROPY_HARDWARE_ALT"
if_build_succeeded make test
if_build_succeeded tests/ssl-opt.sh --filter "^Default, DTLS$"
}
component_test_allow_sha1 () {
msg "build: allow SHA1 in certificates by default"
scripts/config.pl set MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES

View file

@ -561,6 +561,16 @@ static int uecc_rng_wrapper( uint8_t *dest, unsigned int size )
}
#endif /* MBEDTLS_USE_TINYCRYPT */
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
int mbedtls_hardware_poll( void *data, unsigned char *output,
size_t len, size_t *olen )
{
(void) data;
*olen = len;
return( rnd_std_rand( NULL, output, len ) );
}
#endif
/**
* This function only returns zeros
*