Hello, I have the same problem. But I found a workaround. Don't know if this
is going to help you, though. 

instead of specifying the key and the iv do the following:

memset( key_DES_1, 0x00, DES_EDE3::DEFAULT_KEYLENGTH );
memset( iv_DES_1, 0x00, DES_EDE3::BLOCKSIZE );

the decrypted text/file is same as the original one.

I've tried with AutoSeededRandomPool, but no luck. The decrypted text is
never the same as the original one. Does he mean the the input text can not
be larger than 56-bits or 7-bytes? I'm using 3-des. 
If you have a solution for the one with specified key and iv, please let me
know.


Francisco Ortiz-2 wrote:
> 
> ok, i'm going to use an StreamTransformationFilter.
> 
>       byte key[]=
>       {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
>       byte iv[]=
>       {'1','2','3','4','5','6','7','8','9','0','a','b','c','d','e','f'};
> 
>    //
>     // String and Sink setup
>     //
>     std::string plaintext = "Now is the time for all .";
>     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::DES::Encryption desEncryption(key,
> CryptoPP::DES::DEFAULT_KEYLENGTH);
>     CryptoPP::CBC_Mode_ExternalCipher::Encryption cbcEncryption
> ( desEncryption, 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 << std::hex << (0xFF & static_cast<byte>(ciphertext
> [i])) ;
>     }
> 
>     std::cout << std::endl << std::endl;
> 
> 
> it doesn't work.
> 
> 
> Thanks anyway Geoff , but i really don't know why it's not working
> well. Encrpytion text is limited with the param 64.. so which 56 bytes
> do you refer to?
> 
> 
> 
> 
> 
> On 4 ene, 02:25, Geoff Beier <[email protected]> wrote:
>> Hi,
>>
>> I haven't built or run your code. But here:
>>
>> > byte PlainText[]= { 0x4e , 0x6f , 0x77 ,0x20, 0x69, 0x73 ,0x20 ,
>> > 0x74} ;
>> > byte cbCipherText[ 64 ] ;
>> >  CryptoPP::ECB_Mode< CryptoPP::DES >::Encryption Encryptor;
>> >  Encryptor.SetKey( key, 8);
>> >  Encryptor.ProcessData( cbCipherText,PlainText, 64);
>>
>> you would appear to be encrypting whatever 56 bytes follow your
>> plaintext on the stack in addition to your plaintext.
>>
>> http://www.cryptopp.com/docs/ref/class_symmetric_cipher.html
>>
>> HTH,
>>
>> Geoff
> 
> -- 
> 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.
> 
> 

-- 
View this message in context: 
http://old.nabble.com/DES-%2C-is-working-properly---tp27006265p32675584.html
Sent from the Crypto++ Users mailing list archive at Nabble.com.

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