@@ -107,16 +107,13 @@ public void KeyAgree_MatchesCSharp(
107
107
var ( _, testPrivateKey ) = TestKeys . GetKeyPair ( keyType ) ;
108
108
109
109
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 ) ;
115
113
116
114
// 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 ) ;
120
117
121
118
var hashAlgorithm = digestAlgorithm switch
122
119
{
@@ -132,14 +129,14 @@ public void KeyAgree_MatchesCSharp(
132
129
// The YubiKey computes the shared secret.
133
130
Session . ImportPrivateKey ( slotNumber , testPrivateKey . AsPrivateKey ( ) , PivPinPolicy . Always ,
134
131
PivTouchPolicy . Never ) ;
135
- var sharedSecret = Session . KeyAgree ( slotNumber , peerEcc ) ;
132
+
133
+ var sharedSecret = Session . KeyAgree ( slotNumber , peerPub ) ;
136
134
137
135
using var digester = GetHashAlgorithm ( digestAlgorithm ) ;
138
136
digester . Initialize ( ) ;
139
137
_ = digester . TransformFinalBlock ( sharedSecret , 0 , sharedSecret . Length ) ;
140
138
141
- Assert . True (
142
- peerSecret . SequenceEqual ( digester . Hash ! ) ) ;
139
+ Assert . True ( peerSecret . SequenceEqual ( digester . Hash ! ) ) ;
143
140
}
144
141
145
142
[ Theory ]
0 commit comments