2 #include "tests/arc4.h"
6 swap_byte (uint8_t *a, uint8_t *b)
14 arc4_init (struct arc4 *arc4, const void *key_, size_t size)
16 const uint8_t *key = key_;
22 arc4->i = arc4->j = 0;
23 for (i = 0; i < 256; i++)
25 for (key_idx = 0, i = j = 0; i < 256; i++)
27 j = (j + s[i] + key[key_idx]) & 255;
28 swap_byte (s + i, s + j);
29 if (++key_idx >= size)
35 arc4_crypt (struct arc4 *arc4, void *buf_, size_t size)
48 swap_byte (s + i, s + j);
49 *buf++ ^= s[(s[i] + s[j]) & 255];