1 /* nettle, low-level cryptographics library
3 * Copyright (C) 2004 Simon Josefsson
4 * Copyright (C) 2004 Niels Möller
6 * The nettle library is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or (at your
9 * option) any later version.
11 * The nettle library is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 * License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with the nettle library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22 #include "testutils.h"
25 /* For tests with obscure values of ebk. */
27 test_arctwo(unsigned ekb,
28 const struct tstring *key,
29 const struct tstring *cleartext,
30 const struct tstring *ciphertext)
32 struct arctwo_ctx ctx;
36 ASSERT (cleartext->length == ciphertext->length);
37 length = cleartext->length;
39 data = xalloc(length);
41 arctwo_set_key_ekb(&ctx, key->length, key->data, ekb);
42 arctwo_encrypt(&ctx, length, data, cleartext->data);
44 ASSERT(MEMEQ(length, data, ciphertext->data));
46 arctwo_decrypt(&ctx, length, data, data);
48 ASSERT(MEMEQ(length, data, cleartext->data));
56 /* Test vectors from Peter Gutmann's paper. */
57 test_cipher(&nettle_arctwo_gutmann128,
58 SHEX("00000000 00000000 00000000 00000000"),
59 SHEX("00000000 00000000"),
60 SHEX("1c198a83 8df028b7"));
62 test_cipher(&nettle_arctwo_gutmann128,
63 SHEX("00010203 04050607 08090a0b 0c0d0e0f"),
64 SHEX("00000000 00000000"),
65 SHEX("50dc0162 bd757f31"));
67 /* This one was checked against libmcrypt's RFC2268. */
68 test_cipher(&nettle_arctwo_gutmann128,
69 SHEX("30000000 00000000 00000000 00000000"),
70 SHEX("10000000 00000000"),
71 SHEX("8fd10389 336bf95e"));
73 /* Test vectors from RFC 2268. */
74 test_cipher(&nettle_arctwo64,
75 SHEX("ffffffff ffffffff"),
76 SHEX("ffffffff ffffffff"),
77 SHEX("278b27e4 2e2f0d49"));
79 test_cipher(&nettle_arctwo64,
80 SHEX("30000000 00000000"),
81 SHEX("10000000 00000001"),
82 SHEX("30649edf 9be7d2c2"));
84 test_cipher(&nettle_arctwo128,
85 SHEX("88bca90e 90875a7f 0f79c384 627bafb2"),
86 SHEX("00000000 00000000"),
87 SHEX("2269552a b0f85ca6"));
89 /* More obscure tests from RFC 2286 */
91 SHEX("00000000 00000000"),
92 SHEX("00000000 00000000"),
93 SHEX("ebb773f9 93278eff"));
97 SHEX("00000000 00000000"),
98 SHEX("61a8a244 adacccf0"));
101 SHEX("88bca90e 90875a"),
102 SHEX("00000000 00000000"),
103 SHEX("6ccf4308 974c267f"));
106 SHEX("88bca90e 90875a7f 0f79c384 627bafb2"),
107 SHEX("00000000 00000000"),
108 SHEX("1a807d27 2bbe5db1"));
111 SHEX("88bca90e 90875a7f 0f79c384 627bafb2"
112 "16f80a6f 85920584 c42fceb0 be255daf 1e"),
113 SHEX("00000000 00000000"),
114 SHEX("5b78d3a4 3dfff1f1"));