I am new to cryptopp library, even new to C++ coding, and facing some issue 
in C++ cryptopp library.

I have written following code for Encryption:

try{

        

        AES::Encryption aesEncryption(pass,

                                      AES_256);

        CBC_Mode_ExternalCipher::Encryption cbcEncryption(aesEncryption,

                                                          true_iv);

        

        StreamTransformationFilter *encryptor;

        encryptor = new StreamTransformationFilter(cbcEncryption,

                                                   new FileSink(outputFileName) 
);

        

        encryptor->Put(iv, AES_256);

        

        FileSource(inputFileName, true, encryptor);

        

        return true;

        

    }catch(CryptoPP::Exception &e)

    {

        cerr << "Caught exception during decryption!" << endl;

        return false;

    }


Following code for Decryption:


try {

        StringSource(password, true, new HashFilter(*(new SHA256), new

                                                    ArraySink(pass,AES_256
)));

        

        CryptoPP::AES::Decryption aesDecryption(pass,

                                                AES_256);

        CryptoPP::CBC_Mode_ExternalCipher::Decryption 
cbcDecryption(aesDecryption, iv);

        

        StreamTransformationFilter *decryptor;

        decryptor = new

        StreamTransformationFilter(cbcDecryption, new

                                   FileSink(outputFileName));

        

        

        char garbage[AES_256], iv_garbage[AES_256];

        ifstream inf;

        inf.open(inputFileName); inf.read(iv_garbage, AES_256);

        

        cbcDecryption.ProcessData((byte *)garbage, (const byte 
*)iv_garbage, AES_256);

        

        FileSource(inf, true, decryptor);

        

        inf.close();

        

        return true;

    }

    catch(CryptoPP::Exception &e)

    {

        cerr << "Caught exception during decryption!" << endl;

        return false;

    }


My problem is when I use this code on iOS and Android platforms, it is 
working like Magic and encrypting and decrypting files. 

However on Windows platform I am getting following errors while Decryption. 


   - PKCS#7 padding error for some files
   - Cipher text is not of block size for others.

None of the files are getting Decrypted. Although Encryption is working 
fine. I am sure about Encryption, because I have encrypted one file on 
Windows Platform and decrypted the same on iOS, it worked. So I am almost 
sure that Encryption is not issue on Windows, only Decryption is causing me 
problems.

Any help would be appreciated. I have searched for above errors a lot on 
this and other groups, lots of solutions are present none of them worked 
till now for me.

Please help. Thanks in advance.

-- 
-- 
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/d/optout.

Reply via email to