crypto++ - Crypto++ - InvertibleRSAFunction::GenerateRandomWithKeySize 中的内存泄漏?
问题描述
我使用crypto++创建了以下函数,但如果使用它,程序会因GenerateRandomWithKeySize()
调用导致内存泄漏而退出。这是正常的还是我做错了什么?我是否必须清理不能自行清理的对象?
#include "rsa.h"
using CryptoPP::RSA;
using CryptoPP::InvertibleRSAFunction;
using CryptoPP::RSAES;
using CryptoPP::OAEP;
#include "sha.h"
using CryptoPP::SHA256;
#include "osrng.h"
using CryptoPP::AutoSeededRandomPool;
#include "cryptlib.h"
using CryptoPP::Exception;
using CryptoPP::DecodingResult;
DOCUMENTED_TYPEDEF(RSAES<OAEP<SHA256> >::Encryptor, RSAES_OAEP_SHA256_Encryptor);
DOCUMENTED_TYPEDEF(RSAES<OAEP<SHA256> >::Decryptor , RSAES_OAEP_SHA256_Decryptor);
bool CryptoCreateKeys(RSA::PrivateKey& privatekey, RSA::PublicKey& publickey)
{
bool result=true;
try {
// Generate keys
AutoSeededRandomPool rng;
InvertibleRSAFunction parameters;
parameters.GenerateRandomWithKeySize(rng, 4096);
privatekey=parameters;
publickey=parameters;
}
catch (CryptoPP::Exception) {
result=false;
}
return result;
}
// this isn't real - I just put it here for the basic call structure
int main(void)
{
RSA::PrivateKey privatekey;
RSA::PublicKey publickey;
CryptoCreateKeys(privatekey, publickey);
return 0
}
解决方案
推荐阅读
- regex - 变量定义的正则表达式
- c++ - 重命名 Win32 函数以确保 C++ 上的安全性
- excel - 在 Excel 中,更新公式似乎会在同一个工作表上触发一个不相关的私有子。我怎样才能让它停止?
- python - 我正在尝试制作一个不和谐的机器人,它有时会给出随机响应 python
- python - 从相似度矩阵中识别异常值
- c++ - 具有 1 个通道分段张量的分段应用程序
- omnet++ - 如何从静脉而不是 SUMO 创建/生成车辆
- c# - 如何创建一个缓存每个计算项的 Observable?(懒惰的等价物
) - excel - 数据透视表不使用 VBA 刷新
- java - BufferUtils 和 MemoryUtil 有什么区别?(LWJGL)