PKUOS - Pintos
Pintos source browser for PKU Operating System course
child-linear.c
Go to the documentation of this file.
1/** Child process of page-parallel.
2 Encrypts 1 MB of zeros, then decrypts it, and ensures that
3 the zeros are back. */
4
5#include <string.h>
6#include "tests/arc4.h"
7#include "tests/lib.h"
8#include "tests/main.h"
9
10const char *test_name = "child-linear";
11
12#define SIZE (1024 * 1024)
13static char buf[SIZE];
14
15int
16main (int argc, char *argv[])
17{
18 const char *key = argv[argc - 1];
19 struct arc4 arc4;
20 size_t i;
21
22 /* Encrypt zeros. */
23 arc4_init (&arc4, key, strlen (key));
25
26 /* Decrypt back to zeros. */
27 arc4_init (&arc4, key, strlen (key));
29
30 /* Check that it's all zeros. */
31 for (i = 0; i < SIZE; i++)
32 if (buf[i] != '\0')
33 fail ("byte %zu != 0", i);
34
35 return 0x42;
36}
void arc4_init(struct arc4 *arc4, const void *key_, size_t size)
Definition: arc4.c:14
void arc4_crypt(struct arc4 *arc4, void *buf_, size_t size)
tests/arc4.h
Definition: arc4.c:35
int main(int argc, char *argv[])
Definition: child-linear.c:16
#define SIZE
Definition: child-linear.c:12
static char buf[SIZE]
Definition: child-linear.c:13
const char * test_name
Child process of page-parallel.
Definition: child-linear.c:10
void fail(const char *format,...)
Definition: lib.c:40
size_t strlen(const char *string)
Returns the length of STRING.
Definition: string.c:293
Alleged RC4 algorithm encryption state.
Definition: arc4.h:9
uint8_t i
Definition: arc4.h:11