Commit 75288e44 authored by Niels Möller's avatar Niels Möller

Testsuite overhaul, including proper deallocation of storage.

parent 728a20ee
2012-09-16 Niels Möller <nisse@lysator.liu.se> 2012-09-16 Niels Möller <nisse@lysator.liu.se>
* testsuite/: Overhaul of testsuite, affecting almost all files.
+ Use struct tstring for allocated strings, and deallocate before
exit.
+ Changed most test functions to take struct tstring as arguments.
+ Made all test_main return on success.
* testsuite/testutils.h (struct tstring): New struct type.
(H2, HL, MEMEQH, SUCCESS): Deleted macros.
(SHEX, SDATA): New macros.
(H): Redefined to track storage.
* testsuite/testutils.c (tstring_alloc): New function.
(tstring_clear): New function.
(tstring_data): New function.
(tstring_hex): New function.
(tstring_print_hex): New function.
(decode_hex_length): Made static.
(decode_hex): Made static. No return value, abort on error.
(main): Expect test_main to return, and call tstring_clear before
exit.
(test_dsa_key): Added missing mpz_clear.
(test_mac): Deleted unused function.
* testsuite/rsa2sexp-test.c (test_main): Added missing
nettle_buffer_clear.
* testsuite/yarrow-test.c (open_file): Don't leak filename.
(test_main): fclose input file properly.
* testsuite/sexp-format-test.c (test_main): Added missing calls to
nettle_buffer_clear and mpz_clear.
* testsuite/serpent-test.c (tstring_hex_reverse): New function,
replacing...
(decode_hex_reverse): ... deleted function.
(RHEX): New macro, replacing...
(RH, RHL): ... deleted macros.
* testsuite/rsa2sexp-test.c (test_main): Added missing
nettle_buffer_clear.
* testsuite/random-prime-test.c (test_main): Added missing
mpz_clear.
* realloc.c (nettle_realloc): Only call libc realloc if length > * realloc.c (nettle_realloc): Only call libc realloc if length >
0, otherwise call free. Fixes a small memory leak. 0, otherwise call free. Fixes a small memory leak.
(nettle_xrealloc): Likewise. (nettle_xrealloc): Likewise.
......
...@@ -2,25 +2,28 @@ ...@@ -2,25 +2,28 @@
#include "aes.h" #include "aes.h"
static void static void
test_invert(unsigned key_length, const uint8_t *key, test_invert(const struct tstring *key,
unsigned length, const uint8_t *cleartext, const struct tstring *cleartext,
const uint8_t *ciphertext) const struct tstring *ciphertext)
{ {
struct aes_ctx encrypt; struct aes_ctx encrypt;
struct aes_ctx decrypt; struct aes_ctx decrypt;
uint8_t *data = xalloc(length); uint8_t *data = xalloc(cleartext->length);
unsigned length;
ASSERT (cleartext->length == ciphertext->length);
length = cleartext->length;
aes_set_encrypt_key (&encrypt, key_length, key); aes_set_encrypt_key (&encrypt, key->length, key->data);
aes_encrypt (&encrypt, length, data, cleartext); aes_encrypt (&encrypt, length, data, cleartext->data);
if (!MEMEQ(length, data, ciphertext)) if (!MEMEQ(length, data, ciphertext->data))
{ {
fprintf(stderr, "test_invert: Encrypt failed:\nInput:"); fprintf(stderr, "test_invert: Encrypt failed:\nInput:");
print_hex(length, cleartext); tstring_print_hex(cleartext);
fprintf(stderr, "\nOutput: "); fprintf(stderr, "\nOutput: ");
print_hex(length, data); print_hex(length, data);
fprintf(stderr, "\nExpected:"); fprintf(stderr, "\nExpected:");
print_hex(length, ciphertext); tstring_print_hex(ciphertext);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
FAIL(); FAIL();
} }
...@@ -28,72 +31,72 @@ test_invert(unsigned key_length, const uint8_t *key, ...@@ -28,72 +31,72 @@ test_invert(unsigned key_length, const uint8_t *key,
aes_invert_key (&decrypt, &encrypt); aes_invert_key (&decrypt, &encrypt);
aes_decrypt (&decrypt, length, data, data); aes_decrypt (&decrypt, length, data, data);
if (!MEMEQ(length, data, cleartext)) if (!MEMEQ(length, data, cleartext->data))
{ {
fprintf(stderr, "test_invert: Decrypt failed:\nInput:"); fprintf(stderr, "test_invert: Decrypt failed:\nInput:");
print_hex(length, ciphertext); tstring_print_hex(ciphertext);
fprintf(stderr, "\nOutput: "); fprintf(stderr, "\nOutput: ");
print_hex(length, data); print_hex(length, data);
fprintf(stderr, "\nExpected:"); fprintf(stderr, "\nExpected:");
print_hex(length, cleartext); tstring_print_hex(cleartext);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
FAIL(); FAIL();
} }
free (data); free (data);
} }
int void
test_main(void) test_main(void)
{ {
/* 128 bit keys */ /* 128 bit keys */
test_cipher(&nettle_aes128, test_cipher(&nettle_aes128,
HL("0001020305060708 0A0B0C0D0F101112"), SHEX("0001020305060708 0A0B0C0D0F101112"),
HL("506812A45F08C889 B97F5980038B8359"), SHEX("506812A45F08C889 B97F5980038B8359"),
H("D8F532538289EF7D 06B506A4FD5BE9C9")); SHEX("D8F532538289EF7D 06B506A4FD5BE9C9"));
test_cipher(&nettle_aes128, test_cipher(&nettle_aes128,
HL("14151617191A1B1C 1E1F202123242526"), SHEX("14151617191A1B1C 1E1F202123242526"),
HL("5C6D71CA30DE8B8B 00549984D2EC7D4B"), SHEX("5C6D71CA30DE8B8B 00549984D2EC7D4B"),
H("59AB30F4D4EE6E4F F9907EF65B1FB68C")); SHEX("59AB30F4D4EE6E4F F9907EF65B1FB68C"));
test_cipher(&nettle_aes128, test_cipher(&nettle_aes128,
HL("28292A2B2D2E2F30 323334353738393A"), SHEX("28292A2B2D2E2F30 323334353738393A"),
HL("53F3F4C64F8616E4 E7C56199F48F21F6"), SHEX("53F3F4C64F8616E4 E7C56199F48F21F6"),
H("BF1ED2FCB2AF3FD4 1443B56D85025CB1")); SHEX("BF1ED2FCB2AF3FD4 1443B56D85025CB1"));
test_cipher(&nettle_aes128, test_cipher(&nettle_aes128,
HL("A0A1A2A3A5A6A7A8 AAABACADAFB0B1B2"), SHEX("A0A1A2A3A5A6A7A8 AAABACADAFB0B1B2"),
HL("F5F4F7F684878689 A6A7A0A1D2CDCCCF"), SHEX("F5F4F7F684878689 A6A7A0A1D2CDCCCF"),
H("CE52AF650D088CA5 59425223F4D32694")); SHEX("CE52AF650D088CA5 59425223F4D32694"));
/* 192 bit keys */ /* 192 bit keys */
test_cipher(&nettle_aes192, test_cipher(&nettle_aes192,
HL("0001020305060708 0A0B0C0D0F101112" SHEX("0001020305060708 0A0B0C0D0F101112"
"14151617191A1B1C"), "14151617191A1B1C"),
HL("2D33EEF2C0430A8A 9EBF45E809C40BB6"), SHEX("2D33EEF2C0430A8A 9EBF45E809C40BB6"),
H("DFF4945E0336DF4C 1C56BC700EFF837F")); SHEX("DFF4945E0336DF4C 1C56BC700EFF837F"));
/* 256 bit keys */ /* 256 bit keys */
test_cipher(&nettle_aes256, test_cipher(&nettle_aes256,
HL("0001020305060708 0A0B0C0D0F101112" SHEX("0001020305060708 0A0B0C0D0F101112"
"14151617191A1B1C 1E1F202123242526"), "14151617191A1B1C 1E1F202123242526"),
HL("834EADFCCAC7E1B30664B1ABA44815AB"), SHEX("834EADFCCAC7E1B30664B1ABA44815AB"),
H("1946DABF6A03A2A2 C3D0B05080AED6FC")); SHEX("1946DABF6A03A2A2 C3D0B05080AED6FC"));
/* This test case has been problematic with the CBC test case */ /* This test case has been problematic with the CBC test case */
test_cipher(&nettle_aes256, test_cipher(&nettle_aes256,
HL("8d ae 93 ff fc 78 c9 44" SHEX("8d ae 93 ff fc 78 c9 44"
"2a bd 0c 1e 68 bc a6 c7" "2a bd 0c 1e 68 bc a6 c7"
"05 c7 84 e3 5a a9 11 8b" "05 c7 84 e3 5a a9 11 8b"
"d3 16 aa 54 9b 44 08 9e"), "d3 16 aa 54 9b 44 08 9e"),
HL("a5 ce 55 d4 21 15 a1 c6 4a a4 0c b2 ca a6 d1 37"), SHEX("a5 ce 55 d4 21 15 a1 c6 4a a4 0c b2 ca a6 d1 37"),
/* In the cbc test, I once got the bad value /* In the cbc test, I once got the bad value
* "b2 a0 6c d2 2f df 7d 2c 26 d2 42 88 8f 20 74 a2" */ * "b2 a0 6c d2 2f df 7d 2c 26 d2 42 88 8f 20 74 a2" */
H("1f 94 fc 85 f2 36 21 06" SHEX("1f 94 fc 85 f2 36 21 06"
"4a ea e3 c9 cc 38 01 0e")); "4a ea e3 c9 cc 38 01 0e"));
/* From draft NIST spec on AES modes. /* From draft NIST spec on AES modes.
* *
...@@ -102,56 +105,54 @@ test_main(void) ...@@ -102,56 +105,54 @@ test_main(void)
*/ */
test_cipher(&nettle_aes128, test_cipher(&nettle_aes128,
HL("2b7e151628aed2a6abf7158809cf4f3c"), SHEX("2b7e151628aed2a6abf7158809cf4f3c"),
HL("6bc1bee22e409f96e93d7e117393172a" SHEX("6bc1bee22e409f96e93d7e117393172a"
"ae2d8a571e03ac9c9eb76fac45af8e51" "ae2d8a571e03ac9c9eb76fac45af8e51"
"30c81c46a35ce411e5fbc1191a0a52ef" "30c81c46a35ce411e5fbc1191a0a52ef"
"f69f2445df4f9b17ad2b417be66c3710"), "f69f2445df4f9b17ad2b417be66c3710"),
H("3ad77bb40d7a3660a89ecaf32466ef97" SHEX("3ad77bb40d7a3660a89ecaf32466ef97"
"f5d3d58503b9699de785895a96fdbaaf" "f5d3d58503b9699de785895a96fdbaaf"
"43b1cd7f598ece23881b00e3ed030688" "43b1cd7f598ece23881b00e3ed030688"
"7b0c785e27e8ad3f8223207104725dd4")); "7b0c785e27e8ad3f8223207104725dd4"));
/* F.1.3 ECB-AES192-Encrypt */ /* F.1.3 ECB-AES192-Encrypt */
test_cipher(&nettle_aes192, test_cipher(&nettle_aes192,
HL("8e73b0f7da0e6452c810f32b809079e5 62f8ead2522c6b7b"), SHEX("8e73b0f7da0e6452c810f32b809079e5 62f8ead2522c6b7b"),
HL("6bc1bee22e409f96e93d7e117393172a" SHEX("6bc1bee22e409f96e93d7e117393172a"
"ae2d8a571e03ac9c9eb76fac45af8e51" "ae2d8a571e03ac9c9eb76fac45af8e51"
"30c81c46a35ce411e5fbc1191a0a52ef" "30c81c46a35ce411e5fbc1191a0a52ef"
"f69f2445df4f9b17ad2b417be66c3710"), "f69f2445df4f9b17ad2b417be66c3710"),
H("bd334f1d6e45f25ff712a214571fa5cc" SHEX("bd334f1d6e45f25ff712a214571fa5cc"
"974104846d0ad3ad7734ecb3ecee4eef" "974104846d0ad3ad7734ecb3ecee4eef"
"ef7afd2270e2e60adce0ba2face6444e" "ef7afd2270e2e60adce0ba2face6444e"
"9a4b41ba738d6c72fb16691603c18e0e")); "9a4b41ba738d6c72fb16691603c18e0e"));
/* F.1.5 ECB-AES256-Encrypt */ /* F.1.5 ECB-AES256-Encrypt */
test_cipher(&nettle_aes256, test_cipher(&nettle_aes256,
HL("603deb1015ca71be2b73aef0857d7781" SHEX("603deb1015ca71be2b73aef0857d7781"
"1f352c073b6108d72d9810a30914dff4"), "1f352c073b6108d72d9810a30914dff4"),
HL("6bc1bee22e409f96e93d7e117393172a" SHEX("6bc1bee22e409f96e93d7e117393172a"
"ae2d8a571e03ac9c9eb76fac45af8e51" "ae2d8a571e03ac9c9eb76fac45af8e51"
"30c81c46a35ce411e5fbc1191a0a52ef" "30c81c46a35ce411e5fbc1191a0a52ef"
"f69f2445df4f9b17ad2b417be66c3710"), "f69f2445df4f9b17ad2b417be66c3710"),
H("f3eed1bdb5d2a03c064b5a7e3db181f8" SHEX("f3eed1bdb5d2a03c064b5a7e3db181f8"
"591ccb10d410ed26dc5ba74a31362870" "591ccb10d410ed26dc5ba74a31362870"
"b6ed21b99ca6f4f9f153e7b1beafed1d" "b6ed21b99ca6f4f9f153e7b1beafed1d"
"23304b7a39f9f3ff067d8d8f9e24ecc7")); "23304b7a39f9f3ff067d8d8f9e24ecc7"));
/* Test aes_invert_key with src != dst */ /* Test aes_invert_key with src != dst */
test_invert(HL("0001020305060708 0A0B0C0D0F101112"), test_invert(SHEX("0001020305060708 0A0B0C0D0F101112"),
HL("506812A45F08C889 B97F5980038B8359"), SHEX("506812A45F08C889 B97F5980038B8359"),
H("D8F532538289EF7D 06B506A4FD5BE9C9")); SHEX("D8F532538289EF7D 06B506A4FD5BE9C9"));
test_invert(HL("0001020305060708 0A0B0C0D0F101112" test_invert(SHEX("0001020305060708 0A0B0C0D0F101112"
"14151617191A1B1C"), "14151617191A1B1C"),
HL("2D33EEF2C0430A8A 9EBF45E809C40BB6"), SHEX("2D33EEF2C0430A8A 9EBF45E809C40BB6"),
H("DFF4945E0336DF4C 1C56BC700EFF837F")); SHEX("DFF4945E0336DF4C 1C56BC700EFF837F"));
test_invert(HL("0001020305060708 0A0B0C0D0F101112" test_invert(SHEX("0001020305060708 0A0B0C0D0F101112"
"14151617191A1B1C 1E1F202123242526"), "14151617191A1B1C 1E1F202123242526"),
HL("834EADFCCAC7E1B30664B1ABA44815AB"), SHEX("834EADFCCAC7E1B30664B1ABA44815AB"),
H("1946DABF6A03A2A2 C3D0B05080AED6FC")); SHEX("1946DABF6A03A2A2 C3D0B05080AED6FC"));
SUCCESS();
} }
/* Internal state for the first test case: /* Internal state for the first test case:
......
#include "testutils.h" #include "testutils.h"
#include "arcfour.h" #include "arcfour.h"
int void
test_main(void) test_main(void)
{ {
test_cipher_stream(&nettle_arcfour128, test_cipher_stream(&nettle_arcfour128,
HL("01234567 89ABCDEF 00000000 00000000"), SHEX("01234567 89ABCDEF 00000000 00000000"),
HL("01234567 89ABCDEF"), SHEX("01234567 89ABCDEF"),
H("69723659 1B5242B1")); SHEX("69723659 1B5242B1"));
/* More data. This ensures that we get some collisions between the S /* More data. This ensures that we get some collisions between the S
accesses at index i,j and the access at si + sj. I.e. the cases accesses at index i,j and the access at si + sj. I.e. the cases
where the ordering of loads and stores matter. */ where the ordering of loads and stores matter. */
test_cipher_stream(&nettle_arcfour128, test_cipher_stream(&nettle_arcfour128,
HL("aaaaaaaa bbbbbbbb cccccccc dddddddd"), SHEX("aaaaaaaa bbbbbbbb cccccccc dddddddd"),
HL("00000000 00000000 00000000 00000000" SHEX("00000000 00000000 00000000 00000000"
"00000000 00000000 00000000 00000000" "00000000 00000000 00000000 00000000"
"00000000 00000000 00000000 00000000" "00000000 00000000 00000000 00000000"
"00000000 00000000 00000000 00000000" "00000000 00000000 00000000 00000000"
"00000000 00000000 00000000 00000000" "00000000 00000000 00000000 00000000"
"00000000 00000000 00000000 00000000" "00000000 00000000 00000000 00000000"
"00000000 00000000 00000000 00000000" "00000000 00000000 00000000 00000000"
"00000000 00000000 00000000 00000000" "00000000 00000000 00000000 00000000"
"00000000 00000000 00000000 00000000" "00000000 00000000 00000000 00000000"
"00000000 00000000 00000000 00000000" "00000000 00000000 00000000 00000000"
"00000000 00000000 00000000 00000000" "00000000 00000000 00000000 00000000"
"00000000 00000000 00000000 00000000" "00000000 00000000 00000000 00000000"
"00000000 00000000 00000000 00000000" "00000000 00000000 00000000 00000000"
"00000000 00000000 00000000 00000000" "00000000 00000000 00000000 00000000"
"00000000 00000000 00000000 00000000" "00000000 00000000 00000000 00000000"
"00000000 00000000 00000000 00000000" "00000000 00000000 00000000 00000000"
"00000000 00000000 00000000 00000000" "00000000 00000000 00000000 00000000"
"00000000 00000000 00000000 00000000" "00000000 00000000 00000000 00000000"
"00000000 00000000 00000000 00000000" "00000000 00000000 00000000 00000000"
"00000000 00000000 00000000 00000000" "00000000 00000000 00000000 00000000"
"00000000 00000000 00000000 00000000" "00000000 00000000 00000000 00000000"
"00000000 00000000 00000000 00000000" "00000000 00000000 00000000 00000000"
"00000000 00000000 00000000 00000000" "00000000 00000000 00000000 00000000"
"00000000 00000000 00000000 00000000" "00000000 00000000 00000000 00000000"
"00000000 00000000 00000000 00000000" "00000000 00000000 00000000 00000000"
"00000000 00000000 00000000 00000000" "00000000 00000000 00000000 00000000"
"00000000 00000000 00000000 00000000" "00000000 00000000 00000000 00000000"
"00000000 00000000 00000000 00000000" "00000000 00000000 00000000 00000000"
"00000000 00000000 00000000 00000000" "00000000 00000000 00000000 00000000"
"00000000 00000000 00000000 00000000" "00000000 00000000 00000000 00000000"
"00000000 00000000 00000000 00000000" "00000000 00000000 00000000 00000000"
"00000000 00000000 00000000 00000000"), "00000000 00000000 00000000 00000000"),
H("a2b35dc7 bf95ae1e 1c432d15 f4fb8c1c" SHEX("a2b35dc7 bf95ae1e 1c432d15 f4fb8c1c"
"f264e1d0 bd090831 6caa7d17 5401ae67" "f264e1d0 bd090831 6caa7d17 5401ae67"
"3cfbd140 fd3dee42 1012d674 2fb69fa3" "3cfbd140 fd3dee42 1012d674 2fb69fa3"
"6522631e bb3d4703 535de1ce 4a81ddce" "6522631e bb3d4703 535de1ce 4a81ddce"
"5780cfe0 b5fc9fae ebe14c96 26451bd9" "5780cfe0 b5fc9fae ebe14c96 26451bd9"
"992f2204 119cbe37 cbdc453c 7afa08c7" "992f2204 119cbe37 cbdc453c 7afa08c7"
"1380ccf8 48f81e53 a535cdfb 96c64faa" "1380ccf8 48f81e53 a535cdfb 96c64faa"
"c3f759d0 fa1ff920 008d95cf 39d52324" "c3f759d0 fa1ff920 008d95cf 39d52324"
"d0aac3f9 749b22e2 6a065145 06fb249d" "d0aac3f9 749b22e2 6a065145 06fb249d"
"ffb8e05e cb0381fe 5346a04a 63dac61c" "ffb8e05e cb0381fe 5346a04a 63dac61c"
"10b6683e 3ab427de d4c6bc60 6366545e" "10b6683e 3ab427de d4c6bc60 6366545e"
"77d0e121 96037717 a745d49e e72a70aa" "77d0e121 96037717 a745d49e e72a70aa"
"a50a612d 879b0580 fd4a89ae 3ee49871" "a50a612d 879b0580 fd4a89ae 3ee49871"
"2cf6c98d a62dfbc7 d7b2d901 2c3aaf27" "2cf6c98d a62dfbc7 d7b2d901 2c3aaf27"
"42b7e089 ef2466ac 450b440c 138daa1a" "42b7e089 ef2466ac 450b440c 138daa1a"
"cf9ebef6 f66a7a64 2677b213 06640130" "cf9ebef6 f66a7a64 2677b213 06640130"
"de6651df 0065180d 4db366ba 9c377712" "de6651df 0065180d 4db366ba 9c377712"
"53d21cac 82ed72a4 c6c4d81e 4375fea3" "53d21cac 82ed72a4 c6c4d81e 4375fea3"
"1f935909 95322c83 13c64d8e 829c93a6" "1f935909 95322c83 13c64d8e 829c93a6"
"d540a1b3 20f41541 96800888 1a7afc9b" "d540a1b3 20f41541 96800888 1a7afc9b"
"e39e89fc 3ac78be5 cdbbf774 33c36863" "e39e89fc 3ac78be5 cdbbf774 33c36863"
"da2a3b1b d06e54a9 aa4b7edd 70b34941" "da2a3b1b d06e54a9 aa4b7edd 70b34941"
"b886f7db f36c3def f9fc4c80 7ce55ea5" "b886f7db f36c3def f9fc4c80 7ce55ea5"
"98a7257b f68a9e1d caf4bfd6 43bd9853" "98a7257b f68a9e1d caf4bfd6 43bd9853"
"c966629d 54e34221 6e140780 d48c69bb" "c966629d 54e34221 6e140780 d48c69bb"
"5e77e886 86f2ebcb 807732d5 d29bc384" "5e77e886 86f2ebcb 807732d5 d29bc384"
"a4ca1c31 c7c1b5b9 85dbfcf1 8d845905" "a4ca1c31 c7c1b5b9 85dbfcf1 8d845905"
"a0ff487a b4a3f252 a75caebf 857ba48b" "a0ff487a b4a3f252 a75caebf 857ba48b"
"613e3067 92cada3e 0e07f599 2f4794f3" "613e3067 92cada3e 0e07f599 2f4794f3"
"af01f15a 491732fb 22aa09a3 d2e1e408" "af01f15a 491732fb 22aa09a3 d2e1e408"
"fe94bdb4 993c68b1 1bb79eb1 bb7ec446" "fe94bdb4 993c68b1 1bb79eb1 bb7ec446"
"760ef7bf 2caa8713 479760e5 a6e143cd")); "760ef7bf 2caa8713 479760e5 a6e143cd"));
SUCCESS();
} }
...@@ -25,91 +25,91 @@ ...@@ -25,91 +25,91 @@
/* For tests with obscure values of ebk. */ /* For tests with obscure values of ebk. */
static void static void
test_arctwo(unsigned ekb, test_arctwo(unsigned ekb,
unsigned key_length, const struct tstring *key,
const uint8_t *key, const struct tstring *cleartext,
unsigned length, const struct tstring *ciphertext)
const uint8_t *cleartext,
const uint8_t *ciphertext)
{ {
struct arctwo_ctx ctx; struct arctwo_ctx ctx;
uint8_t *data = xalloc(length); uint8_t *data;
unsigned length;
arctwo_set_key_ekb(&ctx, key_length, key, ekb); ASSERT (cleartext->length == ciphertext->length);
arctwo_encrypt(&ctx, length, data, cleartext); length = cleartext->length;
data = xalloc(length);
if (!MEMEQ(length, data, ciphertext)) arctwo_set_key_ekb(&ctx, key->length, key->data, ekb);
FAIL(); arctwo_encrypt(&ctx, length, data, cleartext->data);
ASSERT(MEMEQ(length, data, ciphertext->data));
arctwo_decrypt(&ctx, length, data, data); arctwo_decrypt(&ctx, length, data, data);
if (!MEMEQ(length, data, cleartext)) ASSERT(MEMEQ(length, data, cleartext->data));
FAIL();
free(data); free(data);
} }
int void
test_main(void) test_main(void)
{ {
/* Test vectors from Peter Gutmann's paper. */ /* Test vectors from Peter Gutmann's paper. */
test_cipher(&nettle_arctwo_gutmann128, test_cipher(&nettle_arctwo_gutmann128,
HL("00000000 00000000 00000000 00000000"), SHEX("00000000 00000000 00000000 00000000"),
HL("00000000 00000000"), SHEX("00000000 00000000"),
H ("1c198a83 8df028b7")); SHEX("1c198a83 8df028b7"));
test_cipher(&nettle_arctwo_gutmann128, test_cipher(&nettle_arctwo_gutmann128,
HL("00010203 04050607 08090a0b 0c0d0e0f"), SHEX("00010203 04050607 08090a0b 0c0d0e0f"),
HL("00000000 00000000"), SHEX("00000000 00000000"),
H ("50dc0162 bd757f31")); SHEX("50dc0162 bd757f31"));
/* This one was checked against libmcrypt's RFC2268. */ /* This one was checked against libmcrypt's RFC2268. */
test_cipher(&nettle_arctwo_gutmann128, test_cipher(&nettle_arctwo_gutmann128,
HL("30000000 00000000 00000000 00000000"), SHEX("30000000 00000000 00000000 00000000"),
HL("10000000 00000000"), SHEX("10000000 00000000"),
H ("8fd10389 336bf95e")); SHEX("8fd10389 336bf95e"));
/* Test vectors from RFC 2268. */ /* Test vectors from RFC 2268. */
test_cipher(&nettle_arctwo64, test_cipher(&nettle_arctwo64,
HL("ffffffff ffffffff"), SHEX("ffffffff ffffffff"),
HL("ffffffff ffffffff"), SHEX("ffffffff ffffffff"),
H ("278b27e4 2e2f0d49")); SHEX("278b27e4 2e2f0d49"));
test_cipher(&nettle_arctwo64, test_cipher(&nettle_arctwo64,
HL("30000000 00000000"), SHEX("30000000 00000000"),
HL("10000000 00000001"), SHEX("10000000 00000001"),
H ("30649edf 9be7d2c2")); SHEX("30649edf 9be7d2c2"));
test_cipher(&nettle_arctwo128, test_cipher(&nettle_arctwo128,