Hi,
Crypto++ 5.6.2. was compiled as a static win32 library using VS2010
without problems; however, a
segmentation error occurs during decryption using the
StreamTransformationFilter:: Put( ) function at
the following line.
void CBC_Decryption::ProcessData(byte *outString, const byte *inString,
size_t length)
{
...
m_cipher->AdvancedProcessBlocks(inString+blockSize, inString,
outString+blockSize, length-blockSize,
BlockTransformation::BT_ReverseDirection|BlockTransformation::BT_AllowParallel);
when the size of data is too large, 21 bytes processes through with no
problems, so a least 2 blocks can be processed. ( AES_BLOCK = 16 bytes )
Here is the test program, if you shorten the plaintext to a shorter length
of bytes it works.
Any ideas.
Thanks
---------------------------------------------------
void test()
{
//
// Key and IV setup
//
byte key[ CryptoPP::AES::DEFAULT_KEYLENGTH ], iv[
CryptoPP::AES::BLOCKSIZE ];
memset( key, 0x01, CryptoPP::AES::DEFAULT_KEYLENGTH );
memset( iv, 0x02, CryptoPP::AES::BLOCKSIZE );
//
// String and Sink setup
//
std::string plaintext = "Now is the time for all good men to come to
the aide...";
std::string ciphertext;
std::string decryptedtext;
//
// Dump Plain Text
//
std::cout << "Plain Text (" << plaintext.size() << " bytes)" <<
std::endl;
std::cout << plaintext;
std::cout << std::endl << std::endl;
//
// Create Cipher Text
//
CryptoPP::AES::Encryption aesEncryption(key,
CryptoPP::AES::DEFAULT_KEYLENGTH);
CryptoPP::CBC_Mode_ExternalCipher::Encryption cbcEncryption(
aesEncryption, iv );
CryptoPP::StreamTransformationFilter stfEncryptor(cbcEncryption, new
CryptoPP::StringSink( ciphertext ) );
stfEncryptor.Put( reinterpret_cast<const unsigned char*>(
plaintext.c_str() ), plaintext.length() + 1 );
stfEncryptor.MessageEnd();
//
// Dump Cipher Text
//
std::cout << "Cipher Text (" << ciphertext.size() << " bytes)" <<
std::endl;
for( int i = 0; i < ciphertext.size(); i++ ) {
std::cout << "0x" << std::hex << (0xFF &
static_cast<byte>(ciphertext[i])) << " ";
}
std::cout << std::endl << std::endl;
//
// Decrypt
//
CryptoPP::AES::Decryption aesDecryption(key,
CryptoPP::AES::DEFAULT_KEYLENGTH);
CryptoPP::CBC_Mode_ExternalCipher::Decryption cbcDecryption(
aesDecryption, iv );
CryptoPP::StreamTransformationFilter stfDecryptor(cbcDecryption, new
CryptoPP::StringSink( decryptedtext ) );
stfDecryptor.Put( reinterpret_cast<const unsigned char*>(
ciphertext.c_str() ), ciphertext.size() );
stfDecryptor.MessageEnd();
//
// Dump Decrypted Text
//
std::cout << "Decrypted Text: " << std::endl;
std::cout << decryptedtext;
std::cout << std::endl << std::endl;
}
--
--
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.
---
You received this message because you are subscribed to the Google Groups
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.