diff --git a/examples/platform/silabs/MatterConfig.cpp b/examples/platform/silabs/MatterConfig.cpp index b7f007b07b..63e6b2ff10 100644 --- a/examples/platform/silabs/MatterConfig.cpp +++ b/examples/platform/silabs/MatterConfig.cpp @@ -48,10 +48,12 @@ #include "MemMonitoring.h" #endif -#if defined(SLI_SI91X_MCU_INTERFACE) && SLI_SI91X_MCU_INTERFACE == 1 -#include +#if ( ( defined(SLI_SI91X_MCU_INTERFACE) && SLI_SI91X_MCU_INTERFACE == 1 ) || defined(EXP_BOARD) ) #include -#endif // SLI_SI91X_MCU_INTERFACE +#if !defined(EXP_BOARD) +#include +#endif //!defined(EXP_BOARD) +#endif // ( ( defined(SLI_SI91X_MCU_INTERFACE) && SLI_SI91X_MCU_INTERFACE == 1 ) || defined(EXP_BOARD) ) #include // If building with the EFR32-provided crypto backend, we can use the @@ -379,9 +381,9 @@ CHIP_ERROR SilabsMatterConfig::InitWiFi(void) #endif // SL_WFX_USE_SECURE_LINK #endif // WF200_WIFI -#if defined(SLI_SI91X_MCU_INTERFACE) && SLI_SI91X_MCU_INTERFACE == 1 +#if ( ( defined(SLI_SI91X_MCU_INTERFACE) && SLI_SI91X_MCU_INTERFACE == 1 ) || defined(EXP_BOARD) ) VerifyOrReturnError(sl_matter_wifi_platform_init() == SL_STATUS_OK, CHIP_ERROR_INTERNAL); -#endif // SLI_SI91X_MCU_INTERFACE +#endif // ( ( defined(SLI_SI91X_MCU_INTERFACE) && SLI_SI91X_MCU_INTERFACE == 1 ) || defined(EXP_BOARD) ) return CHIP_NO_ERROR; } diff --git a/examples/refrigerator-app/silabs/BUILD.gn b/examples/refrigerator-app/silabs/BUILD.gn index 27c59f70a8..d902bb9e86 100644 --- a/examples/refrigerator-app/silabs/BUILD.gn +++ b/examples/refrigerator-app/silabs/BUILD.gn @@ -18,7 +18,7 @@ import("//build_overrides/efr32_sdk.gni") import("//build_overrides/pigweed.gni") import("${build_root}/config/defaults.gni") -import("${efr32_sdk_build_root}/silabs_executable.gni") +import("${silabs_sdk_build_root}/silabs_executable.gni") import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni") import("${chip_root}/src/platform/device.gni") @@ -38,7 +38,7 @@ if (wifi_soc) { import("${chip_root}/third_party/silabs/SiWx917_sdk.gni") examples_plat_dir = "${chip_root}/examples/platform/silabs/SiWx917" } else { - import("${efr32_sdk_build_root}/efr32_sdk.gni") + import("${silabs_sdk_build_root}/efr32_sdk.gni") examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32" } diff --git a/examples/refrigerator-app/silabs/data_model/refrigerator-thread-app.matter b/examples/refrigerator-app/silabs/data_model/refrigerator-thread-app.matter index 609073bd13..4032a398a7 100644 --- a/examples/refrigerator-app/silabs/data_model/refrigerator-thread-app.matter +++ b/examples/refrigerator-app/silabs/data_model/refrigerator-thread-app.matter @@ -1642,6 +1642,7 @@ cluster RefrigeratorAlarm = 87 { endpoint 0 { device type ma_rootdevice = 22, version 1; + binding cluster OtaSoftwareUpdateProvider; server cluster Identify { ram attribute identifyTime default = 0x0; @@ -1717,21 +1718,6 @@ endpoint 0 { ram attribute clusterRevision default = 3; } - server cluster OtaSoftwareUpdateProvider { - callback attribute generatedCommandList; - callback attribute acceptedCommandList; - callback attribute eventList; - callback attribute attributeList; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 1; - - handle command QueryImage; - handle command QueryImageResponse; - handle command ApplyUpdateRequest; - handle command ApplyUpdateResponse; - handle command NotifyUpdateApplied; - } - server cluster OtaSoftwareUpdateRequestor { callback attribute defaultOTAProviders; ram attribute updatePossible default = true; diff --git a/examples/refrigerator-app/silabs/data_model/refrigerator-thread-app.zap b/examples/refrigerator-app/silabs/data_model/refrigerator-thread-app.zap index 33f6b28215..504e8145ad 100644 --- a/examples/refrigerator-app/silabs/data_model/refrigerator-thread-app.zap +++ b/examples/refrigerator-app/silabs/data_model/refrigerator-thread-app.zap @@ -41,14 +41,16 @@ "code": 22, "profileId": 259, "label": "MA-rootdevice", - "name": "MA-rootdevice" + "name": "MA-rootdevice", + "deviceTypeOrder": 0 }, "deviceTypes": [ { "code": 22, "profileId": 259, "label": "MA-rootdevice", - "name": "MA-rootdevice" + "name": "MA-rootdevice", + "deviceTypeOrder": 0 } ], "deviceVersions": [ @@ -1027,7 +1029,7 @@ "code": 41, "mfgCode": null, "define": "OTA_SOFTWARE_UPDATE_PROVIDER_CLUSTER", - "side": "server", + "side": "client", "enabled": 1, "commands": [ { @@ -1035,7 +1037,7 @@ "code": 0, "mfgCode": null, "source": "client", - "isIncoming": 1, + "isIncoming": 0, "isEnabled": 1 }, { @@ -1043,7 +1045,7 @@ "code": 1, "mfgCode": null, "source": "server", - "isIncoming": 0, + "isIncoming": 1, "isEnabled": 1 }, { @@ -1051,7 +1053,7 @@ "code": 2, "mfgCode": null, "source": "client", - "isIncoming": 1, + "isIncoming": 0, "isEnabled": 1 }, { @@ -1059,7 +1061,7 @@ "code": 3, "mfgCode": null, "source": "server", - "isIncoming": 0, + "isIncoming": 1, "isEnabled": 1 }, { @@ -1067,107 +1069,9 @@ "code": 4, "mfgCode": null, "source": "client", - "isIncoming": 1, + "isIncoming": 0, "isEnabled": 1 } - ], - "attributes": [ - { - "name": "GeneratedCommandList", - "code": 65528, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "AcceptedCommandList", - "code": 65529, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "EventList", - "code": 65530, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "AttributeList", - "code": 65531, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "FeatureMap", - "code": 65532, - "mfgCode": null, - "side": "server", - "type": "bitmap32", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "ClusterRevision", - "code": 65533, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "1", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - } ] }, { @@ -3149,14 +3053,16 @@ "code": 112, "profileId": 259, "label": "MA-refrigerator", - "name": "MA-refrigerator" + "name": "MA-refrigerator", + "deviceTypeOrder": 0 }, "deviceTypes": [ { "code": 112, "profileId": 259, "label": "MA-refrigerator", - "name": "MA-refrigerator" + "name": "MA-refrigerator", + "deviceTypeOrder": 0 } ], "deviceVersions": [ @@ -3642,14 +3548,16 @@ "code": 113, "profileId": 259, "label": "MA-temperature-controlled-cabinet", - "name": "MA-temperature-controlled-cabinet" + "name": "MA-temperature-controlled-cabinet", + "deviceTypeOrder": 0 }, "deviceTypes": [ { "code": 113, "profileId": 259, "label": "MA-temperature-controlled-cabinet", - "name": "MA-temperature-controlled-cabinet" + "name": "MA-temperature-controlled-cabinet", + "deviceTypeOrder": 0 } ], "deviceVersions": [ @@ -3989,14 +3897,16 @@ "code": 113, "profileId": 259, "label": "MA-temperature-controlled-cabinet", - "name": "MA-temperature-controlled-cabinet" + "name": "MA-temperature-controlled-cabinet", + "deviceTypeOrder": 0 }, "deviceTypes": [ { "code": 113, "profileId": 259, "label": "MA-temperature-controlled-cabinet", - "name": "MA-temperature-controlled-cabinet" + "name": "MA-temperature-controlled-cabinet", + "deviceTypeOrder": 0 } ], "deviceVersions": [ diff --git a/examples/refrigerator-app/silabs/data_model/refrigerator-wifi-app.matter b/examples/refrigerator-app/silabs/data_model/refrigerator-wifi-app.matter index f5ab8368ed..76fc7e74eb 100644 --- a/examples/refrigerator-app/silabs/data_model/refrigerator-wifi-app.matter +++ b/examples/refrigerator-app/silabs/data_model/refrigerator-wifi-app.matter @@ -1553,6 +1553,7 @@ cluster RefrigeratorAlarm = 87 { endpoint 0 { device type ma_rootdevice = 22, version 1; + binding cluster OtaSoftwareUpdateProvider; server cluster Identify { ram attribute identifyTime default = 0x0; @@ -1628,21 +1629,6 @@ endpoint 0 { ram attribute clusterRevision default = 3; } - server cluster OtaSoftwareUpdateProvider { - callback attribute generatedCommandList; - callback attribute acceptedCommandList; - callback attribute eventList; - callback attribute attributeList; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 1; - - handle command QueryImage; - handle command QueryImageResponse; - handle command ApplyUpdateRequest; - handle command ApplyUpdateResponse; - handle command NotifyUpdateApplied; - } - server cluster OtaSoftwareUpdateRequestor { callback attribute defaultOTAProviders; ram attribute updatePossible default = true; diff --git a/examples/refrigerator-app/silabs/data_model/refrigerator-wifi-app.zap b/examples/refrigerator-app/silabs/data_model/refrigerator-wifi-app.zap index cad2cdb21b..bfd95ea278 100644 --- a/examples/refrigerator-app/silabs/data_model/refrigerator-wifi-app.zap +++ b/examples/refrigerator-app/silabs/data_model/refrigerator-wifi-app.zap @@ -41,14 +41,16 @@ "code": 22, "profileId": 259, "label": "MA-rootdevice", - "name": "MA-rootdevice" + "name": "MA-rootdevice", + "deviceTypeOrder": 0 }, "deviceTypes": [ { "code": 22, "profileId": 259, "label": "MA-rootdevice", - "name": "MA-rootdevice" + "name": "MA-rootdevice", + "deviceTypeOrder": 0 } ], "deviceVersions": [ @@ -1027,7 +1029,7 @@ "code": 41, "mfgCode": null, "define": "OTA_SOFTWARE_UPDATE_PROVIDER_CLUSTER", - "side": "server", + "side": "client", "enabled": 1, "commands": [ { @@ -1035,7 +1037,7 @@ "code": 0, "mfgCode": null, "source": "client", - "isIncoming": 1, + "isIncoming": 0, "isEnabled": 1 }, { @@ -1043,7 +1045,7 @@ "code": 1, "mfgCode": null, "source": "server", - "isIncoming": 0, + "isIncoming": 1, "isEnabled": 1 }, { @@ -1051,7 +1053,7 @@ "code": 2, "mfgCode": null, "source": "client", - "isIncoming": 1, + "isIncoming": 0, "isEnabled": 1 }, { @@ -1059,7 +1061,7 @@ "code": 3, "mfgCode": null, "source": "server", - "isIncoming": 0, + "isIncoming": 1, "isEnabled": 1 }, { @@ -1067,107 +1069,9 @@ "code": 4, "mfgCode": null, "source": "client", - "isIncoming": 1, + "isIncoming": 0, "isEnabled": 1 } - ], - "attributes": [ - { - "name": "GeneratedCommandList", - "code": 65528, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "AcceptedCommandList", - "code": 65529, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "EventList", - "code": 65530, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "AttributeList", - "code": 65531, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "FeatureMap", - "code": 65532, - "mfgCode": null, - "side": "server", - "type": "bitmap32", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "ClusterRevision", - "code": 65533, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "1", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - } ] }, { @@ -3038,14 +2942,16 @@ "code": 112, "profileId": 259, "label": "MA-refrigerator", - "name": "MA-refrigerator" + "name": "MA-refrigerator", + "deviceTypeOrder": 0 }, "deviceTypes": [ { "code": 112, "profileId": 259, "label": "MA-refrigerator", - "name": "MA-refrigerator" + "name": "MA-refrigerator", + "deviceTypeOrder": 0 } ], "deviceVersions": [ @@ -3531,14 +3437,16 @@ "code": 113, "profileId": 259, "label": "MA-temperature-controlled-cabinet", - "name": "MA-temperature-controlled-cabinet" + "name": "MA-temperature-controlled-cabinet", + "deviceTypeOrder": 0 }, "deviceTypes": [ { "code": 113, "profileId": 259, "label": "MA-temperature-controlled-cabinet", - "name": "MA-temperature-controlled-cabinet" + "name": "MA-temperature-controlled-cabinet", + "deviceTypeOrder": 0 } ], "deviceVersions": [ @@ -3878,14 +3786,16 @@ "code": 113, "profileId": 259, "label": "MA-temperature-controlled-cabinet", - "name": "MA-temperature-controlled-cabinet" + "name": "MA-temperature-controlled-cabinet", + "deviceTypeOrder": 0 }, "deviceTypes": [ { "code": 113, "profileId": 259, "label": "MA-temperature-controlled-cabinet", - "name": "MA-temperature-controlled-cabinet" + "name": "MA-temperature-controlled-cabinet", + "deviceTypeOrder": 0 } ], "deviceVersions": [ diff --git a/src/platform/silabs/PlatformManagerImpl.cpp b/src/platform/silabs/PlatformManagerImpl.cpp index 9ffb217103..5739fb7e20 100644 --- a/src/platform/silabs/PlatformManagerImpl.cpp +++ b/src/platform/silabs/PlatformManagerImpl.cpp @@ -84,10 +84,10 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) err = chip::DeviceLayer::PersistedStorage::KeyValueStoreMgrImpl().Init(); SuccessOrExit(err); -#if CHIP_SYSTEM_CONFIG_USE_LWIP && !defined(SLI_SI91X_MCU_INTERFACE) +#if CHIP_SYSTEM_CONFIG_USE_LWIP && !defined(SLI_SI91X_MCU_INTERFACE) && !defined(EXP_BOARD) // Initialize LwIP. tcpip_init(NULL, NULL); -#endif // CHIP_SYSTEM_CONFIG_USE_LWIP && !defined(SLI_SI91X_MCU_INTERFACE) +#endif // CHIP_SYSTEM_CONFIG_USE_LWIP && !defined(SLI_SI91X_MCU_INTERFACE) && !defined(EXP_BOARD) ReturnErrorOnFailure(System::Clock::InitClock_RealTime()); diff --git a/src/platform/silabs/SiWx917/BUILD.gn b/src/platform/silabs/SiWx917/BUILD.gn index 826d8accd9..3f7adf8269 100644 --- a/src/platform/silabs/SiWx917/BUILD.gn +++ b/src/platform/silabs/SiWx917/BUILD.gn @@ -101,7 +101,6 @@ static_library("SiWx917") { public_deps += [ "${chip_root}/src/crypto", - "${mbedtls_root}:mbedtls", "${silabs_platform_dir}/wifi:wifi-platform", ] } diff --git a/src/platform/silabs/SiWx917/CHIPCryptoPALTinyCrypt.cpp b/src/platform/silabs/SiWx917/CHIPCryptoPALTinyCrypt.cpp index 52f2cb74b9..afcfe1db83 100644 --- a/src/platform/silabs/SiWx917/CHIPCryptoPALTinyCrypt.cpp +++ b/src/platform/silabs/SiWx917/CHIPCryptoPALTinyCrypt.cpp @@ -17,8 +17,9 @@ /** * @file - * mbedTLS based implementation of CHIP crypto primitives + * mbedTLS and Tinycrypt based implementation of CHIP crypto primitives */ +#include #include @@ -34,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -44,7 +46,6 @@ #include #include -#include #include #include #include @@ -58,14 +59,18 @@ #include #include -#include - -#ifdef SLI_SI91X_MCU_INTERFACE +#ifdef __cplusplus extern "C" { -#include "sl_si91x_trng.h" -} +#endif + +#if defined(SLI_SI91X_MCU_INTERFACE) +#include #endif // SLI_SI91X_MCU_INTERFACE +#ifdef __cplusplus +} +#endif + namespace chip { namespace Crypto { @@ -85,6 +90,8 @@ namespace Crypto { #define CHIP_CRYPTO_PAL_PRIVATE_X509(x) x #endif +namespace { + typedef struct { bool mInitialized; @@ -93,9 +100,15 @@ typedef struct mbedtls_entropy_context mEntropy; } EntropyContext; +typedef struct +{ + uint8_t private_key[NUM_ECC_BYTES]; + uint8_t public_key[2 * NUM_ECC_BYTES]; +} mbedtls_uecc_keypair; + static EntropyContext gsEntropyContext; -static void _log_mbedTLS_error(int error_code) +void _log_mbedTLS_error(int error_code) { if (error_code != 0 && error_code != UECC_SUCCESS) { @@ -110,7 +123,7 @@ static void _log_mbedTLS_error(int error_code) } } -static bool _isValidTagLength(size_t tag_length) +bool _isValidTagLength(size_t tag_length) { if (tag_length == 8 || tag_length == 12 || tag_length == 16) { @@ -118,6 +131,7 @@ static bool _isValidTagLength(size_t tag_length) } return false; } +} // namespace CHIP_ERROR AES_CCM_encrypt(const uint8_t * plaintext, size_t plaintext_length, const uint8_t * aad, size_t aad_length, const Aes128KeyHandle & key, const uint8_t * nonce, size_t nonce_length, uint8_t * ciphertext, @@ -494,11 +508,6 @@ CHIP_ERROR DRBG_get_bytes(uint8_t * out_buffer, const size_t out_length) return CHIP_NO_ERROR; } -static int CryptoRNG(void * ctxt, uint8_t * out_buffer, size_t out_length) -{ - return (chip::Crypto::DRBG_get_bytes(out_buffer, out_length) == CHIP_NO_ERROR) ? 0 : 1; -} - mbedtls_ecp_group_id MapECPGroupId(SupportedECPKeyTypes keyType) { switch (keyType) @@ -734,53 +743,11 @@ P256Keypair::~P256Keypair() CHIP_ERROR P256Keypair::NewCertificateSigningRequest(uint8_t * out_csr, size_t & csr_length) const { - CHIP_ERROR error = CHIP_NO_ERROR; - int result = 0; - size_t out_length; - - mbedtls_x509write_csr csr; - mbedtls_x509write_csr_init(&csr); - - mbedtls_pk_context pk; - pk.CHIP_CRYPTO_PAL_PRIVATE(pk_info) = mbedtls_pk_info_from_type(MBEDTLS_PK_ECKEY); - pk.CHIP_CRYPTO_PAL_PRIVATE(pk_ctx) = to_keypair(&mKeypair); - VerifyOrExit(pk.CHIP_CRYPTO_PAL_PRIVATE(pk_info) != nullptr, error = CHIP_ERROR_INTERNAL); - - VerifyOrExit(mInitialized, error = CHIP_ERROR_UNINITIALIZED); - - mbedtls_x509write_csr_set_key(&csr, &pk); - - mbedtls_x509write_csr_set_md_alg(&csr, MBEDTLS_MD_SHA256); - - // TODO: mbedTLS CSR parser fails if the subject name is not set (or if empty). - // CHIP Spec doesn't specify the subject name that can be used. - // Figure out the correct value and update this code. - result = mbedtls_x509write_csr_set_subject_name(&csr, "O=CSR"); - VerifyOrExit(result == 0, error = CHIP_ERROR_INTERNAL); - - result = mbedtls_x509write_csr_der(&csr, out_csr, csr_length, CryptoRNG, nullptr); - VerifyOrExit(result > 0, error = CHIP_ERROR_INTERNAL); - VerifyOrExit(CanCastTo(result), error = CHIP_ERROR_INTERNAL); - - out_length = static_cast(result); - result = 0; - VerifyOrExit(out_length <= csr_length, error = CHIP_ERROR_INTERNAL); - - if (csr_length != out_length) - { - // mbedTLS API writes the CSR at the end of the provided buffer. - // Let's move it to the start of the buffer. - size_t offset = csr_length - out_length; - memmove(out_csr, &out_csr[offset], out_length); - } - - csr_length = out_length; - -exit: - mbedtls_x509write_csr_free(&csr); - - _log_mbedTLS_error(result); - return error; + MutableByteSpan csr(out_csr, csr_length); + CHIP_ERROR err = GenerateCertificateSigningRequest(this, csr); + csr_length = (CHIP_NO_ERROR == err) ? csr.size() : 0; + ChipLogByteSpan(Crypto, csr); + return err; } CHIP_ERROR VerifyCertificateSigningRequest(const uint8_t * csr_buf, size_t csr_length, P256PublicKey & pubkey) @@ -1523,7 +1490,7 @@ CHIP_ERROR ExtractPubkeyFromX509Cert(const ByteSpan & certificate, Crypto::P256P VerifyOrExit(mbedtls_pk_get_type(&(mbed_cert.CHIP_CRYPTO_PAL_PRIVATE_X509(pk))) == MBEDTLS_PK_ECKEY, error = CHIP_ERROR_INVALID_ARGUMENT); - keypair = mbedtls_pk_uecc(mbed_cert.CHIP_CRYPTO_PAL_PRIVATE_X509(pk)); + keypair = (mbedtls_uecc_keypair *) (mbedtls_pk_ec(mbed_cert.CHIP_CRYPTO_PAL_PRIVATE_X509(pk))); Uint8::to_uchar(pubkey)[0] = 0x04; // uncompressed type memcpy(Uint8::to_uchar(pubkey) + 1, keypair->public_key, 2 * NUM_ECC_BYTES); diff --git a/src/platform/silabs/SiWx917/siwx917-chip-mbedtls-config.h b/src/platform/silabs/SiWx917/siwx917-chip-mbedtls-config.h index de0298957c..fd4d7c45df 100644 --- a/src/platform/silabs/SiWx917/siwx917-chip-mbedtls-config.h +++ b/src/platform/silabs/SiWx917/siwx917-chip-mbedtls-config.h @@ -81,6 +81,7 @@ #define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED #define MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED #define MBEDTLS_KEY_EXCHANGE_PSK_ENABLED +#define MBEDTLS_PK_HAVE_ECC_KEYS #define MBEDTLS_SHA256_SMALLER #define MBEDTLS_SHA512_C #define MBEDTLS_SSL_CLI_C diff --git a/src/platform/silabs/wifi/SiWx/WifiInterface.cpp b/src/platform/silabs/wifi/SiWx/WifiInterface.cpp index 0e8181cc06..12b8b3733c 100644 --- a/src/platform/silabs/wifi/SiWx/WifiInterface.cpp +++ b/src/platform/silabs/wifi/SiWx/WifiInterface.cpp @@ -254,12 +254,6 @@ sl_status_t sl_wifi_siwx917_init(void) RSI_NPSSGPIO_InputBufferEn(RTE_UULP_GPIO_1_PIN, 1); #endif // ENABLE_CHIP_SHELL #endif // CHIP_CONFIG_ENABLE_ICD_SERVER - -#else - // NCP Configurations - status = sl_matter_wifi_platform_init(); - VerifyOrReturnError(status == SL_STATUS_OK, status, - ChipLogError(DeviceLayer, "sl_matter_wifi_platform_init failed: 0x%lx", static_cast(status))); #endif // SLI_SI91X_MCU_INTERFACE sl_wifi_firmware_version_t version = { 0 }; diff --git a/src/platform/silabs/wifi/lwip-support/ethernetif.cpp b/src/platform/silabs/wifi/lwip-support/ethernetif.cpp index 7e880f62e9..0e438161c5 100644 --- a/src/platform/silabs/wifi/lwip-support/ethernetif.cpp +++ b/src/platform/silabs/wifi/lwip-support/ethernetif.cpp @@ -354,6 +354,7 @@ static err_t low_level_output(struct netif * netif, struct pbuf * p) struct pbuf * q; uint16_t framelength = 0; uint16_t datalength = 0; + int32_t status = 0; #ifdef WIFI_DEBUG_ENABLED ChipLogProgress(DeviceLayer, "LWIP : low_level_output"); #endif @@ -375,14 +376,14 @@ static err_t low_level_output(struct netif * netif, struct pbuf * p) #endif if ((netif->flags & (NETIF_FLAG_LINK_UP | NETIF_FLAG_UP)) != (NETIF_FLAG_LINK_UP | NETIF_FLAG_UP)) { - ChipLogProgress(DeviceLayer, "EN-RSI:NOT UP"); + ChipLogError(DeviceLayer, "EN-RSI:NOT UP"); xSemaphoreGive(ethout_sem); return ERR_IF; } packet = wfx_rsi_alloc_pkt(); if (!packet) { - ChipLogProgress(DeviceLayer, "EN-RSI:No buf"); + ChipLogError(DeviceLayer, "EN-RSI:No buf"); xSemaphoreGive(ethout_sem); return ERR_IF; } @@ -410,9 +411,10 @@ static err_t low_level_output(struct netif * netif, struct pbuf * p) /* forward the generated packet to RSI to * send the data over wifi network */ - if (wfx_rsi_send_data(packet, datalength)) + status = wfx_rsi_send_data(packet, datalength); + if (status != 0) { - ChipLogProgress(DeviceLayer, "*ERR*EN-RSI:Send fail"); + ChipLogError(DeviceLayer, "*ERR*EN-RSI:Send fail: %ld", status); xSemaphoreGive(ethout_sem); return ERR_IF; } diff --git a/src/platform/silabs/wifi/rs911x/WifiInterface.cpp b/src/platform/silabs/wifi/rs911x/WifiInterface.cpp index e78507c4f1..9f2c7b3c0e 100644 --- a/src/platform/silabs/wifi/rs911x/WifiInterface.cpp +++ b/src/platform/silabs/wifi/rs911x/WifiInterface.cpp @@ -19,6 +19,7 @@ #include "silabs_utils.h" #include "sl_status.h" #include +#include #include #include #include @@ -599,6 +600,9 @@ void HandleDHCPPolling(void) */ if ((ip6_addr_ispreferred(netif_ip6_addr_state(sta_netif, 0))) && !hasNotifiedIPV6) { + char addrStr[chip::Inet::IPAddress::kMaxStringLength] = { 0 }; + VerifyOrReturn(ip6addr_ntoa_r(netif_ip6_addr(sta_netif, 0), addrStr, sizeof(addrStr)) != nullptr); + ChipLogProgress(DeviceLayer, "SLAAC OK: linklocal addr: %s", addrStr); wfx_ipv6_notify(GET_IPV6_SUCCESS); hasNotifiedIPV6 = true; WifiEvent event = WifiEvent::kStationDhcpDone; diff --git a/src/platform/silabs/wifi/rs911x/platform/efx32_ncp_host.c b/src/platform/silabs/wifi/rs911x/platform/efx32_ncp_host.c index 0d269f5806..1c7fe2d194 100644 --- a/src/platform/silabs/wifi/rs911x/platform/efx32_ncp_host.c +++ b/src/platform/silabs/wifi/rs911x/platform/efx32_ncp_host.c @@ -33,6 +33,9 @@ #include #include #include +#include "sl_spidrv_exp_config.h" +#include "sl_spidrv_instances.h" +#include "spidrv.h" #if defined(SL_CATLOG_POWER_MANAGER_PRESENT) #include "sl_power_manager.h" @@ -42,25 +45,21 @@ #include "sl_board_control.h" #endif // SL_BOARD_NAME -#include "sl_spidrv_exp_config.h" -#include "sl_spidrv_instances.h" -#include "spidrv.h" -#define MAX_DATA_PACKET_SIZE 1800 #define LDMA_MAX_TRANSFER_LENGTH 4096 #define LDMA_DESCRIPTOR_ARRAY_LENGTH (LDMA_MAX_TRANSFER_LENGTH / 2048) +#define SPI_HANDLE sl_spidrv_exp_handle +#define MAX_DATA_PACKET_SIZE 1800 // use SPI handle for EXP header (configured in project settings) extern SPIDRV_Handle_t sl_spidrv_exp_handle; -#define SPI_HANDLE sl_spidrv_exp_handle static uint8_t dummy_buffer[MAX_DATA_PACKET_SIZE] = { 0 }; +static sl_si91x_host_init_configuration init_config = { 0 }; uint32_t rx_ldma_channel; uint32_t tx_ldma_channel; osMutexId_t ncp_transfer_mutex = 0; -static sl_si91x_host_init_configuration init_config = { 0 }; - // LDMA descriptor and transfer configuration structures for USART TX channel LDMA_Descriptor_t ldmaTXDescriptor[LDMA_DESCRIPTOR_ARRAY_LENGTH]; LDMA_TransferCfg_t ldmaTXConfig; diff --git a/third_party/silabs/SiWx917_sdk.gni b/third_party/silabs/SiWx917_sdk.gni index 3d22486601..2688f7efe6 100644 --- a/third_party/silabs/SiWx917_sdk.gni +++ b/third_party/silabs/SiWx917_sdk.gni @@ -534,7 +534,7 @@ template("siwx917_sdk") { } if (sl_si91x_crypto_flavor == "tinycrypt") { - _mbedtls_root = "${mbedtls_root}/repo" + _mbedtls_root = "${efr32_sdk_root}/util/third_party/mbedtls" config("siwx917_tinycrypt_config") { defines = [ @@ -543,7 +543,7 @@ template("siwx917_sdk") { ] include_dirs = [ - "${sdk_support_root}/matter/mbedtls/tinycrypt/inc", + # mbedTLS headers "${_mbedtls_root}/include", "${_mbedtls_root}/library", @@ -551,6 +551,9 @@ template("siwx917_sdk") { "${efr32_sdk_root}/platform/security/sl_component/sl_mbedtls_support/config", "${efr32_sdk_root}/platform/security/sl_component/sl_mbedtls_support/config/preset", "${efr32_sdk_root}/platform/security/sl_component/sl_mbedtls_support/inc", + + # tinycrypt specific headers + "${sdk_support_root}/matter/mbedtls/tinycrypt/inc", ] } @@ -567,6 +570,7 @@ template("siwx917_sdk") { "${_mbedtls_root}/library/asn1write.c", "${_mbedtls_root}/library/base64.c", "${_mbedtls_root}/library/bignum.c", + "${_mbedtls_root}/library/bignum_core.c", "${_mbedtls_root}/library/ccm.c", "${_mbedtls_root}/library/cipher.c", "${_mbedtls_root}/library/cipher_wrap.c", @@ -577,30 +581,34 @@ template("siwx917_sdk") { "${_mbedtls_root}/library/ecp.c", "${_mbedtls_root}/library/ecp_curves.c", "${_mbedtls_root}/library/entropy.c", + "${_mbedtls_root}/library/error.c", "${_mbedtls_root}/library/hkdf.c", "${_mbedtls_root}/library/hmac_drbg.c", "${_mbedtls_root}/library/md.c", "${_mbedtls_root}/library/pem.c", "${_mbedtls_root}/library/pkcs5.c", "${_mbedtls_root}/library/platform.c", + "${_mbedtls_root}/library/platform_util.c", "${_mbedtls_root}/library/sha256.c", "${_mbedtls_root}/library/sha512.c", "${_mbedtls_root}/library/version.c", "${_mbedtls_root}/library/x509_create.c", + # mbedtls + tinycrypt integration + "${_mbedtls_root}/library/oid.c", + "${_mbedtls_root}/library/pk.c", + "${_mbedtls_root}/library/pk_wrap.c", + "${_mbedtls_root}/library/pk_wrap.h", + "${_mbedtls_root}/library/pkparse.c", + "${_mbedtls_root}/library/pkwrite.c", + "${_mbedtls_root}/library/x509_crt.c", + "${_mbedtls_root}/library/x509write_csr.c", + # tinycrypt "${sdk_support_root}/matter/mbedtls/tinycrypt/src/ecc.c", "${sdk_support_root}/matter/mbedtls/tinycrypt/src/ecc_dh.c", "${sdk_support_root}/matter/mbedtls/tinycrypt/src/ecc_dsa.c", - "${sdk_support_root}/matter/mbedtls/tinycrypt/src/error.c", - "${sdk_support_root}/matter/mbedtls/tinycrypt/src/oid.c", - "${sdk_support_root}/matter/mbedtls/tinycrypt/src/pk.c", - "${sdk_support_root}/matter/mbedtls/tinycrypt/src/pk_wrap.c", - "${sdk_support_root}/matter/mbedtls/tinycrypt/src/pkparse.c", - "${sdk_support_root}/matter/mbedtls/tinycrypt/src/pkwrite.c", - "${sdk_support_root}/matter/mbedtls/tinycrypt/src/platform_util.c", - "${sdk_support_root}/matter/mbedtls/tinycrypt/src/x509_crt.c", - "${sdk_support_root}/matter/mbedtls/tinycrypt/src/x509write_csr.c", + "${sdk_support_root}/matter/mbedtls/tinycrypt/src/tinycrypt_util.c", ] public_deps = [ "${chip_root}/src/crypto:crypto_buildconfig" ] diff --git a/third_party/silabs/matter_support b/third_party/silabs/matter_support index eab695e438..a9aecbaa7c 160000 --- a/third_party/silabs/matter_support +++ b/third_party/silabs/matter_support @@ -1 +1 @@ -Subproject commit eab695e438ada903a18956eb916696678227cb0d +Subproject commit a9aecbaa7c4785f214450a49de140f067980337f