Skip to content

Commit 68fecf7

Browse files
committed
test: comments, restructure
tests: fixed comments and code restructure
1 parent 9b2a69f commit 68fecf7

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

Yubico.YubiKey/tests/integration/Yubico/YubiKey/Fido2/CredMgmtTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace Yubico.YubiKey.Fido2
2424
[Trait(TraitTypes.Category, TestCategories.Elevated)]
2525
public class CredMgmtTests : IClassFixture<BioFido2Fixture>
2626
{
27-
private readonly BioFido2Fixture _bioFido2Fixture; // TODO Why bioFido2Fixture?
27+
private readonly BioFido2Fixture _bioFido2Fixture; // This test should be able to run without a bio key
2828

2929
public CredMgmtTests(BioFido2Fixture bioFido2Fixture)
3030
{

Yubico.YubiKey/tests/integration/Yubico/YubiKey/Piv/KeyAgreeTests.cs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,13 @@ public void KeyAgree_MatchesCSharp(
107107
var (_, testPrivateKey) = TestKeys.GetKeyPair(keyType);
108108

109109
var peerPub = testPrivateKey.AsPublicKey();
110-
var peerEcc = (ECPublicKey)peerPub;
111-
112-
var ecDsaObject = testPrivateKey.AsECDsa(); // Wtf, these are the same keys
113-
var ecParams = ecDsaObject.ExportParameters(true);
114-
using var peerEcdh = ECDiffieHellman.Create(ecParams);
110+
var ecDsaObject = testPrivateKey.AsECDsa(); // Should ideally be different keys
111+
var ecParamsPrivate = ecDsaObject.ExportParameters(true);
112+
using var peerEcdh = ECDiffieHellman.Create(ecParamsPrivate);
115113

116114
// Build the YubiKey objects.
117-
ecDsaObject = testPrivateKey.AsECDsa(); // Wtf, these are the same keys
118-
ecParams = ecDsaObject.ExportParameters(false);
119-
using var ecdh = ECDiffieHellman.Create(ecParams);
115+
var ecParamsPublic = ecDsaObject.ExportParameters(false); // This should be the key from the Yubikey
116+
using var ecdh = ECDiffieHellman.Create(ecParamsPublic);
120117

121118
var hashAlgorithm = digestAlgorithm switch
122119
{
@@ -132,14 +129,14 @@ public void KeyAgree_MatchesCSharp(
132129
// The YubiKey computes the shared secret.
133130
Session.ImportPrivateKey(slotNumber, testPrivateKey.AsPrivateKey(), PivPinPolicy.Always,
134131
PivTouchPolicy.Never);
135-
var sharedSecret = Session.KeyAgree(slotNumber, peerEcc);
132+
133+
var sharedSecret = Session.KeyAgree(slotNumber, peerPub);
136134

137135
using var digester = GetHashAlgorithm(digestAlgorithm);
138136
digester.Initialize();
139137
_ = digester.TransformFinalBlock(sharedSecret, 0, sharedSecret.Length);
140138

141-
Assert.True(
142-
peerSecret.SequenceEqual(digester.Hash!));
139+
Assert.True(peerSecret.SequenceEqual(digester.Hash!));
143140
}
144141

145142
[Theory]

0 commit comments

Comments
 (0)