Skip to content
Permalink
Browse files Browse the repository at this point in the history
Use cryptographically secure random number generator.
  • Loading branch information
drieseng committed May 29, 2022
1 parent cad9433 commit 03c6d60
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/Renci.SshNet/Security/KeyExchangeECCurve25519.cs
Expand Up @@ -46,9 +46,7 @@ public override void Start(Session session, KeyExchangeInitMessage message)
var basepoint = new byte[MontgomeryCurve25519.PublicKeySizeInBytes];
basepoint[0] = 9;

var rnd = new Random();
_privateKey = new byte[MontgomeryCurve25519.PrivateKeySizeInBytes];
rnd.NextBytes(_privateKey);
_privateKey = CryptoAbstraction.GenerateRandom(MontgomeryCurve25519.PrivateKeySizeInBytes);

_clientExchangeValue = new byte[MontgomeryCurve25519.PublicKeySizeInBytes];
MontgomeryOperations.scalarmult(_clientExchangeValue, 0, _privateKey, 0, basepoint, 0);
Expand Down

0 comments on commit 03c6d60

Please sign in to comment.