Skip to content

Use native AesGcm for .NET Framework from nuget - #1619

Merged
Rob-Hague merged 3 commits into
sshnet:developfrom
scott-xu:aesgcm-netframework
Nov 14, 2025
Merged

Use native AesGcm for .NET Framework from nuget#1619
Rob-Hague merged 3 commits into
sshnet:developfrom
scott-xu:aesgcm-netframework

Conversation

@scott-xu

Copy link
Copy Markdown
Collaborator

Based on dotnet/runtime#89718, we can use native AesGcm for .NET Framework from Microsoft.Bcl.Cryptography nuget package

@scott-xu
scott-xu marked this pull request as ready for review March 23, 2025 11:14
@Rob-Hague

Copy link
Copy Markdown
Collaborator

LGTM once the package is stable

@scott-xu
scott-xuforce-pushed the aesgcm-netframework branch from b93e470 to b9d888bCompareJune 14, 2025 11:52
@scott-xu
scott-xu marked this pull request as draft June 22, 2025 03:57
@scott-xu
scott-xuforce-pushed the aesgcm-netframework branch from d49b548 to c43bdb5CompareAugust 3, 2025 12:04

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enables the use of the native BCL AesGcm implementation for .NET Framework by adding the Microsoft.Bcl.Cryptography NuGet package. Previously, only .NET (Core) targets could use the native implementation, while .NET Framework and .NET Standard had to fall back to a BouncyCastle implementation.

Key changes:

  • Changed conditional compilation from NET to !NETSTANDARD to include .NET Framework targets
  • Added fallback handling for Mono environments that lack BCrypt.dll
  • Added Microsoft.Bcl.Cryptography package reference for net462 target

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

FileDescription
AesGcmCipher.csUpdated preprocessor directives and added Mono-specific exception handling for missing BCrypt.dll
AesGcmCipher.BclImpl.csUpdated preprocessor directive to enable BCL implementation for .NET Framework
Renci.SshNet.csprojAdded package reference for Microsoft.Bcl.Cryptography for net462 target
Directory.Packages.propsAdded version specification for Microsoft.Bcl.Cryptography package

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@scott-xu
scott-xu marked this pull request as ready for review November 12, 2025 00:19
{
_impl = new BclImpl(key, _iv);
}
catch (DllNotFoundException)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you hit this? I don't think we need to be that worried about it anymore

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CI test was ran at Ubuntu and hit this issue before.
I can unwrap "try catch" if you want.

This was referenced Aug 13, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@scott-xu@Rob-Hague