From dcbf50a91842748870a1251e8ffcb1e4ac119bcd Mon Sep 17 00:00:00 2001 From: s-hadinger <49731213+s-hadinger@users.noreply.github.com> Date: Sun, 19 Feb 2023 22:25:29 +0100 Subject: [PATCH] Matter automatic ifdefs (#18002) --- lib/libesp32/berry/default/be_modtab.c | 2 +- .../src/{berry_tasmota.h => berry_matter.h} | 0 .../berry_tasmota/src/be_crypto_lib.c | 12 -------- tasmota/my_user_config.h | 28 +++++++++++++++++++ .../tasmota_xdrv_driver/xdrv_52_9_berry.ino | 2 +- 5 files changed, 30 insertions(+), 14 deletions(-) rename lib/libesp32/berry_matter/src/{berry_tasmota.h => berry_matter.h} (100%) diff --git a/lib/libesp32/berry/default/be_modtab.c b/lib/libesp32/berry/default/be_modtab.c index e95c65ba2..50c4152b5 100644 --- a/lib/libesp32/berry/default/be_modtab.c +++ b/lib/libesp32/berry/default/be_modtab.c @@ -301,7 +301,7 @@ BERRY_LOCAL bclass_array be_class_table = { #endif // USE_UFILESYS &be_native_class(AudioOpusDecoder), #endif // USE_I2S_AUDIO_BERRY -#ifdef USE_BERRY_INT64 +#if defined(USE_BERRY_INT64) || defined(USE_MATTER_DEVICE) &be_native_class(int64), #endif #endif // TASMOTA diff --git a/lib/libesp32/berry_matter/src/berry_tasmota.h b/lib/libesp32/berry_matter/src/berry_matter.h similarity index 100% rename from lib/libesp32/berry_matter/src/berry_tasmota.h rename to lib/libesp32/berry_matter/src/berry_matter.h diff --git a/lib/libesp32/berry_tasmota/src/be_crypto_lib.c b/lib/libesp32/berry_tasmota/src/be_crypto_lib.c index 90c2ae7c6..621d17113 100644 --- a/lib/libesp32/berry_tasmota/src/be_crypto_lib.c +++ b/lib/libesp32/berry_tasmota/src/be_crypto_lib.c @@ -67,18 +67,6 @@ extern const bclass be_class_md5; #include "be_fixed_be_class_hkdf_sha256.h" #include "be_fixed_crypto.h" -// Enable all the crypto required by Matter -#ifdef USE_BERRY_CRYPTO_SPAKE2P_MATTER - #undef USE_BERRY_CRYPTO_EC_P256 - #define USE_BERRY_CRYPTO_EC_P256 - #undef USE_BERRY_CRYPTO_HMAC_SHA256 - #define USE_BERRY_CRYPTO_HMAC_SHA256 - #undef USE_BERRY_CRYPTO_HKDF_SHA256 - #define USE_BERRY_CRYPTO_HKDF_SHA256 - #undef USE_BERRY_CRYPTO_AES_CCM - #define USE_BERRY_CRYPTO_AES_CCM -#endif - const be_const_member_t be_crypto_members[] = { // name with prefix '/' indicates a Berry class // entries need to be sorted (ignoring the prefix char) diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index 1105b2fb8..73f79b3f4 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -1278,6 +1278,34 @@ #define USE_TLS // flag indicates we need to include TLS code #endif +/*********************************************************************************************\ + * Post-process compile options for Matter +\*********************************************************************************************/ + +#ifdef ESP32 +#ifdef USE_MATTER_DEVICE + #undef USE_DISCOVERY + #define USE_DISCOVERY + +// Enable all the crypto required by Matter + #undef USE_BERRY_CRYPTO_EC_P256 + #define USE_BERRY_CRYPTO_EC_P256 + #undef USE_BERRY_CRYPTO_HMAC_SHA256 + #define USE_BERRY_CRYPTO_HMAC_SHA256 + #undef USE_BERRY_CRYPTO_HKDF_SHA256 + #define USE_BERRY_CRYPTO_HKDF_SHA256 + #undef USE_BERRY_CRYPTO_AES_CCM + #define USE_BERRY_CRYPTO_AES_CCM + #undef USE_BERRY_CRYPTO_AES_CTR + #define USE_BERRY_CRYPTO_AES_CTR + #undef USE_BERRY_CRYPTO_PBKDF2_HMAC_SHA256 + #define USE_BERRY_CRYPTO_PBKDF2_HMAC_SHA256 + #undef USE_BERRY_CRYPTO_SPAKE2P_MATTER + #define USE_BERRY_CRYPTO_SPAKE2P_MATTER + +#endif // USE_MATTER_DEVICE +#endif + /*********************************************************************************************\ * Post-process stack size adjustment \*********************************************************************************************/ diff --git a/tasmota/tasmota_xdrv_driver/xdrv_52_9_berry.ino b/tasmota/tasmota_xdrv_driver/xdrv_52_9_berry.ino index d6e9fabf5..8bee89061 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_52_9_berry.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_52_9_berry.ino @@ -24,7 +24,7 @@ #include #include "berry_tasmota.h" -#ifdef USE_MATTER +#ifdef USE_MATTER_DEVICE #include "berry_matter.h" #endif #include "be_vm.h"