From da8ea698dfda8e2f30eeee2493586b46b3ff31f3 Mon Sep 17 00:00:00 2001 From: Jukka Laitinen Date: Thu, 23 Nov 2023 09:38:43 +0200 Subject: [PATCH] Add AES GCM support to libtomcrypt Signed-off-by: Jukka Laitinen --- src/lib/crypto/CMakeLists.txt | 11 +++++++---- src/lib/crypto/libtomcrypt_wrappers.c | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/lib/crypto/CMakeLists.txt b/src/lib/crypto/CMakeLists.txt index 90936d29b489..aad44c4ada39 100644 --- a/src/lib/crypto/CMakeLists.txt +++ b/src/lib/crypto/CMakeLists.txt @@ -60,6 +60,8 @@ px4_add_library(libtommath file(GLOB_RECURSE PK_SRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "libtomcrypt/src/pk/*.c") file(GLOB_RECURSE MATH_SRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "libtomcrypt/src/math/*.c") +file(GLOB_RECURSE GCM_SRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "libtomcrypt/src/encauth/gcm/*.c") +file(GLOB_RECURSE CRYPT_SRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "libtomcrypt/src/misc/crypt/*.c") px4_add_library(libtomcrypt libtomcrypt_wrappers.c @@ -68,10 +70,11 @@ libtomcrypt_wrappers.c libtomcrypt/src/hashes/sha2/sha256.c libtomcrypt/src/hashes/helper/hash_memory.c libtomcrypt/src/prngs/sprng.c - libtomcrypt/src/misc/crypt/crypt_ltc_mp_descriptor.c - libtomcrypt/src/misc/crypt/crypt_hash_is_valid.c - libtomcrypt/src/misc/crypt/crypt_prng_is_valid.c + ${CRYPT_SRC} + ${GCM_SRC} libtomcrypt/src/misc/zeromem.c + libtomcrypt/src/misc/mem_neq.c + libtomcrypt/src/ciphers/aes/aes.c ) target_include_directories(libtomcrypt @@ -86,7 +89,7 @@ target_include_directories(libtomcrypt # libtomcrypt defines: # ARGTYPE=3: No argument checking -add_definitions(-DARGTYPE=3 -DLTC_EASY -DLTC_NO_TEST -DLTM_DESC -DMP_LOW_MEM) +add_definitions(-DARGTYPE=3 -DLTC_EASY -DLTC_NO_TEST -DLTM_DESC -DMP_LOW_MEM -DLTC_GCM_MODE) # link to libtommath and os provided random library target_link_libraries(libtomcrypt diff --git a/src/lib/crypto/libtomcrypt_wrappers.c b/src/lib/crypto/libtomcrypt_wrappers.c index 17d7027a49e8..475ed80a367e 100644 --- a/src/lib/crypto/libtomcrypt_wrappers.c +++ b/src/lib/crypto/libtomcrypt_wrappers.c @@ -44,4 +44,5 @@ unsigned long rng_get_bytes(unsigned char *out, void libtomcrypt_init(void) { ltc_mp = ltm_desc; + register_cipher(&aes_desc); }