Mercurial > hg > octave-shane > gnulib-hg
annotate tests/test-arctwo.c @ 17632:86af85d364e1 default tip
unistd: port readlink to Mac OS X 10.3.9
* lib/unistd.in.h (_GL_INCLUDING_UNISTD_H): New macro, to work
around self-include problem in Mac OS X 10.3.9 when combined with
readlink module. Problem reported by Klaus Zietler in
<http://bugs.gnu.org/16825>.
author | Paul Eggert <eggert@penguin.cs.ucla.edu> |
---|---|
date | Tue, 25 Feb 2014 11:16:27 -0800 |
parents | 344018b6e5d7 |
children |
rev | line source |
---|---|
6402
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
1 /* |
17587 | 2 * Copyright (C) 2005, 2010-2014 Free Software Foundation, Inc. |
6402
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
3 * Written by Simon Josefsson |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
4 * |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
5 * This program is free software: you can redistribute it and/or modify |
6402
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
6 * it under the terms of the GNU General Public License as published by |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
7 * the Free Software Foundation; either version 3 of the License, or |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
8 * (at your option) any later version. |
6402
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
9 * |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
10 * This program is distributed in the hope that it will be useful, |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
13 * GNU General Public License for more details. |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
14 * |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
8891
diff
changeset
|
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
6402
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
17 |
8891
633babea5f62
Unconditionally include <config.h> in unit tests.
Eric Blake <ebb9@byu.net>
parents:
6402
diff
changeset
|
18 #include <config.h> |
6402
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
19 |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
20 #include <stdio.h> |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
21 #include <string.h> |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
22 #include "arctwo.h" |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
23 |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
24 int |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
25 main (int argc, char *argv[]) |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
26 { |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
27 arctwo_context ctx; |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
28 char scratch[16]; |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
29 |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
30 /* Test vectors from Peter Gutmann's paper. */ |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
31 static char key_1[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
32 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
33 }; |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
34 static char plaintext_1[] = |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
35 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
36 static const char ciphertext_1[] = |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
37 { 0x1C, 0x19, 0x8A, 0x83, 0x8D, 0xF0, 0x28, 0xB7 }; |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
38 |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
39 static char key_2[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
40 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
41 }; |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
42 static char plaintext_2[] = |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
43 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
44 static char ciphertext_2[] = |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
45 { 0x50, 0xDC, 0x01, 0x62, 0xBD, 0x75, 0x7F, 0x31 }; |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
46 |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
47 /* This one was checked against libmcrypt's RFC2268. */ |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
48 static char key_3[] = { 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
49 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
50 }; |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
51 static char plaintext_3[] = |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
52 { 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
53 static char ciphertext_3[] = |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
54 { 0x8f, 0xd1, 0x03, 0x89, 0x33, 0x6b, 0xf9, 0x5e }; |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
55 |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
56 /* From RFC2268. */ |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
57 static char key_4[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
58 static char plaintext_4[] = |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
59 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
60 static char ciphertext_4[] = |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
61 { 0xeb, 0xb7, 0x73, 0xf9, 0x93, 0x27, 0x8e, 0xff }; |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
62 |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
63 static char key_5[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
64 static char plaintext_5[] = |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
65 { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
66 static char ciphertext_5[] = |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
67 { 0x27, 0x8b, 0x27, 0xe4, 0x2e, 0x2f, 0x0d, 0x49 }; |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
68 |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
69 static char key_6[] = { 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
70 static char plaintext_6[] = |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
71 { 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }; |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
72 static char ciphertext_6[] = |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
73 { 0x30, 0x64, 0x9e, 0xdf, 0x9b, 0xe7, 0xd2, 0xc2 }; |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
74 |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
75 /* First test. */ |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
76 arctwo_setkey_ekb (&ctx, sizeof (key_1), key_1, 0); |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
77 arctwo_encrypt (&ctx, plaintext_1, scratch, ARCTWO_BLOCK_SIZE); |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
78 |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
79 if (memcmp (scratch, ciphertext_1, sizeof (ciphertext_1))) |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
80 return 1; |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
81 |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
82 arctwo_setkey_ekb (&ctx, sizeof (key_1), key_1, 0); |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
83 arctwo_decrypt (&ctx, scratch, scratch, ARCTWO_BLOCK_SIZE); |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
84 if (memcmp (scratch, plaintext_1, sizeof (plaintext_1))) |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
85 return 1; |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
86 |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
87 /* Second test. */ |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
88 arctwo_setkey_ekb (&ctx, sizeof (key_2), key_2, 0); |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
89 arctwo_encrypt (&ctx, plaintext_2, scratch, ARCTWO_BLOCK_SIZE); |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
90 if (memcmp (scratch, ciphertext_2, sizeof (ciphertext_2))) |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
91 return 1; |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
92 |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
93 arctwo_setkey_ekb (&ctx, sizeof (key_2), key_2, 0); |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
94 arctwo_decrypt (&ctx, scratch, scratch, ARCTWO_BLOCK_SIZE); |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
95 if (memcmp (scratch, plaintext_2, sizeof (plaintext_2))) |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
96 return 1; |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
97 |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
98 /* Third test. */ |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
99 arctwo_setkey_ekb (&ctx, sizeof (key_3), key_3, 0); |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
100 arctwo_encrypt (&ctx, plaintext_3, scratch, ARCTWO_BLOCK_SIZE); |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
101 |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
102 if (memcmp (scratch, ciphertext_3, sizeof (ciphertext_3))) |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
103 return 1; |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
104 |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
105 arctwo_setkey_ekb (&ctx, sizeof (key_3), key_3, 0); |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
106 arctwo_decrypt (&ctx, scratch, scratch, ARCTWO_BLOCK_SIZE); |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
107 if (memcmp (scratch, plaintext_3, sizeof (plaintext_3))) |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
108 return 1; |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
109 |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
110 /* Fourth test. */ |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
111 arctwo_setkey_ekb (&ctx, sizeof (key_4), key_4, 63); |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
112 arctwo_encrypt (&ctx, plaintext_4, scratch, ARCTWO_BLOCK_SIZE); |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
113 |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
114 if (memcmp (scratch, ciphertext_4, sizeof (ciphertext_4))) |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
115 { |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
116 size_t i; |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
117 printf ("expected:\n"); |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
118 for (i = 0; i < sizeof (ciphertext_4); i++) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
119 printf ("%02x ", ciphertext_4[i] & 0xFF); |
6402
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
120 printf ("\ncomputed:\n"); |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
121 for (i = 0; i < sizeof (ciphertext_4); i++) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
122 printf ("%02x ", scratch[i] & 0xFF); |
6402
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
123 printf ("\n"); |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
124 return 1; |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
125 } |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
126 |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
127 arctwo_setkey_ekb (&ctx, sizeof (key_4), key_4, 63); |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
128 arctwo_decrypt (&ctx, scratch, scratch, ARCTWO_BLOCK_SIZE); |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
129 if (memcmp (scratch, plaintext_4, sizeof (plaintext_4))) |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
130 return 1; |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
131 |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
132 /* Fifth test. */ |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
133 arctwo_setkey_ekb (&ctx, sizeof (key_5), key_5, 64); |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
134 arctwo_encrypt (&ctx, plaintext_5, scratch, ARCTWO_BLOCK_SIZE); |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
135 |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
136 if (memcmp (scratch, ciphertext_5, sizeof (ciphertext_5))) |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
137 { |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
138 size_t i; |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
139 printf ("expected:\n"); |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
140 for (i = 0; i < sizeof (ciphertext_5); i++) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
141 printf ("%02x ", ciphertext_5[i] & 0xFF); |
6402
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
142 printf ("\ncomputed:\n"); |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
143 for (i = 0; i < sizeof (ciphertext_5); i++) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
144 printf ("%02x ", scratch[i] & 0xFF); |
6402
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
145 printf ("\n"); |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
146 return 1; |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
147 } |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
148 |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
149 arctwo_setkey_ekb (&ctx, sizeof (key_5), key_5, 64); |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
150 arctwo_decrypt (&ctx, scratch, scratch, ARCTWO_BLOCK_SIZE); |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
151 if (memcmp (scratch, plaintext_5, sizeof (plaintext_5))) |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
152 return 1; |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
153 |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
154 /* Sixth test. */ |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
155 arctwo_setkey_ekb (&ctx, 8, key_6, 64); |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
156 arctwo_encrypt (&ctx, plaintext_6, scratch, ARCTWO_BLOCK_SIZE); |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
157 |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
158 if (memcmp (scratch, ciphertext_6, sizeof (ciphertext_6))) |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
159 { |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
160 size_t i; |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
161 printf ("expected:\n"); |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
162 for (i = 0; i < sizeof (ciphertext_6); i++) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
163 printf ("%02x ", ciphertext_6[i] & 0xFF); |
6402
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
164 printf ("\ncomputed:\n"); |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
165 for (i = 0; i < sizeof (ciphertext_6); i++) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
166 printf ("%02x ", scratch[i] & 0xFF); |
6402
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
167 printf ("\n"); |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
168 return 1; |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
169 } |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
170 |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
171 arctwo_setkey_ekb (&ctx, sizeof (key_6), key_6, 64); |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
172 arctwo_decrypt (&ctx, scratch, scratch, ARCTWO_BLOCK_SIZE); |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
173 if (memcmp (scratch, plaintext_6, sizeof (plaintext_6))) |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
174 return 1; |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
175 |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
176 return 0; |
31fd570c5ac0
Add arctwo, arctwo-tests, gc-arctwo, gc-arctwo-tests modules.
Simon Josefsson <simon@josefsson.org>
parents:
diff
changeset
|
177 } |