diff options
author | Jens Wiklander <jens.wiklander@linaro.org> | 2018-03-29 12:46:54 +0200 |
---|---|---|
committer | Jérôme Forissier <jerome.forissier@linaro.org> | 2018-04-18 14:21:33 +0200 |
commit | 7531fb245b0e8a4965e231c47b55249402acbe89 (patch) | |
tree | cc047c9a90a1cacb94613439df71472ecbb604d0 /lib/libutee | |
parent | a2eb5b55d169aaf0961ecc98b74ced53b20fe42c (diff) |
Use mempool API from libutils for bignum allocations
Uses the Use mempool API from libutils for bignum allocations.
Reviewed-by: Volodymyr Babchuk <vlad.babchuk@gmail.com>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Diffstat (limited to 'lib/libutee')
-rw-r--r-- | lib/libutee/tee_api_arith.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/libutee/tee_api_arith.c b/lib/libutee/tee_api_arith.c index 2597b665..cb2d2633 100644 --- a/lib/libutee/tee_api_arith.c +++ b/lib/libutee/tee_api_arith.c @@ -29,6 +29,7 @@ #include <tee_api.h> #include <tee_arith_internal.h> #include <mpalib.h> +#include <mempool.h> /* * The mem pool. @@ -42,7 +43,7 @@ static uint32_t mempool_u32[mpa_scratch_mem_size_in_U32( MPA_INTERNAL_MEM_POOL_SIZE, CFG_TA_BIGNUM_MAX_BITS)]; -static mpa_scratch_mem mempool = (void *)mempool_u32; +static mpa_scratch_mem mempool; /************************************************************* * PANIC @@ -70,8 +71,18 @@ static void __attribute__ ((noreturn)) TEE_BigInt_Panic(const char *msg) */ void _TEE_MathAPI_Init(void) { - mpa_init_scratch_mem(mempool, sizeof(mempool_u32), - CFG_TA_BIGNUM_MAX_BITS); + static mpa_scratch_mem_base mem; + + mem.pool = mempool_alloc_pool(mempool_u32, sizeof(mempool_u32), NULL); + if (!mem.pool) + TEE_Panic(0); + /* + * The default size (bits) of a big number that will be required is + * equal to the max size of the computation (for example 4096 + * bits), multiplied by 2 to allow overflow in computation + */ + mem.bn_bits = CFG_TA_BIGNUM_MAX_BITS * 2; + mempool = &mem; mpa_set_random_generator(get_rng_array); } |