3 Copyright (C) 2004 Simon Josefsson
4 Copyright (C) 2004 Niels Möller
6 This file is part of GNU Nettle.
8 GNU Nettle is free software: you can redistribute it and/or
9 modify it under the terms of either:
11 * the GNU Lesser General Public License as published by the Free
12 Software Foundation; either version 3 of the License, or (at your
13 option) any later version.
17 * the GNU General Public License as published by the Free
18 Software Foundation; either version 2 of the License, or (at your
19 option) any later version.
21 or both in parallel, as here.
23 GNU Nettle is distributed in the hope that it will be useful,
24 but WITHOUT ANY WARRANTY; without even the implied warranty of
25 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26 General Public License for more details.
28 You should have received copies of the GNU General Public License and
29 the GNU Lesser General Public License along with this program. If
30 not, see http://www.gnu.org/licenses/.
33 #include "testutils.h"
36 /* For tests with obscure values of ebk. */
38 test_arctwo(unsigned ekb,
39 const struct tstring *key,
40 const struct tstring *cleartext,
41 const struct tstring *ciphertext)
43 struct arctwo_ctx ctx;
47 ASSERT (cleartext->length == ciphertext->length);
48 length = cleartext->length;
50 data = xalloc(length);
52 arctwo_set_key_ekb(&ctx, key->length, key->data, ekb);
53 arctwo_encrypt(&ctx, length, data, cleartext->data);
55 ASSERT(MEMEQ(length, data, ciphertext->data));
57 arctwo_decrypt(&ctx, length, data, data);
59 ASSERT(MEMEQ(length, data, cleartext->data));
67 /* Test vectors from Peter Gutmann's paper. */
68 test_cipher(&nettle_arctwo_gutmann128,
69 SHEX("00000000 00000000 00000000 00000000"),
70 SHEX("00000000 00000000"),
71 SHEX("1c198a83 8df028b7"));
73 test_cipher(&nettle_arctwo_gutmann128,
74 SHEX("00010203 04050607 08090a0b 0c0d0e0f"),
75 SHEX("00000000 00000000"),
76 SHEX("50dc0162 bd757f31"));
78 /* This one was checked against libmcrypt's RFC2268. */
79 test_cipher(&nettle_arctwo_gutmann128,
80 SHEX("30000000 00000000 00000000 00000000"),
81 SHEX("10000000 00000000"),
82 SHEX("8fd10389 336bf95e"));
84 /* Test vectors from RFC 2268. */
85 test_cipher(&nettle_arctwo64,
86 SHEX("ffffffff ffffffff"),
87 SHEX("ffffffff ffffffff"),
88 SHEX("278b27e4 2e2f0d49"));
90 test_cipher(&nettle_arctwo64,
91 SHEX("30000000 00000000"),
92 SHEX("10000000 00000001"),
93 SHEX("30649edf 9be7d2c2"));
95 test_cipher(&nettle_arctwo128,
96 SHEX("88bca90e 90875a7f 0f79c384 627bafb2"),
97 SHEX("00000000 00000000"),
98 SHEX("2269552a b0f85ca6"));
100 /* More obscure tests from RFC 2286 */
102 SHEX("00000000 00000000"),
103 SHEX("00000000 00000000"),
104 SHEX("ebb773f9 93278eff"));
108 SHEX("00000000 00000000"),
109 SHEX("61a8a244 adacccf0"));
112 SHEX("88bca90e 90875a"),
113 SHEX("00000000 00000000"),
114 SHEX("6ccf4308 974c267f"));
117 SHEX("88bca90e 90875a7f 0f79c384 627bafb2"),
118 SHEX("00000000 00000000"),
119 SHEX("1a807d27 2bbe5db1"));
122 SHEX("88bca90e 90875a7f 0f79c384 627bafb2"
123 "16f80a6f 85920584 c42fceb0 be255daf 1e"),
124 SHEX("00000000 00000000"),
125 SHEX("5b78d3a4 3dfff1f1"));