6 * Description: Implementation of the ARCFOUR (RC4 compatible) stream cipher algorithm.
10 /* +---+---+---------------------+
11 * | i | j | ......<256>........ |
12 * +---+---+---------------------+
18 ; this function initialises the context
19 ; param1: 16-bit pointer to a ctx struct
21 ; param2: 16-bit pointer to a key
23 ; param1: 8-bit integer indicating keylength in byte
31 movw r26, r24 /* X points to ctx */
32 movw r30, r22 /* Z points to key */
34 st X+, r1 /* X points to S */
41 adiw r24, 2 /* r24:r25 points to S */
42 clr r21 /* r21 is j */
43 mov r18, r20 /* r18 is keyindex counter */
48 add r21, r19 /* j+= key[i%length] */
53 add r21, r19 /* j += S[i] */
55 dec r18 /* check the key-index counter */
59 3: /* now swap(S[i], S[j]) */ /* r19 is still S[i] */
62 adc r29, r0 /* Y points to S[j]*/
75 uint8_t arcfour_gen(arcfour_ctx_t *c){
80 c->s[c->j] = c->s[c->i];
82 return c->s[(c->s[c->j] + c->s[c->i]) & 0xff];
88 ; this function initialises the context
89 ; param1: 16-bit pointer to a ctx struct
103 st Z+, r19 /* i,j loaded&saved; X->S[i]; Z->S[0]; r20=S[i] */
106 ld r21, Z /* X->S[i]; Z->S[j]; r20=S[i]; r21=S[j]*/
111 movw r26, r24 /* X and Z point to S */