]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
* x86/arcfour-crypt.asm (nettle_arcfour_crypt): Bug fix, half of
authorNiels Möller <nisse@lysator.liu.se>
Thu, 5 Feb 2004 18:40:06 +0000 (19:40 +0100)
committerNiels Möller <nisse@lysator.liu.se>
Thu, 5 Feb 2004 18:40:06 +0000 (19:40 +0100)
the S array swap was forgotten.
* arcfour.c (arcfour_stream): Likewise.
* arcfour-crypt.c (arcfour_crypt): Likewise.

Rev: src/nettle/ChangeLog:1.233
Rev: src/nettle/arcfour-crypt.c:1.2
Rev: src/nettle/arcfour.c:1.6
Rev: src/nettle/x86/arcfour-crypt.asm:1.5

ChangeLog
arcfour-crypt.c
arcfour.c
x86/arcfour-crypt.asm

index ad65f733ff67ed1cac695eb0453e660080750129..30f84e2fedcac3ba8cd12022cc81713769ff794b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2004-02-05  Niels Möller  <nisse@lysator.liu.se>
+
+       * testsuite/arcfour-test.c (test_main): Use test_cipher_stream.
+
+       * testsuite/testutils.c (test_cipher_stream): New function, that
+       tries dividing the input into varying size blocks before
+       processing. 
+
+       * x86/arcfour-crypt.asm (nettle_arcfour_crypt): Bug fix, half of
+       the S array swap was forgotten.
+       * arcfour.c (arcfour_stream): Likewise.
+       * arcfour-crypt.c (arcfour_crypt): Likewise.
+
 2004-02-05  Niels Möller  <niels@s3.kth.se>
 
        * x86/arcfour-crypt.asm (nettle_arcfour_crypt): Must store the new
index e3d678ff8f1f53ce2bed09e60e621a4a05d0ca27..78f68311e7eb617d7bb7b4714ed76cd4689565ee 100644 (file)
@@ -46,6 +46,7 @@ arcfour_crypt(struct arcfour_ctx *ctx,
       si = ctx->S[i];
       j += si; j &= 0xff;
       sj = ctx->S[i] = ctx->S[j];
+      ctx->S[j] = si;
       *dst++ = *src++ ^ ctx->S[ (si + sj) & 0xff ];
     }
   ctx->i = i; ctx->j = j;
index da0394289166c937b2b1bed57b2f086e7e79ba28..d83342220ab60541f4ff7d5577e6eec3c684007d 100644 (file)
--- a/arcfour.c
+++ b/arcfour.c
@@ -70,6 +70,7 @@ arcfour_stream(struct arcfour_ctx *ctx,
       si = ctx->S[i];
       j += si; j &= 0xff;
       sj = ctx->S[i] = ctx->S[j];
+      ctx->S[j] = si;
       *dst++ = ctx->S[ (si + sj) & 0xff ];
     }
   ctx->i = i; ctx->j = j;
index 007315aefe62dac3428cd18dfe48f21028ffdf37..b997abaff7a7281f0c6c75c053cb055502f879f2 100644 (file)
@@ -54,7 +54,8 @@ nettle_arcfour_crypt:
        movzbl  (%ebp, %eax), %ecx      C  si. Clears high bytes
        addb    %cl, %bl
        movb    (%ebp, %ebx), %ch       C  sj
-       movb    %ch, (%ebp, %eax)
+       movb    %ch, (%ebp, %eax)       C  S[i] = sj
+       movb    %cl, (%ebp, %ebx)       C  C[j] = si
        addb    %ch, %cl
        xorb    %ch, %ch                C  Clear, so it can be used
                                        C  for indexing.