Formatting changes

Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
This commit is contained in:
Andrzej Kurek 2020-07-06 15:28:59 -04:00
parent 84bde419e1
commit 0919b142b6
No known key found for this signature in database
GPG Key ID: 89A90840DC388527
4 changed files with 142 additions and 143 deletions

View File

@ -2470,7 +2470,6 @@ static int ssl_cid_build_inner_plaintext( unsigned char *content,
volatile size_t *content_size_dup = content_size; volatile size_t *content_size_dup = content_size;
volatile size_t remaining_dup = remaining; volatile size_t remaining_dup = remaining;
/* Write real content type */ /* Write real content type */
if( remaining == 0 ) if( remaining == 0 )
return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL ); return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL );
@ -4888,6 +4887,7 @@ static void ssl_bitmask_set( unsigned char *mask, size_t offset, size_t len )
memset( mask + offset / 8, 0xFF, len / 8 ); memset( mask + offset / 8, 0xFF, len / 8 );
} }
#define BITMASK_CHECK_FAILED 0x75555555
/* /*
* Check that bitmask is full * Check that bitmask is full
*/ */
@ -4897,11 +4897,11 @@ static int ssl_bitmask_check( unsigned char *mask, size_t len )
for( i = 0; i < len / 8; i++ ) for( i = 0; i < len / 8; i++ )
if( mask[i] != 0xFF ) if( mask[i] != 0xFF )
return( 0x75555555 ); return( BITMASK_CHECK_FAILED );
for( i = 0; i < len % 8; i++ ) for( i = 0; i < len % 8; i++ )
if( ( mask[len / 8] & ( 1 << ( 7 - i ) ) ) == 0 ) if( ( mask[len / 8] & ( 1 << ( 7 - i ) ) ) == 0 )
return( 0x75555555 ); return( BITMASK_CHECK_FAILED );
return( 0 ); return( 0 );
} }
@ -7129,6 +7129,7 @@ write_msg:
#if defined(MBEDTLS_SSL_RENEGOTIATION) && defined(MBEDTLS_SSL_CLI_C) #if defined(MBEDTLS_SSL_RENEGOTIATION) && defined(MBEDTLS_SSL_CLI_C)
#if defined(MBEDTLS_SSL_KEEP_PEER_CERTIFICATE) #if defined(MBEDTLS_SSL_KEEP_PEER_CERTIFICATE)
#define PEER_CRT_CHANGED 0x75555555
static int ssl_check_peer_crt_unchanged( mbedtls_ssl_context *ssl, static int ssl_check_peer_crt_unchanged( mbedtls_ssl_context *ssl,
unsigned char *crt_buf, unsigned char *crt_buf,
size_t crt_buf_len ) size_t crt_buf_len )
@ -7136,14 +7137,15 @@ static int ssl_check_peer_crt_unchanged( mbedtls_ssl_context *ssl,
mbedtls_x509_crt const * const peer_crt = ssl->session->peer_cert; mbedtls_x509_crt const * const peer_crt = ssl->session->peer_cert;
if( peer_crt == NULL ) if( peer_crt == NULL )
return( 0x75555555 ); return( PEER_CRT_CHANGED );
if( peer_crt->raw.len != crt_buf_len ) if( peer_crt->raw.len != crt_buf_len )
return( 0x75555555 ); return( PEER_CRT_CHANGED );
return( mbedtls_platform_memcmp( peer_crt->raw.p, crt_buf, crt_buf_len ) ); return( mbedtls_platform_memcmp( peer_crt->raw.p, crt_buf, crt_buf_len ) );
} }
#elif defined(MBEDTLS_SSL_RENEGOTIATION) #elif defined(MBEDTLS_SSL_RENEGOTIATION)
#define PEER_CRT_CHANGED 0x75555555
static int ssl_check_peer_crt_unchanged( mbedtls_ssl_context *ssl, static int ssl_check_peer_crt_unchanged( mbedtls_ssl_context *ssl,
unsigned char *crt_buf, unsigned char *crt_buf,
size_t crt_buf_len ) size_t crt_buf_len )
@ -7161,7 +7163,7 @@ static int ssl_check_peer_crt_unchanged( mbedtls_ssl_context *ssl,
if( peer_cert_digest == NULL || if( peer_cert_digest == NULL ||
digest_info == MBEDTLS_MD_INVALID_HANDLE ) digest_info == MBEDTLS_MD_INVALID_HANDLE )
{ {
return( 0x75555555 ); return( PEER_CRT_CHANGED );
} }
digest_len = mbedtls_md_get_size( digest_info ); digest_len = mbedtls_md_get_size( digest_info );
@ -7170,7 +7172,7 @@ static int ssl_check_peer_crt_unchanged( mbedtls_ssl_context *ssl,
ret = mbedtls_md( digest_info, crt_buf, crt_buf_len, tmp_digest ); ret = mbedtls_md( digest_info, crt_buf, crt_buf_len, tmp_digest );
if( ret != 0 ) if( ret != 0 )
return( 0x75555555 ); return( PEER_CRT_CHANGED );
return( mbedtls_platform_memcmp( tmp_digest, peer_cert_digest, digest_len ) ); return( mbedtls_platform_memcmp( tmp_digest, peer_cert_digest, digest_len ) );
} }

View File

@ -150,8 +150,7 @@ int uECC_make_key(uint8_t *public_key, uint8_t *private_key)
/* erasing temporary buffer that stored secret: */ /* erasing temporary buffer that stored secret: */
mbedtls_platform_memset(_private, 0, NUM_ECC_BYTES); mbedtls_platform_memset(_private, 0, NUM_ECC_BYTES);
if(private_key == private_key_dup && if (private_key == private_key_dup && public_key == public_key_dup) {
public_key == public_key_dup){
return UECC_SUCCESS; return UECC_SUCCESS;
} }
return UECC_FAULT_DETECTED; return UECC_FAULT_DETECTED;
@ -173,7 +172,6 @@ int uECC_shared_secret(const uint8_t *public_key, const uint8_t *private_key,
volatile const uint8_t *private_key_dup = private_key; volatile const uint8_t *private_key_dup = private_key;
volatile const uint8_t *secret_dup = secret; volatile const uint8_t *secret_dup = secret;
/* Converting buffers to correct bit order: */ /* Converting buffers to correct bit order: */
uECC_vli_bytesToNative(_private, uECC_vli_bytesToNative(_private,
private_key, private_key,
@ -190,8 +188,7 @@ int uECC_shared_secret(const uint8_t *public_key, const uint8_t *private_key,
/* erasing temporary buffer used to store secret: */ /* erasing temporary buffer used to store secret: */
mbedtls_platform_zeroize(_private, sizeof(_private)); mbedtls_platform_zeroize(_private, sizeof(_private));
if(public_key_dup != public_key || private_key_dup != private_key || if (public_key_dup != public_key || private_key_dup != private_key || secret_dup != secret) {
secret_dup != secret){
return UECC_FAULT_DETECTED; return UECC_FAULT_DETECTED;
} }