1 /* Encrypts, then decrypts, 1 MB of memory and verifies that the
2 values are as they should be. */
5 #include "tests/arc4.h"
7 #include "tests/main.h"
9 #define SIZE (1024 * 1024)
11 static char buf[SIZE];
19 /* Initialize to 0x5a. */
21 memset (buf, 0x5a, sizeof buf);
23 /* Check that it's all 0x5a. */
25 for (i = 0; i < SIZE; i++)
27 fail ("byte %zu != 0x5a", i);
30 msg ("read/modify/write pass one");
31 arc4_init (&arc4, "foobar", 6);
32 arc4_crypt (&arc4, buf, SIZE);
34 /* Decrypt back to zeros. */
35 msg ("read/modify/write pass two");
36 arc4_init (&arc4, "foobar", 6);
37 arc4_crypt (&arc4, buf, SIZE);
39 /* Check that it's all 0x5a. */
41 for (i = 0; i < SIZE; i++)
43 fail ("byte %zu != 0x5a", i);