Hello
I'm playing around a little bit around with AES encryption in ECB mode
but somehow I'm doing something wrong???
using Visual Studio 2005 with Servicepack/updates and CryptoPP 5.6.1
here is the code:
std::string initialHandshake2(std::string const& password,__time64_t
const& timeAtGUI)
{
byte thedata[CryptSize];
byte encodeddata[CryptSize];
memset (thedata,0,CryptSize);
memset (encodeddata,0,CryptSize);
CryptoPP::SecByteBlock the_key(CryptSize);
int i=0 ;
std::string result;
CryptoPP::SHA256 sha;
sha.Update(reinterpret_cast<const byte
*>(password.c_str()),password.size());
sha.Final(the_key);
strcpy(reinterpret_cast< char * > (thedata),"My Name is...");
CryptoPP::ECB_Mode <CryptoPP::AES>::Encryption enc;
enc.SetKey(the_key,CryptSize);
CryptoPP::ArraySource(thedata,CryptSize,true,new
CryptoPP::StreamTransformationFilter(enc,new
CryptoPP::ArraySink(encodeddata,CryptSize)));
memset (thedata,0,CryptSize);
CryptoPP::ECB_Mode <CryptoPP::AES>::Decryption dec;
dec.SetKey(the_key,the_key.size());
//try
//{
CryptoPP::StreamTransformationFilter fil(dec,new
CryptoPP::ArraySink(thedata,CryptSize));
CryptoPP::StringSource(encodeddata,CryptSize,true,&fil); //if
i
don't pass the CryptSize, it works, if passing the cryptsize I receive
_BLOCK_TYPE_IS_VALID(pHead->nBlockUse) in the debug "delete" function
//}
//catch (CryptoPP::Exception& e )
//{
// std::cout << "ERROR: " << e.what() << "\r\n";
//}
return result;
}
If I use Arraysource instead Stringsource (or pass the arraylength)
the code crashes...
but why? and whats the difference compared to the encoding several
lines above?
--
You received this message because you are subscribed to the "Crypto++ Users"
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at
http://www.cryptopp.com.