Skip to content

Commit bf976d5

Browse files
scott-xuRob-Hague
andauthored
Use native AesGcm for .NET Framework from nuget (#1619)
* Use native AesGcm for .NET Framework from nuget * drop mono exception --------- Co-authored-by: Rob Hague <rob.hague00@gmail.com>
1 parent 8629c39 commit bf976d5

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<PackageVersion Include="GitHubActionsTestLogger" Version="2.4.1" />
1212
<PackageVersion Include="Meziantou.Analyzer" Version="2.0.220" />
1313
<!-- Should stay on LTS .NET releases. -->
14+
<PackageVersion Include="Microsoft.Bcl.Cryptography" Version="10.0.0" />
1415
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.3" />
1516
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="9.0.9" />
1617
<PackageVersion Include="MSTest" Version="3.9.3" />

src/Renci.SshNet/Renci.SshNet.csproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@
4949
</PackageReference>
5050
</ItemGroup>
5151

52-
<ItemGroup Condition=" !$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0')) ">
52+
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">
53+
<PackageReference Include="Microsoft.Bcl.Cryptography" />
54+
</ItemGroup>
55+
56+
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
5357
<PackageReference Include="System.Formats.Asn1" />
5458
</ItemGroup>
5559

src/Renci.SshNet/Security/Cryptography/Ciphers/AesGcmCipher.BclImpl.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if NET
1+
#if !NETSTANDARD
22
using System;
33
using System.Security.Cryptography;
44

src/Renci.SshNet/Security/Cryptography/Ciphers/AesGcmCipher.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ internal sealed partial class AesGcmCipher : SymmetricCipher, IDisposable
1515
private const int TagSizeInBytes = 16;
1616
private readonly byte[] _iv;
1717
private readonly int _aadLength;
18-
#if NET
18+
#if !NETSTANDARD
1919
private readonly Impl _impl;
2020
#else
2121
private readonly BouncyCastleImpl _impl;
@@ -62,7 +62,7 @@ public AesGcmCipher(byte[] key, byte[] iv, int aadLength)
6262
// SSH AES-GCM requires a 12-octet Initial IV
6363
_iv = iv.Take(12);
6464
_aadLength = aadLength;
65-
#if NET
65+
#if !NETSTANDARD
6666
if (System.Security.Cryptography.AesGcm.IsSupported)
6767
{
6868
_impl = new BclImpl(key, _iv);

0 commit comments

Comments
 (0)