From: Simon Josefsson Date: Sat, 22 Oct 2005 16:45:57 +0000 (+0000) Subject: Fix arcfour module. X-Git-Tag: cvs-readonly~2763 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=a0326dc6b8e1401e51f969b1929440abb90e412e;p=gnulib.git Fix arcfour module. --- diff --git a/ChangeLog b/ChangeLog index 312289caa..095539f40 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2005-10-22 Simon Josefsson + + * modules/arcfour (Depends-on): Need stdint. + 2005-10-21 Bruno Haible * gnulib-tool (func_import, func_create_testdir): Add quoting to last diff --git a/lib/ChangeLog b/lib/ChangeLog index a35c4c557..60f30a6a7 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,5 +1,11 @@ 2005-10-22 Simon Josefsson + * arcfour.h, arcfour.c: Use fixed size indices in the + arcfour_context struct (simplify test vector testing in GNU + Shishi). + +2005-10-22 Simon Josefsson + * md4.c, md4.c: Simplify buffer handling visavi alignment, suggested by Bruno Haible . diff --git a/lib/arcfour.c b/lib/arcfour.c index 61b851127..97b61160e 100644 --- a/lib/arcfour.c +++ b/lib/arcfour.c @@ -36,16 +36,16 @@ void arcfour_stream (arcfour_context * context, const char *inbuf, char *outbuf, size_t length) { - size_t i = context->idx_i; - size_t j = context->idx_j; + uint8_t i = context->idx_i; + uint8_t j = context->idx_j; char *sbox = context->sbox; for (; length > 0; length--) { char t; - i = (i + 1) % ARCFOUR_SBOX_SIZE; - j = (j + sbox[i]) % ARCFOUR_SBOX_SIZE; + i++; + j += sbox[i]; t = sbox[i]; sbox[i] = sbox[j]; sbox[j] = t; diff --git a/lib/arcfour.h b/lib/arcfour.h index 28ef679d0..0a9d75c0f 100644 --- a/lib/arcfour.h +++ b/lib/arcfour.h @@ -25,13 +25,14 @@ # define ARCFOUR_H # include +# include #define ARCFOUR_SBOX_SIZE 256 typedef struct { - size_t idx_i, idx_j; char sbox[ARCFOUR_SBOX_SIZE]; + uint8_t idx_i, idx_j; } arcfour_context; /* Apply ARCFOUR stream to INBUF placing the result in OUTBUF, both of diff --git a/modules/arcfour b/modules/arcfour index 328fcbd28..a37ec0b7f 100644 --- a/modules/arcfour +++ b/modules/arcfour @@ -7,6 +7,7 @@ lib/arcfour.c m4/arcfour.m4 Depends-on: +stdint configure.ac: gl_ARCFOUR