我正在尝试将 OSX 上的一段代码从 OpenSSL(已删除)移植到 Crypto++,但无法使 RSA 签名验证正常工作。我对公钥的构造方式有点怀疑。现有代码将 base64 值解码为字节缓冲区,然后使用 BIN_bin2bn
创建模数和指数。我将相同的字节缓冲区提供给 CrytoPP::Integer
但我怀疑这是否是正确的方法。
最佳答案
Is BN_bin2bn from OpenSSL the same as the constructor of Crypto++ Integer that takes a byte array?
给予或索取,是的。
OpenSSL 的 BN_bin2bn
接受一个二进制字节数组并返回一个 BIGNUM
。这相当于 Crypto++ Integer
。您应该展示如何使用字节数组以确保正确使用它。
加密++ Integer
constructor Integer (const byte *encodedInteger, size_t byteCount, Signedness sign=UNSIGNED, ByteOrder order=BIG_ENDIAN_ORDER)
与 OpenSSL 的 BN_bin2bn
几乎相同。当您去掉默认参数时,构造函数是 Integer (const byte *encodedInteger, size_t byteCount)
。您应该展示如何使用字节数组以确保正确使用它。
为了完整起见,这里是他们在 RSA Signing and Verifying 上的 wiki 中的 OpenSSL 文档。 .这里是来自他们维基的 Crypto++ 文档 RSA Signing and Verifying .
但是如前所述,您应该展示您的代码。对于您的算法描述,我们无能为力。
关于c++ - 来自 OpenSSL 的 BN_bin2bn 是否与采用字节数组的 Crypto++ Integer 的构造函数相同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45299461/