From 4b401c35f5df67dcc76cbbe506fe18b15a02efb2 Mon Sep 17 00:00:00 2001 From: Jiye Tang Date: Mon, 20 Sep 2021 20:45:48 -0400 Subject: [PATCH] AES-GCM support under Netstandard2.1 and Net Core 3.0 --- src/Renci.SshNet/ConnectionInfo.cs | 9 +- src/Renci.SshNet/Renci.SshNet.csproj | 13 +- .../Security/Cryptography/Cipher.cs | 39 +- .../Cryptography/Ciphers/AEADCipher.cs | 423 ++++++++++++++++++ .../Ciphers/Paddings/AEADPadding.cs | 101 +++++ .../Cryptography/EcdsaDigitalSignature.cs | 4 +- .../Security/Cryptography/EcdsaKey.cs | 8 +- src/Renci.SshNet/Session.cs | 116 ++++- 8 files changed, 692 insertions(+), 21 deletions(-) create mode 100644 src/Renci.SshNet/Security/Cryptography/Ciphers/AEADCipher.cs create mode 100644 src/Renci.SshNet/Security/Cryptography/Ciphers/Paddings/AEADPadding.cs diff --git a/src/Renci.SshNet/ConnectionInfo.cs b/src/Renci.SshNet/ConnectionInfo.cs index af8e1ca5c..f583eb9c4 100644 --- a/src/Renci.SshNet/ConnectionInfo.cs +++ b/src/Renci.SshNet/ConnectionInfo.cs @@ -7,6 +7,10 @@ using Renci.SshNet.Messages.Connection; using Renci.SshNet.Common; using Renci.SshNet.Messages.Authentication; +#if NETCOREAPP3_0 || NETSTANDARD2_1 +using Renci.SshNet.Security.Cryptography; +using Renci.SshNet.Security.Cryptography.Ciphers.Paddings; +#endif using Renci.SshNet.Security.Cryptography.Ciphers.Modes; using Renci.SshNet.Security.Cryptography.Ciphers; @@ -361,6 +365,9 @@ public ConnectionInfo(string host, int port, string username, ProxyTypes proxyTy ////{"rijndael-cbc@lysator.liu.se", typeof(...)}, {"aes128-ctr", new CipherInfo(128, (key, iv) => new AesCipher(key, new CtrCipherMode(iv), null))}, {"aes192-ctr", new CipherInfo(192, (key, iv) => new AesCipher(key, new CtrCipherMode(iv), null))}, +#if NETCOREAPP3_0 || NETSTANDARD2_1 + {"aes128-gcm@openssh.com", new CipherInfo(128, (key, iv) => new AEADCipher(key, iv, 16, null, new AEADPadding()))}, +#endif }; HmacAlgorithms = new Dictionary @@ -478,4 +485,4 @@ IList IConnectionInfoInternal.AuthenticationMethods get { return AuthenticationMethods.Cast().ToList(); } } } -} +} \ No newline at end of file diff --git a/src/Renci.SshNet/Renci.SshNet.csproj b/src/Renci.SshNet/Renci.SshNet.csproj index 124ce9d4b..7122d9468 100644 --- a/src/Renci.SshNet/Renci.SshNet.csproj +++ b/src/Renci.SshNet/Renci.SshNet.csproj @@ -7,7 +7,9 @@ ../Renci.SshNet.snk 5 true - net35;net40;netstandard1.3;netstandard2.0 + net35;net40;netstandard1.3;netstandard2.0;netstandard2.1 + Library + false