mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-19 22:23:33 +08:00
crypto: define XMALLOC & XFREE for sw_crypto
Use the same memory allocation in sw_crypto driver as what is used in src/lib/crypto libraries In addition, in nuttx protected build, allocate all memory from kernel heap Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
This commit is contained in:
committed by
Daniel Agar
parent
a537925c3c
commit
9c94e4c5ef
@@ -52,11 +52,11 @@ extern void libtomcrypt_init(void);
|
||||
#define KEY_CACHE_LEN 16
|
||||
|
||||
#ifndef SECMEM_ALLOC
|
||||
#define SECMEM_ALLOC malloc
|
||||
#define SECMEM_ALLOC XMALLOC
|
||||
#endif
|
||||
|
||||
#ifndef SECMEM_FREE
|
||||
#define SECMEM_FREE free
|
||||
#define SECMEM_FREE XFREE
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -156,7 +156,7 @@ crypto_session_handle_t crypto_open(px4_crypto_algorithm_t algorithm)
|
||||
|
||||
switch (algorithm) {
|
||||
case CRYPTO_XCHACHA20: {
|
||||
chacha20_context_t *context = malloc(sizeof(chacha20_context_t));
|
||||
chacha20_context_t *context = XMALLOC(sizeof(chacha20_context_t));
|
||||
|
||||
if (!context) {
|
||||
ret.handle = 0;
|
||||
@@ -188,7 +188,7 @@ void crypto_close(crypto_session_handle_t *handle)
|
||||
crypto_open_count--;
|
||||
handle->handle = 0;
|
||||
keystore_close(&handle->keystore_handle);
|
||||
free(handle->context);
|
||||
XFREE(handle->context);
|
||||
handle->context = NULL;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user