bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

arcfour fix


From: Simon Josefsson
Subject: arcfour fix
Date: Sat, 22 Oct 2005 18:45:44 +0200
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

I have installed this.  GNU Shishi in CVS has now started to use GC
too, and the self tests suggested this...

Index: ChangeLog
===================================================================
RCS file: /cvsroot/gnulib/gnulib/ChangeLog,v
retrieving revision 1.436
diff -u -p -r1.436 ChangeLog
--- ChangeLog   21 Oct 2005 15:05:31 -0000      1.436
+++ ChangeLog   22 Oct 2005 16:44:35 -0000
@@ -1,3 +1,7 @@
+2005-10-22  Simon Josefsson  <address@hidden>
+
+       * modules/arcfour (Depends-on): Need stdint.
+
 2005-10-21  Bruno Haible  <address@hidden>
 
        * gnulib-tool (func_import, func_create_testdir): Add quoting to last
Index: modules/arcfour
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/arcfour,v
retrieving revision 1.1
diff -u -p -r1.1 arcfour
--- modules/arcfour     15 Oct 2005 18:19:45 -0000      1.1
+++ modules/arcfour     22 Oct 2005 16:44:35 -0000
@@ -7,6 +7,7 @@ lib/arcfour.c
 m4/arcfour.m4
 
 Depends-on:
+stdint
 
 configure.ac:
 gl_ARCFOUR
Index: lib/ChangeLog
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/ChangeLog,v
retrieving revision 1.1035
diff -u -p -r1.1035 ChangeLog
--- lib/ChangeLog       22 Oct 2005 16:32:14 -0000      1.1035
+++ lib/ChangeLog       22 Oct 2005 16:44:37 -0000
@@ -1,5 +1,11 @@
 2005-10-22  Simon Josefsson  <address@hidden>
 
+       * 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  <address@hidden>
+
        * md4.c, md4.c: Simplify buffer handling visavi alignment,
        suggested by Bruno Haible <address@hidden>.
 
Index: lib/arcfour.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/arcfour.c,v
retrieving revision 1.1
diff -u -p -r1.1 arcfour.c
--- lib/arcfour.c       15 Oct 2005 18:19:45 -0000      1.1
+++ lib/arcfour.c       22 Oct 2005 16:44:37 -0000
@@ -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: lib/arcfour.h
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/arcfour.h,v
retrieving revision 1.1
diff -u -p -r1.1 arcfour.h
--- lib/arcfour.h       15 Oct 2005 18:19:45 -0000      1.1
+++ lib/arcfour.h       22 Oct 2005 16:44:37 -0000
@@ -25,13 +25,14 @@
 # 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]