mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-22 17:15:38 +01:00
Added some descriptions of functions
Signed-off-by: Piotr Nowicki <piotr.nowicki@arm.com>
This commit is contained in:
parent
1a9d33e8c8
commit
f0ab6d62ac
@ -111,6 +111,9 @@ void *mbedtls_platform_memcpy( void *dst, const void *src, size_t num )
|
|||||||
/* Randomize initial data to prevent leakage while copying */
|
/* Randomize initial data to prevent leakage while copying */
|
||||||
uint32_t data = mbedtls_platform_random_in_range( 256 );
|
uint32_t data = mbedtls_platform_random_in_range( 256 );
|
||||||
|
|
||||||
|
/* Use memset with random value at first to increase security - memset is
|
||||||
|
not normally part of the memcpy function and here can be useed
|
||||||
|
with regular, unsecured implementation */
|
||||||
memset( (void *) dst, data, num );
|
memset( (void *) dst, data, num );
|
||||||
memcpy( (void *) ( (unsigned char *) dst + start_offset ),
|
memcpy( (void *) ( (unsigned char *) dst + start_offset ),
|
||||||
(void *) ( (unsigned char *) src + start_offset ),
|
(void *) ( (unsigned char *) src + start_offset ),
|
||||||
@ -124,8 +127,8 @@ int mbedtls_platform_memcmp( const void *buf1, const void *buf2, size_t num )
|
|||||||
volatile const unsigned char *B = (volatile const unsigned char *) buf2;
|
volatile const unsigned char *B = (volatile const unsigned char *) buf2;
|
||||||
volatile unsigned char diff = 0;
|
volatile unsigned char diff = 0;
|
||||||
|
|
||||||
size_t i = num;
|
/* Start from a random location and check the correct number of iterations */
|
||||||
size_t flow_counter = 0;
|
size_t i, flow_counter = 0;
|
||||||
size_t start_offset = (size_t) mbedtls_platform_random_in_range( num );
|
size_t start_offset = (size_t) mbedtls_platform_random_in_range( num );
|
||||||
|
|
||||||
for( i = start_offset; i < num; i++ )
|
for( i = start_offset; i < num; i++ )
|
||||||
|
@ -290,6 +290,7 @@ uECC_word_t uECC_vli_equal(const uECC_word_t *left, const uECC_word_t *right)
|
|||||||
uECC_word_t tmp1, tmp2;
|
uECC_word_t tmp1, tmp2;
|
||||||
volatile int i;
|
volatile int i;
|
||||||
|
|
||||||
|
/* Start from a random location and check the correct number of iterations */
|
||||||
int start_offset = mbedtls_platform_random_in_range(NUM_ECC_WORDS);
|
int start_offset = mbedtls_platform_random_in_range(NUM_ECC_WORDS);
|
||||||
|
|
||||||
for (i = start_offset; i < NUM_ECC_WORDS; ++i) {
|
for (i = start_offset; i < NUM_ECC_WORDS; ++i) {
|
||||||
@ -306,6 +307,7 @@ uECC_word_t uECC_vli_equal(const uECC_word_t *left, const uECC_word_t *right)
|
|||||||
diff |= (tmp1 ^ tmp2);
|
diff |= (tmp1 ^ tmp2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Random delay to increase security */
|
||||||
mbedtls_platform_random_delay();
|
mbedtls_platform_random_delay();
|
||||||
|
|
||||||
/* Return 0 only when diff is 0 and flow_counter is equal to NUM_ECC_WORDS */
|
/* Return 0 only when diff is 0 and flow_counter is equal to NUM_ECC_WORDS */
|
||||||
|
Loading…
Reference in New Issue
Block a user