- adjustments to scores for P3 as discussed.
[pintos-anon] / src / tests / vm / page-linear.c
1 /* Encrypts, then decrypts, 2 MB of memory and verifies that the
2    values are as they should be. */
3
4 #include <string.h>
5 #include "tests/arc4.h"
6 #include "tests/lib.h"
7 #include "tests/main.h"
8
9 #define SIZE (2 * 1024 * 1024)
10
11 static char buf[SIZE];
12
13 void
14 test_main (void)
15 {
16   struct arc4 arc4;
17   size_t i;
18
19   /* Initialize to 0x5a. */
20   msg ("initialize");
21   memset (buf, 0x5a, sizeof buf);
22
23   /* Check that it's all 0x5a. */
24   msg ("read pass");
25   for (i = 0; i < SIZE; i++)
26     if (buf[i] != 0x5a)
27       fail ("byte %zu != 0x5a", i);
28
29   /* Encrypt zeros. */
30   msg ("read/modify/write pass one");
31   arc4_init (&arc4, "foobar", 6);
32   arc4_crypt (&arc4, buf, SIZE);
33
34   /* Decrypt back to zeros. */
35   msg ("read/modify/write pass two");
36   arc4_init (&arc4, "foobar", 6);
37   arc4_crypt (&arc4, buf, SIZE);
38
39   /* Check that it's all 0x5a. */
40   msg ("read pass");
41   for (i = 0; i < SIZE; i++)
42     if (buf[i] != 0x5a)
43       fail ("byte %zu != 0x5a", i);
44 }