mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-22 11:35:44 +01:00
Introduce a platform fault on bad input in uECC_vli_mmod
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
This commit is contained in:
parent
5ef12c0cbc
commit
7aebd7f55d
@ -3028,9 +3028,11 @@
|
|||||||
/**
|
/**
|
||||||
* \def MBEDTLS_PLATFORM_FAULT_CALLBACKS
|
* \def MBEDTLS_PLATFORM_FAULT_CALLBACKS
|
||||||
*
|
*
|
||||||
* Uncomment to provide your own alternate implementation for mbedtls_platform_fault(),
|
* Uncomment to provide your own alternate implementation for
|
||||||
* used in library/platform_util.c to signal a fault injection in either
|
* mbedtls_platform_fault(), used in library/platform_util.c and
|
||||||
* mbedtls_platform_memcpy, mbedtls_platform_memset or mbedtls_platform_random_buf.
|
* tinycrypt/ecc.c to signal a fault injection in either
|
||||||
|
* mbedtls_platform_memcpy, mbedtls_platform_memset, mbedtls_platform_random_buf,
|
||||||
|
* or uECC_vli_mmod.
|
||||||
*
|
*
|
||||||
* You will need to provide a header "platform_fault.h" and an implementation at
|
* You will need to provide a header "platform_fault.h" and an implementation at
|
||||||
* compile time.
|
* compile time.
|
||||||
|
@ -70,6 +70,12 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "mbedtls/platform_util.h"
|
#include "mbedtls/platform_util.h"
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_PLATFORM_FAULT_CALLBACKS)
|
||||||
|
#include "platform_fault.h"
|
||||||
|
#else
|
||||||
|
static void mbedtls_platform_fault(){}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined MBEDTLS_OPTIMIZE_TINYCRYPT_ASM
|
#if defined MBEDTLS_OPTIMIZE_TINYCRYPT_ASM
|
||||||
#ifndef asm
|
#ifndef asm
|
||||||
#define asm __asm
|
#define asm __asm
|
||||||
@ -1167,6 +1173,12 @@ void uECC_vli_mmod(uECC_word_t *result, uECC_word_t *product,
|
|||||||
wordcount_t word_shift = shift / uECC_WORD_BITS;
|
wordcount_t word_shift = shift / uECC_WORD_BITS;
|
||||||
wordcount_t bit_shift = shift % uECC_WORD_BITS;
|
wordcount_t bit_shift = shift % uECC_WORD_BITS;
|
||||||
uECC_word_t carry = 0;
|
uECC_word_t carry = 0;
|
||||||
|
|
||||||
|
if(word_shift > NUM_ECC_WORDS)
|
||||||
|
{
|
||||||
|
mbedtls_platform_fault();
|
||||||
|
}
|
||||||
|
|
||||||
uECC_vli_clear(mod_multiple);
|
uECC_vli_clear(mod_multiple);
|
||||||
if (bit_shift > 0) {
|
if (bit_shift > 0) {
|
||||||
for(index = 0; index < (uECC_word_t)num_words; ++index) {
|
for(index = 0; index < (uECC_word_t)num_words; ++index) {
|
||||||
|
Loading…
Reference in New Issue
Block a user