aboutsummaryrefslogtreecommitdiff
path: root/core/lib
diff options
context:
space:
mode:
authorJerome Forissier <jerome.forissier@linaro.org>2018-03-27 00:16:38 +0800
committerJérôme Forissier <jerome.forissier@linaro.org>2018-04-03 18:25:00 +0200
commit409d2ff0a248904b871dd7345ef3f8fdd55ad119 (patch)
tree763019020c191166d401f93cf60db865d6a33c30 /core/lib
parente3458e03c8bb1a97a55912b3efc31cf3371ef830 (diff)
core: crypto: ltc: introduce CFG_CORE_BIGNUM_MAX_BITS
Make the size of big numbers in the TEE core configurable. The default (4096 bits) may be reduced if such a large key size is not needed, to save core memory. Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Diffstat (limited to 'core/lib')
-rw-r--r--core/lib/libtomcrypt/src/tee_ltc_provider.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/core/lib/libtomcrypt/src/tee_ltc_provider.c b/core/lib/libtomcrypt/src/tee_ltc_provider.c
index 7bda173d..da6f06e9 100644
--- a/core/lib/libtomcrypt/src/tee_ltc_provider.c
+++ b/core/lib/libtomcrypt/src/tee_ltc_provider.c
@@ -493,12 +493,11 @@ TEE_Result crypto_hash_final(void *ctx, uint32_t algo, uint8_t *digest,
#if defined(_CFG_CRYPTO_WITH_ACIPHER)
-#define LTC_MAX_BITS_PER_VARIABLE (4096)
#define LTC_VARIABLE_NUMBER (50)
#define LTC_MEMPOOL_U32_SIZE \
mpa_scratch_mem_size_in_U32(LTC_VARIABLE_NUMBER, \
- LTC_MAX_BITS_PER_VARIABLE)
+ CFG_CORE_BIGNUM_MAX_BITS)
#if defined(CFG_WITH_PAGER)
#include <mm/tee_pager.h>
@@ -654,7 +653,7 @@ static void tee_ltc_alloc_mpa(void)
pool = get_mpa_scratch_memory_pool(&size_pool);
init_mpa_tomcrypt(pool);
- mpa_init_scratch_mem_sync(pool, size_pool, LTC_MAX_BITS_PER_VARIABLE,
+ mpa_init_scratch_mem_sync(pool, size_pool, CFG_CORE_BIGNUM_MAX_BITS,
get_pool, put_pool, &pool_sync);
mpa_set_random_generator(crypto_rng_read);
@@ -719,7 +718,7 @@ void crypto_bignum_clear(struct bignum *s)
static bool bn_alloc_max(struct bignum **s)
{
- size_t sz = mpa_StaticVarSizeInU32(LTC_MAX_BITS_PER_VARIABLE) *
+ size_t sz = mpa_StaticVarSizeInU32(CFG_CORE_BIGNUM_MAX_BITS) *
sizeof(uint32_t) * 8;
*s = crypto_bignum_allocate(sz);
@@ -837,7 +836,7 @@ static TEE_Result rsadorep(rsa_key *ltc_key, const uint8_t *src,
* required size of the out buffer without doing a partial decrypt.
* We know the upper bound though.
*/
- blen = (mpa_StaticTempVarSizeInU32(LTC_MAX_BITS_PER_VARIABLE)) *
+ blen = (mpa_StaticTempVarSizeInU32(CFG_CORE_BIGNUM_MAX_BITS)) *
sizeof(uint32_t);
buf = malloc(blen);
if (!buf) {