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., 59 Temple Place - Suite 330, Boston,
22 #include "testutils.h"
25 /* For tests with obscure values of ebk. */
27 test_arctwo(unsigned ekb,
31 const uint8_t *cleartext,
32 const uint8_t *ciphertext)
34 struct arctwo_ctx ctx;
35 uint8_t *data = xalloc(length);
37 arctwo_set_key_ekb(&ctx, key_length, key, ekb);
38 arctwo_encrypt(&ctx, length, data, cleartext);
40 if (!MEMEQ(length, data, ciphertext))
43 arctwo_decrypt(&ctx, length, data, data);
45 if (!MEMEQ(length, data, cleartext))
54 /* Test vectors from Peter Gutmann's paper. */
55 test_cipher(&nettle_arctwo_gutmann128,
56 HL("00000000 00000000 00000000 00000000"),
57 HL("00000000 00000000"),
58 H ("1c198a83 8df028b7"));
60 test_cipher(&nettle_arctwo_gutmann128,
61 HL("00010203 04050607 08090a0b 0c0d0e0f"),
62 HL("00000000 00000000"),
63 H ("50dc0162 bd757f31"));
65 /* This one was checked against libmcrypt's RFC2268. */
66 test_cipher(&nettle_arctwo_gutmann128,
67 HL("30000000 00000000 00000000 00000000"),
68 HL("10000000 00000000"),
69 H ("8fd10389 336bf95e"));
71 /* Test vectors from RFC 2268. */
72 test_cipher(&nettle_arctwo64,
73 HL("ffffffff ffffffff"),
74 HL("ffffffff ffffffff"),
75 H ("278b27e4 2e2f0d49"));
77 test_cipher(&nettle_arctwo64,
78 HL("30000000 00000000"),
79 HL("10000000 00000001"),
80 H ("30649edf 9be7d2c2"));
82 test_cipher(&nettle_arctwo128,
83 HL("88bca90e 90875a7f 0f79c384 627bafb2"),
84 HL("00000000 00000000"),
85 H ("2269552a b0f85ca6"));
87 /* More obscure tests from RFC 2286 */
89 HL("00000000 00000000"),
90 HL("00000000 00000000"),
91 H ("ebb773f9 93278eff"));
95 HL("00000000 00000000"),
96 H ("61a8a244 adacccf0"));
99 HL("88bca90e 90875a"),
100 HL("00000000 00000000"),
101 H ("6ccf4308 974c267f"));
104 HL("88bca90e 90875a7f 0f79c384 627bafb2"),
105 HL("00000000 00000000"),
106 H ("1a807d27 2bbe5db1"));
109 HL("88bca90e 90875a7f 0f79c384 627bafb2"
110 "16f80a6f 85920584 c42fceb0 be255daf 1e"),
111 HL("00000000 00000000"),
112 H ("5b78d3a4 3dfff1f1"));