From: Collin Funk Date: Sun, 31 Aug 2025 19:51:14 +0000 (-0700) Subject: crypto/sha3-buffer: Add tests. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ec500f501da4eab0eecb862ad734d9276c600654;p=thirdparty%2Fgnulib.git crypto/sha3-buffer: Add tests. * modules/crypto/sha3-buffer-tests: New file. * tests/test-sha3-224-buffer.c: Likewise. * tests/test-sha3-256-buffer.c: Likewise. * tests/test-sha3-384-buffer.c: Likewise. * tests/test-sha3-512-buffer.c: Likewise. * tests/bench-sha3-224.c: Likewise. * tests/bench-sha3-256.c: Likewise. * tests/bench-sha3-384.c: Likewise. * tests/bench-sha3-512.c: Likewise. --- diff --git a/ChangeLog b/ChangeLog index 24093d2d63..924d67e135 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2025-08-31 Collin Funk + crypto/sha3-buffer: Add tests. + * modules/crypto/sha3-buffer-tests: New file. + * tests/test-sha3-224-buffer.c: Likewise. + * tests/test-sha3-256-buffer.c: Likewise. + * tests/test-sha3-384-buffer.c: Likewise. + * tests/test-sha3-512-buffer.c: Likewise. + * tests/bench-sha3-224.c: Likewise. + * tests/bench-sha3-256.c: Likewise. + * tests/bench-sha3-384.c: Likewise. + * tests/bench-sha3-512.c: Likewise. + crypto/sha3-buffer: New module. * lib/u64.h (u64getlo, u64not): New functions. * lib/sha3.c: New file, based on lib/sha512.c. diff --git a/modules/crypto/sha3-buffer-tests b/modules/crypto/sha3-buffer-tests new file mode 100644 index 0000000000..0f9e57318a --- /dev/null +++ b/modules/crypto/sha3-buffer-tests @@ -0,0 +1,30 @@ +Files: +tests/test-sha3-224-buffer.c +tests/test-sha3-256-buffer.c +tests/test-sha3-384-buffer.c +tests/test-sha3-512-buffer.c +tests/bench-sha3-224.c +tests/bench-sha3-256.c +tests/bench-sha3-384.c +tests/bench-sha3-512.c +tests/bench-digest.h +tests/bench.h + +Depends-on: +c99 +getrusage +gettimeofday + +configure.ac: + +Makefile.am: +TESTS += test-sha3-224-buffer test-sha3-256-buffer +TESTS += test-sha3-384-buffer test-sha3-512-buffer +check_PROGRAMS += test-sha3-224-buffer test-sha3-256-buffer +check_PROGRAMS += test-sha3-384-buffer test-sha3-512-buffer +noinst_PROGRAMS += bench-sha3-224 bench-sha3-256 +noinst_PROGRAMS += bench-sha3-384 bench-sha3-512 +bench_sha3_224_CPPFLAGS = $(AM_CPPFLAGS) -DNDEBUG +bench_sha3_256_CPPFLAGS = $(AM_CPPFLAGS) -DNDEBUG +bench_sha3_384_CPPFLAGS = $(AM_CPPFLAGS) -DNDEBUG +bench_sha3_512_CPPFLAGS = $(AM_CPPFLAGS) -DNDEBUG diff --git a/tests/bench-sha3-224.c b/tests/bench-sha3-224.c new file mode 100644 index 0000000000..db90e654fe --- /dev/null +++ b/tests/bench-sha3-224.c @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2025 Free Software Foundation, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + +/* Benchmark program for the sha3_224_buffer function. */ + +#include + +#include "sha3.h" + +#define FUNC sha3_224_buffer +#include "bench-digest.h" diff --git a/tests/bench-sha3-256.c b/tests/bench-sha3-256.c new file mode 100644 index 0000000000..24583c02b1 --- /dev/null +++ b/tests/bench-sha3-256.c @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2025 Free Software Foundation, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + +/* Benchmark program for the sha3_256_buffer function. */ + +#include + +#include "sha3.h" + +#define FUNC sha3_256_buffer +#include "bench-digest.h" diff --git a/tests/bench-sha3-384.c b/tests/bench-sha3-384.c new file mode 100644 index 0000000000..09834adeaa --- /dev/null +++ b/tests/bench-sha3-384.c @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2025 Free Software Foundation, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + +/* Benchmark program for the sha3_384_buffer function. */ + +#include + +#include "sha3.h" + +#define FUNC sha3_384_buffer +#include "bench-digest.h" diff --git a/tests/bench-sha3-512.c b/tests/bench-sha3-512.c new file mode 100644 index 0000000000..8479ffc5ad --- /dev/null +++ b/tests/bench-sha3-512.c @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2025 Free Software Foundation, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + +/* Benchmark program for the sha3_512_buffer function. */ + +#include + +#include "sha3.h" + +#define FUNC sha3_512_buffer +#include "bench-digest.h" diff --git a/tests/test-sha3-224-buffer.c b/tests/test-sha3-224-buffer.c new file mode 100644 index 0000000000..0fe5f329d8 --- /dev/null +++ b/tests/test-sha3-224-buffer.c @@ -0,0 +1,93 @@ +/* Test of the sha3_224_buffer() function. + Copyright (C) 2025 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Collin Funk , 2025. */ + +#include + +/* Specification. */ +#include "sha3.h" + +#include +#include +#include + +struct test_case { + char const *message; + char const *digest; +}; + +static const struct test_case test_cases[] = { + { "", "\x6b\x4e\x03\x42\x36\x67\xdb\xb7\x3b\x6e\x15\x45\x4f\x0e\xb1\xab\xd4" + "\x59\x7f\x9a\x1b\x07\x8e\x3f\x5b\x5a\x6b\xc7" }, + { "abc", "\xe6\x42\x82\x4c\x3f\x8c\xf2\x4a\xd0\x92\x34\xee\x7d\x3c\x76\x6f" + "\xc9\xa3\xa5\x16\x8d\x0c\x94\xad\x73\xb4\x6f\xdf" }, + { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", + "\x8a\x24\x10\x8b\x15\x4a\xda\x21\xc9\xfd\x55\x74\x49\x44\x79\xba\x5c\x7e" + "\x7a\xb7\x6e\xf2\x64\xea\xd0\xfc\xce\x33" }, + { "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopj" + "klmnopqklmnopqrlmnopqrsmnopqrstnopqrstu", + "\x54\x3e\x68\x68\xe1\x66\x6c\x1a\x64\x36\x30\xdf\x77\x36\x7a\xe5\xa6\x2a" + "\x85\x07\x0a\x51\xc1\x4c\xbf\x66\x5c\xbc" }, +}; + +static int +check (char const *message, size_t len, char const *expect) +{ + char buf[SHA3_224_DIGEST_SIZE]; + if (memcmp (sha3_224_buffer (message, len, buf), + expect, SHA3_224_DIGEST_SIZE) != 0) + { + size_t i; + printf ("expected:\n"); + for (i = 0; i < SHA3_224_DIGEST_SIZE; i++) + printf ("%02x ", expect[i] & 0xFFu); + printf ("\ncomputed:\n"); + for (i = 0; i < SHA3_224_DIGEST_SIZE; i++) + printf ("%02x ", buf[i] & 0xFFu); + printf ("\n"); + return 1; + } + return 0; +} + +int +main (void) +{ + /* Check the test vectors. */ + for (size_t i = 0; i < sizeof test_cases / sizeof *test_cases; ++i) + { + char const *message = test_cases[i].message; + char const *digest = test_cases[i].digest; + if (check (message, strlen (message), digest) != 0) + return 1; + } + + /* Check that a large buffer works. */ + char *large = malloc (1000000); + if (large != NULL) + { + memset (large, 'a', 1000000); + char const *expect = ("\xd6\x93\x35\xb9\x33\x25\x19\x2e\x51\x6a\x91\x2e" + "\x6d\x19\xa1\x5c\xb5\x1c\x6e\xd5\xc1\x52\x43\xe7" + "\xa7\xfd\x65\x3c"); + if (check (large, 1000000, expect) != 0) + return 1; + free (large); + } + + return 0; +} diff --git a/tests/test-sha3-256-buffer.c b/tests/test-sha3-256-buffer.c new file mode 100644 index 0000000000..8d47874adc --- /dev/null +++ b/tests/test-sha3-256-buffer.c @@ -0,0 +1,94 @@ +/* Test of the sha3_256_buffer() function. + Copyright (C) 2025 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Collin Funk , 2025. */ + +#include + +/* Specification. */ +#include "sha3.h" + +#include +#include +#include + +struct test_case { + char const *message; + char const *digest; +}; + +static const struct test_case test_cases[] = { + { "", "\xa7\xff\xc6\xf8\xbf\x1e\xd7\x66\x51\xc1\x47\x56\xa0\x61\xd6\x62\xf5" + "\x80\xff\x4d\xe4\x3b\x49\xfa\x82\xd8\x0a\x4b\x80\xf8\x43\x4a" }, + { "abc", + "\x3a\x98\x5d\xa7\x4f\xe2\x25\xb2\x04\x5c\x17\x2d\x6b\xd3\x90\xbd\x85\x5f" + "\x08\x6e\x3e\x9d\x52\x5b\x46\xbf\xe2\x45\x11\x43\x15\x32" }, + { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", + "\x41\xc0\xdb\xa2\xa9\xd6\x24\x08\x49\x10\x03\x76\xa8\x23\x5e\x2c\x82\xe1" + "\xb9\x99\x8a\x99\x9e\x21\xdb\x32\xdd\x97\x49\x6d\x33\x76" }, + { "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopj" + "klmnopqklmnopqrlmnopqrsmnopqrstnopqrstu", + "\x91\x6f\x60\x61\xfe\x87\x97\x41\xca\x64\x69\xb4\x39\x71\xdf\xdb\x28\xb1" + "\xa3\x2d\xc3\x6c\xb3\x25\x4e\x81\x2b\xe2\x7a\xad\x1d\x18" }, +}; + +static int +check (char const *message, size_t len, char const *expect) +{ + char buf[SHA3_256_DIGEST_SIZE]; + if (memcmp (sha3_256_buffer (message, len, buf), + expect, SHA3_256_DIGEST_SIZE) != 0) + { + size_t i; + printf ("expected:\n"); + for (i = 0; i < SHA3_256_DIGEST_SIZE; i++) + printf ("%02x ", expect[i] & 0xFFu); + printf ("\ncomputed:\n"); + for (i = 0; i < SHA3_256_DIGEST_SIZE; i++) + printf ("%02x ", buf[i] & 0xFFu); + printf ("\n"); + return 1; + } + return 0; +} + +int +main (void) +{ + /* Check the test vectors. */ + for (size_t i = 0; i < sizeof test_cases / sizeof *test_cases; ++i) + { + char const *message = test_cases[i].message; + char const *digest = test_cases[i].digest; + if (check (message, strlen (message), digest) != 0) + return 1; + } + + /* Check that a large buffer works. */ + char *large = malloc (1000000); + if (large != NULL) + { + memset (large, 'a', 1000000); + char const *expect = ("\x5c\x88\x75\xae\x47\x4a\x36\x34\xba\x4f\xd5\x5e" + "\xc8\x5b\xff\xd6\x61\xf3\x2a\xca\x75\xc6\xd6\x99" + "\xd0\xcd\xcb\x6c\x11\x58\x91\xc1"); + if (check (large, 1000000, expect) != 0) + return 1; + free (large); + } + + return 0; +} diff --git a/tests/test-sha3-384-buffer.c b/tests/test-sha3-384-buffer.c new file mode 100644 index 0000000000..c85408ed4a --- /dev/null +++ b/tests/test-sha3-384-buffer.c @@ -0,0 +1,99 @@ +/* Test of the sha3_384_buffer() function. + Copyright (C) 2025 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Collin Funk , 2025. */ + +#include + +/* Specification. */ +#include "sha3.h" + +#include +#include +#include + +struct test_case { + char const *message; + char const *digest; +}; + +static const struct test_case test_cases[] = { + { "", "\x0c\x63\xa7\x5b\x84\x5e\x4f\x7d\x01\x10\x7d\x85\x2e\x4c\x24\x85\xc5" + "\x1a\x50\xaa\xaa\x94\xfc\x61\x99\x5e\x71\xbb\xee\x98\x3a\x2a\xc3\x71" + "\x38\x31\x26\x4a\xdb\x47\xfb\x6b\xd1\xe0\x58\xd5\xf0\x04" }, + { "abc", + "\xec\x01\x49\x82\x88\x51\x6f\xc9\x26\x45\x9f\x58\xe2\xc6\xad\x8d\xf9\xb4" + "\x73\xcb\x0f\xc0\x8c\x25\x96\xda\x7c\xf0\xe4\x9b\xe4\xb2\x98\xd8\x8c\xea" + "\x92\x7a\xc7\xf5\x39\xf1\xed\xf2\x28\x37\x6d\x25" }, + { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", + "\x99\x1c\x66\x57\x55\xeb\x3a\x4b\x6b\xbd\xfb\x75\xc7\x8a\x49\x2e\x8c\x56" + "\xa2\x2c\x5c\x4d\x7e\x42\x9b\xfd\xbc\x32\xb9\xd4\xad\x5a\xa0\x4a\x1f\x07" + "\x6e\x62\xfe\xa1\x9e\xef\x51\xac\xd0\x65\x7c\x22" }, + { "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopj" + "klmnopqklmnopqrlmnopqrsmnopqrstnopqrstu", + "\x79\x40\x7d\x3b\x59\x16\xb5\x9c\x3e\x30\xb0\x98\x22\x97\x47\x91\xc3\x13" + "\xfb\x9e\xcc\x84\x9e\x40\x6f\x23\x59\x2d\x04\xf6\x25\xdc\x8c\x70\x9b\x98" + "\xb4\x3b\x38\x52\xb3\x37\x21\x61\x79\xaa\x7f\xc7" } +}; + +static int +check (char const *message, size_t len, char const *expect) +{ + char buf[SHA3_384_DIGEST_SIZE]; + if (memcmp (sha3_384_buffer (message, len, buf), + expect, SHA3_384_DIGEST_SIZE) != 0) + { + size_t i; + printf ("expected:\n"); + for (i = 0; i < SHA3_384_DIGEST_SIZE; i++) + printf ("%02x ", expect[i] & 0xFFu); + printf ("\ncomputed:\n"); + for (i = 0; i < SHA3_384_DIGEST_SIZE; i++) + printf ("%02x ", buf[i] & 0xFFu); + printf ("\n"); + return 1; + } + return 0; +} + +int +main (void) +{ + /* Check the test vectors. */ + for (size_t i = 0; i < sizeof test_cases / sizeof *test_cases; ++i) + { + char const *message = test_cases[i].message; + char const *digest = test_cases[i].digest; + if (check (message, strlen (message), digest) != 0) + return 1; + } + + /* Check that a large buffer works. */ + char *large = malloc (1000000); + if (large != NULL) + { + memset (large, 'a', 1000000); + char const *expect = ("\xee\xe9\xe2\x4d\x78\xc1\x85\x53\x37\x98\x34\x51" + "\xdf\x97\xc8\xad\x9e\xed\xf2\x56\xc6\x33\x4f\x8e" + "\x94\x8d\x25\x2d\x5e\x0e\x76\x84\x7a\xa0\x77\x4d" + "\xdb\x90\xa8\x42\x19\x0d\x2c\x55\x8b\x4b\x83\x40"); + if (check (large, 1000000, expect) != 0) + return 1; + free (large); + } + + return 0; +} diff --git a/tests/test-sha3-512-buffer.c b/tests/test-sha3-512-buffer.c new file mode 100644 index 0000000000..535dfde168 --- /dev/null +++ b/tests/test-sha3-512-buffer.c @@ -0,0 +1,105 @@ +/* Test of the sha3_512_buffer() function. + Copyright (C) 2025 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* Written by Collin Funk , 2025. */ + +#include + +/* Specification. */ +#include "sha3.h" + +#include +#include +#include + +struct test_case { + char const *message; + char const *digest; +}; + +static const struct test_case test_cases[] = { + { "", "\xa6\x9f\x73\xcc\xa2\x3a\x9a\xc5\xc8\xb5\x67\xdc\x18\x5a\x75\x6e\x97" + "\xc9\x82\x16\x4f\xe2\x58\x59\xe0\xd1\xdc\xc1\x47\x5c\x80\xa6\x15\xb2" + "\x12\x3a\xf1\xf5\xf9\x4c\x11\xe3\xe9\x40\x2c\x3a\xc5\x58\xf5\x00\x19" + "\x9d\x95\xb6\xd3\xe3\x01\x75\x85\x86\x28\x1d\xcd\x26" }, + { "abc", + "\xb7\x51\x85\x0b\x1a\x57\x16\x8a\x56\x93\xcd\x92\x4b\x6b\x09\x6e\x08\xf6" + "\x21\x82\x74\x44\xf7\x0d\x88\x4f\x5d\x02\x40\xd2\x71\x2e\x10\xe1\x16\xe9" + "\x19\x2a\xf3\xc9\x1a\x7e\xc5\x76\x47\xe3\x93\x40\x57\x34\x0b\x4c\xf4\x08" + "\xd5\xa5\x65\x92\xf8\x27\x4e\xec\x53\xf0" }, + { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", + "\x04\xa3\x71\xe8\x4e\xcf\xb5\xb8\xb7\x7c\xb4\x86\x10\xfc\xa8\x18\x2d\xd4" + "\x57\xce\x6f\x32\x6a\x0f\xd3\xd7\xec\x2f\x1e\x91\x63\x6d\xee\x69\x1f\xbe" + "\x0c\x98\x53\x02\xba\x1b\x0d\x8d\xc7\x8c\x08\x63\x46\xb5\x33\xb4\x9c\x03" + "\x0d\x99\xa2\x7d\xaf\x11\x39\xd6\xe7\x5e" }, + { "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopj" + "klmnopqklmnopqrlmnopqrsmnopqrstnopqrstu", + "\xaf\xeb\xb2\xef\x54\x2e\x65\x79\xc5\x0c\xad\x06\xd2\xe5\x78\xf9\xf8\xdd" + "\x68\x81\xd7\xdc\x82\x4d\x26\x36\x0f\xee\xbf\x18\xa4\xfa\x73\xe3\x26\x11" + "\x22\x94\x8e\xfc\xfd\x49\x2e\x74\xe8\x2e\x21\x89\xed\x0f\xb4\x40\xd1\x87" + "\xf3\x82\x27\x0c\xb4\x55\xf2\x1d\xd1\x85" } +}; + +static int +check (char const *message, size_t len, char const *expect) +{ + char buf[SHA3_512_DIGEST_SIZE]; + if (memcmp (sha3_512_buffer (message, len, buf), + expect, SHA3_512_DIGEST_SIZE) != 0) + { + size_t i; + printf ("expected:\n"); + for (i = 0; i < SHA3_512_DIGEST_SIZE; i++) + printf ("%02x ", expect[i] & 0xFFu); + printf ("\ncomputed:\n"); + for (i = 0; i < SHA3_512_DIGEST_SIZE; i++) + printf ("%02x ", buf[i] & 0xFFu); + printf ("\n"); + return 1; + } + return 0; +} + +int +main (void) +{ + /* Check the test vectors. */ + for (size_t i = 0; i < sizeof test_cases / sizeof *test_cases; ++i) + { + char const *message = test_cases[i].message; + char const *digest = test_cases[i].digest; + if (check (message, strlen (message), digest) != 0) + return 1; + } + + /* Check that a large buffer works. */ + char *large = malloc (1000000); + if (large != NULL) + { + memset (large, 'a', 1000000); + char const *expect = ("\x3c\x3a\x87\x6d\xa1\x40\x34\xab\x60\x62\x7c\x07" + "\x7b\xb9\x8f\x7e\x12\x0a\x2a\x53\x70\x21\x2d\xff" + "\xb3\x38\x5a\x18\xd4\xf3\x88\x59\xed\x31\x1d\x0a" + "\x9d\x51\x41\xce\x9c\xc5\xc6\x6e\xe6\x89\xb2\x66" + "\xa8\xaa\x18\xac\xe8\x28\x2a\x0e\x0d\xb5\x96\xc9" + "\x0b\x0a\x7b\x87"); + if (check (large, 1000000, expect) != 0) + return 1; + free (large); + } + + return 0; +}