mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-26 13:05:38 +01:00
Merge remote-tracking branch 'public/pr/2870' into baremetal
This commit is contained in:
commit
a26fb4c64f
@ -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()
|
||||
|
@ -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) || \
|
||||
|
@ -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[] )
|
||||
{
|
||||
|
@ -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[] )
|
||||
{
|
||||
|
@ -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 )
|
||||
{
|
||||
|
@ -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 )
|
||||
{
|
||||
|
@ -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 )
|
||||
{
|
||||
|
@ -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 )
|
||||
{
|
||||
|
@ -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 )
|
||||
{
|
||||
|
@ -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[] )
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 )
|
||||
{
|
||||
|
@ -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[] )
|
||||
{
|
||||
|
@ -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[] )
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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[] )
|
||||
{
|
||||
|
@ -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[] )
|
||||
{
|
||||
|
@ -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[] )
|
||||
{
|
||||
|
@ -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 )
|
||||
{
|
||||
|
@ -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[] )
|
||||
{
|
||||
|
@ -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[] )
|
||||
{
|
||||
|
@ -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[] )
|
||||
{
|
||||
|
@ -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[] )
|
||||
{
|
||||
|
@ -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[] )
|
||||
{
|
||||
|
@ -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[] )
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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[] )
|
||||
{
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user