* 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
*/
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
.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
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