.net Framework 4.7中是否可以使用AES(256位)GCM模式加密数据? [英] Is it possible to encrypt data with AES (256 bit) GCM mode in .net framework 4.7?
问题描述
MSDN链接提供对具体AES类的引用:
The MSDN link provides references to concrete AES classes:
- System.Security.Cryptography.AesCng
- System.Security.Cryptography.AesCryptoServiceProvider
- System.Security.Cryptography.AesManaged
但是AesCryptoServiceProvider适用于较旧的计算机,并且AesManaged未通过FIPS认证。因此,唯一的选择是AesCng。 AesCng具有一个名为Mode的属性,该属性仅会使用:CBC,ECB,OFB,CFB,CTS,但没有GCM 。
However AesCryptoServiceProvider is for older machines and AesManaged is not certified for FIPS. So the only option is AesCng. The AesCng has a property called Mode, which will only take: CBC, ECB, OFB, CFB, CTS but no GCM.
- 此框架是否支持AES GCM?
- 如果是,是否有示例?
- 如果不是,那么我该怎么办?选项?
推荐答案
此答案反映了卢克·帕克(Luke Park),bartonjs,蒂莫(Timo)和aart Maarten的评论。上面的Bodewes。
This answer reflects the comments from Luke Park, bartonjs, Timo, aand Maarten Bodewes above.
一个选择是使用 Bouncycastle C#库,它具有自己独立的AES实现以及GCM模式。查看类GCMBlockCipher,AesEngine和AEADParameters的源代码。
One option is to use the Bouncycastle C# library, which has its own self-contained implementation of AES as well as the GCM mode. Look at the source code for the classes GCMBlockCipher, AesEngine, and AEADParameters.
另一个选择是使用P / Invoke手动调用 BCryptEncrypt 。
Another option is to use P/Invoke to manually call BCryptEncrypt.
最后,请注意,.NET Core将在3.0开始支持。来源已经在 github 。
Finally, note that .NET Core will have support starting in 3.0. The source is already available in github.
这篇关于.net Framework 4.7中是否可以使用AES(256位)GCM模式加密数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!