rc4 ksa modification
- From: LightBit <grpintar@xxxxxxxxx>
- Date: Mon, 30 Jan 2012 09:36:12 -0800 (PST)
Hello!
I made some modification to standard rc4 ksa, but I'm not sure if it's
ok?
#include <stddef.h>
#include <stdint.h>
struct rc4
{
uint8_t s[256];
uint8_t i;
uint8_t j;
};
void rc4_ksa(struct rc4 *s, const uint8_t *k, const unsigned int klen)
{
unsigned int i;
unsigned int j;
uint8_t t;
s->i = 0;
s->j = 0;
for(i = 0; i < 256; i++) s->s[i] = i;
/* mix key twice plus 256 for shorter keys, against weak keys?
(instead of drop) */
for(j = 0, i = (klen << 1) + 256; i; i--)
{
s->j = s->j + s->s[s->i] + k[j++];
if(j == klen) j = 0;
t = s->s[s->i];
s->s[s->i] = s->s[s->j];
s->s[s->j] = t;
s->i++;
}
/* standard rc4 sets s->i = s->j = 0 here, but what is the point?
(It's better if attacker doesn't know i and j) */
}
.
- Follow-Ups:
- Re: rc4 ksa modification
- From: tom st denis
- Re: rc4 ksa modification
- Prev by Date: Re: Bitmap Steganography freeware
- Next by Date: Re: rc4 ksa modification
- Previous by thread: [Daily Brain Teaser] Best Of Puzzle of 2011
- Next by thread: Re: rc4 ksa modification
- Index(es):
Relevant Pages
|