mbedtls_common.c 660 Bytes
Newer Older
1
/*
dp-arm's avatar
dp-arm committed
2
 * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
3
 *
dp-arm's avatar
dp-arm committed
4
 * SPDX-License-Identifier: BSD-3-Clause
5
6
7
8
 */

#include <assert.h>

Juan Castillo's avatar
Juan Castillo committed
9
10
/* mbed TLS headers */
#include <mbedtls/memory_buffer_alloc.h>
11
12

/*
Juan Castillo's avatar
Juan Castillo committed
13
 * mbed TLS heap
14
 */
dp-arm's avatar
dp-arm committed
15
#if (TBBR_KEY_ALG_ID == TBBR_ECDSA)
16
#define MBEDTLS_HEAP_SIZE		(14*1024)
dp-arm's avatar
dp-arm committed
17
#elif (TBBR_KEY_ALG_ID == TBBR_RSA)
18
19
20
21
22
#define MBEDTLS_HEAP_SIZE		(8*1024)
#endif
static unsigned char heap[MBEDTLS_HEAP_SIZE];

/*
Juan Castillo's avatar
Juan Castillo committed
23
 * mbed TLS initialization function
24
25
26
27
28
29
 */
void mbedtls_init(void)
{
	static int ready;

	if (!ready) {
Juan Castillo's avatar
Juan Castillo committed
30
31
32
		/* Initialize the mbed TLS heap */
		mbedtls_memory_buffer_alloc_init(heap, MBEDTLS_HEAP_SIZE);
		ready = 1;
33
34
	}
}