[dataset] set key rotation time in security policy on random generation (#5877)

This commit updates `Dataset::Info::GenerateRandom()` to set the Key
Rotation Time in Security Policy component on a Dataset using the
default value (from `KeyManager`). This addresses the issue where the
generated Operational Dataset could potentially use zero for Key
Rotation time.

This commit also changes Security Policy Flags to use default value
from `KeyManager`.
This commit is contained in:
Abtin Keshavarzian
2020-11-29 20:02:17 -08:00
committed by GitHub
parent c7165c9bf0
commit 23f5d09d66
3 changed files with 17 additions and 7 deletions
+6 -5
View File
@@ -67,11 +67,12 @@ otError Dataset::Info::GenerateRandom(Instance &aInstance)
Clear();
mActiveTimestamp = 1;
mChannel = preferredChannels.ChooseRandomChannel();
mChannelMask = supportedChannels.GetMask();
mSecurityPolicy.mFlags = aInstance.Get<KeyManager>().GetSecurityPolicyFlags();
mPanId = Mac::GenerateRandomPanId();
mActiveTimestamp = 1;
mChannel = preferredChannels.ChooseRandomChannel();
mChannelMask = supportedChannels.GetMask();
mSecurityPolicy.mRotationTime = KeyManager::kDefaultKeyRotationTime;
mSecurityPolicy.mFlags = KeyManager::kDefaultSecurityPolicyFlags;
mPanId = Mac::GenerateRandomPanId();
SuccessOrExit(error = static_cast<MasterKey &>(mMasterKey).GenerateRandom());
SuccessOrExit(error = static_cast<Pskc &>(mPskc).GenerateRandom());
+1 -1
View File
@@ -78,7 +78,7 @@ KeyManager::KeyManager(Instance &aInstance)
, mKeySwitchGuardEnabled(false)
, mKeyRotationTimer(aInstance, KeyManager::HandleKeyRotationTimer, this)
, mKekFrameCounter(0)
, mSecurityPolicyFlags(0xff)
, mSecurityPolicyFlags(kDefaultSecurityPolicyFlags)
, mIsPskcSet(false)
{
mMasterKey = static_cast<const MasterKey &>(kDefaultMasterKey);
+10 -1
View File
@@ -115,6 +115,16 @@ typedef Mac::Key Kek;
class KeyManager : public InstanceLocator, private NonCopyable
{
public:
enum : uint16_t
{
kDefaultKeyRotationTime = 672, ///< Default Key Rotation Time (in unit of hours).
};
enum : uint8_t
{
kDefaultSecurityPolicyFlags = 0xff, ///< Default Security Policy Flags.
};
/**
* This constructor initializes the object.
*
@@ -448,7 +458,6 @@ private:
enum
{
kMinKeyRotationTime = 1,
kDefaultKeyRotationTime = 672,
kDefaultKeySwitchGuardTime = 624,
kOneHourIntervalInMsec = 3600u * 1000u,
};