Hi , I think there's a mistake about crypto++ in memory allocation , every string we decrypt by cryptopp stores in memory and it never clean up itself , for example :
I have an important string that I have to send it privately to another win32 application and it can destroy everything !
What can I do ?
What can I do ?
Use a SecByteBlock.
Please ask questions on the mailing list. Please reserve the bug tracker for library bugs.
@noloader Sorry about that ! I searched about it but I couldn't find out how to use it , can you please send me an example or snippet ?
My Function is :
std::string _d_c(const std::string& str_in, const std::string& key, const std::string& iv)
{
std::string str_out;
CryptoPP::CFB_Mode<CryptoPP::AES>::Decryption decryption((byte*)key.c_str(), key.length(), (byte*)iv.c_str());
CryptoPP::StringSource decryptor(str_in, true,
new CryptoPP::Base64Decoder(
new CryptoPP::StreamTransformationFilter(decryption,
new CryptoPP::StringSink(str_out)
)
)
);
return str_out;
str_out.clear();
}
How can i use SecByteBlockin it ? thanks again.
Have you tried SecByteBlockSink? See also SecBlock.
dear @smlu , I tried this on my code based on what you sent
/// I added this headers
#include <Bits.h>
#include "secblock.h"
//// I used this code
std::string dec = _d_c(test_string,aes_key,aes_iv);
CryptoPP::SecByteBlock key(reinterpret_cast<const byte*>(&dec[0], dec.size()));
but I get this error :
1>dllmain.cpp(370): error C2664: 'CryptoPP::SecBlock
::SecBlock(unsigned int)' : cannot convert parameter 1 from 'const byte *' to 'unsigned int'
1> with
1> [
1> T=CryptoPP::byte
1> ]
1> There is no context in which this conversion is possible
What am I doing wrong ?
CryptoPP::SecByteBlock key(reinterpret_cast
(&dec[0], dec.size()));
The reinterpret_cast args are wrong.
Try:
CryptoPP::SecByteBlock key(reinterpret_cast<const byte*>(&dec[0]), dec.size());
Note: I see this bug is also in the documentation, it will have to be fixed.
Note: I see this bug is also in the documentation, it will have to be fixed.
Done, thanks.
Most helpful comment
Done, thanks.