Re: mbedtls and memory allocator
Rodriguez, Sergio SF <sergio.sf.rodriguez@...>
Hi Tomasztoggle quoted messageShow quoted text
Mbedtls has his own allocator, version of calloc to enable it, you need the a configuration file that enables the compilation of that feature
You can see an example in
if you need an specific configuration file this is where you will put it , and add to your prj.conf
now as a reference how to enable you can take a look to
in the file dtls_client.c look for
static unsigned char heap;
There a heap is statically created and eventually you have to assign the heap with the function
For that point on mbedtls will use its own memory allocator
Let me know if this helps
From: firstname.lastname@example.org [mailto:email@example.com] On Behalf Of Tomasz Bursztyka
Sent: Thursday, April 27, 2017 3:56 AM
Subject: [Zephyr-devel] mbedtls and memory allocator
I sent a draft for a mbedtls shim crypto device driver, so it exposes CCM operations (for now) through Crypto API.
Patch is here:
While running the cryto sample on top of it, I get a mbedtls memory allocation error when calling mbedtls_ccm_setkey().
Looking quickly at mbdetls code, it seems to want to allocate some space for the chosen cipher (AES here) and obviously fails because there is no calloc in Zephyr, and instead mbedtls is built to return NULL from a default built-in memory allocator.
I used ext/lib/crypto/mbedtls/configs/config-ccm-psk-tls1_2.h
That one is being used in, for instance, samples/net/mbedtls_sslclient. And AES and CCM could be used there, I wonder how it is supposed to work if it has the same issue.
So, before I dive deeper into mbedtls myself:
How is mbedtls supposed to be configured to get AES CCM working without any dynamic memory allocator?
If by any chance someone has already worked with mbedtls, it will be of great help to give me hints.
Zephyr-devel mailing list