From 18b0ff3f251e3a454d96dfdd47841f75cce2d598 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Mon, 12 Feb 2024 17:59:54 +0000 Subject: [PATCH] perf: use static RandomNumberGenerator to generate AES key --- TcpDotNet/ProtocolClient.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/TcpDotNet/ProtocolClient.cs b/TcpDotNet/ProtocolClient.cs index f9a464f..f16829e 100644 --- a/TcpDotNet/ProtocolClient.cs +++ b/TcpDotNet/ProtocolClient.cs @@ -113,8 +113,7 @@ public sealed class ProtocolClient : ClientNode byte[] encryptedPayload = rsa.Encrypt(encryptionRequest.Payload, true); var key = new byte[128]; - using var rng = new RNGCryptoServiceProvider(); - rng.GetBytes(key); + RandomNumberGenerator.Fill(key); Aes = CryptographyUtils.GenerateAes(key); byte[] aesKey = rsa.Encrypt(key, true);