Hi Rash,

If I recall correctly, the IV should be the same size as the block
size. This is because once a block is encrypted at stage i, it is fed
into stage i+1. For the first pass (stage 0), there is no stage -1. So
an IV is required.

Perhaps refreshing the topic with Schneier's Applied Cryptography or
Menenze (et al) Handbook of Applied Cryptography will be of assistance
to you.

As for stepping over your IV in the data stream, take a look at sample
4 in this example. It steps over salt housed in a std::string.
http://www.codeproject.com/cpp/AESProductKey.asp

Jeff

On 9/2/07, Rash <[EMAIL PROTECTED]> wrote:
>
> Hello All,
>  Following are my specifications to encrypt/decrypt files using
> AES::CBC mode
>
> Encrypt process:
> 1) 8 bytes random IV ( Initialization Vector ).
>   Insert the 8 bytes random IV to the beginning of the data stream.
>
> 2) Key length with 16 bytes ( digest using MD5 ).
> 3) padding method compatible with RFC 2898.
> 4) Encrypt the file.
>
> Decrypt process:
> 1) Read the first 8 bytes block and ignore it.
> 2) Digest the key using MD5.
> 3) Use the same padding method used when encrypting the file.
> 4) Decrypt the file.
>
> To encrypt the file here is my code
> void encryptFile(const char* password, const char* inputFileName,
> const
> char* outputFileName)
> {
>    byte pass[ AES::BLOCKSIZE ];        // digest of password
>    byte iv[ 8 ];               // Initial Vector (IV)
>
>    AutoSeededRandomPool rng;           // random number generator
>        try
>        {
>                // digest password
>                StringSource( password, true,new HashFilter(*(new MD5), new
>                                ArraySink(pass, AES::BLOCKSIZE)) );
>
>                // random Initial Vector
>                rng.GenerateBlock(iv, 8);
>
>                // create object for encrypting
>                AES::Encryption aesEncryption(pass,
> CryptoPP::AES::DEFAULT_KEYLENGTH);
>                CBC_Mode_ExternalCipher::Encryption 
> cbcEncryption(aesEncryption,
> iv);
>
>                StreamTransformationFilter *encryptor;
>                encryptor = new StreamTransformationFilter(cbcEncryption, new
> FileSink(outputFileName) );
>
>                encryptor->Put(iv, 8);
>
>                // "bind" a file and encrypt one
>                FileSource(inputFileName, true, encryptor);
>        }
>        catch(CryptoPP::Exception &e)
>        {
>                return;
>        }
> }
> void decryptFile(const char* password, const char*inputFileName,const
> char*outputFileName)
> {
>   //help me to write the decrypt functionality
> }
>
> How do I decrypt the file? I'm unable to read the first 8 bytes block
> and ignore it.
> Please help me to write the decrypt function satisfying the above
> specifications.
>
> 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.
-~----------~----~----~----~------~----~------~--~---

Reply via email to