Intel® Integrated Performance Primitives
Community support and discussions relating to developing high-performance vision, signal, security, and storage applications.

ARCFour Encryption/Decryption Problem

Heidarian
Beginner
170 Views

Dear friends

I wrote this simple code to test the ARCFour algorithm,but when I run my program the decrypted cipher-text is not the same as the original plain-text...could anyone tell me what is wrong with my code??

int ctxSize;
Ipp8u ctext[8];
Ipp8u pDst[8];
Ipp8u key[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
Ipp8u pSrc[] ={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

ippsARCFourGetSize(&ctxSize);
IppsARCFourState* pCtx = (IppsARCFourState*)( new Ipp8u [ctxSize] );
ippsARCFourInit(key,sizeof(key),pCtx);
ippsARCFourEncrypt(pSrc,ctext,sizeof(pSrc),pCtx);
ippsARCFourDecrypt(ctext, pDst, sizeof(ctext), pCtx);

when I debug this code pDst is not the same as PSrc!!!

Thanks in advance
0 Kudos
1 Solution
achrzesz2
New Contributor I
170 Views
Hello Heidarian

I think You should do:

ippsARCFourReset(pCtx);

before decrypting.

Andrzej Ch

View solution in original post

2 Replies
achrzesz2
New Contributor I
171 Views
Hello Heidarian

I think You should do:

ippsARCFourReset(pCtx);

before decrypting.

Andrzej Ch
Heidarian
Beginner
170 Views
Quoting - achrzesz2
Hello Heidarian

I think You should do:

ippsARCFourReset(pCtx);

before decrypting.

Andrzej Ch

Hello achrzesz2

Thanx very much for your help, I have added ippsARCFourReset(pCtx) before decrption function and decrypted ctext become the same as the original ptext.

again many tanks to you dear.
Reply