Fix arcfour module.
authorSimon Josefsson <simon@josefsson.org>
Sat, 22 Oct 2005 16:45:57 +0000 (16:45 +0000)
committerSimon Josefsson <simon@josefsson.org>
Sat, 22 Oct 2005 16:45:57 +0000 (16:45 +0000)
ChangeLog
lib/ChangeLog
lib/arcfour.c
lib/arcfour.h
modules/arcfour

index 312289c..095539f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2005-10-22  Simon Josefsson  <jas@extundo.com>
+
+       * modules/arcfour (Depends-on): Need stdint.
+
 2005-10-21  Bruno Haible  <bruno@clisp.org>
 
        * gnulib-tool (func_import, func_create_testdir): Add quoting to last
index a35c4c5..60f30a6 100644 (file)
@@ -1,5 +1,11 @@
 2005-10-22  Simon Josefsson  <jas@extundo.com>
 
+       * 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  <jas@extundo.com>
+
        * md4.c, md4.c: Simplify buffer handling visavi alignment,
        suggested by Bruno Haible <bruno@clisp.org>.
 
index 61b8511..97b6116 100644 (file)
@@ -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;
index 28ef679..0a9d75c 100644 (file)
 # define ARCFOUR_H
 
 # include <stddef.h>
+# include <stdint.h>
 
 #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
index 328fcbd..a37ec0b 100644 (file)
@@ -7,6 +7,7 @@ lib/arcfour.c
 m4/arcfour.m4
 
 Depends-on:
+stdint
 
 configure.ac:
 gl_ARCFOUR