mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-26 00:05:36 +01:00
Add a callback for platform faults in platform_util.c
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
This commit is contained in:
parent
5eba1d82a2
commit
7f81c86a0d
@ -2951,6 +2951,18 @@
|
||||
*/
|
||||
//#define MBEDTLS_MEMORY_BUFFER_ALLOC_C
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_PLATFORM_FAULT_CALLBACKS
|
||||
*
|
||||
* Uncomment to provide your own alternate implementation for mbedtls_platform_fault(),
|
||||
* used in library/platform_util.c to signal a fault injection in either
|
||||
* mbedtls_platform_memcpy or mbedtls_platform_memset.
|
||||
*
|
||||
* You will need to provide a header "platform_fault.h" and an implementation at
|
||||
* compile time.
|
||||
*/
|
||||
//#define MBEDTLS_PLATFORM_FAULT_CALLBACKS
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_NET_C
|
||||
*
|
||||
|
@ -48,6 +48,12 @@
|
||||
#include "mbedtls/entropy_poll.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_FAULT_CALLBACKS)
|
||||
#include "platform_fault.h"
|
||||
#else
|
||||
static void mbedtls_platform_fault(){}
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
@ -167,7 +173,7 @@ void *mbedtls_platform_memset( void *ptr, int value, size_t num )
|
||||
return ptr;
|
||||
}
|
||||
}
|
||||
|
||||
mbedtls_platform_fault();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -207,6 +213,7 @@ void *mbedtls_platform_memcpy( void *dst, const void *src, size_t num )
|
||||
return dst;
|
||||
}
|
||||
}
|
||||
mbedtls_platform_fault();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -729,6 +729,9 @@ static const char *features[] = {
|
||||
#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C)
|
||||
"MBEDTLS_MEMORY_BUFFER_ALLOC_C",
|
||||
#endif /* MBEDTLS_MEMORY_BUFFER_ALLOC_C */
|
||||
#if defined(MBEDTLS_PLATFORM_FAULT_CALLBACKS)
|
||||
"MBEDTLS_PLATFORM_FAULT_CALLBACKS",
|
||||
#endif /* MBEDTLS_PLATFORM_FAULT_CALLBACKS */
|
||||
#if defined(MBEDTLS_NET_C)
|
||||
"MBEDTLS_NET_C",
|
||||
#endif /* MBEDTLS_NET_C */
|
||||
|
@ -1986,6 +1986,14 @@ int query_config( const char *config )
|
||||
}
|
||||
#endif /* MBEDTLS_MEMORY_BUFFER_ALLOC_C */
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_FAULT_CALLBACKS)
|
||||
if( strcmp( "MBEDTLS_PLATFORM_FAULT_CALLBACKS", config ) == 0 )
|
||||
{
|
||||
MACRO_EXPANSION_TO_STR( MBEDTLS_PLATFORM_FAULT_CALLBACKS );
|
||||
return( 0 );
|
||||
}
|
||||
#endif /* MBEDTLS_PLATFORM_FAULT_CALLBACKS */
|
||||
|
||||
#if defined(MBEDTLS_NET_C)
|
||||
if( strcmp( "MBEDTLS_NET_C", config ) == 0 )
|
||||
{
|
||||
|
@ -146,6 +146,7 @@ MBEDTLS_CTR_DRBG_USE_128_BIT_KEY
|
||||
MBEDTLS_SSL_TRANSFORM_OPTIMIZE_CIPHERS
|
||||
MBEDTLS_VALIDATE_SSL_KEYS_INTEGRITY
|
||||
MBEDTLS_OPTIMIZE_TINYCRYPT_ASM
|
||||
MBEDTLS_PLATFORM_FAULT_CALLBACKS
|
||||
_ALT\s*$
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user