mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2025-12-23 15:55:10 +01:00
Add MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN
This option allows to test the constant-flow nature of selected code, using MemSan and the fundamental observation behind ctgrind that the set of operations allowed on undefined memory by dynamic analysers is the same as the set of operations allowed on secret data to avoid leaking it to a local attacker via side channels, namely, any operation except branching and dereferencing. (This isn't the full story, as on some CPUs some instructions have variable execution depending on the inputs, most notably division and on some cores multiplication. However, testing that no branch or memory access depends on secret data is already a good start.) Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
This commit is contained in:
parent
368fc65f80
commit
a237722118
7 changed files with 63 additions and 0 deletions
|
|
@ -46,6 +46,22 @@ typedef UINT32 uint32_t;
|
|||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN)
|
||||
#include <sanitizer/msan_interface.h>
|
||||
|
||||
/* Use macros to avoid messing up with origin tracking */
|
||||
#define TEST_CF_SECRET __msan_allocated_memory
|
||||
// void __msan_allocated_memory(const volatile void* data, size_t size);
|
||||
#define TEST_CF_PUBLIC __msan_unpoison
|
||||
// void __msan_unpoison(const volatile void *a, size_t size);
|
||||
|
||||
#else /* MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN */
|
||||
|
||||
#define TEST_CF_SECRET(ptr, size)
|
||||
#define TEST_CF_PUBLIC(ptr, size)
|
||||
|
||||
#endif /* MBEDTLS_TEST_CONSTANT_FLOW_MEMSAN */
|
||||
|
||||
/* Type for Hex parameters */
|
||||
typedef struct data_tag
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue