Hi all,

I am trying to perform an AES decryption using the following code:

                byte key[AES_KEYLEN];
        byte iv[AES_BLOCKSIZE];

        memset(key, 0x00, AES_KEYLEN);
        memset(iv, 0x00, AES_BLOCKSIZE);

        AES::Encryption aesEncryption(key, AES_KEYLEN);
        CBC_Mode_ExternalCipher::Encryption cbcEncryption(aesEncryption, iv);

        string plaintext = "test";
        string ciphertext;
        StreamTransformationFilter stfEncryptor(cbcEncryption, new
StringSink(ciphertext));
        stfEncryptor.Put(reinterpret_cast<const unsigned
char*>(plaintext.data()), plaintext.length());
        stfEncryptor.MessageEnd();

        AES::Decryption aesDecryption(key, AES_KEYLEN);
        CBC_Mode_ExternalCipher::Decryption cbcDecryption(aesDecryption, iv);

        string decryptedtext;
        StreamTransformationFilter stfDecryptor(cbcDecryption, new
StringSink(decryptedtext));
        stfDecryptor.Put(reinterpret_cast<const unsigned
char*>(ciphertext.data()), ciphertext.length()+1);
        try
        {
                        stfDecryptor.MessageEnd();
                }
        catch(Exception ex)
        {
                Exception::ErrorType et = ex.GetErrorType();
        }

The above code produces the exception - InvalidCiphertext with the
error type - INVALID_DATA_FORMAT.  Any idea what I have missed out?


Regards

cleohm


--~--~---------~--~----~------------~-------~--~----~
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.
-~----------~----~----~----~------~----~------~--~---

Reply via email to