如何在给定 public / 私钥的情况下实施 PGP Encryption/Decrypttion

How to implement PGP Encryption/Decrypttion given the public / private keys

我想我知道基础知识:

但这还不足以实现它。例如,使用什么加密算法以及如何实现?

在给定消息和相关密钥的情况下,在 .NET 中编写可通过的 pgp encryption/decryption 库有多难?

我在哪里可以找到这个的标准算法?

Bouncy Castle 有一个 .NET API 可用于 encrypt/decrypt files/data。 (源代码包含在他们的网站上)

有一些示例代码 here 演示了如何加密数据。

我用过,效果很好

OpenPGP 在 RFC 4880 中定义。

它是一个高级协议,使用 broad variety of cryptographic algorithms,一些是强制性的(3DES、DSA、Elgamal、SHA-1),其他的也应该实现(RSA、AES、SHA-2) , 压缩, ...)。特别建议不要自己实现这些基本算法以防止大量的边信道和定时攻击,而是依赖现成的加密库(GnuTLS、OpenSSL)。

如果您想基于现有算法实现 OpenPGP 消息格式,请务必阅读 Security ConsiderationsImplementation Nits 章,其中包含一些关于需要考虑的可能攻击和兼容性问题的重要信息。

如果您的主要 objective 正在学习 OpenPGP 和一般密码学,我建议您查看 BouncyCastle (which already has a C# and Java implementation), GnuPG (which probably is the OpenPGP implementation with largest user base, and ships with pretty much every Linux distribution, but is also available for Windows) or the OpenPGP.go library (written in well, go). All of them are open source, and probably have interesting problems to solve in their bug trackers (BouncyCastle, GnuPG)。