mirror of
https://github.com/espressif/openthread.git
synced 2026-09-16 06:00:13 +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();
|
Clear();
|
||||||
|
|
||||||
mActiveTimestamp = 1;
|
mActiveTimestamp = 1;
|
||||||
mChannel = preferredChannels.ChooseRandomChannel();
|
mChannel = preferredChannels.ChooseRandomChannel();
|
||||||
mChannelMask = supportedChannels.GetMask();
|
mChannelMask = supportedChannels.GetMask();
|
||||||
mSecurityPolicy.mFlags = aInstance.Get<KeyManager>().GetSecurityPolicyFlags();
|
mSecurityPolicy.mRotationTime = KeyManager::kDefaultKeyRotationTime;
|
||||||
mPanId = Mac::GenerateRandomPanId();
|
mSecurityPolicy.mFlags = KeyManager::kDefaultSecurityPolicyFlags;
|
||||||
|
mPanId = Mac::GenerateRandomPanId();
|
||||||
|
|
||||||
SuccessOrExit(error = static_cast<MasterKey &>(mMasterKey).GenerateRandom());
|
SuccessOrExit(error = static_cast<MasterKey &>(mMasterKey).GenerateRandom());
|
||||||
SuccessOrExit(error = static_cast<Pskc &>(mPskc).GenerateRandom());
|
SuccessOrExit(error = static_cast<Pskc &>(mPskc).GenerateRandom());
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ KeyManager::KeyManager(Instance &aInstance)
|
|||||||
, mKeySwitchGuardEnabled(false)
|
, mKeySwitchGuardEnabled(false)
|
||||||
, mKeyRotationTimer(aInstance, KeyManager::HandleKeyRotationTimer, this)
|
, mKeyRotationTimer(aInstance, KeyManager::HandleKeyRotationTimer, this)
|
||||||
, mKekFrameCounter(0)
|
, mKekFrameCounter(0)
|
||||||
, mSecurityPolicyFlags(0xff)
|
, mSecurityPolicyFlags(kDefaultSecurityPolicyFlags)
|
||||||
, mIsPskcSet(false)
|
, mIsPskcSet(false)
|
||||||
{
|
{
|
||||||
mMasterKey = static_cast<const MasterKey &>(kDefaultMasterKey);
|
mMasterKey = static_cast<const MasterKey &>(kDefaultMasterKey);
|
||||||
|
|||||||
@@ -115,6 +115,16 @@ typedef Mac::Key Kek;
|
|||||||
class KeyManager : public InstanceLocator, private NonCopyable
|
class KeyManager : public InstanceLocator, private NonCopyable
|
||||||
{
|
{
|
||||||
public:
|
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.
|
* This constructor initializes the object.
|
||||||
*
|
*
|
||||||
@@ -448,7 +458,6 @@ private:
|
|||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
kMinKeyRotationTime = 1,
|
kMinKeyRotationTime = 1,
|
||||||
kDefaultKeyRotationTime = 672,
|
|
||||||
kDefaultKeySwitchGuardTime = 624,
|
kDefaultKeySwitchGuardTime = 624,
|
||||||
kOneHourIntervalInMsec = 3600u * 1000u,
|
kOneHourIntervalInMsec = 3600u * 1000u,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user