mirror of
https://github.com/espressif/openthread.git
synced 2026-09-11 03:30:09 +00:00
[meshcop] add GenerateRandom() to ExtendedPanId class (#12342)
This commit adds a `GenerateRandom()` method to the `ExtendedPanId` class, enabling the generation of a cryptographically secure random Extended PAN Identifier.
This commit is contained in:
@@ -71,7 +71,7 @@ Error Dataset::Info::GenerateRandom(Instance &aInstance)
|
||||
|
||||
SuccessOrExit(error = AsCoreType(&mNetworkKey).GenerateRandom());
|
||||
SuccessOrExit(error = AsCoreType(&mPskc).GenerateRandom());
|
||||
SuccessOrExit(error = Random::Crypto::Fill(mExtendedPanId));
|
||||
SuccessOrExit(error = AsCoreType(&mExtendedPanId).GenerateRandom());
|
||||
SuccessOrExit(error = AsCoreType(&mMeshLocalPrefix).GenerateRandomUla());
|
||||
|
||||
nameWriter.Append("%s-%04x", NetworkName::kNetworkNameInit, mPanId);
|
||||
|
||||
@@ -51,6 +51,8 @@ ExtendedPanId::InfoString ExtendedPanId::ToString(void) const
|
||||
return string;
|
||||
}
|
||||
|
||||
Error ExtendedPanId::GenerateRandom(void) { return Random::Crypto::Fill(*this); }
|
||||
|
||||
ExtendedPanIdManager::ExtendedPanIdManager(Instance &aInstance)
|
||||
: InstanceLocator(aInstance)
|
||||
{
|
||||
|
||||
@@ -69,6 +69,14 @@ public:
|
||||
*/
|
||||
InfoString ToString(void) const;
|
||||
|
||||
/**
|
||||
* Generates a cryptographically secure random sequence to populate the Extended PAN Identifier.
|
||||
*
|
||||
* @retval kErrorNone Successfully generated a random Extended PAN ID.
|
||||
* @retval kErrorFailed Failed to generate random sequence.
|
||||
*/
|
||||
Error GenerateRandom(void);
|
||||
|
||||
} OT_TOOL_PACKED_END;
|
||||
|
||||
class ExtendedPanIdManager : public InstanceLocator, private NonCopyable
|
||||
|
||||
Reference in New Issue
Block a user