mirror of
https://github.com/espressif/openthread.git
synced 2026-07-05 20:00:23 +00:00
[crypto] adding ARM PSA (Platform Security Architecture) support (#6862)
- New format for MAC keys, as a union between literal key and keyrefs. - Modified key_manager to handle both literal keys or keyrefs. - Modified MAC and sub_mac modules to handle both Literal Keys or keyrefs. - Updated Crypto Modules to use abstracted APIs. - New CLIs to handle networkkey and pskc references.
This commit is contained in:
@@ -112,13 +112,22 @@ otError otThreadSetLinkMode(otInstance *aInstance, otLinkModeConfig aConfig)
|
||||
return instance.Get<Mle::MleRouter>().SetDeviceMode(Mle::DeviceMode(aConfig));
|
||||
}
|
||||
|
||||
const otNetworkKey *otThreadGetNetworkKey(otInstance *aInstance)
|
||||
void otThreadGetNetworkKey(otInstance *aInstance, otNetworkKey *aNetworkKey)
|
||||
{
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
return &instance.Get<KeyManager>().GetNetworkKey();
|
||||
instance.Get<KeyManager>().GetNetworkKey(*static_cast<NetworkKey *>(aNetworkKey));
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE
|
||||
otNetworkKeyRef otThreadGetNetworkKeyRef(otInstance *aInstance)
|
||||
{
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
return instance.Get<KeyManager>().GetNetworkKeyRef();
|
||||
}
|
||||
#endif
|
||||
|
||||
otError otThreadSetNetworkKey(otInstance *aInstance, const otNetworkKey *aKey)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
@@ -128,7 +137,8 @@ otError otThreadSetNetworkKey(otInstance *aInstance, const otNetworkKey *aKey)
|
||||
|
||||
VerifyOrExit(instance.Get<Mle::MleRouter>().IsDisabled(), error = kErrorInvalidState);
|
||||
|
||||
error = instance.Get<KeyManager>().SetNetworkKey(*static_cast<const NetworkKey *>(aKey));
|
||||
instance.Get<KeyManager>().SetNetworkKey(*static_cast<const NetworkKey *>(aKey));
|
||||
|
||||
instance.Get<MeshCoP::ActiveDataset>().Clear();
|
||||
instance.Get<MeshCoP::PendingDataset>().Clear();
|
||||
|
||||
@@ -136,6 +146,25 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_KEY_REFERENCES_ENABLE
|
||||
otError otThreadSetNetworkKeyRef(otInstance *aInstance, otNetworkKeyRef aKeyRef)
|
||||
{
|
||||
Error error = kErrorNone;
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
VerifyOrExit(aKeyRef != 0, error = kErrorInvalidArgs);
|
||||
|
||||
VerifyOrExit(instance.Get<Mle::MleRouter>().IsDisabled(), error = kErrorInvalidState);
|
||||
|
||||
instance.Get<KeyManager>().SetNetworkKeyRef(static_cast<NetworkKeyRef>(aKeyRef));
|
||||
instance.Get<MeshCoP::ActiveDataset>().Clear();
|
||||
instance.Get<MeshCoP::PendingDataset>().Clear();
|
||||
|
||||
exit:
|
||||
return error;
|
||||
}
|
||||
#endif
|
||||
|
||||
const otIp6Address *otThreadGetRloc(otInstance *aInstance)
|
||||
{
|
||||
Instance &instance = *static_cast<Instance *>(aInstance);
|
||||
|
||||
Reference in New Issue
Block a user