mirror of
https://github.com/espressif/openthread.git
synced 2026-07-26 05:53:45 +00:00
[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:
@@ -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());
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user