X-Git-Url: https://git.cryptolib.org/?a=blobdiff_plain;f=arcfour.c;h=5dcb84fb4e4ec7b44e6d34b8c81dbb821ff037c4;hb=017345097a7e5e05d7751816d2c8e29af3bacadc;hp=7c35a0353f3fef055708ca56ea39f5fd13f32448;hpb=c58f43febaefd188708dca010198629c0935728c;p=avr-crypto-lib.git
diff --git a/arcfour.c b/arcfour.c
index 7c35a03..5dcb84f 100644
--- a/arcfour.c
+++ b/arcfour.c
@@ -16,16 +16,16 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
-/*
+/*
* File: arcfour.c
* Author: Daniel Otte
* email: daniel.otte@rub.de
* Date: 2006-06-07
* License: GPLv3 or later
* Description: Implementation of the ARCFOUR (RC4 compatible) stream cipher algorithm.
- *
+ *
*/
-
+
#include
#include "arcfour.h"
@@ -38,7 +38,7 @@ void arcfour_init(const void *key, uint8_t length_B, arcfour_ctx_t *ctx){
uint16_t x,y=0;
for(x=0; x<= 255; ++x)
ctx->s[x]=x;
-
+
for(x=0; x<= 255; ++x){
y += ctx->s[x] + ((uint8_t*)key)[x % length_B];
y &= 0xff;
@@ -46,7 +46,7 @@ void arcfour_init(const void *key, uint8_t length_B, arcfour_ctx_t *ctx){
t = ctx->s[y];
ctx->s[y] = ctx->s[x];
ctx->s[x] = t;
- }
+ }
ctx->i = ctx->j = 0;
}
@@ -54,6 +54,7 @@ uint8_t arcfour_gen(arcfour_ctx_t *ctx){
uint8_t t;
ctx->i++;
ctx->j += ctx->s[ctx->i];
+ /* ctx->s[i] <--> ctx->s[j] */
t = ctx->s[ctx->j];
ctx->s[ctx->j] = ctx->s[ctx->i];
ctx->s[ctx->i] = t;