diff --git a/src/core/mac/mac.hpp b/src/core/mac/mac.hpp index 790823b73..7d7ca9083 100644 --- a/src/core/mac/mac.hpp +++ b/src/core/mac/mac.hpp @@ -134,6 +134,11 @@ public: */ explicit Mac(Instance &aInstance); + /** + * Clears the Mode2Key on destruction. + */ + ~Mac(void) { ClearMode2Key(); } + /** * Starts an IEEE 802.15.4 Active Scan. * diff --git a/src/core/thread/key_manager.cpp b/src/core/thread/key_manager.cpp index d520d8162..f98793a7a 100644 --- a/src/core/thread/key_manager.cpp +++ b/src/core/thread/key_manager.cpp @@ -691,7 +691,6 @@ void KeyManager::DestroyTemporaryKeys(void) mMleKey.Clear(); mKek.Clear(); Get().ClearMacKeys(); - Get().ClearMode2Key(); } void KeyManager::DestroyPersistentKeys(void) { Get().DestroyPersistentKeys(); }