2015-04-02 15:44:20 +01:00
|
|
|
/*
|
2017-03-07 10:08:42 +00:00
|
|
|
* Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
|
2015-04-02 15:44:20 +01:00
|
|
|
*
|
2017-05-03 09:38:09 +01:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
2015-04-02 15:44:20 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
2015-11-05 09:24:53 +00:00
|
|
|
/* mbed TLS headers */
|
|
|
|
#include <mbedtls/memory_buffer_alloc.h>
|
2015-04-02 15:44:20 +01:00
|
|
|
|
|
|
|
/*
|
2015-11-05 09:24:53 +00:00
|
|
|
* mbed TLS heap
|
2015-04-02 15:44:20 +01:00
|
|
|
*/
|
2017-03-07 10:08:42 +00:00
|
|
|
#if (TBBR_KEY_ALG_ID == TBBR_ECDSA)
|
2015-04-02 15:44:20 +01:00
|
|
|
#define MBEDTLS_HEAP_SIZE (14*1024)
|
2017-03-07 10:08:42 +00:00
|
|
|
#elif (TBBR_KEY_ALG_ID == TBBR_RSA)
|
2015-04-02 15:44:20 +01:00
|
|
|
#define MBEDTLS_HEAP_SIZE (8*1024)
|
|
|
|
#endif
|
|
|
|
static unsigned char heap[MBEDTLS_HEAP_SIZE];
|
|
|
|
|
|
|
|
/*
|
2015-11-05 09:24:53 +00:00
|
|
|
* mbed TLS initialization function
|
2015-04-02 15:44:20 +01:00
|
|
|
*/
|
|
|
|
void mbedtls_init(void)
|
|
|
|
{
|
|
|
|
static int ready;
|
|
|
|
|
|
|
|
if (!ready) {
|
2015-11-05 09:24:53 +00:00
|
|
|
/* Initialize the mbed TLS heap */
|
|
|
|
mbedtls_memory_buffer_alloc_init(heap, MBEDTLS_HEAP_SIZE);
|
|
|
|
ready = 1;
|
2015-04-02 15:44:20 +01:00
|
|
|
}
|
|
|
|
}
|