Add FI countermeasures to the ssl module
This commit adds mainly buffer pointer and length duplication and checks, but also some hamming distance and return values checking improvements. Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
This commit is contained in:
parent
74f7d0f03d
commit
84bde419e1
3 changed files with 153 additions and 34 deletions
|
@ -3587,7 +3587,10 @@ static int ssl_out_client_key_exchange_write( mbedtls_ssl_context *ssl,
|
|||
{
|
||||
int ret;
|
||||
unsigned char *p, *end;
|
||||
volatile unsigned char *buf_dup = buf;
|
||||
volatile size_t buflen_dup = buflen;
|
||||
size_t n;
|
||||
|
||||
mbedtls_ssl_ciphersuite_handle_t ciphersuite_info =
|
||||
mbedtls_ssl_handshake_get_ciphersuite( ssl->handshake );
|
||||
|
||||
|
@ -3870,7 +3873,12 @@ static int ssl_out_client_key_exchange_write( mbedtls_ssl_context *ssl,
|
|||
}
|
||||
|
||||
*olen = p - buf;
|
||||
return( 0 );
|
||||
/* Secure against buffer substitution */
|
||||
if( buf_dup == buf && buflen_dup == buflen )
|
||||
{
|
||||
return( 0 );
|
||||
}
|
||||
return( MBEDTLS_ERR_PLATFORM_FAULT_DETECTED );
|
||||
}
|
||||
|
||||
static int ssl_out_client_key_exchange_postprocess( mbedtls_ssl_context *ssl )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue