X-Git-Url: https://git.cryptolib.org/?a=blobdiff_plain;f=arcfour.c;h=7c35a0353f3fef055708ca56ea39f5fd13f32448;hb=c58f43febaefd188708dca010198629c0935728c;hp=13fb159e7aff4e559e69e91327935e2feb93aca9;hpb=b07fb998ba047b641edb843e73f5284fe5fff9af;p=avr-crypto-lib.git diff --git a/arcfour.c b/arcfour.c index 13fb159..7c35a03 100644 --- a/arcfour.c +++ b/arcfour.c @@ -33,15 +33,16 @@ * length is length of key in bytes! */ -void arcfour_init(arcfour_ctx_t *ctx, void *key, uint8_t length_B){ +void arcfour_init(const void *key, uint8_t length_B, arcfour_ctx_t *ctx){ uint8_t t; - unsigned x,y=0; + 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; + /* ctx->s[y] <--> ctx->s[x] */ t = ctx->s[y]; ctx->s[y] = ctx->s[x]; ctx->s[x] = t;