Skip to content

Commit b0a8b13

Browse files
committed
refactor: move GetOidByAlgorithm method to a more appropriate location in EcdsaVerify
1 parent 85dde40 commit b0a8b13

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

Yubico.YubiKey/src/Yubico/YubiKey/Cryptography/EcdsaVerify.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -201,20 +201,8 @@ public EcdsaVerify(CoseKey coseKey)
201201
xCoordinate = ecKey.XCoordinate.ToArray();
202202
yCoordinate = ecKey.YCoordinate.ToArray();
203203
}
204-
205-
ECDsa = ConvertPublicKey(oid, xCoordinate, yCoordinate);
206-
}
207204

208-
private static string GetOidByAlgorithm(CoseAlgorithmIdentifier algorithm)
209-
{
210-
return algorithm switch
211-
{
212-
CoseAlgorithmIdentifier.ES256 => KeyDefinitions.KeyOids.P256,
213-
CoseAlgorithmIdentifier.ECDHwHKDF256 => KeyDefinitions.KeyOids.P256,
214-
CoseAlgorithmIdentifier.ES384 => KeyDefinitions.KeyOids.P384,
215-
CoseAlgorithmIdentifier.ES512 => KeyDefinitions.KeyOids.P521,
216-
_ => "",
217-
};
205+
ECDsa = ConvertPublicKey(oid, xCoordinate, yCoordinate);
218206
}
219207

220208
/// <summary>
@@ -404,7 +392,7 @@ private static ECDsa CheckECDsa(ECDsa toCheck)
404392
if (ecParameters.Q.X.Length == 0 ||
405393
ecParameters.Q.X.Length > coordinateLength ||
406394
ecParameters.Q.Y.Length == 0 ||
407-
ecParameters.Q.Y.Length > coordinateLength )
395+
ecParameters.Q.Y.Length > coordinateLength)
408396
{
409397
throw new ArgumentException(ExceptionMessages.UnsupportedAlgorithm);
410398
}
@@ -466,6 +454,18 @@ private static bool TryCopyNextInteger(TlvReader tlvReader, Memory<byte> signatu
466454
return false;
467455
}
468456

457+
private static string GetOidByAlgorithm(CoseAlgorithmIdentifier algorithm)
458+
{
459+
return algorithm switch
460+
{
461+
CoseAlgorithmIdentifier.ES256 => KeyDefinitions.KeyOids.P256,
462+
CoseAlgorithmIdentifier.ECDHwHKDF256 => KeyDefinitions.KeyOids.P256,
463+
CoseAlgorithmIdentifier.ES384 => KeyDefinitions.KeyOids.P384,
464+
CoseAlgorithmIdentifier.ES512 => KeyDefinitions.KeyOids.P521,
465+
_ => "",
466+
};
467+
}
468+
469469
/// <summary>
470470
/// Clean up
471471
/// </summary>

0 commit comments

Comments
 (0)