[srp] simplify crypto ReadOrGenerateKey in srp client (#9764)

In method `ReadOrGenerateKey` removing call to `GetPublicKey`
which was unnecessary operation (value was't used afterward).
This commit is contained in:
Przemysław Bida
2024-01-11 11:04:55 -08:00
committed by GitHub
parent 5576e0ce0d
commit 557ecf925f
+6 -9
View File
@@ -961,19 +961,16 @@ Error Client::ReadOrGenerateKey(Crypto::Ecdsa::P256::KeyPairAsRef &aKeyRef)
if (error == kErrorNone)
{
Crypto::Ecdsa::P256::PublicKey publicKey;
if (keyPair.GetPublicKey(publicKey) == kErrorNone)
if (aKeyRef.ImportKeyPair(keyPair) != kErrorNone)
{
SuccessOrExit(error = aKeyRef.ImportKeyPair(keyPair));
IgnoreError(Get<Settings>().Delete<Settings::SrpEcdsaKey>());
ExitNow();
SuccessOrExit(error = aKeyRef.Generate());
}
IgnoreError(Get<Settings>().Delete<Settings::SrpEcdsaKey>());
}
error = aKeyRef.Generate();
else
{
SuccessOrExit(error = aKeyRef.Generate());
}
exit:
return error;
}