Skip to content

Commit e2f7241

Browse files
committed
refactor: correct SHA algorithm mapping and rename test method for clarity
1 parent 85c5e34 commit e2f7241

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ public bool VerifyData(
286286
{
287287
256 => CryptographyProviders.Sha256Creator(),
288288
384 => CryptographyProviders.Sha384Creator(),
289-
512 => CryptographyProviders.Sha512Creator(),
289+
521 => CryptographyProviders.Sha512Creator(),
290290
_ => throw new ArgumentException(ExceptionMessages.UnsupportedAlgorithm),
291291
};
292292

Yubico.YubiKey/tests/unit/Yubico/YubiKey/Cryptography/EcdsaVerifyTests.cs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,17 @@ public void ECDsa_VerifyDigestedData_WithDerFormat_Succeeds(KeyDefinitions.KeyTy
144144
Assert.True(isVerified);
145145
}
146146

147+
[Fact]
148+
public void EncodedKey_VerifyDigestedData_Succeeds()
149+
{
150+
byte[] pubKey = GetEncodedPoint();
151+
byte[] digest = GetDigest();
152+
byte[] signature = GetSignature();
153+
154+
using var verifier = new EcdsaVerify(pubKey);
155+
bool isVerified = verifier.VerifyDigestedData(digest, signature);
156+
Assert.True(isVerified);
157+
}
147158

148159
[Theory]
149160
[InlineData(KeyDefinitions.KeyType.P256)]
@@ -166,19 +177,6 @@ public void ECDsa_VerifyData_WithDerFormat_Succeeds(KeyDefinitions.KeyType keyTy
166177
Assert.True(isVerified);
167178
}
168179

169-
170-
[Fact]
171-
public void EncodedKey_Verify_Succeeds()
172-
{
173-
byte[] pubKey = GetEncodedPoint();
174-
byte[] digest = GetDigest();
175-
byte[] signature = GetSignature();
176-
177-
using var verifier = new EcdsaVerify(pubKey);
178-
bool isVerified = verifier.VerifyDigestedData(digest, signature);
179-
Assert.True(isVerified);
180-
}
181-
182180
private byte[] GetEncodedPoint()
183181
{
184182
byte[] xCoord = GetX();

0 commit comments

Comments
 (0)