[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: arcfour
From: |
Stepan Kasal |
Subject: |
Re: arcfour |
Date: |
Fri, 14 Oct 2005 16:32:28 +0200 |
User-agent: |
Mutt/1.4.1i |
Hello,
Ralf proposed:
> > > #define ARCFOUR_BLOCKBITS 8
we have a random number generator, which gives us a sequence of 8-bit
integers. So, in a sense, we are working with 8-bit blocks.
But I see no reason why the other constants should contain the substring
"BLOCK".
On Fri, Oct 14, 2005 at 04:01:23PM +0200, Ralf Wildenhues wrote:
> Come to think of it, I'd probably call the first one LOGSZ
> (or LOGSIZE, FWIW), and the second SIZE.
The first one might be ARCFOUR_BLOCKBITS, but ARCFOUR_LOGSZ might be better,
to avoid misunderstanding. The second one should be ARCFOUR_SIZE.
Perhaps:
#define ARCFOUR_LOGSZ 8
#define ARCFOUR_SIZE (1 << ARCFOUR_LOGSZ)
/* Some compilers may not be able to optimize n % ARCFOUR_SIZE properly. */
#define ARCFOUR_MODULO(n) ((n) & (ARCFOUR_SIZE - 1))
You asked Simon to use constants, to make the code more general.
But there is actually no need that the SIZE of the permutation (sbox) be
a power of 2. It can be any positive number, in theory.
Yes, the size of the sbox determines the range of the numbers generated,
so if ARCFOUR_SIZE is not a power of 2, then the pseuso-random genrator
is not directly applicable for enciphering a binary data, but that's just
a detail.
So, in a sense, it would be better to use i % ARCFOUR_SIZE, instead of
i & ARCFOUR_MASK.
But, OTOH, we are not willing to compromise the performance, not even with
less capable compilers.
I think the macro ARCFOUR_MODULO proposed above might be a good solution.
Have a nice day,
Stepan
- Re: arcfour, (continued)
- Re: arcfour, Stepan Kasal, 2005/10/14
- Re: arcfour, Simon Josefsson, 2005/10/14
- Re: arcfour, Paul Eggert, 2005/10/14
- Re: arcfour, Bruno Haible, 2005/10/14
- Re: arcfour, Simon Josefsson, 2005/10/14
- Re: arcfour, Paul Eggert, 2005/10/14
- Re: arcfour, Simon Josefsson, 2005/10/15
- Re: arcfour,
Stepan Kasal <=
Re: [bug-gnulib] arcfour, Bruno Haible, 2005/10/14