This source file includes following definitions.
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 #include <config.h>
19
20 #include "arcfour.h"
21
22 #include <stdio.h>
23 #include <string.h>
24
25 int
26 main (int argc, char *argv[])
27 {
28 arcfour_context ctx;
29
30
31 static char key_1[] = { 0x61, 0x8A, 0x63, 0xD2, 0xFB };
32 static char plaintext_1[] = { 0xDC, 0xEE, 0x4C, 0xF9, 0x2C };
33 static const char ciphertext_1[] = { 0xF1, 0x38, 0x29, 0xC9, 0xDE };
34 char scratch[16];
35
36 arcfour_setkey (&ctx, key_1, sizeof (key_1));
37 arcfour_stream (&ctx, plaintext_1, scratch, sizeof (plaintext_1));
38 if (memcmp (scratch, ciphertext_1, sizeof (ciphertext_1)))
39 {
40 size_t i;
41 printf ("expected:\n");
42 for (i = 0; i < 5; i++)
43 printf ("%02x ", scratch[i] & 0xFF);
44 printf ("\ncomputed:\n");
45 for (i = 0; i < 5; i++)
46 printf ("%02x ", ciphertext_1[i] & 0xFF);
47 printf ("\n");
48 return 1;
49 }
50
51
52
53 arcfour_setkey (&ctx, key_1, sizeof (key_1));
54 arcfour_stream (&ctx, scratch, scratch, sizeof (plaintext_1));
55 if (memcmp (scratch, plaintext_1, sizeof (plaintext_1)))
56 {
57 size_t i;
58 printf ("expected:\n");
59 for (i = 0; i < 5; i++)
60 printf ("%02x ", plaintext_1[i] & 0xFF);
61 printf ("\ncomputed:\n");
62 for (i = 0; i < 5; i++)
63 printf ("%02x ", scratch[i] & 0xFF);
64 printf ("\n");
65 return 1;
66 }
67
68
69 return 0;
70 }