diff --git a/samples/matter/common/src/app/matter_init.cpp b/samples/matter/common/src/app/matter_init.cpp index 8a5f1a8a0ba8..1e629919603c 100644 --- a/samples/matter/common/src/app/matter_init.cpp +++ b/samples/matter/common/src/app/matter_init.cpp @@ -46,6 +46,10 @@ #include #endif +#ifdef CONFIG_CHIP_STORE_KEYS_IN_KMU +#include +#endif + #include #include #include @@ -72,6 +76,10 @@ Clusters::NetworkCommissioning::Instance Nrf::Matter::InitData::sWiFiCommissioni chip::Crypto::PSAOperationalKeystore Nrf::Matter::InitData::sOperationalKeystoreDefault{}; #endif +#ifdef CONFIG_CHIP_STORE_KEYS_IN_KMU +chip::DeviceLayer::KMUSessionKeystore Nrf::Matter::InitData::sKMUSessionKeystoreDefault{}; +#endif + #ifdef CONFIG_CHIP_FACTORY_DATA FactoryDataProvider Nrf::Matter::InitData::sFactoryDataProviderDefault{}; #endif @@ -87,6 +95,9 @@ Nrf::Matter::InitData sLocalInitData{ .mNetworkingInstance = nullptr, #endif #ifdef CONFIG_CHIP_CRYPTO_PSA .mOperationalKeyStore = nullptr, +#endif +#ifdef CONFIG_CHIP_STORE_KEYS_IN_KMU + .mSessionKeystore = nullptr, #endif .mPreServerInitClbk = nullptr, .mPostServerInitClbk = nullptr }; @@ -277,6 +288,13 @@ void DoInitChipServer(intptr_t /* unused */) sLocalInitData.mServerInitParams->operationalKeystore = sLocalInitData.mOperationalKeyStore; #endif +/* Set KMUKeyAllocator for devices that supports KMU */ +#ifdef CONFIG_CHIP_STORE_KEYS_IN_KMU + static KMUKeyAllocator kmuAllocator; + Crypto::SetPSAKeyAllocator(&kmuAllocator); + sLocalInitData.mServerInitParams->sessionKeystore = sLocalInitData.mSessionKeystore; +#endif + VerifyOrReturn(sLocalInitData.mServerInitParams, LOG_ERR("No valid server initialization parameters")); sInitResult = sLocalInitData.mServerInitParams->InitializeStaticResourcesBeforeServerInit(); VerifyInitResultOrReturn(sInitResult, "InitializeStaticResourcesBeforeServerInit() failed"); diff --git a/samples/matter/common/src/app/matter_init.h b/samples/matter/common/src/app/matter_init.h index 8a5d31da6f3f..3c3b1ae9171c 100644 --- a/samples/matter/common/src/app/matter_init.h +++ b/samples/matter/common/src/app/matter_init.h @@ -23,6 +23,10 @@ #include #endif +#ifdef CONFIG_CHIP_STORE_KEYS_IN_KMU +#include +#endif + #ifdef CONFIG_CHIP_FACTORY_DATA #include #else @@ -58,6 +62,10 @@ struct InitData { #ifdef CONFIG_CHIP_CRYPTO_PSA /** @brief Pointer to the user provided OperationalKeystore implementation. */ chip::Crypto::OperationalKeystore *mOperationalKeyStore{ &sOperationalKeystoreDefault }; +#endif +#ifdef CONFIG_CHIP_STORE_KEYS_IN_KMU + /** @brief Pointer to the user provided SessionKeystore implementation. */ + chip::Crypto::SessionKeystore *mSessionKeystore{ &sKMUSessionKeystoreDefault }; #endif /** @brief Custom code to execute in the Matter main event loop before the server initialization. */ CustomInit mPreServerInitClbk{ nullptr }; @@ -77,6 +85,9 @@ struct InitData { #ifdef CONFIG_CHIP_CRYPTO_PSA static chip::Crypto::PSAOperationalKeystore sOperationalKeystoreDefault; #endif +#ifdef CONFIG_CHIP_STORE_KEYS_IN_KMU + static chip::DeviceLayer::KMUSessionKeystore sKMUSessionKeystoreDefault; +#endif }; /** diff --git a/west.yml b/west.yml index 8dff90ec146f..65f0008d468f 100644 --- a/west.yml +++ b/west.yml @@ -159,7 +159,7 @@ manifest: - name: matter repo-path: sdk-connectedhomeip path: modules/lib/matter - revision: c63ff3ffd71d97ab36d9231fe8bd1ade1674e49e + revision: pull/539/head west-commands: scripts/west/west-commands.yml submodules: - name: nlio