What size should i use in encrypt/decrypt in ARC4 ?

Adam Langley agl at imperialviolet.org
Wed Jul 30 17:58:15 CEST 2008


On Wed, Jul 30, 2008 at 5:42 AM, Jabka Atu <mashrom.head at gmail.com> wrote:
>  char * plain_text = "Attack at down";

Firstly, it should be 'dawn', otherwise you army will return -EINVAL
and the barbarian hoards will overrun them ;)

> gcry_cipher_encrypt (cipher_handler,c_str,strlen(c_str) , NULL,0);
> cout<<c_str<<endl;
>
> gcry_cipher_decrypt (cipher_handler, c_str,strlen(c_str),NULL,0);
> cout<<c_str<<" " <<endl;
>
> i get the next output :
>
> ��g�zB�QK]o
> ��A�R����       2�9�

I'm just guessing here, but it's a stream cipher and you're reusing
the same cipher_handler. If you tried creating two handles for the
cipher (and setting the same key on both, of course) and used one for
encryption and the other for decryption, you might have better luck.
The reason is that RC4 mutates itself as it processes the plaintext[1]

AGL

[1] http://en.wikipedia.org/wiki/RC4

-- 
Adam Langley agl at imperialviolet.org http://www.imperialviolet.org


More information about the Gcrypt-devel mailing list