X-Git-Url: https://git.cryptolib.org/?p=avr-crypto-lib.git;a=blobdiff_plain;f=arcfour%2Farcfour-asm.S;h=a7f5a88b22f9ed804838036eff2247093f243559;hp=1ef8218ce971a608ffaf096959dc40fb63141804;hb=4b5da1dc27a791b5c448274a3db09cd035b33493;hpb=d32eba56ce10ea6b9eff123b50d9842673b38f2b diff --git a/arcfour/arcfour-asm.S b/arcfour/arcfour-asm.S index 1ef8218..a7f5a88 100644 --- a/arcfour/arcfour-asm.S +++ b/arcfour/arcfour-asm.S @@ -1,7 +1,7 @@ /* arcfour-asm.S */ /* This file is part of the AVR-Crypto-Lib. - Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) + Copyright (C) 2006-2015 Daniel Otte (bg@nerilex.org) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -40,8 +40,8 @@ * this function initialises the context * param1: 16-bit pointer to the key * given in r24:r25 - * param2: 8-bit integer indicating keylength in byte - * given in r22 + * param2: 8-bit integer indicating keylength in bits + * given in r22:r23 * param3: 16-bit pointer to a ctx struct * given in r20:r21 */ @@ -52,7 +52,12 @@ arcfour_init: st X+, r1 st X+, r1 /* X points to S */ movw r20, r26 /* store pointer to S in r21:r20 */ - + lsr r23 + ror r22 + lsr r23 + ror r22 + lsr r23 + ror r22 1: st X+, r1 inc r1 @@ -96,7 +101,7 @@ uint8_t arcfour_gen(arcfour_ctx_t *c){ .global arcfour_gen ;== arcfour_gen == -; this function initialises the context +; this function generates a keystream byte ; param1: 16-bit pointer to a ctx struct ; given in r25,r24 @@ -114,7 +119,7 @@ arcfour_gen: st Z+, r19 /* i,j loaded&saved; X->S[i]; Z->S[0]; r20=S[i] */ add r30, r19 adc r31, r1 - ld r21, Z /* X->S[i]; Z->S[j]; r20=S[i]; r21=S[j]*/ + ld r21, Z /* X->S[i]; Z->S[j]; r20=S[i]; r21=S[j] */ st Z, r20 st X, r21 add r20, r21