如何在 C++ 中使用 Cryptolib 加载 puttygen RSA 密钥?

How to Load puttygen RSA keys using Cryptolib in C++?

我有 API 来加载使用 Cryptolib 开发的私钥和 public 密钥。

    CryptoPP::RSA::PrivateKey
    CryptoPP::RSA::PublicKey

当我尝试加载由 puttygen 生成的 RSA(私钥和 Public)密钥时,加载函数崩溃。是否可以在 Cryptolib 中加载 Puttygen 生成的密钥?

Crypto++ 对私钥使用 PCKS #8 私钥信息标准和 their documentation 中指定的 X.509 Public 密钥标准格式。 Puttygen 使用 PuTTY 格式。这些不容易使用 C++ 转换,但它是可能的。不过,从 puttygen 中导出为 OpenSSH 格式要容易得多。

如果您仍想以编程方式执行此操作,可以使用 Chilkat CKSshKey library which was developed for just this purpose. You can see an example of converting a PuTTY private key to OpenSSH PEM (which is what Crypto++ will read) here