diff --git a/subsys/bluetooth/CMakeLists.txt b/subsys/bluetooth/CMakeLists.txt index a1cd6b51bbd..a670ad2901b 100644 --- a/subsys/bluetooth/CMakeLists.txt +++ b/subsys/bluetooth/CMakeLists.txt @@ -10,7 +10,7 @@ add_subdirectory_ifdef(CONFIG_BT_SHELL shell) add_subdirectory_ifdef(CONFIG_BT_CONN services) add_subdirectory_ifdef(CONFIG_BT_MESH mesh) add_subdirectory_ifdef(CONFIG_BT_AUDIO audio) -add_subdirectory_ifdef(CONFIG_BT_CRYPTO bt_crypto) +add_subdirectory_ifdef(CONFIG_BT_CRYPTO crypto) if(CONFIG_BT_CTLR AND CONFIG_BT_LL_SW_SPLIT) add_subdirectory(controller) diff --git a/subsys/bluetooth/Kconfig b/subsys/bluetooth/Kconfig index fee0c992047..5d4d42e651e 100644 --- a/subsys/bluetooth/Kconfig +++ b/subsys/bluetooth/Kconfig @@ -186,7 +186,7 @@ rsource "common/Kconfig" rsource "host/Kconfig" rsource "controller/Kconfig" rsource "shell/Kconfig" -rsource "bt_crypto/Kconfig" +rsource "crypto/Kconfig" endif # BT_HCI diff --git a/subsys/bluetooth/bt_crypto/CMakeLists.txt b/subsys/bluetooth/crypto/CMakeLists.txt similarity index 71% rename from subsys/bluetooth/bt_crypto/CMakeLists.txt rename to subsys/bluetooth/crypto/CMakeLists.txt index fc0a6f95cbe..cdb029c0989 100644 --- a/subsys/bluetooth/bt_crypto/CMakeLists.txt +++ b/subsys/bluetooth/crypto/CMakeLists.txt @@ -2,6 +2,4 @@ zephyr_library() -zephyr_include_directories(include) - zephyr_library_sources(bt_crypto.c) diff --git a/subsys/bluetooth/bt_crypto/Kconfig b/subsys/bluetooth/crypto/Kconfig similarity index 100% rename from subsys/bluetooth/bt_crypto/Kconfig rename to subsys/bluetooth/crypto/Kconfig diff --git a/subsys/bluetooth/bt_crypto/bt_crypto.c b/subsys/bluetooth/crypto/bt_crypto.c similarity index 98% rename from subsys/bluetooth/bt_crypto/bt_crypto.c rename to subsys/bluetooth/crypto/bt_crypto.c index 62497517a7e..828d4b65bd5 100644 --- a/subsys/bluetooth/bt_crypto/bt_crypto.c +++ b/subsys/bluetooth/crypto/bt_crypto.c @@ -7,15 +7,16 @@ #include -#include #include #include #define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_CRYPTO) -#define LOG_MODULE_NAME bt_crypto_toolbox +#define LOG_MODULE_NAME bt_crypto #include "common/bt_str.h" #include "common/log.h" +#include "bt_crypto.h" + int bt_crypto_aes_cmac(const uint8_t *key, const uint8_t *in, size_t len, uint8_t *out) { struct tc_aes_key_sched_struct sched; diff --git a/subsys/bluetooth/bt_crypto/include/bt_crypto.h b/subsys/bluetooth/crypto/bt_crypto.h similarity index 98% rename from subsys/bluetooth/bt_crypto/include/bt_crypto.h rename to subsys/bluetooth/crypto/bt_crypto.h index 57c28a888e8..aaa6b31830e 100644 --- a/subsys/bluetooth/bt_crypto/include/bt_crypto.h +++ b/subsys/bluetooth/crypto/bt_crypto.h @@ -2,6 +2,9 @@ * SPDX-License-Identifier: Apache-2.0 */ +#ifndef __BT_CRYPTO_H +#define __BT_CRYPTO_H + #include #include @@ -143,3 +146,5 @@ int bt_crypto_h7(const uint8_t salt[16], const uint8_t w[16], uint8_t res[16]); */ int bt_crypto_h8(const uint8_t k[16], const uint8_t s[16], const uint8_t key_id[4], uint8_t res[16]); + +#endif /* __BT_CRYPTO_H */ diff --git a/subsys/bluetooth/host/crypto.c b/subsys/bluetooth/host/crypto.c index 541c0962125..a8e0a08f9ec 100644 --- a/subsys/bluetooth/host/crypto.c +++ b/subsys/bluetooth/host/crypto.c @@ -23,7 +23,7 @@ #include #define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_HCI_CORE) -#define LOG_MODULE_NAME bt_crypto +#define LOG_MODULE_NAME bt_host_crypto #include "common/log.h" #include "common/bt_str.h" diff --git a/subsys/bluetooth/host/smp.c b/subsys/bluetooth/host/smp.c index d1bda602355..e398e3fd7b8 100644 --- a/subsys/bluetooth/host/smp.c +++ b/subsys/bluetooth/host/smp.c @@ -26,13 +26,14 @@ #include #include -#include #define BT_DBG_ENABLED IS_ENABLED(CONFIG_BT_DEBUG_SMP) #define LOG_MODULE_NAME bt_smp #include "common/log.h" #include "common/bt_str.h" +#include "crypto/bt_crypto.h" + #include "hci_core.h" #include "ecc.h" #include "keys.h" diff --git a/tests/bluetooth/bt_crypto/CMakeLists.txt b/tests/bluetooth/bt_crypto/CMakeLists.txt index 0da1d4e73f9..4253e5cf11d 100644 --- a/tests/bluetooth/bt_crypto/CMakeLists.txt +++ b/tests/bluetooth/bt_crypto/CMakeLists.txt @@ -4,6 +4,8 @@ cmake_minimum_required(VERSION 3.20.0) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(app) +target_include_directories(app PRIVATE ${ZEPHYR_BASE}/subsys/bluetooth/crypto) + target_sources(app PRIVATE src/test_bt_crypto.c ) diff --git a/tests/bluetooth/bt_crypto/src/test_bt_crypto.c b/tests/bluetooth/bt_crypto/src/test_bt_crypto.c index cab198af550..3ed0059baf2 100644 --- a/tests/bluetooth/bt_crypto/src/test_bt_crypto.c +++ b/tests/bluetooth/bt_crypto/src/test_bt_crypto.c @@ -8,8 +8,7 @@ #include #include - -#include +#include "bt_crypto.h" ZTEST_SUITE(bt_crypto, NULL, NULL, NULL, NULL, NULL);