2 * Copyright (C) 2005 Free Software Foundation
3 * Written by Simon Josefsson
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
27 main (int argc, char *argv[])
30 /* Test vector from Cryptlib via Libgcrypt labeled there: "from the
31 State/Commerce Department". */
32 static char key_1[] = { 0x61, 0x8A, 0x63, 0xD2, 0xFB };
33 static char plaintext_1[] = { 0xDC, 0xEE, 0x4C, 0xF9, 0x2C };
34 static const char ciphertext_1[] = { 0xF1, 0x38, 0x29, 0xC9, 0xDE };
37 arcfour_setkey (&ctx, key_1, sizeof (key_1));
38 arcfour_stream (&ctx, plaintext_1, scratch, sizeof (plaintext_1));
39 if (memcmp (scratch, ciphertext_1, sizeof (ciphertext_1)))
42 printf ("expected:\n");
43 for (i = 0; i < 5; i++)
44 printf ("%02x ", scratch[i] & 0xFF);
45 printf ("\ncomputed:\n");
46 for (i = 0; i < 5; i++)
47 printf ("%02x ", ciphertext_1[i] & 0xFF);
54 arcfour_setkey (&ctx, key_1, sizeof (key_1));
55 arcfour_stream (&ctx, scratch, scratch, sizeof (plaintext_1));
56 if (memcmp (scratch, plaintext_1, sizeof (plaintext_1)))
59 printf ("expected:\n");
60 for (i = 0; i < 5; i++)
61 printf ("%02x ", plaintext_1[i] & 0xFF);
62 printf ("\ncomputed:\n");
63 for (i = 0; i < 5; i++)
64 printf ("%02x ", scratch[i] & 0xFF);