mirror of
https://github.com/espressif/openthread.git
synced 2026-07-29 07:07:47 +00:00
[key-manager] check if the key is present before exporting the key (#9814)
While trying to read the Pskc or networkkey, we check if the keyref is valid. We instead need to check if the key is present. There is a possibility that the persistent data was erased before trying to read the key, which might result in asserts.
This commit is contained in:
@@ -516,7 +516,7 @@ void KeyManager::HandleKeyRotationTimer(void)
|
||||
void KeyManager::GetNetworkKey(NetworkKey &aNetworkKey) const
|
||||
{
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE
|
||||
if (Crypto::Storage::IsKeyRefValid(mNetworkKeyRef))
|
||||
if (Crypto::Storage::HasKey(mNetworkKeyRef))
|
||||
{
|
||||
size_t keyLen;
|
||||
|
||||
@@ -535,7 +535,7 @@ void KeyManager::GetNetworkKey(NetworkKey &aNetworkKey) const
|
||||
void KeyManager::GetPskc(Pskc &aPskc) const
|
||||
{
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE
|
||||
if (Crypto::Storage::IsKeyRefValid(mPskcRef))
|
||||
if (Crypto::Storage::HasKey(mPskcRef))
|
||||
{
|
||||
size_t keyLen;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user