diff --git a/modules/openthread/platform/crypto_psa.c b/modules/openthread/platform/crypto_psa.c index b5a63d60e43..e61177ef4c4 100644 --- a/modules/openthread/platform/crypto_psa.c +++ b/modules/openthread/platform/crypto_psa.c @@ -8,9 +8,14 @@ #include +#include + +#if !defined(CONFIG_BUILD_WITH_TFM) && defined(CONFIG_OPENTHREAD_CRYPTO_PSA) +#include +#endif + #if defined(CONFIG_OPENTHREAD_ECDSA) #include -#include #endif static otError psaToOtError(psa_status_t aStatus) @@ -125,6 +130,17 @@ static void ensureKeyIsLoaded(otCryptoKeyRef aKeyRef) void otPlatCryptoInit(void) { psa_crypto_init(); + +#if !defined(CONFIG_BUILD_WITH_TFM) && defined(CONFIG_OPENTHREAD_CRYPTO_PSA) + /* + * In OpenThread, Settings are initialized after KeyManager by default. If device uses + * PSA with emulated TFM, Settings have to be initialized at the end of otPlatCryptoInit(), + * to be available before storing Network Key. + */ + int err = settings_subsys_init(); + + __ASSERT(!err, "Failed to initialize settings"); +#endif } otError otPlatCryptoImportKey(otCryptoKeyRef *aKeyRef,