1 /* 2 * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #include <assert.h> 8 9 /* mbed TLS headers */ 10 #include <mbedtls/memory_buffer_alloc.h> 11 12 /* 13 * mbed TLS heap 14 */ 15 #if (TBBR_KEY_ALG_ID == TBBR_ECDSA) 16 #define MBEDTLS_HEAP_SIZE (14*1024) 17 #elif (TBBR_KEY_ALG_ID == TBBR_RSA) 18 #define MBEDTLS_HEAP_SIZE (8*1024) 19 #endif 20 static unsigned char heap[MBEDTLS_HEAP_SIZE]; 21 22 /* 23 * mbed TLS initialization function 24 */ 25 void mbedtls_init(void) 26 { 27 static int ready; 28 29 if (!ready) { 30 /* Initialize the mbed TLS heap */ 31 mbedtls_memory_buffer_alloc_init(heap, MBEDTLS_HEAP_SIZE); 32 ready = 1; 33 } 34 } 35