Require Thread Master Key to be 16 bytes. (#1724)

- Update code to use `otMasterKey` type.
This commit is contained in:
Jonathan Hui
2017-05-05 09:21:43 -07:00
committed by GitHub
parent 08f46b3038
commit da7ba8ba19
18 changed files with 89 additions and 140 deletions
+5 -4
View File
@@ -170,19 +170,20 @@ exit:
}
#endif
const uint8_t *otThreadGetMasterKey(otInstance *aInstance, uint8_t *aKeyLength)
const otMasterKey *otThreadGetMasterKey(otInstance *aInstance)
{
return aInstance->mThreadNetif.GetKeyManager().GetMasterKey(aKeyLength);
return &aInstance->mThreadNetif.GetKeyManager().GetMasterKey();
}
ThreadError otThreadSetMasterKey(otInstance *aInstance, const uint8_t *aKey, uint8_t aKeyLength)
ThreadError otThreadSetMasterKey(otInstance *aInstance, const otMasterKey *aKey)
{
ThreadError error = kThreadError_None;
VerifyOrExit(aKey != NULL, error = kThreadError_InvalidArgs);
VerifyOrExit(aInstance->mThreadNetif.GetMle().GetDeviceState() == Mle::kDeviceStateDisabled,
error = kThreadError_InvalidState);
error = aInstance->mThreadNetif.GetKeyManager().SetMasterKey(aKey, aKeyLength);
error = aInstance->mThreadNetif.GetKeyManager().SetMasterKey(*aKey);
aInstance->mThreadNetif.GetActiveDataset().Clear(false);
aInstance->mThreadNetif.GetPendingDataset().Clear(false);