Skip to content

Commit

Permalink
Update code style
Browse files Browse the repository at this point in the history
  • Loading branch information
scott-xu committed Dec 30, 2024
1 parent 510a795 commit 0d2f050
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/Tmds.Ssh/Curve25519KeyExchange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@ public override async Task<KeyExchangeOutput> TryExchangeAsync(KeyExchangeContex
var connectionInfo = input.ConnectionInfo;

AsymmetricCipherKeyPair x25519KeyPair;
using (var _randomGenerator = new CryptoApiRandomGenerator())
using (var randomGenerator = new CryptoApiRandomGenerator())
{
var x25519KeyPairGenerator = new X25519KeyPairGenerator();
x25519KeyPairGenerator.Init(new X25519KeyGenerationParameters(new SecureRandom(_randomGenerator)));
x25519KeyPairGenerator.Init(new X25519KeyGenerationParameters(new SecureRandom(randomGenerator)));
x25519KeyPair = x25519KeyPairGenerator.GenerateKeyPair();
}

// Send ECDH_INIT.
var q_c = ((X25519PublicKeyParameters)x25519KeyPair.Public).GetEncoded();
byte[] q_c = ((X25519PublicKeyParameters)x25519KeyPair.Public).GetEncoded();
await context.SendPacketAsync(CreateEcdhInitMessage(sequencePool, q_c), ct).ConfigureAwait(false);

// Receive ECDH_REPLY.
using Packet ecdhReplyMsg = await context.ReceivePacketAsync(MessageId.SSH_MSG_KEX_ECDH_REPLY, firstPacket.Move(), ct).ConfigureAwait(false);
var ecdhReply = ParceEcdhReply(ecdhReplyMsg);

// Verify received key is valid.
var publicHostKey = await VerifyHostKeyAsync(hostKeyVerification, input, ecdhReply.public_host_key, ct).ConfigureAwait(false);
PublicKey publicHostKey = await VerifyHostKeyAsync(hostKeyVerification, input, ecdhReply.public_host_key, ct).ConfigureAwait(false);

// Compute shared secret.
BigInteger sharedSecret;
Expand Down
4 changes: 2 additions & 2 deletions src/Tmds.Ssh/ECDHKeyExchange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ECDHKeyExchange : KeyExchange
public ECDHKeyExchange(ECCurve ecCurve, HashAlgorithmName hashAlgorithmName)
{
_ecCurve = ecCurve;
this._hashAlgorithmName = hashAlgorithmName;
_hashAlgorithmName = hashAlgorithmName;
}

public override async Task<KeyExchangeOutput> TryExchangeAsync(KeyExchangeContext context, IHostKeyVerification hostKeyVerification, Packet firstPacket, KeyExchangeInput input, ILogger logger, CancellationToken ct)
Expand All @@ -36,7 +36,7 @@ public override async Task<KeyExchangeOutput> TryExchangeAsync(KeyExchangeContex
var ecdhReply = ParceEcdhReply(ecdhReplyMsg);

// Verify received key is valid.
var publicHostKey = await VerifyHostKeyAsync(hostKeyVerification, input, ecdhReply.public_host_key, ct).ConfigureAwait(false);
PublicKey publicHostKey = await VerifyHostKeyAsync(hostKeyVerification, input, ecdhReply.public_host_key, ct).ConfigureAwait(false);

// Compute shared secret.
BigInteger sharedSecret;
Expand Down

0 comments on commit 0d2f050

Please sign in to comment.