diff options
Diffstat (limited to 't')
-rw-r--r-- | t/blake224.c | 133 | ||||
-rw-r--r-- | t/blake256.c | 133 | ||||
-rw-r--r-- | t/blake384.c | 187 | ||||
-rw-r--r-- | t/blake512.c | 256 | ||||
-rw-r--r-- | t/keccak.c | 244 | ||||
-rw-r--r-- | t/keccak_224.c | 28 | ||||
-rw-r--r-- | t/keccak_256.c | 28 | ||||
-rw-r--r-- | t/keccak_384.c | 28 | ||||
-rw-r--r-- | t/keccak_512.c | 42 | ||||
-rw-r--r-- | t/md2.c | 33 | ||||
-rw-r--r-- | t/md4.c | 38 | ||||
-rw-r--r-- | t/md5.c | 129 | ||||
-rw-r--r-- | t/misc-tests.c | 785 | ||||
-rw-r--r-- | t/rawshake128.c | 80 | ||||
-rw-r--r-- | t/rawshake256.c | 81 | ||||
-rw-r--r-- | t/rawshake512.c | 88 | ||||
-rw-r--r-- | t/ripemd-128.c | 36 | ||||
-rw-r--r-- | t/ripemd-160.c | 36 | ||||
-rw-r--r-- | t/ripemd-256.c | 51 | ||||
-rw-r--r-- | t/ripemd-320.c | 51 | ||||
-rw-r--r-- | t/sha0.c | 28 | ||||
-rw-r--r-- | t/sha1.c | 50 | ||||
-rw-r--r-- | t/sha3_224.c | 358 | ||||
-rw-r--r-- | t/sha3_256.c | 28 | ||||
-rw-r--r-- | t/sha3_384.c | 28 | ||||
-rw-r--r-- | t/sha3_512.c | 42 | ||||
-rw-r--r-- | t/sha_224.c | 50 | ||||
-rw-r--r-- | t/sha_256.c | 46 | ||||
-rw-r--r-- | t/sha_384.c | 57 | ||||
-rw-r--r-- | t/sha_512.c | 84 | ||||
-rw-r--r-- | t/sha_512_224.c | 26 | ||||
-rw-r--r-- | t/sha_512_256.c | 26 | ||||
-rw-r--r-- | t/shake128.c | 88 | ||||
-rw-r--r-- | t/shake256.c | 89 | ||||
-rw-r--r-- | t/shake512.c | 88 |
35 files changed, 3575 insertions, 0 deletions
diff --git a/t/blake224.c b/t/blake224.c new file mode 100644 index 0000000..5605033 --- /dev/null +++ b/t/blake224.c @@ -0,0 +1,133 @@ +/* See LICENSE file for copyright and license details. */ +#ifdef SUPPORT_BLAKE224 +# define TEST +# include "../common.h" + + +static struct testcase testcases[] = { + {1, 0, "", "7dc5313b1c04512a174bd6503b89607aecbee0903d40a8a569c94eed"}, + {0, 1, "\xff", "6f464fcaa901babeb27cb94dea4aca966756a1759a24e3cae93f3a05"}, + {0, 1, "\x7f", "6f464fcaa901babeb27cb94dea4aca966756a1759a24e3cae93f3a05"}, + {0, 1, "\x01", "6f464fcaa901babeb27cb94dea4aca966756a1759a24e3cae93f3a05"}, + {0, 1, "\xfe", "615b9bd1077a8270d4f647799ffaaf87c03d72efd37e4947fcf01cca"}, + {0, 1, "\x7e", "615b9bd1077a8270d4f647799ffaaf87c03d72efd37e4947fcf01cca"}, + {1, 1, "\x00", "615b9bd1077a8270d4f647799ffaaf87c03d72efd37e4947fcf01cca"}, + {1, 2, "\x03", "6a829dca3a3d0d35762d7b0f9a2c8379c32415c87a8ad773fefec19f"}, + {1, 3, "\x03", "5478a106aca2b539d5bd52db8b19717d436ca27c14ef99ed565bc4a7"}, + {1, 4, "\x01", "2b10ebc335731de6148ce84ed05a2685b9c274105c6aaf1dd59ef000"}, + {1, 5, "\x12", "a49e36fd01041a0a86eb12d7f110bf4ef798b686fff48e5abc6bc8b4"}, + {1, 6, "\x0a", "57036a8ad47cb24e0f329ef991b571211f171bf86f546aa068577cb5"}, + {1, 7, "\x19", "82417e4fdb2b426d125415b10fe7dae7e944291f8daeb049b80e93a0"}, + {1, 8, "\xcc", "5e21c1e375c7bc822046fad96910c95031bd4262ada71b4c91052fea"}, + {1, 9, "\x98\x00", "30df15eb42922a41c1ef59102115d2f656e94f39fd1eeca115a9a07a"}, + {1, 10, "\x9d\x02", "5c6c22d948c98644057c9ad31107164ecda652f4c51abd8cc4652ee6"}, + {1, 11, "\xaa\x01", "276babfb45f0da4ddce7012d009122cdb974702cce1fcc83e0b254af"}, + {1, 12, "\x98\x0c", "5dd804d86cc32084c81caea4ee5b472b2ba6e8c17eb2ff982e9e885b"}, + {1, 13, "\x50\x0c", "e3d122c703be5ebca4ecc1860a8f50cff518c3984d3605f3c98bb52b"}, + {1, 14, "\x4d\x24", "35e05b766f7fcfb136e62cef59400b3e776f74e69a16912a9e7a9d78"}, + {1, 15, "\xcb\x7b", "227804938f7d63d96a54778f71bfb7421dcf056ddd78ab8b739a7a2e"}, + {1, 16, "\x41\xfb", "195707e8ce71fb91c2c82ccf78022609a598bd80c9a505ef035314db"}, + {1, 17, "\x4f\xf4\x00", "86113100dd674ebf5d0c36b609d9ab8bbd8ecb5d54b0a5aaea9d5e1d"}, + {1, 18, "\xfd\x04\x02", "608997b3ae1483e0298a08d816029d112124743cde703dd0350edbe9"}, + {1, 19, "\x42\x4d\x00", "89f898843d7ab0bb50ac8f6d1139e18aca0ef1d4e95b089ec2172685"}, + {1, 20, "\x3f\xde\x07", "280cee22ba45b2ff9dfa70462cd34c106a24842c6a247f74ade67158"}, + {1, 21, "\x33\x57\x16", "780f1fb7fd80898a10e9c6d63d212372bf7f6b3cd6a6c231ee5daa9b"}, + {1, 22, "\x05\x1e\x3e", "0296e4a199194d5b65aa40fb0ec33870e36daa3e2e962d2c5b6f3a99"}, + {1, 23, "\x71\x7f\x31", "1e95aa999a1a68c1c5191d2365664415344ed1673cb6c12a849abf0a"}, + {1, 24, "\x1f\x87\x7c", "4239b4afa926f2269b117059dc0310033c9c85acea1a031f97cd4e2a"}, + {1, 25, "\xeb\x35\xcf\x01", "dfd3f804fbc9ad5805fc5b529c1d0564e96454710d0b21d561357ac5"}, + {1, 26, "\xb4\x06\xc4\x01", "e1fd87c6396d42e19713290547cc324268c27b7fa40398ed3797b148"}, + {1, 27, "\xce\xe8\x80\x02", "dfebe7b56e9247d4023cecda04c28e1fc4eb6049fa27a747f75d832d"}, + {1, 28, "\xc5\x84\xdb\x0e", "79737f20528fac047c7ea52a2a295bd7ce15087773747cb450be6874"}, + {1, 29, "\x53\x58\x7b\x13", "de42f62c6eeddc5bd80fdf52edcf64754d875bb2b214d5e715833270"}, + {1, 30, "\x69\xa3\x05\x0d", "328a913d190fa087c58958a321138400e5a9e9a8983c9853c0b932ea"}, + {1, 31, "\xc9\x37\x5e\x73", "efa18a9d2ada4755c260482989442f21b8c5b2e09155517e201d269e"}, + {1, 32, "\xc1\xec\xfd\xfc", "9cd80af6d0181b831e1879959f287735c9cbf5d1e480e7341266d6f0"}, + {1, 33, "\x8d\x73\xe8\xa2\x01", "2849a31c29e378fa9eef77ad80043e822c70cde973cb99a4a7f21a07"}, + {1, 34, "\x06\xf2\x52\x20\x01", "d9315ee5d1e33178363ddfdd7d595e0ba4a6d82522500e27ed3075ae"}, + {1, 35, "\x3e\xf6\xc3\x6f\x04", "40663b7856cfb2d57987a85dbd76c447dcf582481912c9a373924127"}, + {1, 36, "\x01\x27\xa1\xd3\x02", "61a5fdead981d711d72d3dc5cfe7f8c40916ce16a42a97cb7b8a016e"}, + {1, 37, "\x6a\x6a\xb6\xc2\x08", "a63d8d4a5239c7132031c1ca6527ebe3e7d6d647124fafdf5f123de2"}, + {1, 38, "\xaf\x31\x75\xe1\x06", "3e7c863db3e16c2350a44e161a2aa3810764cf523c62ab71999a9d24"}, + {1, 39, "\xb6\x66\x09\xed\x61", "e3b7ce19f60913cd5aa1d43bd92de285f72163e0f9453f4e5f21bf52"}, + {1, 40, "\x21\xf1\x34\xac\x57", "9e908983741757ff632c01f2b2c4d7f1ec8e642d112c212ba9739fd1"}, + {1, 41, "\x3d\xc2\xaa\xdf\xfc\x01", "4e1a8c57c3713217530a5f667b37f6bc23939d2fb43dea9745f50068"}, + {1, 42, "\x92\x02\x73\x6d\x22\x02", "a3c9ece5a71fed7c2e58bfd0b67fcf286668c2bcc31826c1b4cd6d59"}, + {1, 43, "\xf2\x19\xbd\x62\x98\x04", "f087f490d55044aa4d147f79d0f1e980fdba1d78cacb5999ff9e67ca"}, + {1, 44, "\xf3\x51\x1e\xe2\xc4\x0d", "49da5bdbc1fe187a28cbd493f383108ff1c6bcd71b3fef2c742074a5"}, + {1, 45, "\x3e\xca\xb6\xbf\x77\x04", "2143ed11184621cb64716a451688291bd0799574f2a28537885540be"}, + {1, 46, "\xcd\x62\xf6\x88\xf4\x19", "0874dba67485be94b9f5a500fade53c94622573059a7fd78f50d0309"}, + {1, 47, "\xc2\xcb\xaa\x33\xa9\x1f", "2e14b39f6de58b0fdd67b9c45eae6c3ff71a363defea06975410e25a"}, + {1, 48, "\xc6\xf5\x0b\xb7\x4e\x29", "6d6d952053aead200de9daa856c2993a7a7fa4a15b3924fb77dbb384"}, + {1, 49, "\x79\xf1\xb4\xcc\xc6\x2a\x00", "ad93ea3f245493cf2b660d6f5fe82b8bfb0d3394854e88c2704c98c2"} +}; + + +#else +# define TEST_UNSUPPORTED +# include "../common.h" +#endif + + +static int +kat_test(void) +{ + TEST_MAIN("BLAKE224", BLAKE224); +} + + +int +main(void) +{ +#ifdef SUPPORT_BLAKE224 + struct libhashsum_hasher hasher1, hasher2; + char salt1[16], salt2[16]; +#endif + + int r = kat_test(); + if (r) + return r; + +#ifdef SUPPORT_BLAKE224 + memset(salt1, 0, sizeof(salt1)); + memset(salt2, 0xAB, sizeof(salt2)); + + ASSERT(!libhashsum_init_blake224_hasher(&hasher1, NULL)); + ASSERT(!libhashsum_init_blake224_hasher(&hasher2, salt1)); + ASSERT(!strcmp(hasher1.algorithm_string, "BLAKE224")); + ASSERT(!strcmp(hasher2.algorithm_string, "BLAKE224")); + ASSERT(!hasher1.finalise_const(&hasher1, NULL, 0, 0)); + ASSERT(!hasher2.finalise_const(&hasher2, NULL, 0, 0)); + ASSERT(!memcmp(hasher1.hash_output, hasher2.hash_output, hasher1.hash_size)); + + ASSERT(!libhashsum_init_blake224_hasher(&hasher1, NULL)); + ASSERT(!libhashsum_init_blake224_hasher(&hasher2, salt1)); + ASSERT(!hasher1.finalise_const(&hasher1, "testdata", 8U, 0)); + ASSERT(!hasher2.finalise_const(&hasher2, "testdata", 8U, 0)); + ASSERT(!memcmp(hasher1.hash_output, hasher2.hash_output, hasher1.hash_size)); + + ASSERT(!libhashsum_init_blake224_hasher(&hasher1, salt1)); + ASSERT(!libhashsum_init_blake224_hasher(&hasher2, salt2)); + ASSERT(!strcmp(hasher1.algorithm_string, "BLAKE224")); + ASSERT(!strcmp(hasher2.algorithm_string, "BLAKE224[salt=abababababababababababababababab]")); + ASSERT(!hasher1.finalise_const(&hasher1, NULL, 0, 0)); + ASSERT(!hasher2.finalise_const(&hasher2, NULL, 0, 0)); + ASSERT(memcmp(hasher1.hash_output, hasher2.hash_output, hasher1.hash_size)); + + ASSERT(!libhashsum_init_blake224_hasher(&hasher1, salt1)); + ASSERT(!libhashsum_init_blake224_hasher(&hasher2, salt2)); + ASSERT(!hasher1.finalise_const(&hasher1, "testdata", 8U, 0)); + ASSERT(!hasher2.finalise_const(&hasher2, "testdata", 8U, 0)); + ASSERT(memcmp(hasher1.hash_output, hasher2.hash_output, hasher1.hash_size)); + + ASSERT(!libhashsum_init_hasher_from_string(&hasher1, "BLAKE224[salt=00000000000000000000000000000000]")); + ASSERT(!libhashsum_init_hasher_from_string(&hasher2, "BLAKE224[salt=abababababababababababababababab]")); + ASSERT(!strcmp(hasher1.algorithm_string, "BLAKE224")); + ASSERT(!strcmp(hasher2.algorithm_string, "BLAKE224[salt=abababababababababababababababab]")); + ASSERT(!hasher1.finalise_const(&hasher1, NULL, 0, 0)); + ASSERT(!hasher2.finalise_const(&hasher2, NULL, 0, 0)); + ASSERT(memcmp(hasher1.hash_output, hasher2.hash_output, hasher1.hash_size)); +#endif + + return 0; +} diff --git a/t/blake256.c b/t/blake256.c new file mode 100644 index 0000000..e42cec7 --- /dev/null +++ b/t/blake256.c @@ -0,0 +1,133 @@ +/* See LICENSE file for copyright and license details. */ +#ifdef SUPPORT_BLAKE256 +# define TEST +# include "../common.h" + + +static struct testcase testcases[] = { + {1, 0, "", "716f6e863f744b9ac22c97ec7b76ea5f5908bc5b2f67c61510bfc4751384ea7a"}, + {0, 1, "\xff", "9151be4536b8f5a0550713425a55cfeadecf71cdb170c647d9bc2d5d56110cc8"}, + {0, 1, "\x7f", "9151be4536b8f5a0550713425a55cfeadecf71cdb170c647d9bc2d5d56110cc8"}, + {0, 1, "\x01", "9151be4536b8f5a0550713425a55cfeadecf71cdb170c647d9bc2d5d56110cc8"}, + {0, 1, "\xfe", "81a10984912cd57c12e923b46142b2b434dfe1a0ef29c03de05555f9f2fee9b4"}, + {0, 1, "\x7e", "81a10984912cd57c12e923b46142b2b434dfe1a0ef29c03de05555f9f2fee9b4"}, + {1, 1, "\x00", "81a10984912cd57c12e923b46142b2b434dfe1a0ef29c03de05555f9f2fee9b4"}, + {1, 2, "\x03", "eae1614ea36088a8fd69a4614c2d98fada81134baa991aebfb743cd297669b01"}, + {1, 3, "\x03", "4ac92b8903f7076563a6309eb9bd386807d28fe721fc8128af86e88967739443"}, + {1, 4, "\x01", "c575142b6e471398bf9fc90a5660bb97f24cb106443b76e22b58084e82667b5d"}, + {1, 5, "\x12", "45bc790b0180778efe9fd0381528ba9e9ec4460685375e1283e519e338b4c55d"}, + {1, 6, "\x0a", "673acd73e1ea3c418e7707cf543155e9dc0c52c6d4aa8a9b0559680b06992d48"}, + {1, 7, "\x19", "46bf46a9db7079a34f1b2b4ceffc8236730c2b5ec2a9f0d105ab5b66be9f6fd8"}, + {1, 8, "\xcc", "e104256a2bc501f459d03fac96b9014f593e22d30f4de525fa680c3aa189eb4f"}, + {1, 9, "\x98\x00", "1088da8ca79a1498f7d4629654307d63715f26edf916c8fb8c09d2039d28c8bc"}, + {1, 10, "\x9d\x02", "1b34cb31b73d6966f038cdd3d93fe973776f9f4bd5bd9b1008ae105edc53add3"}, + {1, 11, "\xaa\x01", "6df64c36384f863cbed1ccf0a615c04b808b73f35131e3f95adfcb93e54e8df0"}, + {1, 12, "\x98\x0c", "37e539c6dfb9c94bc392090a41ae4eca0fe3eff478ef401cf163a73486754ef4"}, + {1, 13, "\x50\x0c", "10ec14653844b6cbda11d908680f27de195a00446b773eb64480168074fb9439"}, + {1, 14, "\x4d\x24", "8f9d0cb5d596260935d8057c260c218091ba666ac14b1a46f2d918484cfbe173"}, + {1, 15, "\xcb\x7b", "891837f7f166cd0603379a2803fe27fed35853f5c4b6feed0fc74b4502d6105c"}, + {1, 16, "\x41\xfb", "8f341148be7e354fdf38b693d8c6b4e0bd57301a734f6fd35cd85b8491c3ddcd"}, + {1, 17, "\x4f\xf4\x00", "ddfc63311a6e1996b257af4ec0750bcbe400d7d507eea84aee9fc44b88127236"}, + {1, 18, "\xfd\x04\x02", "5b452b7b003fab1abe488ba0dca0a6f5945d797a94f52e93d6e921af1a157fc4"}, + {1, 19, "\x42\x4d\x00", "6733ca84f1652ff5d5252d4affa42d3ebda3fbd21a9a8fc07297dad28df7273c"}, + {1, 20, "\x3f\xde\x07", "1e5c24058d33f16a7cef6ad102e3a19b59e595598dd4ddc2c9b8182abbb89b84"}, + {1, 21, "\x33\x57\x16", "29a77b3fa2b97407791da3fa792e40555a2cae9fa85d559ba633ac2e817d6b5e"}, + {1, 22, "\x05\x1e\x3e", "3ef17d53fb61fe2f543a935820f244e25cc8c0ae30d9774ff22427a3fb820d7a"}, + {1, 23, "\x71\x7f\x31", "b2224450512df4c070084e17f6c8a423c5e22a66a77f4eb5792418832dcb05a0"}, + {1, 24, "\x1f\x87\x7c", "bc334d1069099f10c601883ac6f3e7e9787c6aa53171f76a21923cc5ad3ab937"}, + {1, 25, "\xeb\x35\xcf\x01", "7360eb4415d316866b8a748fcd90b7a014c6d62a18218a48cdf681538dcac8ec"}, + {1, 26, "\xb4\x06\xc4\x01", "9e4a8d15be6cfd06425f224035a90ccb5fc8bf92e4d315bc6efe3d9c93085943"}, + {1, 27, "\xce\xe8\x80\x02", "643cf377e140bb1f5d2710927c84ab23b0c258b6c0ab47da4b592180086c24d2"}, + {1, 28, "\xc5\x84\xdb\x0e", "94b4d7f4830fda2e6ba7346f38456d28346589dec8b7dc6e61e3ec3580243c5e"}, + {1, 29, "\x53\x58\x7b\x13", "2d7508d69c7fb9bfacf35fafc118840b8ad42fabae5f27adc9d74154f2e3a78a"}, + {1, 30, "\x69\xa3\x05\x0d", "eec86da7600c3953f088084364b37a3d2bb6522876b82f9cf9cfed764746d53d"}, + {1, 31, "\xc9\x37\x5e\x73", "7ff30cb54acd2e019c3664c42f37002d67132098d313525e5bced93470d19a56"}, + {1, 32, "\xc1\xec\xfd\xfc", "b672a16f53982bab1e77685b71c0a5f6703ffd46a1c834be69f614bd128d658e"}, + {1, 33, "\x8d\x73\xe8\xa2\x01", "3b171d80684fcbb88067e7519e0af3ab3d378254d36633b3eb8585553717ecf0"}, + {1, 34, "\x06\xf2\x52\x20\x01", "d71133d28291531730403dbc363bf3d5a4c3db80861b7c3afbc4c769fedfd3aa"}, + {1, 35, "\x3e\xf6\xc3\x6f\x04", "2e9830df74711da1a21e815aa6ab37013ebded7de7088ae8d5fdb5174440fe0b"}, + {1, 36, "\x01\x27\xa1\xd3\x02", "5ba9f0532fbd0b44f0f7efd9988aa2e062a813797c732242ea5239f571adfb0f"}, + {1, 37, "\x6a\x6a\xb6\xc2\x08", "e03567eefd4e515a73999fac87deb90726bdc488f4be6aa8a974c7b4ee13fc65"}, + {1, 38, "\xaf\x31\x75\xe1\x06", "238036d9eeb9b09d9c9703b484833cc88097f27e34b8a94bef9f5e121b6d5575"}, + {1, 39, "\xb6\x66\x09\xed\x61", "284e01f8b5604db347cd9d4ab95cc8d62d3640aeaf7502a2439fe780c598ba39"}, + {1, 40, "\x21\xf1\x34\xac\x57", "d9134b2899057a7d8d320cc99e3e116982bc99d3c69d260a7f1ed3da8be68d99"}, + {1, 41, "\x3d\xc2\xaa\xdf\xfc\x01", "3e64d5852d9a09ea76007a7b159430c3715598017850ec288316e13b80fd61c7"}, + {1, 42, "\x92\x02\x73\x6d\x22\x02", "95f5bcf07e8a6c02b26f9fe29a5deb7faa5c03ab0e6180239924f5d48c7125af"}, + {1, 43, "\xf2\x19\xbd\x62\x98\x04", "0fcf4c343c9d94bf3dea22069a28d23ff953bde89cd0dee4d1a521d4a302f8a3"}, + {1, 44, "\xf3\x51\x1e\xe2\xc4\x0d", "c32364fa782462bc3a3af38e03fb4f052bd238ab756eaabdd5f8000006446184"}, + {1, 45, "\x3e\xca\xb6\xbf\x77\x04", "511150cbab4c6be4d59d926b093a2d10fb6d9fb06169f47af2f1d75c07463428"}, + {1, 46, "\xcd\x62\xf6\x88\xf4\x19", "a08519ce60cfef0554e8cd1a4d3cbe82504fe97b8b933cfccff5faac85bc787b"}, + {1, 47, "\xc2\xcb\xaa\x33\xa9\x1f", "cc8eb0c743b2440399632474ba84980bebc9f6eedbbce3e31fdc497e0ba32d9d"}, + {1, 48, "\xc6\xf5\x0b\xb7\x4e\x29", "637923bd29a35aa3ecbbd2a50549fc32c14cf0fdcaf41c3194dd7414fd224815"}, + {1, 49, "\x79\xf1\xb4\xcc\xc6\x2a\x00", "106cd7e18e3bd16353cf561411d87b609536856d57180155b60d7bc0a73b9d45"} +}; + + +#else +# define TEST_UNSUPPORTED +# include "../common.h" +#endif + + +static int +kat_test(void) +{ + TEST_MAIN("BLAKE256", BLAKE256); +} + + +int +main(void) +{ +#ifdef SUPPORT_BLAKE256 + struct libhashsum_hasher hasher1, hasher2; + char salt1[16], salt2[16]; +#endif + + int r = kat_test(); + if (r) + return r; + +#ifdef SUPPORT_BLAKE256 + memset(salt1, 0, sizeof(salt1)); + memset(salt2, 0xAB, sizeof(salt2)); + + ASSERT(!libhashsum_init_blake256_hasher(&hasher1, NULL)); + ASSERT(!libhashsum_init_blake256_hasher(&hasher2, salt1)); + ASSERT(!strcmp(hasher1.algorithm_string, "BLAKE256")); + ASSERT(!strcmp(hasher2.algorithm_string, "BLAKE256")); + ASSERT(!hasher1.finalise_const(&hasher1, NULL, 0, 0)); + ASSERT(!hasher2.finalise_const(&hasher2, NULL, 0, 0)); + ASSERT(!memcmp(hasher1.hash_output, hasher2.hash_output, hasher1.hash_size)); + + ASSERT(!libhashsum_init_blake256_hasher(&hasher1, NULL)); + ASSERT(!libhashsum_init_blake256_hasher(&hasher2, salt1)); + ASSERT(!hasher1.finalise_const(&hasher1, "testdata", 8U, 0)); + ASSERT(!hasher2.finalise_const(&hasher2, "testdata", 8U, 0)); + ASSERT(!memcmp(hasher1.hash_output, hasher2.hash_output, hasher1.hash_size)); + + ASSERT(!libhashsum_init_blake256_hasher(&hasher1, salt1)); + ASSERT(!libhashsum_init_blake256_hasher(&hasher2, salt2)); + ASSERT(!strcmp(hasher1.algorithm_string, "BLAKE256")); + ASSERT(!strcmp(hasher2.algorithm_string, "BLAKE256[salt=abababababababababababababababab]")); + ASSERT(!hasher1.finalise_const(&hasher1, NULL, 0, 0)); + ASSERT(!hasher2.finalise_const(&hasher2, NULL, 0, 0)); + ASSERT(memcmp(hasher1.hash_output, hasher2.hash_output, hasher1.hash_size)); + + ASSERT(!libhashsum_init_blake256_hasher(&hasher1, salt1)); + ASSERT(!libhashsum_init_blake256_hasher(&hasher2, salt2)); + ASSERT(!hasher1.finalise_const(&hasher1, "testdata", 8U, 0)); + ASSERT(!hasher2.finalise_const(&hasher2, "testdata", 8U, 0)); + ASSERT(memcmp(hasher1.hash_output, hasher2.hash_output, hasher1.hash_size)); + + ASSERT(!libhashsum_init_hasher_from_string(&hasher1, "BLAKE256[salt=00000000000000000000000000000000]")); + ASSERT(!libhashsum_init_hasher_from_string(&hasher2, "BLAKE256[salt=abababababababababababababababab]")); + ASSERT(!strcmp(hasher1.algorithm_string, "BLAKE256")); + ASSERT(!strcmp(hasher2.algorithm_string, "BLAKE256[salt=abababababababababababababababab]")); + ASSERT(!hasher1.finalise_const(&hasher1, NULL, 0, 0)); + ASSERT(!hasher2.finalise_const(&hasher2, NULL, 0, 0)); + ASSERT(memcmp(hasher1.hash_output, hasher2.hash_output, hasher1.hash_size)); +#endif + + return 0; +} diff --git a/t/blake384.c b/t/blake384.c new file mode 100644 index 0000000..b2f5478 --- /dev/null +++ b/t/blake384.c @@ -0,0 +1,187 @@ +/* See LICENSE file for copyright and license details. */ +#ifdef SUPPORT_BLAKE384 +# define TEST +# include "../common.h" + + +static struct testcase testcases[] = { + {1, 0, "", "c6cbd89c926ab525c242e6621f2f5fa73aa4afe3d9e24aed727faaadd6af38b620bdb623dd2b4788b1c8086984af8706"}, + {0, 1, "\xff", "212ddd52b932eec23b7f38b5b91d2e7e614e64cbce43fc7e1021fed58202a737859634072e6e1847bd0ab5f73e938bc4"}, + {0, 1, "\x7f", "212ddd52b932eec23b7f38b5b91d2e7e614e64cbce43fc7e1021fed58202a737859634072e6e1847bd0ab5f73e938bc4"}, + {0, 1, "\x01", "212ddd52b932eec23b7f38b5b91d2e7e614e64cbce43fc7e1021fed58202a737859634072e6e1847bd0ab5f73e938bc4"}, + {0, 1, "\xfe", "1ffde9711b419d7c97dc142e7704d2ae61163f8a818c47938b978d6113949d8e7819b9699d497a3b289b8bb4415ffae7"}, + {0, 1, "\x7e", "1ffde9711b419d7c97dc142e7704d2ae61163f8a818c47938b978d6113949d8e7819b9699d497a3b289b8bb4415ffae7"}, + {0, 1, "\x00", "1ffde9711b419d7c97dc142e7704d2ae61163f8a818c47938b978d6113949d8e7819b9699d497a3b289b8bb4415ffae7"}, + {1, 1, "\x00", + "1ffde9711b419d7c97dc142e7704d2ae61163f8a818c47938b978d6113949d8e7819b9699d497a3b289b8bb4415ffae7"}, + {1, 2, "\x03", + "195d771c302bb1ca0c9ac55a782cbe877bc0bc28016f735de68d7cf5fc1d0a99cc69a32cb0174fd2a97d5fcf46aafded"}, + {1, 3, "\x03", + "883b186d9372a04d585eb1eef1cd32ff8a7c061d5e396f05fd9d3d9d6033de757bfc3adf30b06d7fb02a875a2ac0db70"}, + {1, 4, "\x01", + "91140c47ba7ef06fe6810acef4be65ad772576291778c6b5588b08fd48beeae4e70c3ac4abb9636a637e9a6359a19053"}, + {1, 5, "\x12", + "f03566b78ead38d98f787c08f117817702d24d3bc8c663551393a1f2e6a079855434414789b34dd360df198eb00e67a2"}, + {1, 6, "\x0a", + "68eeca6e6550ece0662882bd36605eeabea74230171225b708c1a375c90e4a59fec2eff42eba07441dc1f48d39665bd6"}, + {1, 7, "\x19", + "70bb604b0893b22e2f4e2fc0e9cfd725648c9ff217df8eee219a7a1cab3039158ff1ae3c8b2106165f00e3dac9301adb"}, + {1, 8, "\xcc", + "a77e65c0c03ecb831dbcdd50a3c2bce300d55eac002a9c197095518d8514c0b578e3ecb7415291f99ede91d49197dd05"}, + {1, 9, "\x98\x00", + "fdf53e189982aead4849b6fba84b9e84a7f4c38a580840344e4017819f30901ca333b12954ea811049e023f073a69ae2"}, + {1, 10, "\x9d\x02", + "0afc73af8a4f8645cfb30ceab03c256cabf8088d5452c66a766159428de6050484f39b31cb4eebbcb2a06a8a7b0e4626"}, + {1, 11, "\xaa\x01", + "7939c08121bcbdd2d87069a3f8feedc3e1eeaa7a140574afd126441f4ed9e32b783ca02f33bb454aa6d05494d4c9028d"}, + {1, 12, "\x98\x0c", + "a9045405bb39e7f6f89398160208d61f2f4ccbd5c688a6b67aa6eef78d00ef1ee8c6779b781b8603eaf585d475cd86d5"}, + {1, 13, "\x50\x0c", + "bcbc3cff50f0bd0f03c9dcba0296f7bd7a9e111361335cdd8cb47cc02fe6bcff01d3244c6b7141b77b4cbfc88d6cd320"}, + {1, 14, "\x4d\x24", + "9bc5c48e85de4ea136072a53b31d964668175c378a424af4503a454637cd55fa091b2e1a005a6f308f18f5f2b90900a3"}, + {1, 15, "\xcb\x7b", + "4f1eea4e836e12d8521bce58831481e80fec26d40fbef756e571c9cf1e1072008a2475fbdda6b1dc6ff09238f2675329"}, + {1, 16, "\x41\xfb", + "e80a87362c9d39e2074ac135e2514b0cdf0001bfd8c35888d7ca8bbc4e918a157386524d41579e7fcd9c3c9a4f7a991a"}, + {1, 17, "\x4f\xf4\x00", + "28a0158d802b4e6ca90dbd9558140dada402b3fa3f556fc06ab9cd0e645a32eb1793d5ba321e8e6fcbaef6403ba5d4c3"}, + {1, 18, "\xfd\x04\x02", + "cf58d202fc28371bca34f2698569a87d06633777c457312341ce3651259041feefd2fcabe1618ad24d4707292a2f2c63"}, + {1, 19, "\x42\x4d\x00", + "b0f5ab250b2f65cb9a6b200f6bc39ba74db8a5282fdd9e8d1bf87c733da89005fac37f40dcdb9b095a70a018392c3018"}, + {1, 20, "\x3f\xde\x07", + "ffd7f9bf50dcca42c961bbc4fff717ab586e01968d606407ec610aa3d2462987af054c694474c7b5878dd7af5124c1dc"}, + {1, 21, "\x33\x57\x16", + "1f288d53346f74a9618c47f5a77a9e41aece4005037e3b6b908f6d0b4d8faaf148cc18ac1632b3362e1a78369edfc6f6"}, + {1, 22, "\x05\x1e\x3e", + "d5dbcb933c5cba8c1b355b6152a947051a71ea0a9ad295ab308afa39fdce8a07e9e0192a187df0ff9e089718534a7c46"}, + {1, 23, "\x71\x7f\x31", + "c6c62993fb330dd106932569300a97ab54837fe5927adcd0a418fa24e01148d80de54ddc63dc58705c62be1ea4b3ee32"}, + {1, 24, "\x1f\x87\x7c", + "d67cfa1b09c8c050094ea018bb5ecd3ce0c02835325467a8fa79701f0ad6bbd4a34947bbaa2fc5f9379985ccd6a1dc0e"}, + {1, 25, "\xeb\x35\xcf\x01", + "dfba2a0077e56cacb0df1be549dfe06c9828e1eef91b77d83acc0300c0c67db0e2594a4bd552c80f4a0d98fae44a860c"}, + {1, 26, "\xb4\x06\xc4\x01", + "a20846d26c780b03d4d0fe15757d664111aaedc435af784ae85e1a1b25ca56c476b86351edc1ad3825667b86328678d3"}, + {1, 27, "\xce\xe8\x80\x02", + "ee885ca24e330d26bde1b3ea640fd0af5ab1840697bd12d015fc515d219cdd2c13bb3429f374727ee632a1555fef1ca3"}, + {1, 28, "\xc5\x84\xdb\x0e", + "243a3c6ad6fb97298c04200273cbe829c636daab73ea7abaaf1caff193e9dc9b7399ed859a46a6daba98ee9fd810cf00"}, + {1, 29, "\x53\x58\x7b\x13", + "01c6579dd37e707e33ec4a0a768499f28be4e80ba4952e645faa07f09d507dec9e81ab2cf34c0318a34a0ac4af621655"}, + {1, 30, "\x69\xa3\x05\x0d", + "081633892d928cd7debc78ce70b0a82f8595cf32e1998b0298490b8799b26f76ed428d13ca4da02e504efda5a3379dca"}, + {1, 31, "\xc9\x37\x5e\x73", + "24a2d2af040b31fc238abfb935fb0f699eaf97291b75d5a7eaaf542e19c7e486554c166962943b762f2818172bbcdee5"}, + {1, 32, "\xc1\xec\xfd\xfc", + "7a57c41d850b7ab51c6075aba299ff649fdaf08a4c37088ece73b21304b1072c21930cc34ac6b0fc5f27b95f4f389b26"}, + {1, 33, "\x8d\x73\xe8\xa2\x01", + "e1480a83839ab8747935690f1922e0f05e8f67239f7dced9cfd39a1678ee10febb4f7580bd803c66ec5584ef102a12db"}, + {1, 34, "\x06\xf2\x52\x20\x01", + "f386f8bdd36de67d43aeb976b2d57a9499b3796c1c37e6c7b133bf2545d7efcd21be6935425a5dfaa627ceec834400b6"}, + {1, 35, "\x3e\xf6\xc3\x6f\x04", + "311c0aafbb8e6729641d9bb12d0434614f5be6e0d3d27933e1469b0c662430de7153b2aab9c4085758099e6064d2f883"}, + {1, 36, "\x01\x27\xa1\xd3\x02", + "9933fe64ef4de19c78695186286831534f30721b82d031b9f938fb19b4c2cab1d4ac53f63f96a60cf172702f9305854e"}, + {1, 37, "\x6a\x6a\xb6\xc2\x08", + "094b79964b193bf655f91f76f4d3589eab2a902587f730ec76251b98d9de4db846d81c29dba5eb20ede52db447f429a7"}, + {1, 38, "\xaf\x31\x75\xe1\x06", + "e05997f725613d05ec2a3edab5b9af53de9eeaef986ad4ed1f83c6c4211bb0b1a6058d8eaed94d52299e2e32225e2545"}, + {1, 39, "\xb6\x66\x09\xed\x61", + "c0b0e332a81821d4dd06a72ef108fae9060f2c826b3905db037ad75db15efac9c04d0f284aae722e407b41f132a75980"}, + {1, 40, "\x21\xf1\x34\xac\x57", + "324155f4f5e346bfe0b08e9642bebe86505795be186146d30242273ebebb3d51e076b1105ab647c130e6efc0b75072a7"}, + {1, 41, "\x3d\xc2\xaa\xdf\xfc\x01", + "4202b2a7fd50f9f64268a5cecaa979e68fb5e5b4f16050baa0eee6254640a243f8f775c44f26c0d950498c8f1bbb34cb"}, + {1, 42, "\x92\x02\x73\x6d\x22\x02", + "18987d9b924db295acb2645618b772fa7d451ef841f207d525c2c501e472fafb44b3078537515ed39475743c7d2d04c2"}, + {1, 43, "\xf2\x19\xbd\x62\x98\x04", + "b059cd3e9e615574d0f2bbe11522ed7c2243f070272880a5f58bd147985a24afbdf8be2cf139792b482b97bfc94d6788"}, + {1, 44, "\xf3\x51\x1e\xe2\xc4\x0d", + "028c6ea676b4ab01cbdf0918a90e507429ca7b926763dc26ced6f7a851923b91fd4ac6054cc7432139af954c3abe5a94"}, + {1, 45, "\x3e\xca\xb6\xbf\x77\x04", + "5f46d3abe50df2b402567f95468862ecfc91508019c85a190a3c3eb2f6a77e794835697987dc4bce0bd3ef2afb89a026"}, + {1, 46, "\xcd\x62\xf6\x88\xf4\x19", + "444921bbc8e0dceb33e0b4660f2e09fc8a0d8254ae03327af448408b1dc9229c95253c3873f09a522f428899d23d6846"}, + {1, 47, "\xc2\xcb\xaa\x33\xa9\x1f", + "b4a57910d5ef0113585fbe7f3a5ebd7a3e3ddc4e66bd42a8baed7c59134d3cdc36c70a4a39fa11449ff8adfe4da66cb8"}, + {1, 48, "\xc6\xf5\x0b\xb7\x4e\x29", + "5ddb50068ca430bffae7e5a8bbcb2c59171743cce027c0ea937fa2b511848192af2aca98ead30b0850b4d2d1542decdb"}, + {1, 49, "\x79\xf1\xb4\xcc\xc6\x2a\x00", + "7c80a8320015dfc5143d1c6d60a4b51c6943208005aa5176300ecdfa728d5bb53c9817b33c934eca94332716458572dc"} +}; + + +#else +# define TEST_UNSUPPORTED +# include "../common.h" +#endif + + +static int +kat_test(void) +{ + TEST_MAIN("BLAKE384", BLAKE384); +} + + +int +main(void) +{ +#ifdef SUPPORT_BLAKE384 + struct libhashsum_hasher hasher1, hasher2; + char salt1[32], salt2[32]; +#endif + + int r = kat_test(); + if (r) + return r; + +#ifdef SUPPORT_BLAKE384 + memset(salt1, 0, sizeof(salt1)); + memset(salt2, 0xAB, sizeof(salt2)); + + ASSERT(!libhashsum_init_blake384_hasher(&hasher1, NULL)); + ASSERT(!libhashsum_init_blake384_hasher(&hasher2, salt1)); + ASSERT(!strcmp(hasher1.algorithm_string, "BLAKE384")); + ASSERT(!strcmp(hasher2.algorithm_string, "BLAKE384")); + ASSERT(!hasher1.finalise_const(&hasher1, NULL, 0, 0)); + ASSERT(!hasher2.finalise_const(&hasher2, NULL, 0, 0)); + ASSERT(!memcmp(hasher1.hash_output, hasher2.hash_output, hasher1.hash_size)); + + ASSERT(!libhashsum_init_blake384_hasher(&hasher1, NULL)); + ASSERT(!libhashsum_init_blake384_hasher(&hasher2, salt1)); + ASSERT(!hasher1.finalise_const(&hasher1, "testdata", 8U, 0)); + ASSERT(!hasher2.finalise_const(&hasher2, "testdata", 8U, 0)); + ASSERT(!memcmp(hasher1.hash_output, hasher2.hash_output, hasher1.hash_size)); + + ASSERT(!libhashsum_init_blake384_hasher(&hasher1, salt1)); + ASSERT(!libhashsum_init_blake384_hasher(&hasher2, salt2)); + ASSERT(!strcmp(hasher1.algorithm_string, "BLAKE384")); + ASSERT(!strcmp(hasher2.algorithm_string, "BLAKE384[salt=abababababababababababababababab" + "abababababababababababababababab]")); + ASSERT(!hasher1.finalise_const(&hasher1, NULL, 0, 0)); + ASSERT(!hasher2.finalise_const(&hasher2, NULL, 0, 0)); + ASSERT(memcmp(hasher1.hash_output, hasher2.hash_output, hasher1.hash_size)); + + ASSERT(!libhashsum_init_blake384_hasher(&hasher1, salt1)); + ASSERT(!libhashsum_init_blake384_hasher(&hasher2, salt2)); + ASSERT(!hasher1.finalise_const(&hasher1, "testdata", 8U, 0)); + ASSERT(!hasher2.finalise_const(&hasher2, "testdata", 8U, 0)); + ASSERT(memcmp(hasher1.hash_output, hasher2.hash_output, hasher1.hash_size)); + + ASSERT(!libhashsum_init_hasher_from_string(&hasher1, "BLAKE384[salt=00000000000000000000000000000000" + "00000000000000000000000000000000]")); + ASSERT(!libhashsum_init_hasher_from_string(&hasher2, "BLAKE384[salt=abababababababababababababababab" + "abababababababababababababababab]")); + ASSERT(!strcmp(hasher1.algorithm_string, "BLAKE384")); + ASSERT(!strcmp(hasher2.algorithm_string, "BLAKE384[salt=abababababababababababababababab" + "abababababababababababababababab]")); + ASSERT(!hasher1.finalise_const(&hasher1, NULL, 0, 0)); + ASSERT(!hasher2.finalise_const(&hasher2, NULL, 0, 0)); + ASSERT(memcmp(hasher1.hash_output, hasher2.hash_output, hasher1.hash_size)); +#endif + + return 0; +} diff --git a/t/blake512.c b/t/blake512.c new file mode 100644 index 0000000..7166769 --- /dev/null +++ b/t/blake512.c @@ -0,0 +1,256 @@ +/* See LICENSE file for copyright and license details. */ +#ifdef SUPPORT_BLAKE512 +# define TEST +# include "../common.h" + + +static struct testcase testcases[] = { + {1, 0, "", + "a8cfbbd73726062df0c6864dda65defe58ef0cc52a5625090fa17601e1eecd1b" + "628e94f396ae402a00acc9eab77b4d4c2e852aaaa25a636d80af3fc7913ef5b8"}, + {1, 0, "The quick brown fox jumps over the lazy dog", + "1f7e26f63b6ad25a0896fd978fd050a1766391d2fd0471a77afb975e5034b7ad" + "2d9ccf8dfb47abbbe656e1b82fbc634ba42ce186e8dc5e1ce09a885d41f43451"}, + {1, 0, "The quick brown fox jumps over the lazy dof", + "a701c2a1f9baabd8b1db6b75aee096900276f0b86dc15d247ecc03937b370324" + "a16a4ffc0c3a85cd63229cfa15c15f4ba6d46ae2e849ed6335e9ff43b764198a"}, + {0, 1, "\xff", + "69269d2195e03088f928a24a4539849727e47dc46d2596f12b2c88491776f20c" + "31b1526912aec62f29e6641221ca2a67e149857be5e6e08fc3f49ec5d7b7138c"}, + {0, 1, "\x7f", + "69269d2195e03088f928a24a4539849727e47dc46d2596f12b2c88491776f20c" + "31b1526912aec62f29e6641221ca2a67e149857be5e6e08fc3f49ec5d7b7138c"}, + {0, 1, "\x01", + "69269d2195e03088f928a24a4539849727e47dc46d2596f12b2c88491776f20c" + "31b1526912aec62f29e6641221ca2a67e149857be5e6e08fc3f49ec5d7b7138c"}, + {0, 1, "\xfe", + "f0a9b5b755802205fd1a1f56e7a03d7573d46e8ba5037517281560fbe6db03c1" + "74b00597fb4e1427747c7382fe63c6692f05a5e0841e99883cb7c272c2a62191"}, + {0, 1, "\x7e", + "f0a9b5b755802205fd1a1f56e7a03d7573d46e8ba5037517281560fbe6db03c1" + "74b00597fb4e1427747c7382fe63c6692f05a5e0841e99883cb7c272c2a62191"}, + {0, 1, "\x00", + "f0a9b5b755802205fd1a1f56e7a03d7573d46e8ba5037517281560fbe6db03c1" + "74b00597fb4e1427747c7382fe63c6692f05a5e0841e99883cb7c272c2a62191"}, + {1, 1, "\x00", + "f0a9b5b755802205fd1a1f56e7a03d7573d46e8ba5037517281560fbe6db03c1" + "74b00597fb4e1427747c7382fe63c6692f05a5e0841e99883cb7c272c2a62191"}, + {1, 2, "\x03", + "777e21c87839badde651fc37334f6d7cdc8316914e7cb76dab2efab90c62ef30" + "7e590936349b85041542f00d94d870633957699e818db79e1e064b0991a9cd1a"}, + {1, 3, "\x03", + "1ffb9a5c5c4c5a0cb91d806fc1398e8a49bdac2cfb549628c886bf388f5a6c6b" + "0854bc9c68155502016592c3f0cd54ded83276463a2aed864436950d99244958"}, + {1, 4, "\x01", + "32ff282bc8a43dc777ab74582fc2354f4294c6d634b25c4f2f606c72e10ae41e" + "f7f9391f3533649ce73a0dc6b5d30497f655bb87ae45aeb03c50c96d4c5218ff"}, + {1, 5, "\x12", + "783a1850bc31594e382e346351cc004572288f1a12d95b6b52fc47a071033efd" + "7ad6fc0424c93b97708da15cf0482bb0afa1b289545ae6cbbcd2970611dabb46"}, + {1, 6, "\x0a", + "fc355cd7b2f3cec08f4fbf64f8d08394c04ea80e9a6c2920312f450183c53739" + "5a6202d2532ff35597a7c2ec719c4174f347a8cf795fd71d2933a7003ecb05d0"}, + {1, 7, "\x19", + "85bb7f4b9119d4495805c6f5ad9d4eb5f9ee363c34741147483abd6dfd24336b" + "d1a5fa566578f861ffaa0ad6c617491a378477d6dd3d8025ff2b9ce6cdfd0b12"}, + {1, 8, "\xcc", + "4f0ef594f20172d23504873f596984c64c1583c7b2abb8d8786aa2aeeae1c46c" + "744b61893d661b0733b76d1fe19257dd68e0ef05422ca25d058dfe6c33d68709"}, + {1, 9, "\x98\x00", + "073cf7ed8216a6b27f882563986489d1c418874f2b797a9a0c5c95394f3a9dbe" + "b7eb3e2e6598fa5f49ad10e87f4add5f08057e5c1cd0b45004f22b63f91787ad"}, + {1, 10, "\x9d\x02", + "48ec88684d8239091d13d3d1d582a1b7cb07f6b67d9e9f1759c117f8dc447d01" + "2d6802748f1c613763a88e88a996a177ec562ba15c7da086502334f0df97d1b7"}, + {1, 11, "\xaa\x01", + "635213e9c8ffb6a535e6eaae9e9231d901e07607afaecd9122e3dfbacb0f11fb" + "388fcb91e68e1d7f05c70f1f8a5dd6549c93f87fb4f25fa31d6c6abb4b9a55c4"}, + {1, 12, "\x98\x0c", + "75d769e87d7c935faf58cd93043019bae5162e6b54d3b8b4aa2ae5fda3705e72" + "1e669dce33e8d59db6db0ad2c4ba7dc5f931ecf67a3448024b1515800b777129"}, + {1, 13, "\x50\x0c", + "8903efd089efa56634fa8d4bd953abcf30d72fca70ebad0ddfccbd4cda514c56" + "79dc763291dbb888a0bc7af7964a3be07f14c37ee696b51099bd91466429b22b"}, + {1, 14, "\x4d\x24", + "9464762c5824a83eef9445571734261e57a453e30e12e9581c4b378a7ec8219b" + "b3f25b0d900aa8dd446f2788395e4216f539ec4d3f8d41090ae7951a43bdf2ed"}, + {1, 15, "\xcb\x7b", + "ae69b3b57792c5909a8482a4006eccceeb14d1f76b15da66018586ae132adae8" + "641890921c13bdc2164be991b1e248d66b5e647a8e4b4eef73e33d3f06a33a5c"}, + {1, 16, "\x41\xfb", + "20afd72afbb66a5a0efd8b4a627cc2c82a5e4b6c63b0c9a78735c188d248c758" + "8fb4ee566b3b6fdcc235a498f7263feb7ab1411582a7055e3ce7a8c976e61fcc"}, + {1, 17, "\x4f\xf4\x00", + "802ad11445c31e09a51f1431a9b735a009f631e192c78de140a484bfba91d5c5" + "482a5539509f1b0fca92f4e5ab6040d1efdb7fe64f107b6cf5a5c79342c10491"}, + {1, 18, "\xfd\x04\x02", + "0e1a3fdc9506b0fb96bd69a14149fa41484c035a4867cc8f9ae8704e7fbf5b24" + "168089c1ae654a46d6dd2375bea3c62df92b2cba320a09a642917c7c7790f199"}, + {1, 19, "\x42\x4d\x00", + "dd05e2ca3219efe375f2bf8edb2f45c5c490fb5e06bddbb2a813e5e232c62f15" + "b70324db66f442be5d2a437b21df736ebbd3eba0b58591550b45ef9838703054"}, + {1, 20, "\x3f\xde\x07", + "8dc0a2797160f1eb1e4fca864f99298e655572adce432a03e5ff3a5dc814bbd8" + "1e3b328bbf8191e9041c57780f27fbecc1618b3fd140da3b96e2d0f769b441a1"}, + {1, 21, "\x33\x57\x16", + "b501b4abc63aed8c5841e691e7f5ff5b096637e19342fa44feb53ddf84f16eb8" + "bc92730c41f2b29131f3c6701f9b3bb6dcb5af7e8a4d900243e7b136a0d60ddb"}, + {1, 22, "\x05\x1e\x3e", + "9d28c92c6b54f7f6888b6d210029eeafde05b7ab95e2a34d1f3979d3b62c8940" + "c4980a1a46cfead4a630cf8e5efb521b5e412059786f626d1054e62b0f2ed916"}, + {1, 23, "\x71\x7f\x31", + "855c53190122aec182624cd98ec4f97b362bc74c01eef9e1d140ce79ab54e127" + "7e8b873df52585c420b8c6d99652b47e5de322225dc1792788e71aa2912861f8"}, + {1, 24, "\x1f\x87\x7c", + "b1211367fd8a886674f74d92716e7585f9b6e933edc5ee7f974facdccc481cfa" + "42a0532375b94f2c0dd73d6189a815c2bafb5686d784be81fbb447b0f291272b"}, + {1, 25, "\xeb\x35\xcf\x01", + "df4050f53c05fa145dd89bf9ac94dcfd81f96f984ca484dbbbf92259f7b8ae19" + "d2fec657853bb2673ddb0ee26f298d8c4923daaeedc2926e7daf2157c697b2ed"}, + {1, 26, "\xb4\x06\xc4\x01", + "f507a52fb135565c74e5905fe9a43dcbfb29b39344faec39c15ad09b0a465fef" + "0be36183433d29243d74f119b8242bd94b0e6b37c2c1039d9d7c5af316fc46d4"}, + {1, 27, "\xce\xe8\x80\x02", + "06228dc4e1b32e816c77273e5e5b66349e82f48c6c7f3eea8876efa5db32d9fc" + "f2e26dd3eeae7355877ca9e7b31c0924c521b5e729cf08c4175dab8a451e5ad8"}, + {1, 28, "\xc5\x84\xdb\x0e", + "fbbbc6cb4832c6545236f9e36fc92f7a7709e38fdf7ea6cb100048409a3c5f36" + "e8a336360e7ab5ec26a8c13d8e663f08cac2b2519f40c61cd3284b9f320463da"}, + {1, 29, "\x53\x58\x7b\x13", + "91f4c152a8f637247a1747e2ca4df130d3be99c2dc3a9f2991df7a60900b1093" + "1fe670d10dc7725dc30e068f3220575f033e8634dd58904ca3136a04158a42ed"}, + {1, 30, "\x69\xa3\x05\x0d", + "5068d281c4eef98502d0d1de51b1f78764059fb599f036fd7f60c0fd4f50b634" + "205a196306ee78eabd3ce8eb8333a6da8bf0c7176d5230bcc6af48700fd7f343"}, + {1, 31, "\xc9\x37\x5e\x73", + "3501607fa6b01de201a10bd1db756621cd2097e3476acf862e8b723d98bc4399" + "84f8de6bc8514ed800265ef21116cf36aba1f68f9f96befb9b48eafbe19bf805"}, + {1, 32, "\xc1\xec\xfd\xfc", + "ccbcdbc1a30ebbcc4fc015fdb1caba6c0ad6719301b4bbad4b0efab1141174a1" + "5e2e8b8b8e5671c1864a0f75ecb20f76dac45159e67786d07d79a29b1827e5a4"}, + {1, 33, "\x8d\x73\xe8\xa2\x01", + "1f41330d6ad6f6fafa54f7c1a698a03ebd96e74025d0e5476138589e02194c13" + "3fad988e47c81a0ed887943670d41e560327761f897d996dc59cb9025b095315"}, + {1, 34, "\x06\xf2\x52\x20\x01", + "4d9fa2dc0049230afd0d72e6195a19523d3d8b4f1983d1108157b7085ae82a0f" + "90542351fc8d66437fc9a9bc6f98807313abdc2b4c6140b819b201df6c62b1da"}, + {1, 35, "\x3e\xf6\xc3\x6f\x04", + "cc14844fa038671773c4201fdd7e106e951d77cef951d253e9da9f07f2bb3040" + "a2569834d6836b30b743d39bee94a7e7721672ca30fd94b1de23bdcb1c218ff5"}, + {1, 36, "\x01\x27\xa1\xd3\x02", + "37f909daa8a5e503b8af6f0826ba02ac14a4e92221a551cbcf4128a4c867d101" + "d4f158232de31bc4d9ed298def8e202db9490a0da1d09cb665bdf18a14f8ff4a"}, + {1, 37, "\x6a\x6a\xb6\xc2\x08", + "4b6c339182ec57c24832313bba724aa37b2d8833e04fc31a1a869c3da3ba1061" + "36bfda897cec7aedd28227c2b118fa417c2592a71216be6e3766b26f04b4ea4d"}, + {1, 38, "\xaf\x31\x75\xe1\x06", + "04548a4bf2fd865da48c060262bf0f17dc084c9d4162a06f2f7aad1aed7244d7" + "422d257e54a9eef9c24c8827e88fa707c9d0ee1ac555b46b7ee8e5ecc6fa8f1d"}, + {1, 39, "\xb6\x66\x09\xed\x61", + "a5b8b8de6cf9c14ced277140d219755a4af5c80e0dbd67721831b1284a501c50" + "92a669390ecf997e406c4c1a43b25903759d0ae5ac09390f5d2ed747ae1bd361"}, + {1, 40, "\x21\xf1\x34\xac\x57", + "ec6eaabc2a128c38dfcddf9aaad5bb6fba397aac06a4b584b2dbdeb0cd7fdb1f" + "d248ef93c0686b73818b2b78c923c70eba63c096f33d842ada959f7674e4730c"}, + {1, 41, "\x3d\xc2\xaa\xdf\xfc\x01", + "eb9dc2c740374e28d9247393afe2d713e843c289977ea48abda51fb2950c3967" + "aea50d48e7eba75b591140062e14495d416934f9817ec832988397c3a781dfeb"}, + {1, 42, "\x92\x02\x73\x6d\x22\x02", + "0c5dfdfd3167a6ca86abf804e71342e893b0270b3ef2d4c81032482538c0f580" + "2817a16d6ec12f541ce947d5579c27b9b7a5ee424554f3fa2c78a2fa8340d444"}, + {1, 43, "\xf2\x19\xbd\x62\x98\x04", + "40f191621e6a183a0bd3f10df6716ddf09339fba20b48dbbb09fb44b82f15be7" + "7ad595bfdd1f1245b930334ea7042e716626d5fb49bc275df0b60639d9aea618"}, + {1, 44, "\xf3\x51\x1e\xe2\xc4\x0d", + "e76cefbc4621956af8d7d5121bd10bdddaeff359ff2b988425f22bba15c8ad4d" + "bbf70f7e8b5cf2ee044eb9625bf36ec9f910e01701bbc8541d8529a13a56cc98"}, + {1, 45, "\x3e\xca\xb6\xbf\x77\x04", + "39b3d2f730b774e16504fd6e5b2eafca5f68c9d5022e62d3bca67793d3260f34" + "d1dd594b95ef5a735aa9b78ff0b6028b484c34a4bcd9adb4ec5a9736ecd434eb"}, + {1, 46, "\xcd\x62\xf6\x88\xf4\x19", + "69b151653d645e84c6eb509665a89a075210f743f8c7218e6c98895c9436e9ee" + "dfa2094597b13533e1c3af6b21907ddf2f4c5c8379e64a71b66add2a170d5689"}, + {1, 47, "\xc2\xcb\xaa\x33\xa9\x1f", + "eac8acd05f04461d8050b53dafa99b0516adfacc8dbd3adc7dacfc7adea4ad92" + "50fa9e10ad43602e15a762a333a2cdb1c040ede1de79ac51b484507b5ae16536"}, + {1, 48, "\xc6\xf5\x0b\xb7\x4e\x29", + "b6e8a7380df1f007d7c271e7255bbca7714f25029ac1fd6fe92ef74cbcd9e99c" + "112f8ae1a45ccb566ce19d9678a122c612beff5f8eeeee3f3f402fd2781182d4"}, + {1, 49, "\x79\xf1\xb4\xcc\xc6\x2a\x00", + "1cc9fe09100fbc45f20382353785aa753fbd19ea0ab655c0d8338e0d07154cca" + "a5659698a6627302c25dd54cdfde00c0ef06905abc55030563399ca8efae2c22"} +}; + + +#else +# define TEST_UNSUPPORTED +# include "../common.h" +#endif + + +static int +kat_test(void) +{ + TEST_MAIN("BLAKE512", BLAKE512); +} + + +int +main(void) +{ +#ifdef SUPPORT_BLAKE512 + struct libhashsum_hasher hasher1, hasher2; + char salt1[32], salt2[32]; +#endif + + int r = kat_test(); + if (r) + return r; + +#ifdef SUPPORT_BLAKE512 + memset(salt1, 0, sizeof(salt1)); + memset(salt2, 0xAB, sizeof(salt2)); + + ASSERT(!libhashsum_init_blake512_hasher(&hasher1, NULL)); + ASSERT(!libhashsum_init_blake512_hasher(&hasher2, salt1)); + ASSERT(!strcmp(hasher1.algorithm_string, "BLAKE512")); + ASSERT(!strcmp(hasher2.algorithm_string, "BLAKE512")); + ASSERT(!hasher1.finalise_const(&hasher1, NULL, 0, 0)); + ASSERT(!hasher2.finalise_const(&hasher2, NULL, 0, 0)); + ASSERT(!memcmp(hasher1.hash_output, hasher2.hash_output, hasher1.hash_size)); + + ASSERT(!libhashsum_init_blake512_hasher(&hasher1, NULL)); + ASSERT(!libhashsum_init_blake512_hasher(&hasher2, salt1)); + ASSERT(!hasher1.finalise_const(&hasher1, "testdata", 8U, 0)); + ASSERT(!hasher2.finalise_const(&hasher2, "testdata", 8U, 0)); + ASSERT(!memcmp(hasher1.hash_output, hasher2.hash_output, hasher1.hash_size)); + + ASSERT(!libhashsum_init_blake512_hasher(&hasher1, salt1)); + ASSERT(!libhashsum_init_blake512_hasher(&hasher2, salt2)); + ASSERT(!strcmp(hasher1.algorithm_string, "BLAKE512")); + ASSERT(!strcmp(hasher2.algorithm_string, "BLAKE512[salt=abababababababababababababababab" + "abababababababababababababababab]")); + ASSERT(!hasher1.finalise_const(&hasher1, NULL, 0, 0)); + ASSERT(!hasher2.finalise_const(&hasher2, NULL, 0, 0)); + ASSERT(memcmp(hasher1.hash_output, hasher2.hash_output, hasher1.hash_size)); + + ASSERT(!libhashsum_init_blake512_hasher(&hasher1, salt1)); + ASSERT(!libhashsum_init_blake512_hasher(&hasher2, salt2)); + ASSERT(!hasher1.finalise_const(&hasher1, "testdata", 8U, 0)); + ASSERT(!hasher2.finalise_const(&hasher2, "testdata", 8U, 0)); + ASSERT(memcmp(hasher1.hash_output, hasher2.hash_output, hasher1.hash_size)); + + ASSERT(!libhashsum_init_hasher_from_string(&hasher1, "BLAKE512[salt=00000000000000000000000000000000" + "00000000000000000000000000000000]")); + ASSERT(!libhashsum_init_hasher_from_string(&hasher2, "BLAKE512[salt=abababababababababababababababab" + "abababababababababababababababab]")); + ASSERT(!strcmp(hasher1.algorithm_string, "BLAKE512")); + ASSERT(!strcmp(hasher2.algorithm_string, "BLAKE512[salt=abababababababababababababababab" + "abababababababababababababababab]")); + ASSERT(!hasher1.finalise_const(&hasher1, NULL, 0, 0)); + ASSERT(!hasher2.finalise_const(&hasher2, NULL, 0, 0)); + ASSERT(memcmp(hasher1.hash_output, hasher2.hash_output, hasher1.hash_size)); +#endif + + return 0; +} diff --git a/t/keccak.c b/t/keccak.c new file mode 100644 index 0000000..6e4a900 --- /dev/null +++ b/t/keccak.c @@ -0,0 +1,244 @@ +/* See LICENSE file for copyright and license details. */ +#ifndef SUPPORT_KECCAK +# include "../common.h" + +int +main(void) +{ + struct libhashsum_hasher hasher; + if (!libhashsum_init_keccak_hasher(&hasher, 0, 0, 0, 0)) { + fprintf(stderr, "expected libhashsum_init_keccak_hasher to fail, but it returned successfully\n"); + return 2; + } + if (errno != ENOSYS) { + perror("expected libhashsum_init_keccak_hasher to set errno to ENOSYS, but got"); + return 2; + } + return 0; +} + +#else +# include "../common.h" + + +# define ASSERT(ASSERTION)\ + do {\ + if ((ASSERTION))\ + break;\ + fprintf(stderr, "assertion `%s` at line %i failed\n", #ASSERTION, __LINE__);\ + exit(2);\ + } while (0) + + +static const char * +hex(const struct libhashsum_hasher *hasher) +{ + static char buffer[4096]; + char *restrict out = buffer; + unsigned char *restrict in = hasher->hash_output; + size_t n = hasher->hash_size; + for (; n--; in++) { + *out++ = "0123456789abcdef"[(*in >> 4) & 15]; + *out++ = "0123456789abcdef"[(*in >> 0) & 15]; + } + *out = '\0'; + return buffer; +} + + +int +main(void) +{ + char buffer[4096]; + struct libhashsum_hasher h1, h2; + int i; + + for (i = 0; i < 8; i++) { + if ((i&3) == 3) + continue; + + ASSERT(!libhashsum_init_keccak_hasher(&h1, (i&1)?0: 1600 - 2 * 224, (i&2)?0: 2 * 224, 224, 1)); + ASSERT(!libhashsum_init_keccak_224_hasher(&h2)); + ASSERT(!h1.finalise_const(&h1, (i&4) ? "testdata" : 0, (i&4) ? 8 : 0, 0)); + ASSERT(!h2.finalise_const(&h2, (i&4) ? "testdata" : 0, (i&4) ? 8 : 0, 0)); + ASSERT(h1.hash_size == h2.hash_size); + ASSERT(!memcmp(h1.hash_output, h2.hash_output, h2.hash_size)); + ASSERT(h1.algorithm == h2.algorithm); + ASSERT(!strcmp(h1.algorithm_string, h2.algorithm_string)); + + ASSERT(!libhashsum_init_keccak_hasher(&h1, (i&1)?0: 1600 - 2 * 256, (i&2)?0: 2 * 256, 256, 1)); + ASSERT(!libhashsum_init_keccak_256_hasher(&h2)); + ASSERT(!h1.finalise_const(&h1, (i&4) ? "testdata" : 0, (i&4) ? 8 : 0, 0)); + ASSERT(!h2.finalise_const(&h2, (i&4) ? "testdata" : 0, (i&4) ? 8 : 0, 0)); + ASSERT(h1.hash_size == h2.hash_size); + ASSERT(!memcmp(h1.hash_output, h2.hash_output, h2.hash_size)); + ASSERT(h1.algorithm == h2.algorithm); + ASSERT(!strcmp(h1.algorithm_string, h2.algorithm_string)); + + ASSERT(!libhashsum_init_keccak_hasher(&h1, (i&1)?0: 1600 - 2 * 384, (i&2)?0: 2 * 384, 384, 1)); + ASSERT(!libhashsum_init_keccak_384_hasher(&h2)); + ASSERT(!h1.finalise_const(&h1, (i&4) ? "testdata" : 0, (i&4) ? 8 : 0, 0)); + ASSERT(!h2.finalise_const(&h2, (i&4) ? "testdata" : 0, (i&4) ? 8 : 0, 0)); + ASSERT(h1.hash_size == h2.hash_size); + ASSERT(!memcmp(h1.hash_output, h2.hash_output, h2.hash_size)); + ASSERT(h1.algorithm == h2.algorithm); + ASSERT(!strcmp(h1.algorithm_string, h2.algorithm_string)); + + ASSERT(!libhashsum_init_keccak_hasher(&h1, (i&1)?0: 1600 - 2 * 512, (i&2)?0: 2 * 512, 512, 1)); + ASSERT(!libhashsum_init_keccak_512_hasher(&h2)); + ASSERT(!h1.finalise_const(&h1, (i&4) ? "testdata" : 0, (i&4) ? 8 : 0, 0)); + ASSERT(!h2.finalise_const(&h2, (i&4) ? "testdata" : 0, (i&4) ? 8 : 0, 0)); + ASSERT(h1.hash_size == h2.hash_size); + ASSERT(!memcmp(h1.hash_output, h2.hash_output, h2.hash_size)); + ASSERT(h1.algorithm == h2.algorithm); + ASSERT(!strcmp(h1.algorithm_string, h2.algorithm_string)); + } + + ASSERT(!libhashsum_init_keccak_hasher(&h1, 0, 0, 224, 1)); + ASSERT(!libhashsum_init_keccak_224_hasher(&h2)); + ASSERT(!h1.finalise_const(&h1, NULL, 0, 0)); + ASSERT(!h2.finalise_const(&h2, NULL, 0, 0)); + ASSERT(h1.hash_size == h2.hash_size); + ASSERT(memcmp(h1.hash_output, h2.hash_output, h2.hash_size)); + ASSERT(h1.algorithm == LIBHASHSUM_KECCAK); + ASSERT(!strcmp(h1.algorithm_string, "Keccak[r=1024,c=576,n=224]")); + + ASSERT(!libhashsum_init_keccak_hasher(&h1, 0, 0, 256, 1)); + ASSERT(!libhashsum_init_keccak_256_hasher(&h2)); + ASSERT(!h1.finalise_const(&h1, NULL, 0, 0)); + ASSERT(!h2.finalise_const(&h2, NULL, 0, 0)); + ASSERT(h1.hash_size == h2.hash_size); + ASSERT(memcmp(h1.hash_output, h2.hash_output, h2.hash_size)); + ASSERT(h1.algorithm == LIBHASHSUM_KECCAK); + ASSERT(!strcmp(h1.algorithm_string, "Keccak[r=1024,c=576,n=256]")); + + ASSERT(!libhashsum_init_keccak_hasher(&h1, 0, 0, 512, 0)); + ASSERT(!h1.finalise_const(&h1, NULL, 0, 0)); + ASSERT(h1.hash_size == 512U / 8U); + ASSERT(h1.algorithm == LIBHASHSUM_KECCAK); + ASSERT(strcmp(h1.algorithm_string, h2.algorithm_string)); + ASSERT(!strcmp(h1.algorithm_string, "Keccak[r=1024,c=576,n=512]")); + + ASSERT(!libhashsum_init_keccak_hasher(&h1, 0, 0, 0, 0)); + ASSERT(h1.hash_size == 512U / 8U); + ASSERT(h1.algorithm == LIBHASHSUM_KECCAK); + ASSERT(!strcmp(h1.algorithm_string, "Keccak[r=1024,c=576,n=512]")); + + ASSERT(!libhashsum_init_keccak_hasher(&h1, 0, 0, 224, 1)); + ASSERT(!libhashsum_init_keccak_hasher(&h2, 0, 0, 512, 1)); + ASSERT(!h1.finalise(&h1, buffer, 0, 0, sizeof(buffer))); + ASSERT(!h2.finalise(&h2, buffer, 0, 0, sizeof(buffer))); + ASSERT(!memcmp(h1.hash_output, h2.hash_output, h1.hash_size)); + +#define Z1\ + "6753e3380c09e385d0339eb6b050a68f66cfd60a73476e6fd6adeb72f5edd7c6"\ + "f04a5d017a19cbe291935855b4860f69df04c98aa78b407a9ba9826f7266ef14" +#define Z2\ + "c3a2fa33f0bfb1cfef8da7875c4967f332c7fc93c050e81fb404f9a91503d601"\ + "0ee16f50b4ed0bc563ba8431668b003d7e2e6f226cb7fa93bb2e132c861fdc21" +#define Z200\ + "f8354bead24cc78c835813c0eec02dcad2b8caf37d79566ea6dc2836f231070d"\ + "cd786213580093a296578518ecc705c461264359e46c51b7c6beef3e3fb21a05" + + ASSERT(!libhashsum_init_keccak_hasher(&h1, 0, 0, 0, 0)); + ASSERT(!libhashsum_init_keccak_hasher(&h2, 0, 0, 0, 1)); + ASSERT(!h1.finalise(&h1, buffer, 0, 0, sizeof(buffer))); + ASSERT(!h2.finalise(&h2, buffer, 0, 0, sizeof(buffer))); + ASSERT(!strcmp(h1.algorithm_string, "Keccak[r=1024,c=576,n=512]")); + ASSERT(!strcmp(h2.algorithm_string, "Keccak[r=1024,c=576,n=512]")); + ASSERT(!memcmp(h1.hash_output, h2.hash_output, h1.hash_size)); + ASSERT(!strcmp(hex(&h2), Z1)); + + ASSERT(!libhashsum_init_keccak_hasher(&h1, 0, 0, 0, 0)); + ASSERT(!libhashsum_init_keccak_hasher(&h2, 0, 0, 0, 200)); + ASSERT(!h1.finalise(&h1, buffer, 0, 0, sizeof(buffer))); + ASSERT(!h2.finalise(&h2, buffer, 0, 0, sizeof(buffer))); + ASSERT(!strcmp(h1.algorithm_string, "Keccak[r=1024,c=576,n=512]")); + ASSERT(!strcmp(h2.algorithm_string, "Keccak[r=1024,c=576,n=512,z=200]")); + ASSERT(memcmp(h1.hash_output, h2.hash_output, h1.hash_size)); + ASSERT(!strcmp(hex(&h2), Z200)); + + ASSERT(!libhashsum_init_keccak_hasher(&h1, 0, 0, 0, 0)); + ASSERT(!libhashsum_init_keccak_hasher(&h2, 0, 0, 0, 2)); + ASSERT(!h1.finalise(&h1, buffer, 0, 0, sizeof(buffer))); + ASSERT(!h2.finalise(&h2, buffer, 0, 0, sizeof(buffer))); + ASSERT(!strcmp(h1.algorithm_string, "Keccak[r=1024,c=576,n=512]")); + ASSERT(!strcmp(h2.algorithm_string, "Keccak[r=1024,c=576,n=512,z=2]")); + ASSERT(memcmp(h1.hash_output, h2.hash_output, h1.hash_size)); + ASSERT(!strcmp(hex(&h2), Z2)); + + ASSERT(!libhashsum_init_keccak_hasher(&h1, 0, 0, 224, 1)); + ASSERT(!libhashsum_init_keccak_hasher(&h2, 0, 0, 512, 1)); + ASSERT(!h1.finalise(&h1, buffer, 0, 0, 0)); + ASSERT(!h2.finalise(&h2, buffer, 0, 0, 0)); + ASSERT(!memcmp(h1.hash_output, h2.hash_output, h1.hash_size)); + + ASSERT(!libhashsum_init_keccak_hasher(&h1, 0, 0, 0, 0)); + ASSERT(!libhashsum_init_keccak_hasher(&h2, 0, 0, 0, 1)); + ASSERT(!h1.finalise(&h1, buffer, 0, 0, 0)); + ASSERT(!h2.finalise(&h2, buffer, 0, 0, 0)); + ASSERT(!strcmp(h1.algorithm_string, "Keccak[r=1024,c=576,n=512]")); + ASSERT(!strcmp(h2.algorithm_string, "Keccak[r=1024,c=576,n=512]")); + ASSERT(!memcmp(h1.hash_output, h2.hash_output, h1.hash_size)); + ASSERT(!strcmp(hex(&h2), Z1)); + + ASSERT(!libhashsum_init_keccak_hasher(&h1, 0, 0, 0, 0)); + ASSERT(!libhashsum_init_keccak_hasher(&h2, 0, 0, 0, 200)); + ASSERT(!h1.finalise(&h1, buffer, 0, 0, 0)); + ASSERT(!h2.finalise(&h2, buffer, 0, 0, 0)); + ASSERT(!strcmp(h1.algorithm_string, "Keccak[r=1024,c=576,n=512]")); + ASSERT(!strcmp(h2.algorithm_string, "Keccak[r=1024,c=576,n=512,z=200]")); + ASSERT(memcmp(h1.hash_output, h2.hash_output, h1.hash_size)); + ASSERT(!strcmp(hex(&h2), Z200)); + + ASSERT(!libhashsum_init_keccak_hasher(&h1, 0, 0, 0, 0)); + ASSERT(!libhashsum_init_keccak_hasher(&h2, 0, 0, 0, 2)); + ASSERT(!h1.finalise(&h1, buffer, 0, 0, 0)); + ASSERT(!h2.finalise(&h2, buffer, 0, 0, 0)); + ASSERT(!strcmp(h1.algorithm_string, "Keccak[r=1024,c=576,n=512]")); + ASSERT(!strcmp(h2.algorithm_string, "Keccak[r=1024,c=576,n=512,z=2]")); + ASSERT(memcmp(h1.hash_output, h2.hash_output, h1.hash_size)); + ASSERT(!strcmp(hex(&h2), Z2)); + + ASSERT(!libhashsum_init_keccak_hasher(&h1, 0, 0, 224, 1)); + ASSERT(!libhashsum_init_keccak_hasher(&h2, 0, 0, 512, 1)); + ASSERT(!h1.finalise_const(&h1, NULL, 0, 0)); + ASSERT(!h2.finalise_const(&h2, NULL, 0, 0)); + ASSERT(!memcmp(h1.hash_output, h2.hash_output, h1.hash_size)); + + ASSERT(!libhashsum_init_keccak_hasher(&h1, 0, 0, 0, 0)); + ASSERT(!libhashsum_init_keccak_hasher(&h2, 0, 0, 0, 1)); + ASSERT(!h1.finalise_const(&h1, NULL, 0, 0)); + ASSERT(!h2.finalise_const(&h2, NULL, 0, 0)); + ASSERT(!strcmp(h1.algorithm_string, "Keccak[r=1024,c=576,n=512]")); + ASSERT(!strcmp(h2.algorithm_string, "Keccak[r=1024,c=576,n=512]")); + ASSERT(!memcmp(h1.hash_output, h2.hash_output, h1.hash_size)); + ASSERT(!strcmp(hex(&h2), Z1)); + + ASSERT(!libhashsum_init_keccak_hasher(&h1, 0, 0, 0, 0)); + ASSERT(!libhashsum_init_keccak_hasher(&h2, 0, 0, 0, 200)); + ASSERT(!h1.finalise_const(&h1, NULL, 0, 0)); + ASSERT(!h2.finalise_const(&h2, NULL, 0, 0)); + ASSERT(!strcmp(h1.algorithm_string, "Keccak[r=1024,c=576,n=512]")); + ASSERT(!strcmp(h2.algorithm_string, "Keccak[r=1024,c=576,n=512,z=200]")); + ASSERT(memcmp(h1.hash_output, h2.hash_output, h1.hash_size)); + ASSERT(!strcmp(hex(&h2), Z200)); + + ASSERT(!libhashsum_init_keccak_hasher(&h1, 0, 0, 0, 0)); + ASSERT(!libhashsum_init_keccak_hasher(&h2, 0, 0, 0, 2)); + ASSERT(!h1.finalise_const(&h1, NULL, 0, 0)); + ASSERT(!h2.finalise_const(&h2, NULL, 0, 0)); + ASSERT(!strcmp(h1.algorithm_string, "Keccak[r=1024,c=576,n=512]")); + ASSERT(!strcmp(h2.algorithm_string, "Keccak[r=1024,c=576,n=512,z=2]")); + ASSERT(memcmp(h1.hash_output, h2.hash_output, h1.hash_size)); + ASSERT(!strcmp(hex(&h2), Z2)); + +#undef Z1 +#undef Z2 +#undef Z200 + + return 0; +} + + +#endif diff --git a/t/keccak_224.c b/t/keccak_224.c new file mode 100644 index 0000000..2120d1c --- /dev/null +++ b/t/keccak_224.c @@ -0,0 +1,28 @@ +/* See LICENSE file for copyright and license details. */ +#ifdef SUPPORT_KECCAK +# define TEST +# include "../common.h" + + +static struct testcase testcases[] = { + {1, 0, "", "f71837502ba8e10837bdd8d365adb85591895602fc552b48b7390abd"}, + {0, 1, "\xff", "c4ab876a7f74504cb63158562f7a8f855dfde3c6f005a3f2e8feed0d"}, + {0, 1, "\x7f", "c4ab876a7f74504cb63158562f7a8f855dfde3c6f005a3f2e8feed0d"}, + {0, 1, "\x01", "c4ab876a7f74504cb63158562f7a8f855dfde3c6f005a3f2e8feed0d"}, + {0, 1, "\xfe", "860e3ec314c5cbf19c1a4314e9ea8cb85cecd18bd850b42f5c6f2a07"}, + {0, 1, "\x7e", "860e3ec314c5cbf19c1a4314e9ea8cb85cecd18bd850b42f5c6f2a07"}, + {0, 1, "\x00", "860e3ec314c5cbf19c1a4314e9ea8cb85cecd18bd850b42f5c6f2a07"} +}; + + +#else +# define TEST_UNSUPPORTED +# include "../common.h" +#endif + + +int +main(void) +{ + TEST_MAIN("Keccak-224", KECCAK_224); +} diff --git a/t/keccak_256.c b/t/keccak_256.c new file mode 100644 index 0000000..1ab7a76 --- /dev/null +++ b/t/keccak_256.c @@ -0,0 +1,28 @@ +/* See LICENSE file for copyright and license details. */ +#ifdef SUPPORT_KECCAK +# define TEST +# include "../common.h" + + +static struct testcase testcases[] = { + {1, 0, "", "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"}, + {0, 1, "\xff", "1f9e121db558ff4a6111d06e48b47aa9e8c968222397c5867ed627c82a5bcce4"}, + {0, 1, "\x7f", "1f9e121db558ff4a6111d06e48b47aa9e8c968222397c5867ed627c82a5bcce4"}, + {0, 1, "\x01", "1f9e121db558ff4a6111d06e48b47aa9e8c968222397c5867ed627c82a5bcce4"}, + {0, 1, "\xfe", "c3e5cb55999eeff4e07b7effec77582d0a5a11a94fc268a872493099273992e1"}, + {0, 1, "\x7e", "c3e5cb55999eeff4e07b7effec77582d0a5a11a94fc268a872493099273992e1"}, + {0, 1, "\x00", "c3e5cb55999eeff4e07b7effec77582d0a5a11a94fc268a872493099273992e1"} +}; + + +#else +# define TEST_UNSUPPORTED +# include "../common.h" +#endif + + +int +main(void) +{ + TEST_MAIN("Keccak-256", KECCAK_256); +} diff --git a/t/keccak_384.c b/t/keccak_384.c new file mode 100644 index 0000000..9ac068b --- /dev/null +++ b/t/keccak_384.c @@ -0,0 +1,28 @@ +/* See LICENSE file for copyright and license details. */ +#ifdef SUPPORT_KECCAK +# define TEST +# include "../common.h" + + +static struct testcase testcases[] = { + {1, 0, "", "2c23146a63a29acf99e73b88f8c24eaa7dc60aa771780ccc006afbfa8fe2479b2dd2b21362337441ac12b515911957ff"}, + {0, 1, "\xff", "087f1bc0629ee5a186d63b2aa285ad6c8ebc1efffa177ae68801867fa59bad0fe90cfed735b2a86659209b24e1fc4031"}, + {0, 1, "\x7f", "087f1bc0629ee5a186d63b2aa285ad6c8ebc1efffa177ae68801867fa59bad0fe90cfed735b2a86659209b24e1fc4031"}, + {0, 1, "\x01", "087f1bc0629ee5a186d63b2aa285ad6c8ebc1efffa177ae68801867fa59bad0fe90cfed735b2a86659209b24e1fc4031"}, + {0, 1, "\xfe", "4c6d164043571a32e169a527ca3503ea391bf91f22287215df75ea243d53a0d042bc66efe2956d8606a24f39e255a081"}, + {0, 1, "\x7e", "4c6d164043571a32e169a527ca3503ea391bf91f22287215df75ea243d53a0d042bc66efe2956d8606a24f39e255a081"}, + {0, 1, "\x00", "4c6d164043571a32e169a527ca3503ea391bf91f22287215df75ea243d53a0d042bc66efe2956d8606a24f39e255a081"} +}; + + +#else +# define TEST_UNSUPPORTED +# include "../common.h" +#endif + + +int +main(void) +{ + TEST_MAIN("Keccak-384", KECCAK_384); +} diff --git a/t/keccak_512.c b/t/keccak_512.c new file mode 100644 index 0000000..93943d1 --- /dev/null +++ b/t/keccak_512.c @@ -0,0 +1,42 @@ +/* See LICENSE file for copyright and license details. */ +#ifdef SUPPORT_KECCAK +# define TEST +# include "../common.h" + + +static struct testcase testcases[] = { + {1, 0, "", + "0eab42de4c3ceb9235fc91acffe746b29c29a8c366b7c60e4e67c466f36a4304" + "c00fa9caf9d87976ba469bcbe06713b435f091ef2769fb160cdab33d3670680e"}, + {0, 1, "\xff", + "23309d222712996f6caacd52656a11467fc96d8b2666803b2f5ab9019be1f3b1" + "2044f09cdb3c38050ecab7d0f285a6f31ab1f559e645182ffc506289792e9ef9"}, + {0, 1, "\x7f", + "23309d222712996f6caacd52656a11467fc96d8b2666803b2f5ab9019be1f3b1" + "2044f09cdb3c38050ecab7d0f285a6f31ab1f559e645182ffc506289792e9ef9"}, + {0, 1, "\x01", + "23309d222712996f6caacd52656a11467fc96d8b2666803b2f5ab9019be1f3b1" + "2044f09cdb3c38050ecab7d0f285a6f31ab1f559e645182ffc506289792e9ef9"}, + {0, 1, "\xfe", + "7d9025bb145a0814083e934baa80ede67322651de52062bf9eb93623c37efc74" + "c62240cf8539107f9210c1e1126f79cbaeda6b82b4a8ce6821589c403fa76b9a"}, + {0, 1, "\x7e", + "7d9025bb145a0814083e934baa80ede67322651de52062bf9eb93623c37efc74" + "c62240cf8539107f9210c1e1126f79cbaeda6b82b4a8ce6821589c403fa76b9a"}, + {0, 1, "\x00", + "7d9025bb145a0814083e934baa80ede67322651de52062bf9eb93623c37efc74" + "c62240cf8539107f9210c1e1126f79cbaeda6b82b4a8ce6821589c403fa76b9a"} +}; + + +#else +# define TEST_UNSUPPORTED +# include "../common.h" +#endif + + +int +main(void) +{ + TEST_MAIN("Keccak-512", KECCAK_512); +} @@ -0,0 +1,33 @@ +/* See LICENSE file for copyright and license details. */ +#ifdef SUPPORT_MD2 +# define TEST +# define NO_CUSTOM_HASH_BUFFER_SUPPORT +# include "../common.h" + + +static struct testcase testcases[] = { + {1, 0, "The quick brown fox jumps over the lazy dog", "03d85a0d629d2c442e987525319fc471"}, + {1, 0, "The quick brown fox jumps over the lazy cog", "6b890c9292668cdbbfda00a4ebf31f05"}, + {1, 0, "", "8350e5a3e24c153df2275c9f80692773"}, + {1, 0, "a", "32ec01ec4a6dac72c0ab96fb34c0b5d1"}, + {1, 0, "abc", "da853b0d3f88d99b30283a69e6ded6bb"}, + {1, 0, "message digest", "ab4f496bfb2a530b219ff33031fe06b0"}, + {1, 0, "abcdefghijklmnopqrstuvwxyz", "4e8ddff3650292ab5a4108c3aa47940b"}, + {1, 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "da33def2a42df13975352846c30338cd"}, + {1, 0, "12345678901234567890123456789012345678901234567890123456789012345678901234567890", "d5976f79d83d3a0dc9806c3c66f3efd8"}, + {1, 0, "1234567890123456789012345678901234567890123456789012345678901234", "1a07a94849157fc19442f42e84225ebd"}, + {1000000UL, 0, "a", NULL} +}; + + +#else +# define TEST_UNSUPPORTED +# include "../common.h" +#endif + + +int +main(void) +{ + TEST_MAIN("MD2", MD2); +} @@ -0,0 +1,38 @@ +/* See LICENSE file for copyright and license details. */ +#ifdef SUPPORT_MD4 +# define TEST +# include "../common.h" + + +static struct testcase testcases[] = { + {1, 0, "The quick brown fox jumps over the lazy dog", "1bee69a46ba811185c194762abaeae90"}, + {1, 0, "The quick brown fox jumps over the lazy cog", "b86e130ce7028da59e672d56ad0113df"}, + {1, 0, "", "31d6cfe0d16ae931b73c59d7e0c089c0"}, + {1, 0, "a", "bde52cb31de33e46245e05fbdbd6fb24"}, + {1, 0, "abc", "a448017aaf21d8525fc10ae87aa6729d"}, + {1, 0, "message digest", "d9130a8164549fe818874806e1c7014b"}, + {1, 0, "abcdefghijklmnopqrstuvwxyz", "d79e1c308aa5bbcdeea8ed63df412da9"}, + {1, 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "043f8582f241db351ce627e153e7f0e4"}, + {1, 0, "12345678901234567890123456789012345678901234567890123456789012345678901234567890", "e33b4ddc9c38f2199c3e7b164fcc0536"}, + {1, 0, "1234567890123456789012345678901234567890123456789012345678901234", "c30a2de7d6eb547b4ceb82d65e28c029"}, + {1000000UL, 0, "a", NULL}, + {0, 1, "\xff", "15f8f7419944ac564526a3c65da2c5f3"}, + {0, 1, "\x7f", "15f8f7419944ac564526a3c65da2c5f3"}, + {0, 1, "\x01", "15f8f7419944ac564526a3c65da2c5f3"}, + {0, 1, "\xfe", "8d62ecbf6ffbc49dec08bb4c537189bb"}, + {0, 1, "\x7e", "8d62ecbf6ffbc49dec08bb4c537189bb"}, + {0, 1, "\x00", "8d62ecbf6ffbc49dec08bb4c537189bb"} +}; + + +#else +# define TEST_UNSUPPORTED +# include "../common.h" +#endif + + +int +main(void) +{ + TEST_MAIN("MD4", MD4); +} @@ -0,0 +1,129 @@ +/* See LICENSE file for copyright and license details. */ +#ifdef SUPPORT_MD5 +# define TEST +# include "../common.h" + + +static struct testcase testcases[] = { + {1, 0, "", "d41d8cd98f00b204e9800998ecf8427e"}, + {1, 0, "a\n", "60b725f10c9c85c70d97880dfe8191b3"}, + {1, 0, "a", "0cc175b9c0f1b6a831c399e269772661"}, + {1, 0, "\n", "68b329da9893e34099c7d8ad5cb9c940"}, + {1, 0, "\n\n", "e1c06d85ae7b8b032bef47e42e4c08f9"}, + {1, 40, "\0\0\0\0\n", "220837fefd71ea604ab9f99017c9cb0e"}, + {1, 0, "abc", "900150983cd24fb0d6963f7d28e17f72"}, + {1, 0, "The quick brown fox jumps over the lazy dog", + "9e107d9d372bb6826bd81d3542a419d6"}, + {1, 0, "The quick brown fox jumps over the lazy dog.", + "e4d909c290d0fb1ca068ffaddf22cbd0"}, + {1, 0, "a\nb\nc\nd\ne\n", + "1065e32f2cfab7352c6d3211f5447069"}, + {1, 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", + "d174ab98d277d9f5a5611c2c9f419d9f"}, + {1, 0, "12345678901234567890123456789012345678901234567890123456789012345678901234567890", + "57edf4a22be3c955ac49da2e2107b67a"}, + {1, 0, "abcdefghijklmnopqrstuvwxyz", + "c3fcd3d76192e4007dfb496cca67e13b"}, + {1UL, 0, "x", "9dd4e461268c8034f5c8564e155c67a6"}, + {2UL, 0, "x", "9336ebf25087d91c818ee6e9ec29f8c1"}, + {3UL, 0, "x", "f561aaf6ef0bf14d4208bb46a4ccb3ad"}, + {4UL, 0, "x", "ea416ed0759d46a8de58f63a59077499"}, + {5UL, 0, "x", "fb0e22c79ac75679e9881e6ba183b354"}, + {6UL, 0, "x", "dad3a37aa9d50688b5157698acfd7aee"}, + {7UL, 0, "x", "04adb4e2f055c978c9bb101ee1bc5cd4"}, + {8UL, 0, "x", "0b0cfc07fca81c956ab9181d8576f4a8"}, + {9UL, 0, "x", "aba369f7d2b28a9098a0a26feb7dc965"}, + {10UL, 0, "x", "336311a016184326ddbdd61edd4eeb52"}, + {11UL, 0, "x", "dcb740b2c2836cb11f707d63e6ac664f"}, + {12UL, 0, "x", "f94c84fac5cb091c60bb143cb957d229"}, + {13UL, 0, "x", "df7c0a3fa59809752be392c52c4a0559"}, + {14UL, 0, "x", "4e619f5b28df4a9744963e6700abe7ca"}, + {15UL, 0, "x", "de59bd9061c93855e3fdd416e26f27a6"}, + {16UL, 0, "x", "45ed9cc2f92b77cd8b2f5bd59ff635f8"}, + {17UL, 0, "x", "3ef82839679f05ef260e3ac982de93cd"}, + {18UL, 0, "x", "40e6267e5814c629b8e292735a77e2a9"}, + {19UL, 0, "x", "079080d02c875b5a30be6e1e59ce6aa3"}, + {20UL, 0, "x", "baf1da0e2b9065ab5edd36ca00ed1826"}, + {28UL, 0, "x", "cd25b7f1c589ff14b9e9c0c5c2555ff2"}, + {29UL, 0, "x", "0d046efba26ac1a3f561246081c086e7"}, + {30UL, 0, "x", "4495c1948d806f6dd8cbd8e15f7e254a"}, + {31UL, 0, "x", "48e95c91781dcf2c5eb90da6e8dcc14d"}, + {32UL, 0, "x", "dc8fe1d6497ebd23f5975d8d2a1c5e81"}, + {33UL, 0, "x", "b7b82191a246d3563ed060e298add91d"}, + {34UL, 0, "x", "07e932fcd783c8deab1d20a49ed80c39"}, + {35UL, 0, "x", "d77c54ec53a4ef5d5f81ed5685560e31"}, + {36UL, 0, "x", "7c3f98f113332d38d08b5e9014792ba0"}, + {60UL, 0, "x", "1198000c11968f9368e02d6da57ec147"}, + {61UL, 0, "x", "ee8c65d71323cc65e6e8535663ea817c"}, + {62UL, 0, "x", "31f6affeacbf0a8196f061a4e49a8a15"}, + {63UL, 0, "x", "7dc2ca208106a2f703567bdff99d8981"}, + {64UL, 0, "x", "c1bb4f81d892b2d57947682aeb252456"}, + {65UL, 0, "x", "1bc932052302d074bdec39795fe00cf6"}, + {66UL, 0, "x", "3c8d35046511f6b1b05e721d4f60256e"}, + {67UL, 0, "x", "4bbca3f0abeaab4b7342a77e75f31d58"}, + {68UL, 0, "x", "ffec2ae499ea42e2a8fa19b167e873dc"}, + {124UL, 0, "x", "a35da70d31690b66cabdd4288671c263"}, + {125UL, 0, "x", "09caa6eb477f42e8e19f5f3b4b42d849"}, + {126UL, 0, "x", "8dd415f6a3a27df0899c8c6b54ea27ed"}, + {127UL, 0, "x", "a0b28c1da68705c2ff883fe279b72753"}, + {128UL, 0, "x", "d69cb61a6ee87200676eb0d4b90edbcb"}, + {129UL, 0, "x", "3926841d393c00c3f36260e5ace10dc1"}, + {130UL, 0, "x", "cfc92f41305ca00c9f9584bf67ae1b54"}, + {131UL, 0, "x", "6cc46654feb888930c09d25f5c4d45a8"}, + {132UL, 0, "x", "326c994f14a44790edbe0aa08dce10c5"}, + {252UL, 0, "x", "96897c58b701383553034d7027eef698"}, + {253UL, 0, "x", "1a244ae9fefe18985dbeec401592f821"}, + {254UL, 0, "x", "1bfbf8d01c1d8d19664a9834edf6a182"}, + {255UL, 0, "x", "cb3ead3ffb3d928128c57a88ddc023c9"}, + {256UL, 0, "x", "c7a139a2b8e92164276f778917ba10b9"}, + {257UL, 0, "x", "d36a37136d406826a19f8d222217fcf2"}, + {258UL, 0, "x", "b53fb5e097ce58fa2e4ca1ddd9cb4c17"}, + {259UL, 0, "x", "212075aa9ea2f4dfcd787fd722c6ca36"}, + {260UL, 0, "x", "a9c279980354afb717ecb974915f5735"}, + {508UL, 0, "x", "4dc1fad83b9ed2d53e6ee24ec6e3cd77"}, + {509UL, 0, "x", "d5e9a6bb15c49dd852836ad1e3b7cc55"}, + {510UL, 0, "x", "68c0b8dbb509c84b314782acb7fa8f52"}, + {511UL, 0, "x", "dc1c50246bf0c9d112ae426500a49ccd"}, + {512UL, 0, "x", "9147bc1f0f20e8ae1932e616b51240fb"}, + {513UL, 0, "x", "d70999aa02d6479b04bc87c1c60a5073"}, + {514UL, 0, "x", "51010e21c8ba2f8f37e312a2fa34795c"}, + {515UL, 0, "x", "7f5d20b68c0da40ce24d0124ad5ad67f"}, + {516UL, 0, "x", "2b6c8b791a19fd9de9dc5aba0ed7bf6d"}, + {1020UL, 0, "x", "b73908fc7f1175d53183e646f4298478"}, + {1021UL, 0, "x", "e52374c56cbf8a50e133ef7f8c9aeb50"}, + {1022UL, 0, "x", "5e4d064e9476082eb78ba62a31c0935c"}, + {1023UL, 0, "x", "7c944a22b4db95dd90b61331cafe605c"}, + {1024UL, 0, "x", "7265f4d211b56873a381d321f586e4a9"}, + {1025UL, 0, "x", "41b2b8ce59ecc0c64c9c7ecaae3002c3"}, + {1026UL, 0, "x", "aabf55b958bc5b71749ee9c64523933f"}, + {1027UL, 0, "x", "f8f06f8e36e9435183db627789cdd691"}, + {1028UL, 0, "x", "8f1c68e076235ba5f52bf16f41b12194"}, + {2044UL, 0, "x", "43c5028529ab5f64903b1e1459948a7f"}, + {2045UL, 0, "x", "ea156212359f7894058fa2cc4193b0d7"}, + {2046UL, 0, "x", "a77d0af5147801eceda2e059a6ee8eb4"}, + {2047UL, 0, "x", "5aa00f0f1280c998648ecae491964f66"}, + {2048UL, 0, "x", "cfb767f225d58469c5de3632a8803958"}, + {2049UL, 0, "x", "01ee208262ef50b8ea672d0865ad58fa"}, + {2050UL, 0, "x", "da23b925b41f6160146ade5dc7f65281"}, + {2051UL, 0, "x", "2583da14d43398956e19e24a6f591748"}, + {2052UL, 0, "x", "2388049a9674713a2e82cd59d2cc9241"}, + {0, 1, "\xff", "7e663710ae2348bf0deaca2c79311eae"}, + {0, 1, "\x7f", "7e663710ae2348bf0deaca2c79311eae"}, + {0, 1, "\x01", "7e663710ae2348bf0deaca2c79311eae"}, + {0, 1, "\xfe", "1da635b1430f171c657206fd69fee0e8"}, + {0, 1, "\x7e", "1da635b1430f171c657206fd69fee0e8"}, + {0, 1, "\x00", "1da635b1430f171c657206fd69fee0e8"} +}; + + +#else +# define TEST_UNSUPPORTED +# include "../common.h" +#endif + + +int +main(void) +{ + TEST_MAIN("MD5", MD5); +} diff --git a/t/misc-tests.c b/t/misc-tests.c new file mode 100644 index 0000000..3942bfb --- /dev/null +++ b/t/misc-tests.c @@ -0,0 +1,785 @@ +/* See LICENSE file for copyright and license details. */ +#include "../common.h" + + +#define ASSERT(ASSERTION)\ + do {\ + if ((ASSERTION))\ + break;\ + fprintf(stderr, "assertion `%s` at line %i failed\n", #ASSERTION, __LINE__);\ + exit(2);\ + } while (0) + + +static int +eq(struct libhashsum_hasher *a, struct libhashsum_hasher *b) +{ + if (a->algorithm != b->algorithm || + !a->algorithm_string != !b->algorithm_string || + a->input_block_size != b->input_block_size || + a->hash_size != b->hash_size || + !a->hash_output != !b->hash_output || + a->supports_non_whole_bytes != b->supports_non_whole_bytes || + a->process != b->process || + a->finalise_const != b->finalise_const || + a->finalise != b->finalise || + a->stretch != b->stretch || + a->destroy != b->destroy) + return 0; + if (a->hash_output && memcpy(a->hash_output, b->hash_output, a->hash_size)) + return 0; + if (a->algorithm_string && strcmp(a->algorithm_string, b->algorithm_string)) + return 0; + switch (a->algorithm) { + case LIBHASHSUM_MD2: + case LIBHASHSUM_MD4: + case LIBHASHSUM_MD5: + case LIBHASHSUM_RIPEMD_128: + case LIBHASHSUM_RIPEMD_160: + case LIBHASHSUM_RIPEMD_256: + case LIBHASHSUM_RIPEMD_320: + case LIBHASHSUM_SHA0: + case LIBHASHSUM_SHA1: + case LIBHASHSUM_SHA_224: + case LIBHASHSUM_SHA_256: + case LIBHASHSUM_SHA_384: + case LIBHASHSUM_SHA_512: + case LIBHASHSUM_SHA_512_224: + case LIBHASHSUM_SHA_512_256: + case LIBHASHSUM_BLAKE224: + case LIBHASHSUM_BLAKE256: + case LIBHASHSUM_BLAKE384: + case LIBHASHSUM_BLAKE512: + if (memcmp(&a->state, &b->state, sizeof(a->state))) + return 0; + break; + case LIBHASHSUM_BLAKE2S: +#ifdef LIBHASHSUM_INCLUDE_LIBBLAKE_STATE + if (memcmp(&a->state.blake2s.s, &b->state.blake2s.s, sizeof(a->state.blake2s.s))) + return 0; + if (a->state.blake2s.keybytes != b->state.blake2s.keybytes) + return 0; + if (a->state.blake2s.keybytes && memcmp(a->state.blake2s.buf, b->state.blake2s.buf, sizeof(a->state.blake2s.buf))) + return 0; +#endif + break; + case LIBHASHSUM_BLAKE2B: +#ifdef LIBHASHSUM_INCLUDE_LIBBLAKE_STATE + if (memcmp(&a->state.blake2b.s, &b->state.blake2b.s, sizeof(a->state.blake2b.s))) + return 0; + if (a->state.blake2b.keybytes != b->state.blake2b.keybytes) + return 0; + if (a->state.blake2b.keybytes && memcmp(a->state.blake2b.buf, b->state.blake2b.buf, sizeof(a->state.blake2b.buf))) + return 0; +#endif + break; + case LIBHASHSUM_KECCAK: + case LIBHASHSUM_KECCAK_224: + case LIBHASHSUM_KECCAK_256: + case LIBHASHSUM_KECCAK_384: + case LIBHASHSUM_KECCAK_512: + case LIBHASHSUM_SHA3_224: + case LIBHASHSUM_SHA3_256: + case LIBHASHSUM_SHA3_384: + case LIBHASHSUM_SHA3_512: + case LIBHASHSUM_SHAKE128: + case LIBHASHSUM_SHAKE256: + case LIBHASHSUM_SHAKE512: + case LIBHASHSUM_RAWSHAKE128: + case LIBHASHSUM_RAWSHAKE256: + case LIBHASHSUM_RAWSHAKE512: +#ifdef LIBHASHSUM_INCLUDE_LIBKECCAK_STATE + { + unsigned char *aM, *bM; + int r; + if (a->state.keccak.squeezes != b->state.keccak.squeezes || + a->state.keccak.suffix != b->state.keccak.suffix || + !a->state.keccak.s.M != !b->state.keccak.s.M) + return 0; + aM = a->state.keccak.s.M; + bM = b->state.keccak.s.M; + a->state.keccak.s.M = NULL; + b->state.keccak.s.M = NULL; + r = memcmp(&a->state.keccak.s, &b->state.keccak.s, sizeof(a->state.keccak.s)); + a->state.keccak.s.M = aM; + b->state.keccak.s.M = bM; + if (r) + return 0; + } +#endif + break; + default: + abort(); + } + return 1; +} + + +static void +test_blake(const char *salt) +{ + struct libhashsum_hasher hasher1, hasher2, hasher3; + int r; + + memset(&hasher1, 0xBC, sizeof(hasher1)); + memset(&hasher2, 0xBC, sizeof(hasher2)); + memset(&hasher3, 0xBC, sizeof(hasher3)); + errno = 0; + r = libhashsum_init_blake224_hasher(&hasher1, salt); + if (r) { + ASSERT(r == -1); + ASSERT(errno == ENOSYS); + errno = 0; + ASSERT(libhashsum_init_blakes_hasher(&hasher2, 224, salt) == -1); + ASSERT(errno == ENOSYS); + errno = 0; + ASSERT(libhashsum_init_blake_hasher(&hasher3, 224, salt, 16) == -1); + ASSERT(errno == ENOSYS); + } else { + ASSERT(r == 0); + ASSERT(libhashsum_init_blakes_hasher(&hasher2, 224, salt) == 0); + ASSERT(libhashsum_init_blake_hasher(&hasher3, 224, salt, 16) == 0); + ASSERT(eq(&hasher1, &hasher2)); + ASSERT(eq(&hasher1, &hasher3)); + if (salt) { + errno = 0; + ASSERT(libhashsum_init_blake_hasher(&hasher3, 224, salt, 0) == -1); + ASSERT(errno == EINVAL); + errno = 0; + ASSERT(libhashsum_init_blake_hasher(&hasher3, 224, salt, 8) == -1); + ASSERT(errno == EINVAL); + errno = 0; + ASSERT(libhashsum_init_blake_hasher(&hasher3, 224, salt, 17) == -1); + ASSERT(errno == EINVAL); + errno = 0; + ASSERT(libhashsum_init_blake_hasher(&hasher3, 224, salt, 32) == -1); + ASSERT(errno == EINVAL); + } else { + memset(&hasher3, 0xBC, sizeof(hasher3)); + ASSERT(libhashsum_init_blake_hasher(&hasher3, 224, salt, 0) == 0); + ASSERT(libhashsum_init_blake_hasher(&hasher3, 224, salt, 8) == 0); + ASSERT(libhashsum_init_blake_hasher(&hasher3, 224, salt, 17) == 0); + ASSERT(libhashsum_init_blake_hasher(&hasher3, 224, salt, 32) == 0); + ASSERT(eq(&hasher1, &hasher3)); + } + } + + memset(&hasher1, 0xBC, sizeof(hasher1)); + memset(&hasher2, 0xBC, sizeof(hasher2)); + memset(&hasher3, 0xBC, sizeof(hasher3)); + errno = 0; + r = libhashsum_init_blake256_hasher(&hasher1, salt); + if (r) { + ASSERT(r == -1); + ASSERT(errno == ENOSYS); + errno = 0; + ASSERT(libhashsum_init_blakes_hasher(&hasher2, 256, salt) == -1); + ASSERT(errno == ENOSYS); + errno = 0; + ASSERT(libhashsum_init_blake_hasher(&hasher3, 256, salt, 16) == -1); + ASSERT(errno == ENOSYS); + } else { + ASSERT(r == 0); + ASSERT(libhashsum_init_blakes_hasher(&hasher2, 256, salt) == 0); + ASSERT(libhashsum_init_blake_hasher(&hasher3, 256, salt, 16) == 0); + ASSERT(eq(&hasher1, &hasher2)); + ASSERT(eq(&hasher1, &hasher3)); + if (salt) { + errno = 0; + ASSERT(libhashsum_init_blake_hasher(&hasher3, 256, salt, 0) == -1); + ASSERT(errno == EINVAL); + errno = 0; + ASSERT(libhashsum_init_blake_hasher(&hasher3, 256, salt, 8) == -1); + ASSERT(errno == EINVAL); + errno = 0; + ASSERT(libhashsum_init_blake_hasher(&hasher3, 256, salt, 17) == -1); + ASSERT(errno == EINVAL); + errno = 0; + ASSERT(libhashsum_init_blake_hasher(&hasher3, 256, salt, 32) == -1); + ASSERT(errno == EINVAL); + } else { + memset(&hasher3, 0xBC, sizeof(hasher3)); + ASSERT(libhashsum_init_blake_hasher(&hasher3, 256, salt, 0) == 0); + ASSERT(libhashsum_init_blake_hasher(&hasher3, 256, salt, 8) == 0); + ASSERT(libhashsum_init_blake_hasher(&hasher3, 256, salt, 17) == 0); + ASSERT(libhashsum_init_blake_hasher(&hasher3, 256, salt, 32) == 0); + ASSERT(eq(&hasher1, &hasher3)); + } + } + + memset(&hasher1, 0xBC, sizeof(hasher1)); + memset(&hasher2, 0xBC, sizeof(hasher2)); + memset(&hasher3, 0xBC, sizeof(hasher3)); + errno = 0; + r = libhashsum_init_blake384_hasher(&hasher1, salt); + if (r) { + ASSERT(r == -1); + ASSERT(errno == ENOSYS); + errno = 0; + ASSERT(libhashsum_init_blakeb_hasher(&hasher2, 384, salt) == -1); + ASSERT(errno == ENOSYS); + errno = 0; + ASSERT(libhashsum_init_blake_hasher(&hasher3, 384, salt, 32) == -1); + ASSERT(errno == ENOSYS); + } else { + ASSERT(r == 0); + ASSERT(libhashsum_init_blakeb_hasher(&hasher2, 384, salt) == 0); + ASSERT(libhashsum_init_blake_hasher(&hasher3, 384, salt, 32) == 0); + ASSERT(eq(&hasher1, &hasher2)); + ASSERT(eq(&hasher1, &hasher3)); + if (salt) { + errno = 0; + ASSERT(libhashsum_init_blake_hasher(&hasher3, 384, salt, 0) == -1); + ASSERT(errno == EINVAL); + errno = 0; + ASSERT(libhashsum_init_blake_hasher(&hasher3, 384, salt, 16) == -1); + ASSERT(errno == EINVAL); + errno = 0; + ASSERT(libhashsum_init_blake_hasher(&hasher3, 384, salt, 33) == -1); + ASSERT(errno == EINVAL); + } else { + memset(&hasher3, 0xBC, sizeof(hasher3)); + ASSERT(libhashsum_init_blake_hasher(&hasher3, 384, salt, 0) == 0); + ASSERT(libhashsum_init_blake_hasher(&hasher3, 384, salt, 16) == 0); + ASSERT(libhashsum_init_blake_hasher(&hasher3, 384, salt, 33) == 0); + ASSERT(eq(&hasher1, &hasher3)); + } + } + + memset(&hasher1, 0xBC, sizeof(hasher1)); + memset(&hasher2, 0xBC, sizeof(hasher2)); + memset(&hasher3, 0xBC, sizeof(hasher3)); + errno = 0; + r = libhashsum_init_blake512_hasher(&hasher1, salt); + if (r) { + ASSERT(r == -1); + ASSERT(errno == ENOSYS); + errno = 0; + ASSERT(libhashsum_init_blakeb_hasher(&hasher2, 512, salt) == -1); + ASSERT(errno == ENOSYS); + errno = 0; + ASSERT(libhashsum_init_blake_hasher(&hasher3, 512, salt, 32) == -1); + ASSERT(errno == ENOSYS); + } else { + ASSERT(r == 0); + ASSERT(libhashsum_init_blakeb_hasher(&hasher2, 512, salt) == 0); + ASSERT(libhashsum_init_blake_hasher(&hasher3, 512, salt, 32) == 0); + ASSERT(eq(&hasher1, &hasher2)); + ASSERT(eq(&hasher1, &hasher3)); + if (salt) { + errno = 0; + ASSERT(libhashsum_init_blake_hasher(&hasher3, 512, salt, 0) == -1); + ASSERT(errno == EINVAL); + errno = 0; + ASSERT(libhashsum_init_blake_hasher(&hasher3, 512, salt, 16) == -1); + ASSERT(errno == EINVAL); + errno = 0; + ASSERT(libhashsum_init_blake_hasher(&hasher3, 512, salt, 33) == -1); + ASSERT(errno == EINVAL); + } else { + memset(&hasher3, 0xBC, sizeof(hasher3)); + ASSERT(libhashsum_init_blake_hasher(&hasher3, 512, salt, 0) == 0); + ASSERT(libhashsum_init_blake_hasher(&hasher3, 512, salt, 16) == 0); + ASSERT(libhashsum_init_blake_hasher(&hasher3, 512, salt, 33) == 0); + ASSERT(eq(&hasher1, &hasher3)); + } + } + +#ifdef SUPPORT_BLAKES + errno = 0; + ASSERT(libhashsum_init_blakes_hasher(&hasher2, 128, salt) == -1); + ASSERT(errno == EINVAL); + errno = 0; + ASSERT(libhashsum_init_blakes_hasher(&hasher2, 384, salt) == -1); + ASSERT(errno == EINVAL); +#else + errno = 0; + ASSERT(libhashsum_init_blakes_hasher(&hasher2, 128, salt) == -1); + ASSERT(errno == EINVAL || errno == ENOSYS); + errno = 0; + ASSERT(libhashsum_init_blakes_hasher(&hasher2, 384, salt) == -1); + ASSERT(errno == EINVAL || errno == ENOSYS); +#endif + +#ifdef SUPPORT_BLAKEB + errno = 0; + ASSERT(libhashsum_init_blakeb_hasher(&hasher2, 128, salt) == -1); + ASSERT(errno == EINVAL); + errno = 0; + ASSERT(libhashsum_init_blakeb_hasher(&hasher2, 256, salt) == -1); + ASSERT(errno == EINVAL); + errno = 0; + ASSERT(libhashsum_init_blakeb_hasher(&hasher2, 1024, salt) == -1); + ASSERT(errno == EINVAL); +#else + errno = 0; + ASSERT(libhashsum_init_blakeb_hasher(&hasher2, 128, salt) == -1); + ASSERT(errno == EINVAL || errno == ENOSYS); + errno = 0; + ASSERT(libhashsum_init_blakeb_hasher(&hasher2, 256, salt) == -1); + ASSERT(errno == EINVAL || errno == ENOSYS); + errno = 0; + ASSERT(libhashsum_init_blakeb_hasher(&hasher2, 1024, salt) == -1); + ASSERT(errno == EINVAL || errno == ENOSYS); +#endif + +#ifdef SUPPORT_BLAKE + errno = 0; + ASSERT(libhashsum_init_blake_hasher(&hasher2, 128, salt, 16) == -1); + ASSERT(errno == EINVAL); + errno = 0; + ASSERT(libhashsum_init_blake_hasher(&hasher2, 400, salt, 32) == -1); + ASSERT(errno == EINVAL); + errno = 0; + ASSERT(libhashsum_init_blake_hasher(&hasher2, 1024, salt, 32) == -1); + ASSERT(errno == EINVAL); +#else + errno = 0; + ASSERT(libhashsum_init_blake_hasher(&hasher2, 128, salt, 16) == -1); + ASSERT(errno == EINVAL || errno == ENOSYS); + errno = 0; + ASSERT(libhashsum_init_blake_hasher(&hasher2, 400, salt, 32) == -1); + ASSERT(errno == EINVAL || errno == ENOSYS); + errno = 0; + ASSERT(libhashsum_init_blake_hasher(&hasher2, 1024, salt, 32) == -1); + ASSERT(errno == EINVAL || errno == ENOSYS); +#endif +} + + +int +main(void) +{ + struct libhashsum_hasher hasher; + enum libhashsum_algorithm algo; + + test_blake(NULL); + test_blake("1234567890abcdefhijkABCDEFHIJK,.1234567890abcdefhijkABCDEFHIJK,."); + + errno = 0; + ASSERT(libhashsum_init_hasher(&hasher, -1) == -1); + ASSERT(errno == EINVAL); + + errno = 0; + ASSERT(libhashsum_init_hasher(&hasher, 999) == -1); + ASSERT(errno == EINVAL); + + errno = 0; + ASSERT(libhashsum_init_hasher(&hasher, LIBHASHSUM_KECCAK) == -1); + ASSERT(errno == EINVAL); + + ASSERT(libhashsum_get_algorithm_from_string(&algo, "") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "X") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "MD") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "MD55555") == 0); + + ASSERT(libhashsum_get_algorithm_from_string(&algo, "MD2") == 1 && algo == LIBHASHSUM_MD2); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "MD4") == 1 && algo == LIBHASHSUM_MD4); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "MD5") == 1 && algo == LIBHASHSUM_MD5); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "Keccak") == 1 && algo == LIBHASHSUM_KECCAK); + + ASSERT(libhashsum_get_algorithm_from_string(&algo, "md2") == 1 && algo == LIBHASHSUM_MD2); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "md4") == 1 && algo == LIBHASHSUM_MD4); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "md5") == 1 && algo == LIBHASHSUM_MD5); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "keccak") == 1 && algo == LIBHASHSUM_KECCAK); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "KECCAK") == 1 && algo == LIBHASHSUM_KECCAK); + + ASSERT(libhashsum_get_algorithm_from_string(&algo, "MD2[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "MD4[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "MD5[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "Keccak[]") == 1 && algo == LIBHASHSUM_KECCAK); + + ASSERT(libhashsum_get_algorithm_from_string(&algo, "RIPEMD-128") == 1 && algo == LIBHASHSUM_RIPEMD_128); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "RIPEMD-160") == 1 && algo == LIBHASHSUM_RIPEMD_160); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "RIPEMD-256") == 1 && algo == LIBHASHSUM_RIPEMD_256); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "RIPEMD-320") == 1 && algo == LIBHASHSUM_RIPEMD_320); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "RMD-128") == 1 && algo == LIBHASHSUM_RIPEMD_128); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "RMD-160") == 1 && algo == LIBHASHSUM_RIPEMD_160); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "RMD-256") == 1 && algo == LIBHASHSUM_RIPEMD_256); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "RMD-320") == 1 && algo == LIBHASHSUM_RIPEMD_320); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-0") == 1 && algo == LIBHASHSUM_SHA0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-1") == 1 && algo == LIBHASHSUM_SHA1); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-2-224") == 1 && algo == LIBHASHSUM_SHA_224); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-2-256") == 1 && algo == LIBHASHSUM_SHA_256); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-2-384") == 1 && algo == LIBHASHSUM_SHA_384); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-2-512") == 1 && algo == LIBHASHSUM_SHA_512); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-2-512/224") == 1 && algo == LIBHASHSUM_SHA_512_224); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-2-512/256") == 1 && algo == LIBHASHSUM_SHA_512_256); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-2-512-224") == 1 && algo == LIBHASHSUM_SHA_512_224); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-2-512-256") == 1 && algo == LIBHASHSUM_SHA_512_256); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-2-512_224") == 1 && algo == LIBHASHSUM_SHA_512_224); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-2-512_256") == 1 && algo == LIBHASHSUM_SHA_512_256); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-224") == 1 && algo == LIBHASHSUM_SHA_224); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-256") == 1 && algo == LIBHASHSUM_SHA_256); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-384") == 1 && algo == LIBHASHSUM_SHA_384); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-512") == 1 && algo == LIBHASHSUM_SHA_512); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-512/224") == 1 && algo == LIBHASHSUM_SHA_512_224); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-512/256") == 1 && algo == LIBHASHSUM_SHA_512_256); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-512-224") == 1 && algo == LIBHASHSUM_SHA_512_224); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-512-256") == 1 && algo == LIBHASHSUM_SHA_512_256); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-512_224") == 1 && algo == LIBHASHSUM_SHA_512_224); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-512_256") == 1 && algo == LIBHASHSUM_SHA_512_256); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "Keccak-224") == 1 && algo == LIBHASHSUM_KECCAK_224); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "Keccak-256") == 1 && algo == LIBHASHSUM_KECCAK_256); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "Keccak-384") == 1 && algo == LIBHASHSUM_KECCAK_384); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "Keccak-512") == 1 && algo == LIBHASHSUM_KECCAK_512); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-3-224") == 1 && algo == LIBHASHSUM_SHA3_224); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-3-256") == 1 && algo == LIBHASHSUM_SHA3_256); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-3-384") == 1 && algo == LIBHASHSUM_SHA3_384); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-3-512") == 1 && algo == LIBHASHSUM_SHA3_512); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHAKE-128") == 1 && algo == LIBHASHSUM_SHAKE128); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHAKE-256") == 1 && algo == LIBHASHSUM_SHAKE256); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHAKE-512") == 1 && algo == LIBHASHSUM_SHAKE512); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "RawSHAKE-128") == 1 && algo == LIBHASHSUM_RAWSHAKE128); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "RawSHAKE-256") == 1 && algo == LIBHASHSUM_RAWSHAKE256); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "RawSHAKE-512") == 1 && algo == LIBHASHSUM_RAWSHAKE512); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "BLAKE-224") == 1 && algo == LIBHASHSUM_BLAKE224); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "BLAKE-256") == 1 && algo == LIBHASHSUM_BLAKE256); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "BLAKE-384") == 1 && algo == LIBHASHSUM_BLAKE384); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "BLAKE-512") == 1 && algo == LIBHASHSUM_BLAKE512); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "B-224") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "B-256") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "B-384") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "B-512") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "BLAKE-2s") == 1 && algo == LIBHASHSUM_BLAKE2S); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "BLAKE-2b") == 1 && algo == LIBHASHSUM_BLAKE2B); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "B-2s") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "B-2b") == 0); + + ASSERT(libhashsum_get_algorithm_from_string(&algo, "RIPEMD128") == 1 && algo == LIBHASHSUM_RIPEMD_128); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "RIPEMD160") == 1 && algo == LIBHASHSUM_RIPEMD_160); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "RIPEMD256") == 1 && algo == LIBHASHSUM_RIPEMD_256); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "RIPEMD320") == 1 && algo == LIBHASHSUM_RIPEMD_320); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "RMD128") == 1 && algo == LIBHASHSUM_RIPEMD_128); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "RMD160") == 1 && algo == LIBHASHSUM_RIPEMD_160); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "RMD256") == 1 && algo == LIBHASHSUM_RIPEMD_256); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "RMD320") == 1 && algo == LIBHASHSUM_RIPEMD_320); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA0") == 1 && algo == LIBHASHSUM_SHA0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA1") == 1 && algo == LIBHASHSUM_SHA1); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA2-224") == 1 && algo == LIBHASHSUM_SHA_224); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA2-256") == 1 && algo == LIBHASHSUM_SHA_256); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA2-384") == 1 && algo == LIBHASHSUM_SHA_384); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA2-512") == 1 && algo == LIBHASHSUM_SHA_512); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA2-512/224") == 1 && algo == LIBHASHSUM_SHA_512_224); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA2-512/256") == 1 && algo == LIBHASHSUM_SHA_512_256); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA2-512-224") == 1 && algo == LIBHASHSUM_SHA_512_224); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA2-512-256") == 1 && algo == LIBHASHSUM_SHA_512_256); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA2-512_224") == 1 && algo == LIBHASHSUM_SHA_512_224); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA2-512_256") == 1 && algo == LIBHASHSUM_SHA_512_256); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA224") == 1 && algo == LIBHASHSUM_SHA_224); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA256") == 1 && algo == LIBHASHSUM_SHA_256); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA384") == 1 && algo == LIBHASHSUM_SHA_384); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA512") == 1 && algo == LIBHASHSUM_SHA_512); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA512/224") == 1 && algo == LIBHASHSUM_SHA_512_224); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA512/256") == 1 && algo == LIBHASHSUM_SHA_512_256); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA512-224") == 1 && algo == LIBHASHSUM_SHA_512_224); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA512-256") == 1 && algo == LIBHASHSUM_SHA_512_256); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA512_224") == 1 && algo == LIBHASHSUM_SHA_512_224); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA512_256") == 1 && algo == LIBHASHSUM_SHA_512_256); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "Keccak224") == 1 && algo == LIBHASHSUM_KECCAK_224); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "Keccak256") == 1 && algo == LIBHASHSUM_KECCAK_256); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "Keccak384") == 1 && algo == LIBHASHSUM_KECCAK_384); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "Keccak512") == 1 && algo == LIBHASHSUM_KECCAK_512); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA3-224") == 1 && algo == LIBHASHSUM_SHA3_224); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA3-256") == 1 && algo == LIBHASHSUM_SHA3_256); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA3-384") == 1 && algo == LIBHASHSUM_SHA3_384); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA3-512") == 1 && algo == LIBHASHSUM_SHA3_512); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHAKE128") == 1 && algo == LIBHASHSUM_SHAKE128); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHAKE256") == 1 && algo == LIBHASHSUM_SHAKE256); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHAKE512") == 1 && algo == LIBHASHSUM_SHAKE512); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "RawSHAKE128") == 1 && algo == LIBHASHSUM_RAWSHAKE128); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "RawSHAKE256") == 1 && algo == LIBHASHSUM_RAWSHAKE256); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "RawSHAKE512") == 1 && algo == LIBHASHSUM_RAWSHAKE512); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "BLAKE224") == 1 && algo == LIBHASHSUM_BLAKE224); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "BLAKE256") == 1 && algo == LIBHASHSUM_BLAKE256); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "BLAKE384") == 1 && algo == LIBHASHSUM_BLAKE384); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "BLAKE512") == 1 && algo == LIBHASHSUM_BLAKE512); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "B224") == 1 && algo == LIBHASHSUM_BLAKE224); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "B256") == 1 && algo == LIBHASHSUM_BLAKE256); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "B384") == 1 && algo == LIBHASHSUM_BLAKE384); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "B512") == 1 && algo == LIBHASHSUM_BLAKE512); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "BLAKE2s") == 1 && algo == LIBHASHSUM_BLAKE2S); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "BLAKE2b") == 1 && algo == LIBHASHSUM_BLAKE2B); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "B2s") == 1 && algo == LIBHASHSUM_BLAKE2S); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "B2b") == 1 && algo == LIBHASHSUM_BLAKE2B); + + ASSERT(libhashsum_get_algorithm_from_string(&algo, "RIPEMD-128[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "RIPEMD-160[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "RIPEMD-256[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "RIPEMD-320[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "RMD-128[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "RMD-160[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "RMD-256[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "RMD-320[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-0[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-1[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-2-224[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-2-256[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-2-384[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-2-512[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-2-512/224[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-2-512/256[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-2-512-224[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-2-512-256[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-2-512_224[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-2-512_256[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-224[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-256[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-384[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-512[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-512/224[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-512/256[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-512-224[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-512-256[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-512_224[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-512_256[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "Keccak-224[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "Keccak-256[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "Keccak-384[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "Keccak-512[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-3-224[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-3-256[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-3-384[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHA-3-512[]") == 0); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHAKE-128[]") == 1 && algo == LIBHASHSUM_SHAKE128); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHAKE-256[]") == 1 && algo == LIBHASHSUM_SHAKE256); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "SHAKE-512[]") == 1 && algo == LIBHASHSUM_SHAKE512); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "RawSHAKE-128[]") == 1 && algo == LIBHASHSUM_RAWSHAKE128); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "RawSHAKE-256[]") == 1 && algo == LIBHASHSUM_RAWSHAKE256); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "RawSHAKE-512[]") == 1 && algo == LIBHASHSUM_RAWSHAKE512); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "BLAKE-224[]") == 1 && algo == LIBHASHSUM_BLAKE224); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "BLAKE-256[]") == 1 && algo == LIBHASHSUM_BLAKE256); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "BLAKE-384[]") == 1 && algo == LIBHASHSUM_BLAKE384); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "BLAKE-512[]") == 1 && algo == LIBHASHSUM_BLAKE512); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "B224[]") == 1 && algo == LIBHASHSUM_BLAKE224); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "B256[]") == 1 && algo == LIBHASHSUM_BLAKE256); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "B384[]") == 1 && algo == LIBHASHSUM_BLAKE384); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "B512[]") == 1 && algo == LIBHASHSUM_BLAKE512); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "BLAKE2s[]") == 1 && algo == LIBHASHSUM_BLAKE2S); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "BLAKE2b[]") == 1 && algo == LIBHASHSUM_BLAKE2B); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "B2s[]") == 1 && algo == LIBHASHSUM_BLAKE2S); + ASSERT(libhashsum_get_algorithm_from_string(&algo, "B2b[]") == 1 && algo == LIBHASHSUM_BLAKE2B); + +#define CHECK(ALGO, CALL)\ + do {\ + struct libhashsum_hasher hasher2;\ + int r;\ + memset(&hasher, 0xBC, sizeof(hasher));\ + memset(&hasher2, 0xBC, sizeof(hasher2));\ + r = CALL;\ + if (r) {\ + ASSERT(r == -1);\ + ASSERT(errno == ENOSYS);\ + errno = 0;\ + ASSERT(libhashsum_init_hasher_from_string(&hasher2, ALGO) == -1);\ + ASSERT(errno == ENOSYS);\ + break;\ + }\ + ASSERT(libhashsum_init_hasher_from_string(&hasher2, ALGO) == 0);\ + ASSERT(eq(&hasher, &hasher2));\ + if (hasher.destroy) {\ + hasher.destroy(&hasher);\ + hasher2.destroy(&hasher2);\ + }\ + } while (0) + +#define SALT "\x01\x23\x45\x67\x89\xAb\xcd\xef\x01\x23\x45\x67\x89\xab\xcd\xef" + + CHECK("MD2", libhashsum_init_md2_hasher(&hasher)); + CHECK("MD4", libhashsum_init_md4_hasher(&hasher)); + CHECK("MD5", libhashsum_init_md5_hasher(&hasher)); + CHECK("RIPEMD128", libhashsum_init_ripemd_128_hasher(&hasher)); + CHECK("RIPEMD160", libhashsum_init_ripemd_160_hasher(&hasher)); + CHECK("RIPEMD256", libhashsum_init_ripemd_256_hasher(&hasher)); + CHECK("RIPEMD320", libhashsum_init_ripemd_320_hasher(&hasher)); + CHECK("RMD128", libhashsum_init_ripemd_128_hasher(&hasher)); + CHECK("RMD160", libhashsum_init_ripemd_160_hasher(&hasher)); + CHECK("RMD256", libhashsum_init_ripemd_256_hasher(&hasher)); + CHECK("RMD320", libhashsum_init_ripemd_320_hasher(&hasher)); + CHECK("SHA0", libhashsum_init_sha0_hasher(&hasher)); + CHECK("SHA1", libhashsum_init_sha1_hasher(&hasher)); + CHECK("SHA2-224", libhashsum_init_sha_224_hasher(&hasher)); + CHECK("SHA2-256", libhashsum_init_sha_256_hasher(&hasher)); + CHECK("SHA2-384", libhashsum_init_sha_384_hasher(&hasher)); + CHECK("SHA2-512", libhashsum_init_sha_512_hasher(&hasher)); + CHECK("SHA2-512/224", libhashsum_init_sha_512_224_hasher(&hasher)); + CHECK("SHA2-512/256", libhashsum_init_sha_512_256_hasher(&hasher)); + CHECK("SHA2-512-224", libhashsum_init_sha_512_224_hasher(&hasher)); + CHECK("SHA2-512-256", libhashsum_init_sha_512_256_hasher(&hasher)); + CHECK("SHA2-512_224", libhashsum_init_sha_512_224_hasher(&hasher)); + CHECK("SHA2-512_256", libhashsum_init_sha_512_256_hasher(&hasher)); + CHECK("SHA224", libhashsum_init_sha_224_hasher(&hasher)); + CHECK("SHA256", libhashsum_init_sha_256_hasher(&hasher)); + CHECK("SHA384", libhashsum_init_sha_384_hasher(&hasher)); + CHECK("SHA512", libhashsum_init_sha_512_hasher(&hasher)); + CHECK("SHA512/224", libhashsum_init_sha_512_224_hasher(&hasher)); + CHECK("SHA512/256", libhashsum_init_sha_512_256_hasher(&hasher)); + CHECK("SHA512-224", libhashsum_init_sha_512_224_hasher(&hasher)); + CHECK("SHA512-256", libhashsum_init_sha_512_256_hasher(&hasher)); + CHECK("SHA512_224", libhashsum_init_sha_512_224_hasher(&hasher)); + CHECK("SHA512_256", libhashsum_init_sha_512_256_hasher(&hasher)); + CHECK("Keccak224", libhashsum_init_keccak_224_hasher(&hasher)); + CHECK("Keccak256", libhashsum_init_keccak_256_hasher(&hasher)); + CHECK("Keccak384", libhashsum_init_keccak_384_hasher(&hasher)); + CHECK("Keccak512", libhashsum_init_keccak_512_hasher(&hasher)); + CHECK("SHA3-224", libhashsum_init_sha3_224_hasher(&hasher)); + CHECK("SHA3-256", libhashsum_init_sha3_256_hasher(&hasher)); + CHECK("SHA3-384", libhashsum_init_sha3_384_hasher(&hasher)); + CHECK("SHA3-512", libhashsum_init_sha3_512_hasher(&hasher)); + CHECK("SHAKE128", libhashsum_init_shake128_hasher(&hasher, 0)); + CHECK("SHAKE256", libhashsum_init_shake256_hasher(&hasher, 0)); + CHECK("SHAKE512", libhashsum_init_shake512_hasher(&hasher, 0)); + CHECK("SHAKE128[]", libhashsum_init_shake128_hasher(&hasher, 0)); + CHECK("SHAKE256[]", libhashsum_init_shake256_hasher(&hasher, 0)); + CHECK("SHAKE512[]", libhashsum_init_shake512_hasher(&hasher, 0)); + CHECK("SHAKE128[n=10000]", libhashsum_init_shake128_hasher(&hasher, 10000)); + CHECK("SHAKE256[n=10000]", libhashsum_init_shake256_hasher(&hasher, 10000)); + CHECK("SHAKE512[N=10000]", libhashsum_init_shake512_hasher(&hasher, 10000)); + CHECK("RawSHAKE128", libhashsum_init_rawshake128_hasher(&hasher, 0)); + CHECK("RawSHAKE256", libhashsum_init_rawshake256_hasher(&hasher, 0)); + CHECK("RawSHAKE512", libhashsum_init_rawshake512_hasher(&hasher, 0)); + CHECK("RawSHAKE128[]", libhashsum_init_rawshake128_hasher(&hasher, 0)); + CHECK("RawSHAKE256[]", libhashsum_init_rawshake256_hasher(&hasher, 0)); + CHECK("RawSHAKE512[]", libhashsum_init_rawshake512_hasher(&hasher, 0)); + CHECK("RawSHAKE128[n=200]", libhashsum_init_rawshake128_hasher(&hasher, 200)); + CHECK("RawSHAKE256[N=200]", libhashsum_init_rawshake256_hasher(&hasher, 200)); + CHECK("RawSHAKE512[n=200]", libhashsum_init_rawshake512_hasher(&hasher, 200)); + CHECK("BLAKE224", libhashsum_init_blake224_hasher(&hasher, NULL)); + CHECK("BLAKE256", libhashsum_init_blake256_hasher(&hasher, NULL)); + CHECK("BLAKE384", libhashsum_init_blake384_hasher(&hasher, NULL)); + CHECK("BLAKE512", libhashsum_init_blake512_hasher(&hasher, NULL)); + CHECK("BLAKE224[]", libhashsum_init_blake224_hasher(&hasher, NULL)); + CHECK("BLAKE256[]", libhashsum_init_blake256_hasher(&hasher, NULL)); + CHECK("BLAKE384[]", libhashsum_init_blake384_hasher(&hasher, NULL)); + CHECK("BLAKE512[]", libhashsum_init_blake512_hasher(&hasher, NULL)); + CHECK("BLAKE224[salt=00000000000000000000000000000000]", libhashsum_init_blake224_hasher(&hasher, NULL)); + CHECK("BLAKE224[salt=0123456789abcdef0123456789ABCDEF]", libhashsum_init_blake224_hasher(&hasher, SALT)); + CHECK("BLAKE256[SALT=0123456789abcdef0123456789ABCDEF]", libhashsum_init_blake256_hasher(&hasher, SALT)); + CHECK("BLAKE384[Salt=0123456789abcdef0123456789abcdef0123456789ABCDEF0123456789ABCDEF]", + libhashsum_init_blake384_hasher(&hasher, SALT SALT)); + CHECK("BLAKE512[SaLt=0123456789abcdef0123456789abcdef0123456789ABCDEF0123456789ABCDEF]", + libhashsum_init_blake512_hasher(&hasher, SALT SALT)); + CHECK("BLAKE224[salt=0x0123456789Abcdef0123456789abcdef]", libhashsum_init_blake224_hasher(&hasher, SALT)); + CHECK("BLAKE256[SALT=0X0123456789aBcdef0123456789abcdef]", libhashsum_init_blake256_hasher(&hasher, SALT)); + CHECK("BLAKE384[Salt=0x0123456789abCdef0123456789abcdef0123456789abcdef0123456789abcdef]", + libhashsum_init_blake384_hasher(&hasher, SALT SALT)); + CHECK("BLAKE512[SaLt=0X0123456789abcDef0123456789abcdef0123456789abcdef0123456789abcdef]", + libhashsum_init_blake512_hasher(&hasher, SALT SALT)); + CHECK("Keccak", libhashsum_init_keccak_hasher(&hasher, 0, 0, 0, 0)); + CHECK("Keccak[]", libhashsum_init_keccak_hasher(&hasher, 0, 0, 0, 0)); + CHECK("Keccak[r=256]", libhashsum_init_keccak_hasher(&hasher, 256, 0, 0, 0)); + CHECK("Keccak[R=256]", libhashsum_init_keccak_hasher(&hasher, 256, 0, 0, 0)); + CHECK("Keccak[c=256]", libhashsum_init_keccak_hasher(&hasher, 0, 256, 0, 0)); + CHECK("Keccak[C=256]", libhashsum_init_keccak_hasher(&hasher, 0, 256, 0, 0)); + CHECK("Keccak[n=256]", libhashsum_init_keccak_hasher(&hasher, 0, 0, 256, 0)); + CHECK("Keccak[N=256]", libhashsum_init_keccak_hasher(&hasher, 0, 0, 256, 0)); + CHECK("Keccak[z=256]", libhashsum_init_keccak_hasher(&hasher, 0, 0, 0, 256)); + CHECK("Keccak[Z=256]", libhashsum_init_keccak_hasher(&hasher, 0, 0, 0, 256)); + CHECK("Keccak[r=1200,c=400,n=100,z=60]", libhashsum_init_keccak_hasher(&hasher, 1200, 400, 100, 60)); + CHECK("Keccak[z=60,r=1200,c=400,n=100]", libhashsum_init_keccak_hasher(&hasher, 1200, 400, 100, 60)); + CHECK("BLAKE2s", libhashsum_init_blake2s_hasher(&hasher, 0, NULL, NULL, NULL, 0)); + CHECK("BLAKE2s[]", libhashsum_init_blake2s_hasher(&hasher, 0, NULL, NULL, NULL, 0)); + CHECK("BLAKE2s[n=128]", libhashsum_init_blake2s_hasher(&hasher, 128, NULL, NULL, NULL, 0)); + CHECK("BLAKE2s[Salt=0000000000000000]", libhashsum_init_blake2s_hasher(&hasher, 0, NULL, NULL, NULL, 0)); + CHECK("BLAKE2s[pePPer=0000000000000000]", libhashsum_init_blake2s_hasher(&hasher, 0, NULL, NULL, NULL, 0)); + CHECK("BLAKE2s[key=]", libhashsum_init_blake2s_hasher(&hasher, 0, NULL, NULL, NULL, 0)); + CHECK("BLAKE2s[salt=0123456789abcDEF]", libhashsum_init_blake2s_hasher(&hasher, 0, SALT, NULL, NULL, 0)); + CHECK("BLAKE2s[pepper=0123456789abcDEF]", libhashsum_init_blake2s_hasher(&hasher, 0, NULL, SALT, NULL, 0)); + CHECK("BLAKE2s[key=0123456789abcDEF]", libhashsum_init_blake2s_hasher(&hasher, 0, NULL, NULL, SALT, 8)); + CHECK("BLAKE2s[KEY=0123456789abcdef0123456789ABCDEF]", libhashsum_init_blake2s_hasher(&hasher, 0, NULL, NULL, SALT, 16)); + CHECK("BLAKE2s[key=0123456789abcdef0123456789ABCDEF0123456789abcdef0123456789ABCDEF]", + libhashsum_init_blake2s_hasher(&hasher, 0, NULL, NULL, SALT SALT, 32)); + CHECK("BLAKE2b", libhashsum_init_blake2b_hasher(&hasher, 0, NULL, NULL, NULL, 0)); + CHECK("BLAKE2b[]", libhashsum_init_blake2b_hasher(&hasher, 0, NULL, NULL, NULL, 0)); + CHECK("BLAKE2b[n=64]", libhashsum_init_blake2b_hasher(&hasher, 64, NULL, NULL, NULL, 0)); + CHECK("BLAKE2b[N=128]", libhashsum_init_blake2b_hasher(&hasher, 128, NULL, NULL, NULL, 0)); + CHECK("BLAKE2b[salt=0123456789abcDEF0123456789abcDEF]", + libhashsum_init_blake2b_hasher(&hasher, 0, SALT, NULL, NULL, 0)); + CHECK("BLAKE2b[pepper=0123456789abcDEF0123456789abcDEF]", + libhashsum_init_blake2b_hasher(&hasher, 0, NULL, SALT, NULL, 0)); + CHECK("BLAKE2b[key=0123456789abcDEF]", libhashsum_init_blake2b_hasher(&hasher, 0, NULL, NULL, SALT, 8)); + CHECK("BLAKE2b[salt=00000000000000000000000000000000]", + libhashsum_init_blake2b_hasher(&hasher, 0, NULL, NULL, NULL, 0)); + CHECK("BLAKE2b[pepper=00000000000000000000000000000000]", + libhashsum_init_blake2b_hasher(&hasher, 0, NULL, NULL, NULL, 0)); + CHECK("BLAKE2b[key=]", libhashsum_init_blake2b_hasher(&hasher, 0, NULL, NULL, NULL, 0)); + CHECK("BLAKE2b[key=0123456789abcdef0123456789ABCDEF]", libhashsum_init_blake2b_hasher(&hasher, 0, NULL, NULL, SALT, 16)); + CHECK("BLAKE2b[key=0123456789abcdef0123456789ABCDEF0123456789abcdef0123456789ABCDEF]", + libhashsum_init_blake2b_hasher(&hasher, 0, NULL, NULL, SALT SALT, 32)); + CHECK("BLAKE2b[key=0123456789abcdef0123456789ABCDEF0123456789abcdef0123456789ABCDEF" + "0123456789abcdef0123456789ABCDEF0123456789abcdef0123456789ABCDEF]", + libhashsum_init_blake2b_hasher(&hasher, 0, NULL, NULL, SALT SALT, 64)); + +#undef CHECK +#undef SALT + + ASSERT(libhashsum_init_hasher_from_string(&hasher, "BLAKE2b[]sum") == -1 && errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "BLAKE256[]sum") == -1 && errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "BLAKE256[salt=]") == -1 && errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "BLAKE256[salt=zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz") == -1); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "BLAKE256[salt=00zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz") == -1); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "BLAKE256[salt=000zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz") == -1); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "BLAKE256[salt=00z0zzzzzzzzzzzzzzzzzzzzzzzzzzzzz") == -1); + ASSERT(errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "BLAKE256[salt=00000000]") == -1 && errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "BLAKE256[salt=1234567890abcdef1234567890abcdef" + "1234567890abcdef1234567890abcdef]")); + ASSERT(errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "SHAKE128[n]") == -1 && errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "SHAKE128[n=]") == -1 && errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "SHAKE128[n=0]") == -1 && errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "SHAKE128[n=1000,]") == -1 && errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "SHAKE128[,n=1000]") == -1 && errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "shake128[]sum") == -1 && errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "") == -1 && errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "X") == -1 && errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "Keccak[") == -1 && errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "Keccak[]sum") == -1 && errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "Keccak[n=256]sum") == -1 && errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "Keccak[r=0]") == -1 && errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "Keccak[c=0]") == -1 && errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "Keccak[n=0]") == -1 && errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "Keccak[z=0]") == -1 && errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "BLAKE2s[n=0]") == -1 && errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "BLAKE2b[n=0]") == -1 && errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "BLAKE2s[salt=00000000000000]") == -1 && errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "BLAKE2b[salt=000000000000000000000000000000]") == -1); + ASSERT(errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "BLAKE2s[salt=000000000000000000]") == -1 && errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "BLAKE2b[salt=0000000000000000000000000000000000]") == -1); + ASSERT(errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "BLAKE2s[pepper=00000000000000]") == -1 && errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "BLAKE2b[pepper=000000000000000000000000000000]") == -1); + ASSERT(errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "BLAKE2s[pepper=000000000000000000]") == -1 && errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "BLAKE2b[pepper=0000000000000000000000000000000000]") == -1); + ASSERT(errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "BLAKE2s[salt=zzzzzzzzzzzzzzzz]") == -1 && errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "BLAKE2b[salt=zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz]") == -1); + ASSERT(errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "BLAKE2s[salt=00zzzzzzzzzzzzzz]") == -1 && errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "BLAKE2b[salt=00zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz]") == -1); + ASSERT(errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "BLAKE2s[salt=000zzzzzzzzzzzzz]") == -1 && errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "BLAKE2b[salt=000zzzzzzzzzzzzzzzzzzzzzzzzzzzzz]") == -1); + ASSERT(errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "BLAKE2s[salt=00z0zzzzzzzzzzzz]") == -1 && errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "BLAKE2b[salt=00z0zzzzzzzzzzzzzzzzzzzzzzzzzzzz]") == -1); + ASSERT(errno == EINVAL); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "BLAKE2s[key=00000000000000000000000000000000" + "0000000000000000000000000000000000" + "00000000000000000000000000000000" + "00000000000000000000000000000000]") == -1); + ASSERT(errno == EINVAL || errno == ENOSYS); + ASSERT(libhashsum_init_hasher_from_string(&hasher, "BLAKE2b[key=00000000000000000000000000000000" + "0000000000000000000000000000000000" + "00000000000000000000000000000000" + "00000000000000000000000000000000" + "00000000000000000000000000000000" + "00000000000000000000000000000000" + "00000000000000000000000000000000" + "00000000000000000000000000000000]") == -1); + ASSERT(errno == EINVAL || errno == ENOSYS); + + return 0; +} diff --git a/t/rawshake128.c b/t/rawshake128.c new file mode 100644 index 0000000..5abc8cf --- /dev/null +++ b/t/rawshake128.c @@ -0,0 +1,80 @@ +/* See LICENSE file for copyright and license details. */ +#ifdef SUPPORT_SHAKE +# define TEST +# include "../common.h" + + +#define MSG1600_32 "\xA3\xA3\xA3\xA3" +#define MSG1600_160 MSG1600_32 MSG1600_32 MSG1600_32 MSG1600_32 MSG1600_32 +#define MSG1600_800 MSG1600_160 MSG1600_160 MSG1600_160 MSG1600_160 MSG1600_160 +#define MSG1600 MSG1600_800 MSG1600_800 + + +static struct testcase testcases[] = { + {1, 0, "", "fa019a3b17630df6014853b5470773f1"}, + {1, 0, MSG1600, "96a8092bb1419aefb092e1935190b10e"} +}; + + +#else +# define TEST_UNSUPPORTED +# include "../common.h" +#endif + + +static int +main_test(void) +{ + TEST_MAIN("RawSHAKE128", RAWSHAKE128); +} + + +int +main(void) +{ +#ifdef SUPPORT_RAWSHAKE + struct libhashsum_hasher hasher; + char hexsum[1024]; +#endif + + int r = main_test(); + if (r) + return r; + + ASSERT(!libhashsum_init_rawshake128_hasher(&hasher, 8)); + ASSERT(!strcmp(hasher.algorithm_string, "RawSHAKE128[n=8]")); + ASSERT(!hasher.finalise_const(&hasher, "", 0, 0)); + ASSERT(hasher.hash_size == 1); + hex(hexsum, hasher.hash_output, hasher.hash_size); + ASSERT(!strcmp(hexsum, "fa")); + + ASSERT(!libhashsum_init_rawshake128_hasher(&hasher, 32)); + ASSERT(!strcmp(hasher.algorithm_string, "RawSHAKE128[n=32]")); + ASSERT(!hasher.finalise_const(&hasher, "", 0, 0)); + ASSERT(hasher.hash_size == 4); + hex(hexsum, hasher.hash_output, hasher.hash_size); + ASSERT(!strcmp(hexsum, "fa019a3b")); + + ASSERT(!libhashsum_init_rawshake128_hasher(&hasher, 32)); + ASSERT(!strcmp(hasher.algorithm_string, "RawSHAKE128[n=32]")); + ASSERT(!hasher.finalise_const(&hasher, MSG1600, 1600/8, 0)); + ASSERT(hasher.hash_size == 4); + hex(hexsum, hasher.hash_output, hasher.hash_size); + ASSERT(!strcmp(hexsum, "96a8092b")); + + ASSERT(!libhashsum_init_rawshake128_hasher(&hasher, 128)); + ASSERT(!strcmp(hasher.algorithm_string, "RawSHAKE128")); + ASSERT(!hasher.finalise_const(&hasher, MSG1600, 1600/8, 0)); + ASSERT(hasher.hash_size == 128/8); + hex(hexsum, hasher.hash_output, hasher.hash_size); + ASSERT(!strcmp(hexsum, "96a8092bb1419aefb092e1935190b10e")); + + ASSERT(!libhashsum_init_rawshake128_hasher(&hasher, 256)); + ASSERT(!strcmp(hasher.algorithm_string, "RawSHAKE128[n=256]")); + ASSERT(!hasher.finalise_const(&hasher, MSG1600, 1600/8, 0)); + ASSERT(hasher.hash_size == 256/8); + hex(hexsum, hasher.hash_output, hasher.hash_size); + ASSERT(!strcmp(hexsum, "96a8092bb1419aefb092e1935190b10e6323db3b2e8e1ecc546518f20820da7b")); + + return 0; +} diff --git a/t/rawshake256.c b/t/rawshake256.c new file mode 100644 index 0000000..6a03448 --- /dev/null +++ b/t/rawshake256.c @@ -0,0 +1,81 @@ +/* See LICENSE file for copyright and license details. */ +#ifdef SUPPORT_SHAKE +# define TEST +# include "../common.h" + + +#define MSG1600_32 "\xA3\xA3\xA3\xA3" +#define MSG1600_160 MSG1600_32 MSG1600_32 MSG1600_32 MSG1600_32 MSG1600_32 +#define MSG1600_800 MSG1600_160 MSG1600_160 MSG1600_160 MSG1600_160 MSG1600_160 +#define MSG1600 MSG1600_800 MSG1600_800 + + +static struct testcase testcases[] = { + {1, 0, "", "3a1108d4a90a31b85a10bdce77f4bfbdcc5b1d70dd405686f8bbde834aa1a410"}, + {1, 0, MSG1600, "f353b1260d7a0adb3f5c08bf292f3372ad3ee4630d56cf11ba15ddfb2e70e7a2"} +}; + + +#else +# define TEST_UNSUPPORTED +# include "../common.h" +#endif + + +static int +main_test(void) +{ + TEST_MAIN("RawSHAKE256", RAWSHAKE256); +} + + +int +main(void) +{ +#ifdef SUPPORT_RAWSHAKE + struct libhashsum_hasher hasher; + char hexsum[1024]; +#endif + + int r = main_test(); + if (r) + return r; + + ASSERT(!libhashsum_init_rawshake256_hasher(&hasher, 8)); + ASSERT(!strcmp(hasher.algorithm_string, "RawSHAKE256[n=8]")); + ASSERT(!hasher.finalise_const(&hasher, "", 0, 0)); + ASSERT(hasher.hash_size == 1); + hex(hexsum, hasher.hash_output, hasher.hash_size); + ASSERT(!strcmp(hexsum, "3a")); + + ASSERT(!libhashsum_init_rawshake256_hasher(&hasher, 32)); + ASSERT(!strcmp(hasher.algorithm_string, "RawSHAKE256[n=32]")); + ASSERT(!hasher.finalise_const(&hasher, "", 0, 0)); + ASSERT(hasher.hash_size == 4); + hex(hexsum, hasher.hash_output, hasher.hash_size); + ASSERT(!strcmp(hexsum, "3a1108d4")); + + ASSERT(!libhashsum_init_rawshake256_hasher(&hasher, 32)); + ASSERT(!strcmp(hasher.algorithm_string, "RawSHAKE256[n=32]")); + ASSERT(!hasher.finalise_const(&hasher, MSG1600, 1600/8, 0)); + ASSERT(hasher.hash_size == 4); + hex(hexsum, hasher.hash_output, hasher.hash_size); + ASSERT(!strcmp(hexsum, "f353b126")); + + ASSERT(!libhashsum_init_rawshake256_hasher(&hasher, 256)); + ASSERT(!strcmp(hasher.algorithm_string, "RawSHAKE256")); + ASSERT(!hasher.finalise_const(&hasher, MSG1600, 1600/8, 0)); + ASSERT(hasher.hash_size == 256/8); + hex(hexsum, hasher.hash_output, hasher.hash_size); + ASSERT(!strcmp(hexsum, "f353b1260d7a0adb3f5c08bf292f3372ad3ee4630d56cf11ba15ddfb2e70e7a2")); + + ASSERT(!libhashsum_init_rawshake256_hasher(&hasher, 512)); + ASSERT(!strcmp(hasher.algorithm_string, "RawSHAKE256[n=512]")); + ASSERT(!hasher.finalise_const(&hasher, MSG1600, 1600/8, 0)); + ASSERT(hasher.hash_size == 512/8); + hex(hexsum, hasher.hash_output, hasher.hash_size); + ASSERT(!strcmp(hexsum, "f353b1260d7a0adb3f5c08bf292f3372ad3ee4630d56cf11ba15ddfb2e70e7a2" + "3898431eb2500666c27251025869b0a6251029ba184e6075f5b3118cdc4abaa9")); + + return 0; +} diff --git a/t/rawshake512.c b/t/rawshake512.c new file mode 100644 index 0000000..710514d --- /dev/null +++ b/t/rawshake512.c @@ -0,0 +1,88 @@ +/* See LICENSE file for copyright and license details. */ +#ifdef SUPPORT_SHAKE +# define TEST +# include "../common.h" + + +#define MSG1600_32 "\xA3\xA3\xA3\xA3" +#define MSG1600_160 MSG1600_32 MSG1600_32 MSG1600_32 MSG1600_32 MSG1600_32 +#define MSG1600_800 MSG1600_160 MSG1600_160 MSG1600_160 MSG1600_160 MSG1600_160 +#define MSG1600 MSG1600_800 MSG1600_800 + + +static struct testcase testcases[] = { + {1, 0, "", + "0ae7dac687c3525d5c2a6c4119ea3968d43dfe69c2407a44d3de6b804d784530" + "462440e4881fd42785e1cb69af4f036d96d8ff1ee35d9b3fa4a2859f592fb2dc"}, + {1, 0, MSG1600, + "052eec877ef891c595c00dade1b0bc6717fde267635ef3883ff1f15161e83278" + "8078da28fbd2ae6d3309682b20c39aa40071b184f3db19a03b9251c8b0c323a7"} +}; + + +#else +# define TEST_UNSUPPORTED +# include "../common.h" +#endif + + +static int +main_test(void) +{ + TEST_MAIN("RawSHAKE512", RAWSHAKE512); +} + + +int +main(void) +{ +#ifdef SUPPORT_RAWSHAKE + struct libhashsum_hasher hasher; + char hexsum[1024]; +#endif + + int r = main_test(); + if (r) + return r; + + ASSERT(!libhashsum_init_rawshake512_hasher(&hasher, 8)); + ASSERT(!strcmp(hasher.algorithm_string, "RawSHAKE512[n=8]")); + ASSERT(!hasher.finalise_const(&hasher, "", 0, 0)); + ASSERT(hasher.hash_size == 1); + hex(hexsum, hasher.hash_output, hasher.hash_size); + ASSERT(!strcmp(hexsum, "0a")); + + ASSERT(!libhashsum_init_rawshake512_hasher(&hasher, 32)); + ASSERT(!strcmp(hasher.algorithm_string, "RawSHAKE512[n=32]")); + ASSERT(!hasher.finalise_const(&hasher, "", 0, 0)); + ASSERT(hasher.hash_size == 4); + hex(hexsum, hasher.hash_output, hasher.hash_size); + ASSERT(!strcmp(hexsum, "0ae7dac6")); + + ASSERT(!libhashsum_init_rawshake512_hasher(&hasher, 32)); + ASSERT(!strcmp(hasher.algorithm_string, "RawSHAKE512[n=32]")); + ASSERT(!hasher.finalise_const(&hasher, MSG1600, 1600/8, 0)); + ASSERT(hasher.hash_size == 4); + hex(hexsum, hasher.hash_output, hasher.hash_size); + ASSERT(!strcmp(hexsum, "052eec87")); + + ASSERT(!libhashsum_init_rawshake512_hasher(&hasher, 512)); + ASSERT(!strcmp(hasher.algorithm_string, "RawSHAKE512")); + ASSERT(!hasher.finalise_const(&hasher, MSG1600, 1600/8, 0)); + ASSERT(hasher.hash_size == 512/8); + hex(hexsum, hasher.hash_output, hasher.hash_size); + ASSERT(!strcmp(hexsum, "052eec877ef891c595c00dade1b0bc6717fde267635ef3883ff1f15161e83278" + "8078da28fbd2ae6d3309682b20c39aa40071b184f3db19a03b9251c8b0c323a7")); + + ASSERT(!libhashsum_init_rawshake512_hasher(&hasher, 1024)); + ASSERT(!strcmp(hasher.algorithm_string, "RawSHAKE512[n=1024]")); + ASSERT(!hasher.finalise_const(&hasher, MSG1600, 1600/8, 0)); + ASSERT(hasher.hash_size == 1024/8); + hex(hexsum, hasher.hash_output, hasher.hash_size); + ASSERT(!strcmp(hexsum, "052eec877ef891c595c00dade1b0bc6717fde267635ef3883ff1f15161e83278" + "8078da28fbd2ae6d3309682b20c39aa40071b184f3db19a03b9251c8b0c323a7" + "e1699d793f43a292de7ccbe4f8621284bfcce07db44a3c20e23e691aebc8cd81" + "a9bebcdbbe5137f38292d62a2d5f34022d06b579ab18e6659f6e9fcea36c8e5a")); + + return 0; +} diff --git a/t/ripemd-128.c b/t/ripemd-128.c new file mode 100644 index 0000000..199bdcf --- /dev/null +++ b/t/ripemd-128.c @@ -0,0 +1,36 @@ +/* See LICENSE file for copyright and license details. */ +#ifdef SUPPORT_RIPEMD_128 +# define TEST +# include "../common.h" + + +static struct testcase testcases[] = { + {1, 0, "", "cdf26213a150dc3ecb610f18f6b38b46"}, + {1, 0, "a", "86be7afa339d0fc7cfc785e72f578d33"}, + {1, 0, "abc", "c14a12199c66e4ba84636b0f69144c77"}, + {1, 0, "message digest", "9e327b3d6e523062afc1132d7df9d1b8"}, + {1, 0, "abcdefghijklmnopqrstuvwxyz", "fd2aa607f71dc8f510714922b371834e"}, + {1, 0, "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "a1aa0689d0fafa2ddc22e88b49133a06"}, + {1, 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "d1e959eb179c911faea4624c60c5c702"}, + {8, 0, "1234567890", "3f45ef194732c2dbb2c4a2c769795fa3"}, + {1000000UL, 0, "a", "4a7f5723f954eba1216c9d8f6320431f"}, + {0, 1, "\xff", "2b4535a3d10c346e06cacff50db484ca"}, + {0, 1, "\x7f", "2b4535a3d10c346e06cacff50db484ca"}, + {0, 1, "\x01", "2b4535a3d10c346e06cacff50db484ca"}, + {0, 1, "\xfe", "431f5ff8e69c47afd0212863079ce205"}, + {0, 1, "\x7e", "431f5ff8e69c47afd0212863079ce205"}, + {0, 1, "\x00", "431f5ff8e69c47afd0212863079ce205"} +}; + + +#else +# define TEST_UNSUPPORTED +# include "../common.h" +#endif + + +int +main(void) +{ + TEST_MAIN("RIPEMD-128", RIPEMD_128); +} diff --git a/t/ripemd-160.c b/t/ripemd-160.c new file mode 100644 index 0000000..326cc18 --- /dev/null +++ b/t/ripemd-160.c @@ -0,0 +1,36 @@ +/* See LICENSE file for copyright and license details. */ +#ifdef SUPPORT_RIPEMD_160 +# define TEST +# include "../common.h" + + +static struct testcase testcases[] = { + {1, 0, "", "9c1185a5c5e9fc54612808977ee8f548b2258d31"}, + {1, 0, "a", "0bdc9d2d256b3ee9daae347be6f4dc835a467ffe"}, + {1, 0, "abc", "8eb208f7e05d987a9b044a8e98c6b087f15a0bfc"}, + {1, 0, "message digest", "5d0689ef49d2fae572b881b123a85ffa21595f36"}, + {1, 0, "abcdefghijklmnopqrstuvwxyz", "f71c27109c692c1b56bbdceb5b9d2865b3708dbc"}, + {1, 0, "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "12a053384a9c0c88e405a06c27dcf49ada62eb2b"}, + {1, 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "b0e20b6e3116640286ed3a87a5713079b21f5189"}, + {8, 0, "1234567890", "9b752e45573d4b39f4dbd3323cab82bf63326bfb"}, + {1000000UL, 0, "a", "52783243c1697bdbe16d37f97f68f08325dc1528"}, + {0, 1, "\xff", "4cd9629a69fdd5fa1520047fa19b4b10480041c2"}, + {0, 1, "\x7f", "4cd9629a69fdd5fa1520047fa19b4b10480041c2"}, + {0, 1, "\x01", "4cd9629a69fdd5fa1520047fa19b4b10480041c2"}, + {0, 1, "\xfe", "63d03656713e6e8ea7b6be680328f9501f59f35e"}, + {0, 1, "\x7e", "63d03656713e6e8ea7b6be680328f9501f59f35e"}, + {0, 1, "\x00", "63d03656713e6e8ea7b6be680328f9501f59f35e"} +}; + + +#else +# define TEST_UNSUPPORTED +# include "../common.h" +#endif + + +int +main(void) +{ + TEST_MAIN("RIPEMD-160", RIPEMD_160); +} diff --git a/t/ripemd-256.c b/t/ripemd-256.c new file mode 100644 index 0000000..6706b6c --- /dev/null +++ b/t/ripemd-256.c @@ -0,0 +1,51 @@ +/* See LICENSE file for copyright and license details. */ +#ifdef SUPPORT_RIPEMD_256 +# define TEST +# include "../common.h" + + +static struct testcase testcases[] = { + {1, 0, "", + "02ba4c4e5f8ecd1877fc52d64d30e37a2d9774fb1e5d026380ae0168e3c5522d"}, + {1, 0, "a", + "f9333e45d857f5d90a91bab70a1eba0cfb1be4b0783c9acfcd883a9134692925"}, + {1, 0, "abc", + "afbd6e228b9d8cbbcef5ca2d03e6dba10ac0bc7dcbe4680e1e42d2e975459b65"}, + {1, 0, "message digest", + "87e971759a1ce47a514d5c914c392c9018c7c46bc14465554afcdf54a5070c0e"}, + {1, 0, "abcdefghijklmnopqrstuvwxyz", + "649d3034751ea216776bf9a18acc81bc7896118a5197968782dd1fd97d8d5133"}, + {1, 0, "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", + "3843045583aac6c8c8d9128573e7a9809afb2a0f34ccc36ea9e72f16f6368e3f"}, + {1, 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", + "5740a408ac16b720b84424ae931cbb1fe363d1d0bf4017f1a89f7ea6de77a0b8"}, + {8, 0, "1234567890", + "06fdcc7a409548aaf91368c06a6275b553e3f099bf0ea4edfd6778df89a890dd"}, + {1000000UL, 0, "a", + "ac953744e10e31514c150d4d8d7b677342e33399788296e43ae4850ce4f97978"}, + {0, 1, "\xff", + "837e2738bee15d14b8a6f984b992bcd404e2df2e18f70e89c60647cd90fcfff4"}, + {0, 1, "\x7f", + "837e2738bee15d14b8a6f984b992bcd404e2df2e18f70e89c60647cd90fcfff4"}, + {0, 1, "\x01", + "837e2738bee15d14b8a6f984b992bcd404e2df2e18f70e89c60647cd90fcfff4"}, + {0, 1, "\xfe", + "555d43ce2b77dbc1e292372ef850ff8c92ce2fa6fe778501daf37974948ccfcf"}, + {0, 1, "\x7e", + "555d43ce2b77dbc1e292372ef850ff8c92ce2fa6fe778501daf37974948ccfcf"}, + {0, 1, "\x00", + "555d43ce2b77dbc1e292372ef850ff8c92ce2fa6fe778501daf37974948ccfcf"} +}; + + +#else +# define TEST_UNSUPPORTED +# include "../common.h" +#endif + + +int +main(void) +{ + TEST_MAIN("RIPEMD-256", RIPEMD_256); +} diff --git a/t/ripemd-320.c b/t/ripemd-320.c new file mode 100644 index 0000000..49e3bd1 --- /dev/null +++ b/t/ripemd-320.c @@ -0,0 +1,51 @@ +/* See LICENSE file for copyright and license details. */ +#ifdef SUPPORT_RIPEMD_320 +# define TEST +# include "../common.h" + + +static struct testcase testcases[] = { + {1, 0, "", + "22d65d5661536cdc75c1fdf5c6de7b41b9f27325ebc61e8557177d705a0ec880151c3a32a00899b8"}, + {1, 0, "a", + "ce78850638f92658a5a585097579926dda667a5716562cfcf6fbe77f63542f99b04705d6970dff5d"}, + {1, 0, "abc", + "de4c01b3054f8930a79d09ae738e92301e5a17085beffdc1b8d116713e74f82fa942d64cdbc4682d"}, + {1, 0, "message digest", + "3a8e28502ed45d422f68844f9dd316e7b98533fa3f2a91d29f84d425c88d6b4eff727df66a7c0197"}, + {1, 0, "abcdefghijklmnopqrstuvwxyz", + "cabdb1810b92470a2093aa6bce05952c28348cf43ff60841975166bb40ed234004b8824463e6b009"}, + {1, 0, "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", + "d034a7950cf722021ba4b84df769a5de2060e259df4c9bb4a4268c0e935bbc7470a969c9d072a1ac"}, + {1, 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", + "ed544940c86d67f250d232c30b7b3e5770e0c60c8cb9a4cafe3b11388af9920e1b99230b843c86a4"}, + {8, 0, "1234567890", + "557888af5f6d8ed62ab66945c6d2a0a47ecd5341e915eb8fea1d0524955f825dc717e4a008ab2d42"}, + {1000000UL, 0, "a", + "bdee37f4371e20646b8b0d862dda16292ae36f40965e8c8509e63d1dbddecc503e2b63eb9245bb66"}, + {0, 1, "\xff", + "59eb0bae1fdf140b1d372eda1449048488cc9c9a584e758f33bae6df4ef6d8c472d79ec0e5bb86f9"}, + {0, 1, "\x7f", + "59eb0bae1fdf140b1d372eda1449048488cc9c9a584e758f33bae6df4ef6d8c472d79ec0e5bb86f9"}, + {0, 1, "\x01", + "59eb0bae1fdf140b1d372eda1449048488cc9c9a584e758f33bae6df4ef6d8c472d79ec0e5bb86f9"}, + {0, 1, "\xfe", + "4805943473099cd2e8b2ae39e0f5585444216b852f92d1eb5b4c98f182ad9848a378ad7f8b6ef325"}, + {0, 1, "\x7e", + "4805943473099cd2e8b2ae39e0f5585444216b852f92d1eb5b4c98f182ad9848a378ad7f8b6ef325"}, + {0, 1, "\x00", + "4805943473099cd2e8b2ae39e0f5585444216b852f92d1eb5b4c98f182ad9848a378ad7f8b6ef325"} +}; + + +#else +# define TEST_UNSUPPORTED +# include "../common.h" +#endif + + +int +main(void) +{ + TEST_MAIN("RIPEMD-320", RIPEMD_320); +} diff --git a/t/sha0.c b/t/sha0.c new file mode 100644 index 0000000..3905c91 --- /dev/null +++ b/t/sha0.c @@ -0,0 +1,28 @@ +/* See LICENSE file for copyright and license details. */ +#ifdef SUPPORT_SHA0 +# define TEST +# include "../common.h" + + +static struct testcase testcases[] = { + {1, 0, "abc", "0164b8a914cd2a5e74c4f7ff082c4d97f1edf880"}, + {0, 1, "\xff", "72eb6615d834148bbf63d5ddfe172a36a072a724"}, + {0, 1, "\x7f", "72eb6615d834148bbf63d5ddfe172a36a072a724"}, + {0, 1, "\x01", "72eb6615d834148bbf63d5ddfe172a36a072a724"}, + {0, 1, "\xfe", "b8b0ca781d45a96d2e71f798e7e26b5c2bc8b5c8"}, + {0, 1, "\x7e", "b8b0ca781d45a96d2e71f798e7e26b5c2bc8b5c8"}, + {0, 1, "\x00", "b8b0ca781d45a96d2e71f798e7e26b5c2bc8b5c8"} +}; + + +#else +# define TEST_UNSUPPORTED +# include "../common.h" +#endif + + +int +main(void) +{ + TEST_MAIN("SHA0", SHA0); +} diff --git a/t/sha1.c b/t/sha1.c new file mode 100644 index 0000000..7523dd6 --- /dev/null +++ b/t/sha1.c @@ -0,0 +1,50 @@ +/* See LICENSE file for copyright and license details. */ +#ifdef SUPPORT_SHA1 +# define TEST +# include "../common.h" + + +static struct testcase testcases[] = { + {1, 0, "", "da39a3ee5e6b4b0d3255bfef95601890afd80709"}, + {1, 0, "\xff", "85e53271e14006f0265921d02d4d736cdc580b0b"}, + {1, 0, "\xe5\xe0\x99\x24", "d1dffbc8a175dd8eebe0da87b1792b6dc1018e82"}, + {56UL, 8, "\0", "9438e360f578e12c0e0e8ed28e2c125c1cefee16"}, + {1000UL, 0, "Q", "49f1cfe3829963158e2b2b2cb5df086cee2e3bb0"}, + {1000UL, 0, "A", "3ae3644d6777a1f56a1defeabc74af9c4b313e49"}, + {1005UL, 0, "\x99", "18685d56c8bf67c3cee4443e9a78f65c30752f5d"}, + {1, 0, "abc", "a9993e364706816aba3e25717850c26c9cd0d89d"}, + {1, 0, "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", + "84983e441c3bd26ebaae4aa1f95129e5e54670f1"}, +# ifdef MASSIVE_TESTS + {0x20000000UL, 0, "A", "df3f26fce8fa7bec2c61d0506749a320ac7dc942"}, + {0x41000000UL, 8, "\0", "320c617b0b6ee1b6f9c3271eae135f40cae22c10"}, + {0x6000003FUL, 0, "\x84", "b20aa99b62e6a480fd93b4d24b2c19ffac649bb8"}, +# endif + {1000000UL, 8, "\0", "bef3595266a65a2ff36b700a75e8ed95c68210b6"}, + {0, 1, "\x00", "bb6b3e18f0115b57925241676f5b1ae88747b08a"}, + {0, 2, "\x01", "ec6b39952e1a3ec3ab3507185cf756181c84bbe2"}, + {0, 3, "\x04", "a37596ec13a0d2f9e6c0b8b96f9112823aa6d961"}, + {0, 4, "\x0d", "ba582f5967911beb91599684c2eb2baeefb78da7"}, + {0, 5, "\x09", "3320540d1c28b96ddd03eee1b186a8f2ae883fbe"}, + {0, 6, "\x08", "b372bd120957ebc3392cd060e131699d1fee6059"}, + {0, 7, "\x22", "04f31807151181ad0db278a1660526b0aeef64c2"}, + {0, 1, "\xff", "59c4526aa2cc59f9a5f56b5579ba7108e7ccb61a"}, + {0, 1, "\x7f", "59c4526aa2cc59f9a5f56b5579ba7108e7ccb61a"}, + {0, 1, "\x01", "59c4526aa2cc59f9a5f56b5579ba7108e7ccb61a"}, + {0, 1, "\xfe", "bb6b3e18f0115b57925241676f5b1ae88747b08a"}, + {0, 1, "\x7e", "bb6b3e18f0115b57925241676f5b1ae88747b08a"}, + {0, 1, "\x00", "bb6b3e18f0115b57925241676f5b1ae88747b08a"} +}; + + +#else +# define TEST_UNSUPPORTED +# include "../common.h" +#endif + + +int +main(void) +{ + TEST_MAIN("SHA1", SHA1); +} diff --git a/t/sha3_224.c b/t/sha3_224.c new file mode 100644 index 0000000..2519053 --- /dev/null +++ b/t/sha3_224.c @@ -0,0 +1,358 @@ +/* See LICENSE file for copyright and license details. */ +#ifdef SUPPORT_SHA3 +# define TEST +# include "../common.h" + + +static struct testcase testcases[] = { + {1, 0, "", "6b4e03423667dbb73b6e15454f0eb1abd4597f9a1b078e3f5b5a6bc7"}, + {1UL, 0, " ", "4cb5f87b01b38adc0e6f13f915668c2394cb1fb7a2795635b894dda1"}, + {2UL, 0, " ", "1a64ebab9deb5dd0428b68f9522b81c3db15c318665a820f280e38e3"}, + {3UL, 0, " ", "d838e74fd7808ccb161a8b67d43049b5b331601e858efe112618ed29"}, + {4UL, 0, " ", "a7df693f86a83049c6452db56af52c57bcca7246c2c11606e6a230b2"}, + {5UL, 0, " ", "9e1da0d8926041736b61617e896aded2203152fe4f56435ddb8512c9"}, + {6UL, 0, " ", "ad111c66761182a470fb8aaf23d93debac4ae844edf40fec64118ce8"}, + {7UL, 0, " ", "1b3e1b9e7ee9efd83a847e9a54b38227722197da0ec6481fcb7fa477"}, + {8UL, 0, " ", "bcb19154b2697ceab230a7264fd7c042fc069efabdcd657b300a0b13"}, + {9UL, 0, " ", "b8570a90b9cc7908e71b3cb5a098a32a20beec327aa7b9711d5a6e62"}, + {10UL, 0, " ", "10bd2239e774129ad7d6fcef1a07c601aa096d97abbec6af460f6c11"}, + {11UL, 0, " ", "a06e08351a9c706bd7251e51b32609501e40db29dde5e4c3d4b90fc5"}, + {12UL, 0, " ", "e0ebeba4160f2d899d82b1aaf8c8abed28d2543350ccb4c442de14b2"}, + {13UL, 0, " ", "f2371db8557e2facab26a16099b6174350223b9d1d4d179e38264bf9"}, + {14UL, 0, " ", "18a0d7b068e7d5ffda086f2e448d099422f1b358e68f2b42996a2015"}, + {15UL, 0, " ", "06e2d9303ec62532aea711319046b654a8596dd1361410f9f964d91a"}, + {16UL, 0, " ", "ff4cbd06962d3fae02e4afe3277df71112bc14e74dc3b287268cd057"}, + {17UL, 0, " ", "32ff4116c85b93ec457ce63e2c7038dad660ac905bf8e05845cde5ba"}, + {18UL, 0, " ", "efc9067b68668d57729c4a14a80cdec8773be97323b8f9b9d4ef99e0"}, + {19UL, 0, " ", "54a7324aabb83369ca93f41b66c47f907d9e90677ee1c723618d2a6e"}, + {20UL, 0, " ", "9b5896b60ce7c37794cf866d5c8b8f66f49326f9283b7677d89122ae"}, + {21UL, 0, " ", "fb54443a0acdbbea12b12dfdcd71f623eda3e2eb7f1eb4e0d58e8c3d"}, + {22UL, 0, " ", "764e6daf67d9a2f8ca871ca7b1bff5394c939d7acf2ed400c33726f1"}, + {23UL, 0, " ", "ba70fed2e7fa01851fc86d70d8e2f8ae46d02aa81beb5e9b7b8b8886"}, + {24UL, 0, " ", "dce29090fa1fc99fdea4a90f8a191812dadadf72bbddc339710e688a"}, + {25UL, 0, " ", "fa8043b456cecfa7e7d330daba8d39fa96ec0dce1c92df40ec7eca45"}, + {26UL, 0, " ", "05d6655e456684fec13b6619af2f0394cc39c6ffcf8126ec929947a7"}, + {27UL, 0, " ", "12c7092dee52a14a6272f721da9e1ce0c758555d8951bdad87b2da91"}, + {28UL, 0, " ", "12c61de3ed5da350a17c61682deaca1f68353af0d35462a9a024231b"}, + {29UL, 0, " ", "2e91e9698e6df0fb0459c61be7eeedfa3cdbf08e1ca6e29fd808f44a"}, + {30UL, 0, " ", "88b2dcb691f77593dbd6cc9f28138002adbfce3333c822d9696dac1c"}, + {31UL, 0, " ", "ce463fbf3794d21f793a92499f53d02a44f53c01fa3eb5b18e20dafc"}, + {32UL, 0, " ", "7eee3387239b3d9c4ac92fb1bed98c8246641da762187f5b63ea9bb8"}, + {33UL, 0, " ", "d29e190bda24dace1f3b5b45157832b1fce97e1cea9320d918a6a315"}, + {34UL, 0, " ", "bfe30323b49e91ff242575025fbea326c5351b0f8c9712babda2912e"}, + {35UL, 0, " ", "80a7fa5d858830f6c4bdaf99baa4061264ab5213a85d69d002b29f55"}, + {36UL, 0, " ", "519a4ea539502070782018bb54f610e60fc4a705a5aa6a5e449511b0"}, + {37UL, 0, " ", "73e74ee7e6dfb2dfaa44bcac4180b602c78e14455ab9459435f8825e"}, + {38UL, 0, " ", "de76b15308530e6feb7d658a5d9b8d405d9955da87531b83e457e4b8"}, + {39UL, 0, " ", "d82efb62daa169f11143e75ecd3eddb448d0789ca3e66b390ee74f2f"}, + {40UL, 0, " ", "03768212802432c868de50a057c500a6aea21e12248754b6d64eff41"}, + {41UL, 0, " ", "ce6a5bbe300077d8fc583ae46db88589fd27e21395455479550c979d"}, + {42UL, 0, " ", "9bb69a7ea6f590adf0b42f1589f0d6f98716bca86f8338f69da7f127"}, + {43UL, 0, " ", "b515a6ca9748b3fdd6da818ae4524c7ab7ced020611a403e33f73827"}, + {44UL, 0, " ", "f782b9e0ba4f1ddf599be79cb47318bdaa61261427480bd901d69f5d"}, + {45UL, 0, " ", "7ac893d28cae4bf18c0d8c3b2ba1dff009df61bcf438ef66149c9d47"}, + {46UL, 0, " ", "f18ab51a3cb90e8cc257619fb3e2ebd450338ab817fe929c31e7db1f"}, + {47UL, 0, " ", "cc7633ad00aa9d18a50b8ef77a2af4d4938ca4102e37d404a0422640"}, + {48UL, 0, " ", "49ba79273c4a52897c4dd2767fb14a1439a96121c47a69652c3a75a9"}, + {49UL, 0, " ", "8637e3e08196289674e16691210e4af50fc44375addc8930e3f40016"}, + {50UL, 0, " ", "4012c0272e94861368b163e49b665d21803ac058ce4f021b0d6756a3"}, + {51UL, 0, " ", "4f4099d786e8537d4ee4985bfef12a914505181dff81f26b67e7f9ce"}, + {52UL, 0, " ", "8232d738c5b463ff4da12231ee32fa1026581721477c948fcf6365cd"}, + {53UL, 0, " ", "bdf05fa77432070260422b9337186ae9ba578c47d05f0b7999419b0a"}, + {54UL, 0, " ", "e9ef0323574696dcbe5c35a4ce286749639259f71c77775b699c59d4"}, + {55UL, 0, " ", "1f79f3a5e5ca2e56db8f5fc1a7653a119bdccfc8405766f6d3f3fb73"}, + {56UL, 0, " ", "7dce65ef09f1d47fe6166dcd260808af141dd6ddc86865826b852edf"}, + {57UL, 0, " ", "dac08738db2d96041219ad75f64cb4c9de20c41e6f102f952af8e7a3"}, + {58UL, 0, " ", "48c4408d37ba8571d0984735ae18912d66fcef68534b7d3497b365db"}, + {59UL, 0, " ", "e4ac9ecb01a5d7db7ba544d43b8b1358c61ddb1de32d19482bba325f"}, + {60UL, 0, " ", "5df437e0149202acdb0d555e95ae13e2216235c8001046ebe707daf0"}, + {61UL, 0, " ", "e47cfc77f4385d802ac83b3282b106449497fcf2ab8d43aa2e23f160"}, + {62UL, 0, " ", "957c4dd152f2642cc3df6c999047613fa9fa0f4ea4104d45c4a098e5"}, + {63UL, 0, " ", "9ea8e542b4b1d27dd9cfd8205fe38941e5ca1c08d6a0db40fe92e897"}, + {64UL, 0, " ", "572105803c18e1e284815f7667d2df0adbec5010adf04ccceaa029bb"}, + {65UL, 0, " ", "c51c7e150eee3675ac09762f28ba9a8c993d604cf5af7e97149b0942"}, + {66UL, 0, " ", "25ef1f583f10ab515a952a0a4bb80df1686b8f5fa98104afd2a0277b"}, + {67UL, 0, " ", "3e941387ba3ca58009254cab0cfe67b4e332f11fe845ef65a8fc1044"}, + {68UL, 0, " ", "ac56a59ea8f1d5e8aba085f829dfcd7d56716dbf3b6a2c931d219d8d"}, + {69UL, 0, " ", "522889e8d147ff961c1cc0d9891ad96564c155d89dd2d2f34bb42b76"}, + {70UL, 0, " ", "b884d2b5edd4a00230019ac9bb910408f832255edea81a15d8fd0403"}, + {71UL, 0, " ", "c81951643b4f59624c2b90f9af4bfc2d59fd4921f66122a79814b699"}, + {72UL, 0, " ", "edf52515f6393414239ff789248febfe3b71b83a9d19f1c518b78c5e"}, + {73UL, 0, " ", "af7414feef6be2ac8cff372a8b37c9e92b96fff10a84509aca9a6178"}, + {74UL, 0, " ", "a17b44266b9d5c9a052f95f863f9b1adcddc969ec158d2b3dbba7f22"}, + {75UL, 0, " ", "976d87634ad9da6d2f6032bc8baf1d9a5e913e12fceabbd6d4bc2515"}, + {76UL, 0, " ", "df6968778add7ab73eb487d28d9ca92dcf5bce165e4061d09ed960b3"}, + {77UL, 0, " ", "a1ae4032f560f357d82d0a6dbd1782cb52e668dccb793923d6c7c3f8"}, + {78UL, 0, " ", "bf837f0dfe82d23e74811470045dce11d2119b3978692ba7b7d3c176"}, + {79UL, 0, " ", "0ab8e4c4acf5139877677b7971864e583451ee4897f2a490abe66937"}, + {80UL, 0, " ", "7a27bd7bf609c3f95a37a9580489eff4c59a5f5b843a88e7aae585e2"}, + {81UL, 0, " ", "f574258fbc316d67fcf647964ef444ed6bd2bef2032e9becd15708f5"}, + {82UL, 0, " ", "c0557fdc045f816aeb169b7bf1075c3ffe4f4631e870ba3d3b2fbd8d"}, + {83UL, 0, " ", "3e0d19655af9efeba86341661a1245b59314056b49788fcea5b2a1ea"}, + {84UL, 0, " ", "b7f060a7a4d669b7a7f56dfdbe5befefdd5f0242179a5a986b3118c5"}, + {85UL, 0, " ", "aa622bb2da1853903900f61ec968c345d24fe32b24f9c395e023f414"}, + {86UL, 0, " ", "61379ec35a3ff7d4c4c327f91416482dac46c284713a736688d66ab2"}, + {87UL, 0, " ", "fff4d787733d1d158ad3dca19ae11ea49cb27b29b7d0409685c2583f"}, + {88UL, 0, " ", "c2c0d7f738a17ef3de7fa4daa4e62fd010a543af705c7ec75abb350c"}, + {89UL, 0, " ", "97eb020a8c387b3e7ffd8d3b61856b75c0ac295310c3cb385562aaf9"}, + {90UL, 0, " ", "28f6b0b95e9aca22386ac708ee74201b810827188b4fb810a653e964"}, + {91UL, 0, " ", "981168c506be7765db93600c8ce8526bd95d2ac1871c82c1fa97841a"}, + {92UL, 0, " ", "4c92d48e9c6d8c584a6540581bc87ff4daf83b0fdce4dc824a78cdc5"}, + {93UL, 0, " ", "26eb7b9940a4f4b02d4b93fa129e369c565b6276019d6d006fae1137"}, + {94UL, 0, " ", "894e9cdc6f1662b5b4fd366553d91e167f6980f9522d8ad8555c1f4f"}, + {95UL, 0, " ", "2003c4c6d3dd8cad0fde05541f43e8abd979510a389b0fa4b94d9488"}, + {96UL, 0, " ", "84be87c12408e7898ea7a43f5eed3940ec23f1e33a81a6384272860a"}, + {97UL, 0, " ", "d1f158b0d3c6b66f1e1f363fc5d5a9770f441b5d62479a22f53e091b"}, + {98UL, 0, " ", "234dce0dae15f89a88940bf131bd68b3ba48c7df251ece6e7aa4a0fb"}, + {99UL, 0, " ", "a830be7366b92ad0d737ca8167751b530cc15b66ed202118985e67ce"}, + {100UL, 0, " ", "29219fdd0a2c69fb4f8b268ebd75f9f4f03c990fedc1f8627a9eaa14"}, + {101UL, 0, " ", "5db8d277939bb5f2e6083c2c429298d3976b710abd152f5a6d7da81f"}, + {102UL, 0, " ", "f4cf42a5b3cf0b693e9d1d4cd2e4cda7923e443a9803a488defe91b0"}, + {103UL, 0, " ", "362857fd4ec32a40a99d4e19ecf1bd87f8308846a7eca1f9c6b9bb57"}, + {104UL, 0, " ", "8857671a2b21ad783e8340c70cdcb71926a28fdbe7da27c564d88e99"}, + {105UL, 0, " ", "6d36fdecaeb71720be1ad70c37f0640fbb64bf43bf6b95762c6c4642"}, + {106UL, 0, " ", "2f26d1a7f946fb6adab62333937e0bb59e5e49735e6538c9d0acae89"}, + {107UL, 0, " ", "eaeacd93c9479d1d9250df6ecd3b0a97f264e9d52eeef7d2d474769b"}, + {108UL, 0, " ", "c3485a305320d22bcc25998b25e7661448de1ac6eb0f3c6712c7c7ae"}, + {109UL, 0, " ", "a1d8721cf5ff48a5ddbab3cfa2d603179d25caa7db17f239abb170f4"}, + {110UL, 0, " ", "cd83c5f724384ab58198450386d7840bf2f742e1b85f80a8d568368d"}, + {111UL, 0, " ", "2c34a94c02ad8ab462f209807ad6a5162cebf1e1cdb363b39ea0252e"}, + {112UL, 0, " ", "a524f6ee6a92588c0cff922fc9b8b0c99280e23273b48164dbfd7bdf"}, + {113UL, 0, " ", "402990297221a85f5976adcbf720a49cdb55836516a1253262bdc946"}, + {114UL, 0, " ", "4dd078df2de61eb96cbaa65aa2ad935555ef48d8379438174ab67a73"}, + {115UL, 0, " ", "a0c205a884950c53d7754c0fab722b5fb6b65c5b085cbae471fe9715"}, + {116UL, 0, " ", "3a3906ed6f57e0c5ea1bb33553a98260a4f9cb20a10eca11a3a08123"}, + {117UL, 0, " ", "cefee50848b3c44d996b4a5700715ac2f0a83f694e72a9ff2ffea56b"}, + {118UL, 0, " ", "8dba530e8e27f35f1152132c125de77e780072882a3ddb223b6e69e0"}, + {119UL, 0, " ", "82b1aa5898c5503739e3f064fe145f5b90d610c948a295de14f7507d"}, + {120UL, 0, " ", "d420a83627c4bc1b54add26040cb9268a809de63f98610ce76f8fca6"}, + {121UL, 0, " ", "0fa086ae9132c82fcd2d5dafe09dd7d16895a7a48f2d77ae44872dfe"}, + {122UL, 0, " ", "5edac9117c5e87baf24d046e3c1614578404ccacd727022d5beeb0a0"}, + {123UL, 0, " ", "5edf8bb6725b42b450c8a670446249ce05cb6f993877d8ddb8709bee"}, + {124UL, 0, " ", "19361cf4b805e43d70fbf21c8ed284c8abeabcf951449f93cf0319a0"}, + {125UL, 0, " ", "fed5baeba6d2ec35ab1b8ee7c6772729a5dd6bf5c0831a59e6a892d7"}, + {126UL, 0, " ", "feab143afa749f2ba23d3607009859fa25a09ba3aa8d248882af4d2f"}, + {127UL, 0, " ", "34ff55e13946b0ca188362270e783bc3d9ed82e33472a195fe773d5f"}, + {128UL, 0, " ", "e5d2ec01cc8b3a1ab662de562af04aa41d41b770a59a08fd689c6bbb"}, + {129UL, 0, " ", "e43900681235ff6624e52e87ccc33ccfde5c0038b90999a7d23721c6"}, + {130UL, 0, " ", "7f8085f41c8d60a0f1b0226dd0cfd6a24e5d73557f382ea6f3ce25ad"}, + {131UL, 0, " ", "4a53fea203779ee4555620886f6b6357ff35a0655667d7174a2fd196"}, + {132UL, 0, " ", "b17cf5ba26058d14e2330106ad46485ddf421286ae9bf5772b91e889"}, + {133UL, 0, " ", "0dbc4c808e638cdacba32092666835bc2b2848fad0444afcad8d5e90"}, + {134UL, 0, " ", "3c333f36bafcc787dfcb24d3744114d71a4a9c5e6e09e949a221fc8d"}, + {135UL, 0, " ", "401c11810974a026b48bc9cc8bc72ada4788c97e1f919cc80b125583"}, + {136UL, 0, " ", "4647b8b14eac49619abd178c385621d7658156ce62c5dbb0dc8ccc9d"}, + {137UL, 0, " ", "730af9e6c492ae88b6b0f653f1739ef838c4aeae5b41fbc117c277f8"}, + {138UL, 0, " ", "f3ec86ba95212e34ca2b309686697ac43b9494a7a4e065dfb38ad31a"}, + {139UL, 0, " ", "46b77e999a65d67d295281d766c28be3ce56f98595d440193280e959"}, + {140UL, 0, " ", "d034b0d20a0ab15c600c3bffa475d8d4e26d0ecb44a2e8ff671ab3c8"}, + {141UL, 0, " ", "18342457f26702955f988b84641da1aa2e249478b8aed789588a8067"}, + {142UL, 0, " ", "99714345f222e6a5a3fea9b6679a4b031b651213309bb5c43abb5f9d"}, + {143UL, 0, " ", "7bb36d2c61072f1027ce753d8d6e08f6c7d1dab86576c55d7788c49a"}, + {144UL, 0, " ", "d0f6b2d5d1f6b7c7c7a145226b90a97fa95ab9a3a5e2c444910d6170"}, + {145UL, 0, " ", "1bff9b25b2f62b91dc72857c128a88bca25a9467f6694d6369c2961c"}, + {146UL, 0, " ", "084fa64c2119a58d499b49ab41555f8c14cff3a5b3fb81263973fda4"}, + {147UL, 0, " ", "7f1029071549eef525f187caf9de820b95393183273b34c719282a3d"}, + {148UL, 0, " ", "059b18008a36d138bc67b1d9fa4c7b9d5250bf52a32a9f87268cfcfa"}, + {149UL, 0, " ", "41f79bc4faaff75a9706e225fd36c0d04f5b2dd31500c32843ee5fbb"}, + {150UL, 0, " ", "0884041331c9ccdfbb3bf0ffb104ff6c10442044e4c806daec38f380"}, + {151UL, 0, " ", "db6d15f6b6e4628829841ccd4e6376e20a72e3a8995b0adffbc00d9f"}, + {152UL, 0, " ", "9e5855a42bb807b811a4b4dd1f180a42b108a3f2ab1185b319dbe6df"}, + {153UL, 0, " ", "1ff36fba37665c4dcf6b9975566896ce94b1d8559e1377abc05b885c"}, + {154UL, 0, " ", "5a4b2fd5abc042870ec8b5412032e743d6e015d56c13e9f9face0c2f"}, + {155UL, 0, " ", "46b3680f4bef3d4e2baa95422493c33f245e5c95254134a0548f68e3"}, + {156UL, 0, " ", "834e49322303f470f85c8db3f6cb05a38ebc01a4f4d73573cc9eec79"}, + {157UL, 0, " ", "0125d8e97087c77e72fc65d621853bbabf01a2aeb0d6c430af696fb3"}, + {158UL, 0, " ", "d71341e59f3fccdeaed14c7870eda283cfbb5dbd2ec2f0094a3b5615"}, + {159UL, 0, " ", "c84c32b3aef5d5b83761943e0e7d0f07daa02f4a7138ef5403c3934a"}, + {160UL, 0, " ", "0fefcac220529ca60db134e9028459abcb8ef0a3d9dfdba582fcfca0"}, + {161UL, 0, " ", "2027feef15cc3a0310cafbb8bf6b3df9979065e09f8a768bc269bed8"}, + {162UL, 0, " ", "9ec8a224907e48f1adcb27687baad0e57ecf95058df0adaddc69370f"}, + {163UL, 0, " ", "fa41e1a483ed9e7b8ba351988543d4c8ce3fe81fca2389b3b090f311"}, + {164UL, 0, " ", "9e9f8dc4cf2006bea86845bacb9d450fff2d5df033d9f22fc7074e23"}, + {165UL, 0, " ", "03badc3d8e615d4aba10f377d67d9dc4d95a014f4c28b5aeba4c0331"}, + {166UL, 0, " ", "1c20b60fde8c3c68f5220333c78bcdecc6feb0b707b82cd456ea1d3b"}, + {167UL, 0, " ", "5491e0cb786fb4159110c881963848ffbc732a13ca414bd87d4f5a68"}, + {168UL, 0, " ", "d4a17fc033f1e1680924aeb1261dca3102a089cb817d2e6c498ea925"}, + {169UL, 0, " ", "992025910bae8adacee7e601f02f6213590551f0bd84f5efc68be041"}, + {170UL, 0, " ", "1760cd5fe286b53e3e4b17b6f0007e2b6efcc354888bb596177ef8b5"}, + {171UL, 0, " ", "e700be875d52567a0cababe13d2fe85c0d9d6b3ca3f056e996d453a4"}, + {172UL, 0, " ", "62dc712ee01eaf97db2fa4194473c4209b915d4456076332bc5a2da2"}, + {173UL, 0, " ", "0c55c1464697e3dbbb76870b40dff5d6d5268c300d9baa36a6e603bd"}, + {174UL, 0, " ", "35fdd560c15216f191d9783bb1b5d2caaa09f46fcf9d795a20c57d3b"}, + {175UL, 0, " ", "adfecfc59b87f1d0d9ca2c7042f7668384119567b80b2b326ce77b84"}, + {176UL, 0, " ", "422c69d68d00fcdcd4c9d3723f60a8f5c0d4bcabcc8106c2b1cadfae"}, + {177UL, 0, " ", "481813c9490447df50f7684c392f058ee65d213003e4ca8fd5e1fe0a"}, + {178UL, 0, " ", "702cd8b7fef21033b3fca367fc1a824aad6075f0db11bf6950e7b287"}, + {179UL, 0, " ", "67122376b98ee2f5aceb47b43ab4c70e85d9a777757ce09ab9361466"}, + {180UL, 0, " ", "e81bd70b2a72158614f78110cadd43e943743b9e4cad19227cc2901f"}, + {181UL, 0, " ", "eb90179b1e6a8e614940e7484ff818bf423163b9e3febd2bde3f99d9"}, + {182UL, 0, " ", "4670e30c7a073846d4181470d45c774c765265726cd87c3d61314d2e"}, + {183UL, 0, " ", "8c15ac4278dbebd72ca9f677b67840855e2eb0bf21abd6b4c0c6fc59"}, + {184UL, 0, " ", "9aac77501210594e973b178102ff0a912cefb5a8c650a3a3026edc97"}, + {185UL, 0, " ", "c208a94b304b2c2f3c24fcd32b452a034f14e122a916d98a5cac8457"}, + {186UL, 0, " ", "06faf62b1500cf7bfb97c22f28c0b7b20a061f75f805b89aaa0f8b4b"}, + {187UL, 0, " ", "1c8a8dc40b0f1743462c8a078a12fe4c2fa470ee11d2ba2977b16457"}, + {188UL, 0, " ", "278685b0b1db68fc81a5c58c93ad7d5ef3b0b41707fd50e99c6337eb"}, + {189UL, 0, " ", "bda22e93b44bfa708e37c160d2550591d96bf3169ce6054dfefc4eaa"}, + {190UL, 0, " ", "27dcd4f271994a8ff77070432d4dc7cfbfe44a3d715ff4784c7042b6"}, + {191UL, 0, " ", "736d74d010feed3086fee86c7daf96ffb4f7f90bd67c323bf95c6c27"}, + {192UL, 0, " ", "ff0e655fc2cc4cf5ec5e0a4842cc7eceac0909583fc2bed52d11ed7a"}, + {193UL, 0, " ", "c9dca1cbe5a57db90be0fb8b96da1f5424fd213c698f5b8bd102557a"}, + {194UL, 0, " ", "43406909b362eb9f54111e4e4fcd048b1c9a93147d7418d4008ac205"}, + {195UL, 0, " ", "e6ea6206f13a10326fb177905abcd8085f31958790545ab874434a84"}, + {196UL, 0, " ", "a4fd3f825de2167cf90811fdc171f14667af83b013018d342d7ac2a1"}, + {197UL, 0, " ", "36444ff3b3c34c1b9065aa36b9b62ec31f6be00af4dbc688cdb366e7"}, + {198UL, 0, " ", "bc4dcf21bd02a144773db1bdd63de1f48bd03c222273a9b5bf054926"}, + {199UL, 0, " ", "0cb650297dbc2160cbc534aa52f6357ded53b234a05f010bbd61c81e"}, + {200UL, 0, " ", "e879f9f6cdd4280408bafaf08f6175043945c3c8ec1cadef8432f9e6"}, + {201UL, 0, " ", "820d8ba6fe7f9fd06e09c67210eaa6aacfa51910408d7c34502e29df"}, + {202UL, 0, " ", "dceaee66685def76fd718e114c5e19435a4bcb370ec5bc8e244c954c"}, + {203UL, 0, " ", "fe7c8d0059d34e5364a58b13608c503d1808d05e7fe5a19009615116"}, + {204UL, 0, " ", "4501de44a9359bbfa19685627f98a241d5b6fc107511a727da045dba"}, + {205UL, 0, " ", "e53ada896a5212c69200acad5c32c9b34552c8961267859af9297ea3"}, + {206UL, 0, " ", "040d4f155c3d3ce1598f3926572db62055708a7b1cdbc98b49130073"}, + {207UL, 0, " ", "3d35e459cb26376500cda5f74353e10edc4cdbd3796c6bc7d47fda41"}, + {208UL, 0, " ", "0f9e5be5cc5af398ad7179adc41e4b8d24d1e291ca823bf6f3c75c9e"}, + {209UL, 0, " ", "e7d74553892daa5a4588eaf60ce1e37a32c6fdccfa8ce5f90fb6990e"}, + {210UL, 0, " ", "04957f64cebe1646fdda2c6f3e4161321789b892b901cd18a7497d7f"}, + {211UL, 0, " ", "45683eeab0e5adc9b24ef9a776809226d8dde2a309e137c57fa773e7"}, + {212UL, 0, " ", "568aa85b2003c6b13e5236fc0f256808bf080c23c84b3bae9e567d6b"}, + {213UL, 0, " ", "365660746f5131062f168a91883f8a07a06db1f6336ebfe53d4def69"}, + {214UL, 0, " ", "42136d0f54c770c73a6cddf00e7cbf4ed82a8777b86cc7c14684e142"}, + {215UL, 0, " ", "510524ebb3b16b5fb59dd5fca70a99559804086fa9a3f008aa528827"}, + {216UL, 0, " ", "8fa23e20bf52673db02494a2da8742c31eef7fd691475c64c4416610"}, + {217UL, 0, " ", "e9256d61424c7f03e14037abbc87fa97dd4826f9c4bce86177474a7c"}, + {218UL, 0, " ", "3b85b5435cc101ef24e1aba0647f1a848d237010e74baea82767efd6"}, + {219UL, 0, " ", "378bd933849163a6594cdd93a90c9bb72bfac14f0b8c52affa696c0c"}, + {220UL, 0, " ", "08bf93fa4ef7da7e49c50794f1868f9a27a3238b8d7dae16435389c4"}, + {221UL, 0, " ", "ba96b341ab322c9c8a1d473c34f12c67a0e3054185c9ed04346a444d"}, + {222UL, 0, " ", "399094522a7f468a9791f835c81e5155e2a404938d3540b7b76f9702"}, + {223UL, 0, " ", "a11fec55ae6a2e04f2dee19d437d0db66e7a5db76baf26b385fd4ca0"}, + {224UL, 0, " ", "5e5081a215179aaefab0dd558da783e445b57a67196665998d8d46be"}, + {225UL, 0, " ", "2eb8bc3daed664c24c12c63215a59a005ad177cbf98387f6da5a7db6"}, + {226UL, 0, " ", "94f104cf8efe1943995a66cab74deb6bb3a8feda71924398f151c751"}, + {227UL, 0, " ", "c0560542f09724299cc3ef8b282f204a87534d7ee332bf1131c2d100"}, + {228UL, 0, " ", "3ea4b9c6e1b13f9c2ba48fe545187a531161135addc01e3ce4448174"}, + {229UL, 0, " ", "4b59dc53b5e3e10990eb2bdd5c9df86713bc09e4c52d2bfa8684856d"}, + {230UL, 0, " ", "0d1322c2c4d8660bb4e420ca5e24aeab4efb844cdfdfcae7086c024a"}, + {231UL, 0, " ", "154046fd5d42d559c28933e201b6de7b3460930c87601949374d045b"}, + {232UL, 0, " ", "094da314a46279a975b2e7dde3f8461fc1a6db835f053fe5d69a7ece"}, + {233UL, 0, " ", "eea04248aa221bc98e0fae363ec11e714eabac149b3659dfa64f9369"}, + {234UL, 0, " ", "2e1259b1ccefffc67c1c3ac92b8218bd6e90fea28172531edba1d605"}, + {235UL, 0, " ", "e5064894b918ba5d6a42ea1b35d45f104e0042eee6498b9889de4ae9"}, + {236UL, 0, " ", "9e30b504cf8307ad4810ee6361714fa6c18f25268a40c7aed5feb438"}, + {237UL, 0, " ", "58a083cb59226769d1008f7c27006006cd9b05875a4277391f57d6a3"}, + {238UL, 0, " ", "589dfbe4d3a0d09e355535a73d6832ffd726afdc85cb6dcaeb2953ca"}, + {239UL, 0, " ", "b5e94cceedcce99b64606378e9811b3f6f2ea615a1ac52c63bbb19aa"}, + {240UL, 0, " ", "fb6a4855fa120425fa0b0dada82d52acbb39e9ec8e7e83b3775be115"}, + {241UL, 0, " ", "c4135ba8ac972cb953e05cdecebd59a6d28da424113db1f1b3d351d8"}, + {242UL, 0, " ", "93ac0273eb893107ab282fad3d15436c3c8485d5e68a35533d9652c4"}, + {243UL, 0, " ", "3e71df415a48a0abe6e85d6279f49ee4dbb5ac3e99b3e57b525ec527"}, + {244UL, 0, " ", "64f2803e60ddf00f9ea1d63c11d75bc5c01544782a5679366902499a"}, + {245UL, 0, " ", "e1e89e00b7feab9060c360a902a52b536c30c30e2685d46519b75321"}, + {246UL, 0, " ", "ad28e369fa0085880851b81dded4bc2057563ecb6e011a62f1d804da"}, + {247UL, 0, " ", "e0442d5399aba8a6037cb68c5f9ce147b31a78beb6225a22a5026813"}, + {248UL, 0, " ", "98efb15de4d815d6c8ea6e8a2bfb1d6be6ea527f158ca3af900c8274"}, + {249UL, 0, " ", "a84147783a5fdf69ed4a85a5d466df7795f272fa3e0b560f76ec6e17"}, + {250UL, 0, " ", "df7b41bfd68c5754f5c5844cce21125e103d18863329772794839771"}, + {251UL, 0, " ", "85f68577896af03a6c110a5a96d4b5af893fedde7896ca0fc300f0ea"}, + {252UL, 0, " ", "4df874bebfb8f6bb517a2591c798d12c9a51f618ea34d8133abc8aed"}, + {253UL, 0, " ", "8d3840a59f4991629d3e22c5aae1b1416064e4752c208ef4d8bc29d7"}, + {254UL, 0, " ", "ce0ad294e28c8c8b9a30af709cd39dd82995c842489ae5cbafa45b7d"}, + {255UL, 0, " ", "21bde47a3e44ea0238d07bf5c7f0eafde3fd993773b5c7514b228f95"}, + {256UL, 0, " ", "f254b95019ae83bcb0ed75b591d2152963971d0331437263de2c0529"}, + {257UL, 0, " ", "2b5fc8c4c06e954caa54e7f5b3fde9124314896b5f5fcc5f7cfbb5bc"}, + {258UL, 0, " ", "3c0b272ce7a6890f903826afe5f48609a391c049a4df6fd7de3a3a84"}, + {259UL, 0, " ", "5e4386132842bb256799a9d469b6eb861916ea8dbc6d06a589f4e6cc"}, + {260UL, 0, " ", "63aac12d08b9e4bc9c0b00421527e092a03c4e299311f9c0cb201f37"}, + {261UL, 0, " ", "c292327df2173cd0bbbe87d50c2a3a44c9b912c4c9316ebfca341646"}, + {262UL, 0, " ", "a3cbd97c8e4361ccc71aa5ba620948fcc2b5fbd3763d6cd6394942d4"}, + {263UL, 0, " ", "e3cd028df09267d92d647d2720d86db9b94b4b8dcaa82c68b6cf2693"}, + {264UL, 0, " ", "4867b23bdf67fd66ebc12f3f4b7582969fadb1748cfff4dff1b2aeaa"}, + {265UL, 0, " ", "414cd976c99967269cc29e58d47461d9d01647e7e2270d2f0db07b7e"}, + {266UL, 0, " ", "cb11852ed0fb978aee28dd6c6235de809bacd71fb3ef6f0fa78902bf"}, + {267UL, 0, " ", "fb69179686bbebce15b13bf0500fcc2ca61ca38f7ff54cb013858873"}, + {268UL, 0, " ", "638d9f85c37b9da8b39cacecb3e5a739b2840e63aab7df64f4f2f23e"}, + {269UL, 0, " ", "8c57b259d72d7f3388a0e27330f0a8c01bc11a3e969aa3db34000f8f"}, + {270UL, 0, " ", "f079dd786e5b0caa38cff0832e62cf42d5c6744dc65b17c0c5aeccb2"}, + {271UL, 0, " ", "e6722d9d5018ead0b9fc7a14f7f2f9fe60889e43d278adbdeff3ad3d"}, + {272UL, 0, " ", "a0ab2b81776450ff310753db78a03ef6673f67c0d2de815f8d276c49"}, + {273UL, 0, " ", "e3bac307a12f7b57e5cd5b81faf31d6d3eae200a3a5fc18cad927ae6"}, + {274UL, 0, " ", "d05704912f6c789320c4a756b1f7ebb79800fbdf7bf363dd3740dcdb"}, + {275UL, 0, " ", "a4b30d96b234e8b51596f28a66ff18e0405abbcfdd75168b48c5e393"}, + {276UL, 0, " ", "632da71b1d3bfdffe8ce31dee0c3f761b114dd5296dcb41e108a3531"}, + {277UL, 0, " ", "19162d2b43b01cb24475f82955978bd8875b4df34cd965a582fe61ed"}, + {278UL, 0, " ", "98f44bb1257b419f4cbcbc1c15bfa2c98b8c60d604b0c644672c6706"}, + {279UL, 0, " ", "76aa65f391daafe3abfa3ad4280dd30f9c27bd8297b3d9737c57a0c8"}, + {280UL, 0, " ", "330bc122c2e49c29952049f7d28cb700e227f7e35c2fe6519e20837d"}, + {281UL, 0, " ", "b852fb3011ce42b87581a4acce470f361eb64309033f0e693ea3df0b"}, + {282UL, 0, " ", "9b68b2226c3e539a22d878514dcbdbe63139a9025093ed4c9546d5f7"}, + {283UL, 0, " ", "7137a0f46f4b673a82b955924c8b1c5bcf9166350fe4e2ffd31f2f6a"}, + {284UL, 0, " ", "8f896d6341cadfa294d352970747f7161fcf95e661aa8297d39f1cbe"}, + {285UL, 0, " ", "e44a0c6dda643ba7bbded6179e5541b1fb41221235c67663ce63bc62"}, + {286UL, 0, " ", "9e3441070fdeabef066d7a8059bdb42d6662d9ddc0aa81b23fa09b67"}, + {287UL, 0, " ", "4fcc36bbde5ebe0909af8ab543c400320e90b9a22f68e911404e79b1"}, + {288UL, 0, " ", "be573b027ee2563bea89927c1c30873dee8dc80e30cf7a6f3e7637ff"}, + {289UL, 0, " ", "a9a31e9b3f6e6a319d3997d60065b23d2295a723a99401f9f18fbe23"}, + {290UL, 0, " ", "10ca78c979abc3bf008b53f55578389fcf971828bd222bfb0b0dba36"}, + {291UL, 0, " ", "c93ff60f10edfbad2ec2e5dc962d9c8661dcaf35de83c7697b676b19"}, + {292UL, 0, " ", "ef7b2c084dc0a4b114e927faa5ac73f26cc800e6fd5bb1ea4bf5cdb6"}, + {293UL, 0, " ", "8fa5fb1f8efb64417f1f259490b4c9ceffd5b6b084e2f411c8ad39a7"}, + {294UL, 0, " ", "cd02115f81d1210bd25c93255cdcdc39bb5702604a80bd37340742d0"}, + {295UL, 0, " ", "6b4d5c817c648e778afc58894dfe4d4f891689759008c8a69d9685cb"}, + {296UL, 0, " ", "8345df0eab6b16e1a44ead077328b164cd75ccc658d607848403ca99"}, + {297UL, 0, " ", "b44daf778c692695217f1b54d711a6ef4d2b61634969344dce51b630"}, + {298UL, 0, " ", "db3127d5b76149309a56db6569f066aec01ae8535d60adf57c3281c6"}, + {299UL, 0, " ", "b5b32e77ee3e7513cda85d1d59ba761942f45259efdca91083072d04"}, + {300UL, 0, " ", "35efd6428af373b1a129f471b8af317a28bb1669d8a7884d29653f63"}, + {301UL, 0, " ", "7c665d57c853a1d43dd6ef6bf7068c3dd445c8b84b88ebd3a1d2d3b9"}, + {302UL, 0, " ", "e39774432075fec2958d8a57c2a690a509493fe1553b66f8457b1963"}, + {303UL, 0, " ", "ed5cfc6b074d185714c19825ab33081d6ab7e9b477d1219fe54b4b9c"}, + {304UL, 0, " ", "0a5298110a1fcea7d8c1a1c638ac38704bc4671b4be4ce832bc4498a"}, + {305UL, 0, " ", "e21c6a29c9a92ad78d7602e92c394db80d7fc4d09a5c86ede8f03d8e"}, + {306UL, 0, " ", "3e0584a09c07839d94357e8d596c6d675fc352bad8894213c876826b"}, + {307UL, 0, " ", "692e50890534f51426c4ce2ff5db0b44a28f9f58b03d8d2bd6fb00f5"}, + {308UL, 0, " ", "dc1a17a25b78cb666580f06359589652530ac639801141fa7aad917b"}, + {309UL, 0, " ", "9909d62bb9d4aea57ce6ce6cb7097da1d78a5284d48ebb65398ab1bb"}, + {310UL, 0, " ", "0a81e94d03e7651217167df3512277c065bbdc0bdf22ef91153a4602"}, + {311UL, 0, " ", "6a9e9048072ff95fa14493acbf1a10c572f38abe32991f6c0e18b64c"}, + {312UL, 0, " ", "559fb367be5eb06a2078bc5448b796f389821540bb8ee44495fb858a"}, + {313UL, 0, " ", "3210c0035698c9861111cd6c8ba68a3fdb2539554b797225faf4c472"}, + {314UL, 0, " ", "579ec84c0623b3ad7402e6c056a9ac53453e2eee84dd3b30ac07b967"}, + {315UL, 0, " ", "6cabec5717d36a76909bdf1090aab017cde5476f7dd3f1b431b84005"}, + {316UL, 0, " ", "3ceb3c7f75a934bd7d195d1bd000115672c5cd19b28c696ac3c0dd4f"}, + {317UL, 0, " ", "f16bba90866a163f5ffb0deecaf2f5e7e9a46c5580fa43a9912d8d4e"}, + {318UL, 0, " ", "43dac236cb4e71c80c89e8c60e04372e2622510589e856aed71710d4"}, + {319UL, 0, " ", "fa526a826144bec9c9aca05f81d0c1538033e20542a97ea4b8b6cd47"}, + {320UL, 0, " ", "280cd257d0c4c9a4681d71743a7016e9acd7acec4d09dcd6afa05be2"}, + {1, 0, "withdrew hypothesis snakebird qmc2", "22c8017ac8bcf65f59d1b7e92c9d4c6739d25e34ce5cb608b24ff096"}, + {1, 0, "intensifierat sturdiness perl-image-exiftool vingla", "43808dde2662143dc4eed5dac5e98c74b06711829f02a3b121bd74f3"}, + {1, 0, "timjan avogadro uppdriven lib32-llvm-amdgpu-snapshot", "d32b4ac86065774dee5eb5cdd2f67b4e86501086d7373884e8b20a36"}, + {1, 0, "grilo-plugins auditorium tull dissimilarity's", "efbd76d45bfa952485148f8ad46143897f17c27ffdc8eb7287f9353b"}, + {1, 0, "royalty tt yellowstone deficiencies", "6705aa36ecf58f333e0e6364ac1d0b7931d402e13282127cfd6f876c"}, + {1, 0, "kdegames-kdiamond tunisisk occurrence's outtalad", "803a0ff09dda0df306e483a9f91b20a3dbbf9c2ebb8d0a3b28f3b9e0"}, + {1, 0, "chevalier slat's spindel representations", "a64779aca943a6aef1d2e7c9a0f4e997f4dabd1f77112a22121d3ed5"}, + {1, 0, "archery lexicographical equine veered", "f0a3e0587af7723f0aa4719059d3f5107115a5b3667cd5209cc4d867"}, + {1, 0, "splay washbasin opposing there", "312e7e3c6403ab1a086155fb9a52b22a3d0d257876afd2b93fb7272e"}, + {1, 0, "faktum desist thundered klen", "270ba05b764221ff5b5d94adfb4fdb1f36f07fe7c438904a5f3df071"}, + {0, 1, "\xff", "6f2fc54a6b11a6da611ed734505b9cab89eecc1dc7dd2debd27bd1c9"}, + {0, 1, "\x7f", "6f2fc54a6b11a6da611ed734505b9cab89eecc1dc7dd2debd27bd1c9"}, + {0, 1, "\x01", "6f2fc54a6b11a6da611ed734505b9cab89eecc1dc7dd2debd27bd1c9"}, + {0, 1, "\xfe", "82000b40579ecbbe7f57cc132656530861e408becb51070288cec752"}, + {0, 1, "\x7e", "82000b40579ecbbe7f57cc132656530861e408becb51070288cec752"}, + {0, 1, "\x00", "82000b40579ecbbe7f57cc132656530861e408becb51070288cec752"} +}; + + +#else +# define TEST_UNSUPPORTED +# include "../common.h" +#endif + + +int +main(void) +{ + TEST_MAIN("SHA3-224", SHA3_224); +} diff --git a/t/sha3_256.c b/t/sha3_256.c new file mode 100644 index 0000000..72546bb --- /dev/null +++ b/t/sha3_256.c @@ -0,0 +1,28 @@ +/* See LICENSE file for copyright and license details. */ +#ifdef SUPPORT_SHA3 +# define TEST +# include "../common.h" + + +static struct testcase testcases[] = { + {1, 0, "", "a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a"}, + {0, 1, "\xff", "83f66216d2cc769e153bafce0181b61a471b4c6a213fc6f59a42985f976f33fe"}, + {0, 1, "\x7f", "83f66216d2cc769e153bafce0181b61a471b4c6a213fc6f59a42985f976f33fe"}, + {0, 1, "\x01", "83f66216d2cc769e153bafce0181b61a471b4c6a213fc6f59a42985f976f33fe"}, + {0, 1, "\xfe", "1b2e61923578e35f3b4629e04a0ff3b73daa571ae01130d9c16ef7da7a4cfdc2"}, + {0, 1, "\x7e", "1b2e61923578e35f3b4629e04a0ff3b73daa571ae01130d9c16ef7da7a4cfdc2"}, + {0, 1, "\x00", "1b2e61923578e35f3b4629e04a0ff3b73daa571ae01130d9c16ef7da7a4cfdc2"} +}; + + +#else +# define TEST_UNSUPPORTED +# include "../common.h" +#endif + + +int +main(void) +{ + TEST_MAIN("SHA3-256", SHA3_256); +} diff --git a/t/sha3_384.c b/t/sha3_384.c new file mode 100644 index 0000000..7dff983 --- /dev/null +++ b/t/sha3_384.c @@ -0,0 +1,28 @@ +/* See LICENSE file for copyright and license details. */ +#ifdef SUPPORT_SHA3 +# define TEST +# include "../common.h" + + +static struct testcase testcases[] = { + {1, 0, "", "0c63a75b845e4f7d01107d852e4c2485c51a50aaaa94fc61995e71bbee983a2ac3713831264adb47fb6bd1e058d5f004"}, + {0, 1, "\xff", "3fae4536cd205ee08ed88e0e6f1152717f5afe181f9afeb508507f7429fd5031558e844edb73cb19b129cfeb55082617"}, + {0, 1, "\x7f", "3fae4536cd205ee08ed88e0e6f1152717f5afe181f9afeb508507f7429fd5031558e844edb73cb19b129cfeb55082617"}, + {0, 1, "\x01", "3fae4536cd205ee08ed88e0e6f1152717f5afe181f9afeb508507f7429fd5031558e844edb73cb19b129cfeb55082617"}, + {0, 1, "\xfe", "d880bd58197c5c3d596fb73eca0897c69599b306c9135d3a6765ac41e19faa6e51f10710a4e68cf3c0af0e7869d3219b"}, + {0, 1, "\x7e", "d880bd58197c5c3d596fb73eca0897c69599b306c9135d3a6765ac41e19faa6e51f10710a4e68cf3c0af0e7869d3219b"}, + {0, 1, "\x00", "d880bd58197c5c3d596fb73eca0897c69599b306c9135d3a6765ac41e19faa6e51f10710a4e68cf3c0af0e7869d3219b"} +}; + + +#else +# define TEST_UNSUPPORTED +# include "../common.h" +#endif + + +int +main(void) +{ + TEST_MAIN("SHA3-384", SHA3_384); +} diff --git a/t/sha3_512.c b/t/sha3_512.c new file mode 100644 index 0000000..356516f --- /dev/null +++ b/t/sha3_512.c @@ -0,0 +1,42 @@ +/* See LICENSE file for copyright and license details. */ +#ifdef SUPPORT_SHA3 +# define TEST +# include "../common.h" + + +static struct testcase testcases[] = { + {1, 0, "", + "a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a6" + "15b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26"}, + {0, 1, "\xff", + "0580220015f6b256328efe4d4af7ebd85187c42fe52fdc82ecc6ff5cee7c8473" + "f4a1911073ab7598eb41c6095ecfa05c1e148f726c3d474d66d1e4bcc191923c"}, + {0, 1, "\x7f", + "0580220015f6b256328efe4d4af7ebd85187c42fe52fdc82ecc6ff5cee7c8473" + "f4a1911073ab7598eb41c6095ecfa05c1e148f726c3d474d66d1e4bcc191923c"}, + {0, 1, "\x01", + "0580220015f6b256328efe4d4af7ebd85187c42fe52fdc82ecc6ff5cee7c8473" + "f4a1911073ab7598eb41c6095ecfa05c1e148f726c3d474d66d1e4bcc191923c"}, + {0, 1, "\xfe", + "57600f99901ad7c7232e520a20097cf37c48257b51b7a69a570b2bb9535a7253" + "b8240318cc0e5ab990b3f1b6e8e7e7b16d43936416abe2eb9f84fdbe0f41e0f2"}, + {0, 1, "\x7e", + "57600f99901ad7c7232e520a20097cf37c48257b51b7a69a570b2bb9535a7253" + "b8240318cc0e5ab990b3f1b6e8e7e7b16d43936416abe2eb9f84fdbe0f41e0f2"}, + {0, 1, "\x00", + "57600f99901ad7c7232e520a20097cf37c48257b51b7a69a570b2bb9535a7253" + "b8240318cc0e5ab990b3f1b6e8e7e7b16d43936416abe2eb9f84fdbe0f41e0f2"} +}; + + +#else +# define TEST_UNSUPPORTED +# include "../common.h" +#endif + + +int +main(void) +{ + TEST_MAIN("SHA3-512", SHA3_512); +} diff --git a/t/sha_224.c b/t/sha_224.c new file mode 100644 index 0000000..4abcd28 --- /dev/null +++ b/t/sha_224.c @@ -0,0 +1,50 @@ +/* See LICENSE file for copyright and license details. */ +#ifdef SUPPORT_SHA2 +# define TEST +# include "../common.h" + + +static struct testcase testcases[] = { + {1, 0, "", "d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f"}, + {1, 0, "\xff", "e33f9d75e6ae1369dbabf81b96b4591ae46bba30b591a6b6c62542b5"}, + {1, 0, "\xe5\xe0\x99$", "fd19e74690d291467ce59f077df311638f1c3a46e510d0e49a67062d"}, + {56UL, 8, "\0", "5c3e25b69d0ea26f260cfae87e23759e1eca9d1ecc9fbf3c62266804"}, + {1000UL, 0, "Q", "3706197f66890a41779dc8791670522e136fafa24874685715bd0a8a"}, + {1000UL, 0, "A", "a8d0c66b5c6fdfd836eb3c6d04d32dfe66c3b1f168b488bf4c9c66ce"}, + {1005UL, 0, "\x99", "cb00ecd03788bf6c0908401e0eb053ac61f35e7e20a2cfd7bd96d640"}, + {1000000UL, 8, "\0", "3a5d74b68f14f3a4b2be9289b8d370672d0b3d2f53bc303c59032df3"}, +# ifdef MASSIVE_TESTS + {0x20000000UL, 0, "A", "c4250083cf8230bf21065b3014baaaf9f76fecefc21f91cf237dedc9"}, + {0x41000000UL, 8, "\0", "014674abc5cb980199935695af22fab683748f4261d4c6492b77c543"}, + {0x6000003FUL, 0, "\x84", "a654b50b767a8323c5b519f467d8669837142881dc7ad368a7d5ef8f"}, +# endif + {1, 0, "abc", "23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7"}, + {1, 0, "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", + "75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525"}, + {0, 1, "\x01", "0d05096bca2a4a77a2b47a05a59618d01174b37892376135c1b6e957"}, + {0, 2, "\x02", "ef9c947a47bb9311a0f2b8939cfc12090554868b3b64d8f71e6442f3"}, + {0, 3, "\x04", "4f2ec61c914dce56c3fe5067aa184125ab126c39edb8bf64f58bdccd"}, + {0, 4, "\x05", "b04c423c9091ff5bb32ea4b0063e98814633350c1bc2bd974f776fd2"}, + {0, 5, "\x0d", "e3b048552c3c387bcab37f6eb06bb79b96a4aee5ff27f51531a9551c"}, + {0, 6, "\x2b", "44b64a6dbd91d49df5af0c9f8e001b1378e1dc29c4b891350e5d7bd9"}, + {0, 7, "\x0c", "20f25c1fe299cf337ff7ff9cc4b5b5afac076759720174a29ba79db6"}, + {0, 1, "\xff", "0d05096bca2a4a77a2b47a05a59618d01174b37892376135c1b6e957"}, + {0, 1, "\x7f", "0d05096bca2a4a77a2b47a05a59618d01174b37892376135c1b6e957"}, + {0, 1, "\x01", "0d05096bca2a4a77a2b47a05a59618d01174b37892376135c1b6e957"}, + {0, 1, "\xfe", "d3fe57cb76cdd24e9eb23e7e15684e039c75459beaae100f89712e9d"}, + {0, 1, "\x7e", "d3fe57cb76cdd24e9eb23e7e15684e039c75459beaae100f89712e9d"}, + {0, 1, "\x00", "d3fe57cb76cdd24e9eb23e7e15684e039c75459beaae100f89712e9d"} +}; + + +#else +# define TEST_UNSUPPORTED +# include "../common.h" +#endif + + +int +main(void) +{ + TEST_MAIN("SHA-224", SHA_224); +} diff --git a/t/sha_256.c b/t/sha_256.c new file mode 100644 index 0000000..6dc1b3d --- /dev/null +++ b/t/sha_256.c @@ -0,0 +1,46 @@ +/* See LICENSE file for copyright and license details. */ +#ifdef SUPPORT_SHA2 +# define TEST +# include "../common.h" + + +static struct testcase testcases[] = { + {1, 0, "", "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}, + {1, 0, "\xbd", "68325720aabd7c82f30f554b313d0570c95accbb7dc4b5aae11204c08ffe732b"}, + {1, 0, "\xc9\x8c\x8eU", "7abc22c0ae5af26ce93dbb94433a0e0b2e119d014f8e7f65bd56c61ccccd9504"}, + {55UL, 8, "\0", "02779466cdec163811d078815c633f21901413081449002f24aa3e80f0b88ef7"}, + {56UL, 8, "\0", "d4817aa5497628e7c77e6b606107042bbba3130888c5f47a375e6179be789fbb"}, + {57UL, 8, "\0", "65a16cb7861335d5ace3c60718b5052e44660726da4cd13bb745381b235a1785"}, + {64UL, 8, "\0", "f5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb4b"}, + {1000UL, 8, "\0", "541b3e9daa09b20bf85fa273e5cbd3e80185aa4ec298e765db87742b70138a53"}, + {1000UL, 0, "A", "c2e686823489ced2017f6059b8b239318b6364f6dcd835d0a519105a1eadd6e4"}, + {1005UL, 0, "U", "f4d62ddec0f3dd90ea1380fa16a5ff8dc4c54b21740650f24afc4120903552b0"}, + {1000000UL, 8, "\0", "d29751f2649b32ff572b5e0a9f541ea660a50f94ff0beedfb0b692b924cc8025"}, +#ifdef MASSIVE_TESTS + {0x20000000UL, 0, "Z", "15a1868c12cc53951e182344277447cd0979536badcc512ad24c67e9b2d4f3dd"}, + {0x41000000UL, 8, "\0", "461c19a93bd4344f9215f5ec64357090342bc66b15a148317d276e31cbc20b53"}, + {0x6000003EUL, 0, "B", "c23ce8a7895f4b21ec0daf37920ac0a262a220045a03eb2dfed48ef9b05aabea"}, +#endif + {1, 0, "abc", "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"}, + {1, 0, "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", + "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1"}, + {0, 1, "\xff", "b9debf7d52f36e6468a54817c1fa071166c3a63d384850e1575b42f702dc5aa1"}, + {0, 1, "\x7f", "b9debf7d52f36e6468a54817c1fa071166c3a63d384850e1575b42f702dc5aa1"}, + {0, 1, "\x01", "b9debf7d52f36e6468a54817c1fa071166c3a63d384850e1575b42f702dc5aa1"}, + {0, 1, "\xfe", "bd4f9e98beb68c6ead3243b1b4c7fed75fa4feaab1f84795cbd8a98676a2a375"}, + {0, 1, "\x7e", "bd4f9e98beb68c6ead3243b1b4c7fed75fa4feaab1f84795cbd8a98676a2a375"}, + {0, 1, "\x00", "bd4f9e98beb68c6ead3243b1b4c7fed75fa4feaab1f84795cbd8a98676a2a375"} +}; + + +#else +# define TEST_UNSUPPORTED +# include "../common.h" +#endif + + +int +main(void) +{ + TEST_MAIN("SHA-256", SHA_256); +} diff --git a/t/sha_384.c b/t/sha_384.c new file mode 100644 index 0000000..95b4079 --- /dev/null +++ b/t/sha_384.c @@ -0,0 +1,57 @@ +/* See LICENSE file for copyright and license details. */ +#ifdef SUPPORT_SHA2 +# define TEST +# include "../common.h" + + +static struct testcase testcases[] = { + {1, 0, "", + "38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b"}, + {111UL, 8, "\0", + "435770712c611be7293a66dd0dc8d1450dc7ff7337bfe115bf058ef2eb9bed09cee85c26963a5bcc0905dc2df7cc6a76"}, + {112UL, 8, "\0", + "3e0cbf3aee0e3aa70415beae1bd12dd7db821efa446440f12132edffce76f635e53526a111491e75ee8e27b9700eec20"}, + {113UL, 8, "\0", + "6be9af2cf3cd5dd12c8d9399ec2b34e66034fbd699d4e0221d39074172a380656089caafe8f39963f94cc7c0a07e3d21"}, + {122UL, 8, "\0", + "12a72ae4972776b0db7d73d160a15ef0d19645ec96c7f816411ab780c794aa496a22909d941fe671ed3f3caee900bdd5"}, + {1000UL, 8, "\0", + "aae017d4ae5b6346dd60a19d52130fb55194b6327dd40b89c11efc8222292de81e1a23c9b59f9f58b7f6ad463fa108ca"}, + {1000UL, 0, "A", + "7df01148677b7f18617eee3a23104f0eed6bb8c90a6046f715c9445ff43c30d69e9e7082de39c3452fd1d3afd9ba0689"}, + {1005UL, 0, "U", + "1bb8e256da4a0d1e87453528254f223b4cb7e49c4420dbfa766bba4adba44eeca392ff6a9f565bc347158cc970ce44ec"}, + {1000000UL, 8, "\0", + "8a1979f9049b3fff15ea3a43a4cf84c634fd14acad1c333fecb72c588b68868b66a994386dc0cd1687b9ee2e34983b81"}, +#ifdef MASSIVE_TESTS + {0x20000000UL, 0, "Z", + "18aded227cc6b562cc7fb259e8f404549e52914531aa1c5d85167897c779cc4b25d0425fd1590e40bd763ec3f4311c1a"}, + {0x41000000UL, 8, "\0", + "83ab05ca483abe3faa597ad524d31291ae827c5be2b3efcb6391bfed31ccd937b6135e0378c6c7f598857a7c516f207a"}, + {0x6000003EUL, 0, "B", + "cf852304f8d80209351b37ce69ca7dcf34972b4edb7817028ec55ab67ad3bc96eecb8241734258a85d2afce65d4571e2"}, +#endif + {1, 0, "abc", + "cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7"}, + {1, 0, "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu", + "09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712fcc7c71a557e2db966c3e9fa91746039"}, + {0, 1, "\xff", "9eef0094544d88a6e9ccdf9e31d039c5ca96682293ab1cc3afc6016486190f3d20c89d5a13ebc9d13ff011b411af9186"}, + {0, 1, "\x7f", "9eef0094544d88a6e9ccdf9e31d039c5ca96682293ab1cc3afc6016486190f3d20c89d5a13ebc9d13ff011b411af9186"}, + {0, 1, "\x01", "9eef0094544d88a6e9ccdf9e31d039c5ca96682293ab1cc3afc6016486190f3d20c89d5a13ebc9d13ff011b411af9186"}, + {0, 1, "\xfe", "634aa63038a164ae6c7d48b319f2aca0a107908e548519204c6d72dbeac0fdc3c9246674f98e8fd30221ba986e737d61"}, + {0, 1, "\x7e", "634aa63038a164ae6c7d48b319f2aca0a107908e548519204c6d72dbeac0fdc3c9246674f98e8fd30221ba986e737d61"}, + {0, 1, "\x00", "634aa63038a164ae6c7d48b319f2aca0a107908e548519204c6d72dbeac0fdc3c9246674f98e8fd30221ba986e737d61"} +}; + + +#else +# define TEST_UNSUPPORTED +# include "../common.h" +#endif + + +int +main(void) +{ + TEST_MAIN("SHA-384", SHA_384); +} diff --git a/t/sha_512.c b/t/sha_512.c new file mode 100644 index 0000000..f98685f --- /dev/null +++ b/t/sha_512.c @@ -0,0 +1,84 @@ +/* See LICENSE file for copyright and license details. */ +#ifdef SUPPORT_SHA2 +# define TEST +# include "../common.h" + + +static struct testcase testcases[] = { + {1, 0, "", + "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce" + "47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e"}, + {111UL, 8, "\0", + "77ddd3a542e530fd047b8977c657ba6ce72f1492e360b2b2212cd264e75ec038" + "82e4ff0525517ab4207d14c70c2259ba88d4d335ee0e7e20543d22102ab1788c"}, + {112UL, 8, "\0", + "2be2e788c8a8adeaa9c89a7f78904cacea6e39297d75e0573a73c756234534d6" + "627ab4156b48a6657b29ab8beb73334040ad39ead81446bb09c70704ec707952"}, + {113UL, 8, "\0", + "0e67910bcf0f9ccde5464c63b9c850a12a759227d16b040d98986d54253f9f34" + "322318e56b8feb86c5fb2270ed87f31252f7f68493ee759743909bd75e4bb544"}, + {122UL, 8, "\0", + "4f3f095d015be4a7a7cc0b8c04da4aa09e74351e3a97651f744c23716ebd9b3e" + "822e5077a01baa5cc0ed45b9249e88ab343d4333539df21ed229da6f4a514e0f"}, + {1000UL, 8, "\0", + "ca3dff61bb23477aa6087b27508264a6f9126ee3a004f53cb8db942ed345f2f2" + "d229b4b59c859220a1cf1913f34248e3803bab650e849a3d9a709edc09ae4a76"}, + {1000UL, 0, "A", + "329c52ac62d1fe731151f2b895a00475445ef74f50b979c6f7bb7cae349328c1" + "d4cb4f7261a0ab43f936a24b000651d4a824fcdd577f211aef8f806b16afe8af"}, + {1005UL, 0, "U", + "59f5e54fe299c6a8764c6b199e44924a37f59e2b56c3ebad939b7289210dc8e4" + "c21b9720165b0f4d4374c90f1bf4fb4a5ace17a1161798015052893a48c3d161"}, + {1000000UL, 8, "\0", + "ce044bc9fd43269d5bbc946cbebc3bb711341115cc4abdf2edbc3ff2c57ad4b1" + "5deb699bda257fea5aef9c6e55fcf4cf9dc25a8c3ce25f2efe90908379bff7ed"}, +# ifdef MASSIVE_TESTS + {0x20000000UL, 0, "Z", + "da172279f3ebbda95f6b6e1e5f0ebec682c25d3d93561a1624c2fa9009d64c7e" + "9923f3b46bcaf11d39a531f43297992ba4155c7e827bd0f1e194ae7ed6de4cac"}, + {0x41000000UL, 8, "\0", + "14b1be901cb43549b4d831e61e5f9df1c791c85b50e85f9d6bc64135804ad43c" + "e8402750edbe4e5c0fc170b99cf78b9f4ecb9c7e02a157911d1bd1832d76784f"}, + {0x6000003EUL, 0, "B", + "fd05e13eb771f05190bd97d62647157ea8f1f6949a52bb6daaedbad5f578ec59" + "b1b8d6c4a7ecb2feca6892b4dc138771670a0f3bd577eea326aed40ab7dd58b1"}, +# endif + {1, 0, "abc", + "ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a" + "2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f"}, + {1, 0, "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhi" + "jklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu", + "8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018" + "501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909"}, + {0, 1, "\xff", + "5f72ee8494a425ba13fc8c48ac0a05cbaae7e932e471e948cb524333745aa432" + "c1851c0c43682b0e67d64626f8f45cf165f6b538a94c63be98224e969e75d7ed"}, + {0, 1, "\x7f", + "5f72ee8494a425ba13fc8c48ac0a05cbaae7e932e471e948cb524333745aa432" + "c1851c0c43682b0e67d64626f8f45cf165f6b538a94c63be98224e969e75d7ed"}, + {0, 1, "\x01", + "5f72ee8494a425ba13fc8c48ac0a05cbaae7e932e471e948cb524333745aa432" + "c1851c0c43682b0e67d64626f8f45cf165f6b538a94c63be98224e969e75d7ed"}, + {0, 1, "\xfe", + "b4594eb12959fc2e6979b6783554299cc0369f44083a8b0955baefd8830cda22" + "894b0b46c0ed49490e391ad99af856cc1bd96f238c7f2a17cf37aeb7e793395a"}, + {0, 1, "\x7e", + "b4594eb12959fc2e6979b6783554299cc0369f44083a8b0955baefd8830cda22" + "894b0b46c0ed49490e391ad99af856cc1bd96f238c7f2a17cf37aeb7e793395a"}, + {0, 1, "\x00", + "b4594eb12959fc2e6979b6783554299cc0369f44083a8b0955baefd8830cda22" + "894b0b46c0ed49490e391ad99af856cc1bd96f238c7f2a17cf37aeb7e793395a"} +}; + + +#else +# define TEST_UNSUPPORTED +# include "../common.h" +#endif + + +int +main(void) +{ + TEST_MAIN("SHA-512", SHA_512); +} diff --git a/t/sha_512_224.c b/t/sha_512_224.c new file mode 100644 index 0000000..3c0d33b --- /dev/null +++ b/t/sha_512_224.c @@ -0,0 +1,26 @@ +/* See LICENSE file for copyright and license details. */ +#ifdef SUPPORT_SHA2 +# define TEST +# include "../common.h" + + +static struct testcase testcases[] = { + {1, 0, "", "6ed0dd02806fa89e25de060c19d3ac86cabb87d6a0ddd05c333b84f4"}, + {1000UL, 0, "A", "3000c31a7ab8e9c760257073c4d3be370fab6d1d28eb027c6d874f29"}, + {1, 0, "abc", "4634270f707b6a54daae7530460842e20e37ed265ceee9a43e8924aa"}, + {1, 0, "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu", + "23fec5bb94d60b23308192640b0c453335d664734fe40e7268674af9"} +}; + + +#else +# define TEST_UNSUPPORTED +# include "../common.h" +#endif + + +int +main(void) +{ + TEST_MAIN("SHA-512/224", SHA_512_224); +} diff --git a/t/sha_512_256.c b/t/sha_512_256.c new file mode 100644 index 0000000..bc4b56a --- /dev/null +++ b/t/sha_512_256.c @@ -0,0 +1,26 @@ +/* See LICENSE file for copyright and license details. */ +#ifdef SUPPORT_SHA2 +# define TEST +# include "../common.h" + + +static struct testcase testcases[] = { + {1, 0, "", "c672b8d1ef56ed28ab87c3622c5114069bdd3ad7b8f9737498d0c01ecef0967a"}, + {1000UL, 0, "A", "6ad592c8991fa0fc0fc78b6c2e73f3b55db74afeb1027a5aeacb787fb531e64a"}, + {1, 0, "abc", "53048e2681941ef99b2e29b76b4c7dabe4c2d0c634fc6d46e0e2f13107e7af23"}, + {1, 0, "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu", + "3928e184fb8690f840da3988121d31be65cb9d3ef83ee6146feac861e19b563a"} +}; + + +#else +# define TEST_UNSUPPORTED +# include "../common.h" +#endif + + +int +main(void) +{ + TEST_MAIN("SHA-512/256", SHA_512_256); +} diff --git a/t/shake128.c b/t/shake128.c new file mode 100644 index 0000000..10c24b3 --- /dev/null +++ b/t/shake128.c @@ -0,0 +1,88 @@ +/* See LICENSE file for copyright and license details. */ +#ifdef SUPPORT_SHAKE +# define TEST +# include "../common.h" + + +#define MSG5 "\x13" +#define MSG30 "\x53\x58\x7B\x19" +#define MSG1600_32 "\xA3\xA3\xA3\xA3" +#define MSG1600_160 MSG1600_32 MSG1600_32 MSG1600_32 MSG1600_32 MSG1600_32 +#define MSG1600_800 MSG1600_160 MSG1600_160 MSG1600_160 MSG1600_160 MSG1600_160 +#define MSG1600 MSG1600_800 MSG1600_800 +#define MSG1605 MSG1600_800 MSG1600_800 "\x03" +#define MSG1630 MSG1600_800 MSG1600_800 "\xA3\xA3\xA3\x23" + + +static struct testcase testcases[] = { + {1, 0, "", "7f9c2ba4e88f827d616045507605853e"}, + {1, 5, MSG5, "2e0abfba83e6720bfbc225ff6b7ab9ff"}, + {1, 6, MSG30, "6d5d39c55f3cca567feaf422dc64ba17"}, + {1, 0, MSG1600, "131ab8d2b594946b9c81333f9bb6e0ce"}, + {1, 5, MSG1605, "4ac38ebd1678b4a452792c5673f9777d"}, + {1, 6, MSG1630, "89846dc776ac0f014572ea79f5607734"} +}; + + +#else +# define TEST_UNSUPPORTED +# include "../common.h" +#endif + + +static int +main_test(void) +{ + TEST_MAIN("SHAKE128", SHAKE128); +} + + +int +main(void) +{ +#ifdef SUPPORT_SHAKE + struct libhashsum_hasher hasher; + char hexsum[1024]; +#endif + + int r = main_test(); + if (r) + return r; + + ASSERT(!libhashsum_init_shake128_hasher(&hasher, 8)); + ASSERT(!strcmp(hasher.algorithm_string, "SHAKE128[n=8]")); + ASSERT(!hasher.finalise_const(&hasher, "", 0, 0)); + ASSERT(hasher.hash_size == 1); + hex(hexsum, hasher.hash_output, hasher.hash_size); + ASSERT(!strcmp(hexsum, "7f")); + + ASSERT(!libhashsum_init_shake128_hasher(&hasher, 32)); + ASSERT(!strcmp(hasher.algorithm_string, "SHAKE128[n=32]")); + ASSERT(!hasher.finalise_const(&hasher, "", 0, 0)); + ASSERT(hasher.hash_size == 4); + hex(hexsum, hasher.hash_output, hasher.hash_size); + ASSERT(!strcmp(hexsum, "7f9c2ba4")); + + ASSERT(!libhashsum_init_shake128_hasher(&hasher, 32)); + ASSERT(!strcmp(hasher.algorithm_string, "SHAKE128[n=32]")); + ASSERT(!hasher.finalise_const(&hasher, MSG1600, 1600/8, 0)); + ASSERT(hasher.hash_size == 4); + hex(hexsum, hasher.hash_output, hasher.hash_size); + ASSERT(!strcmp(hexsum, "131ab8d2")); + + ASSERT(!libhashsum_init_shake128_hasher(&hasher, 128)); + ASSERT(!strcmp(hasher.algorithm_string, "SHAKE128")); + ASSERT(!hasher.finalise_const(&hasher, MSG1600, 1600/8, 0)); + ASSERT(hasher.hash_size == 128/8); + hex(hexsum, hasher.hash_output, hasher.hash_size); + ASSERT(!strcmp(hexsum, "131ab8d2b594946b9c81333f9bb6e0ce")); + + ASSERT(!libhashsum_init_shake128_hasher(&hasher, 256)); + ASSERT(!strcmp(hasher.algorithm_string, "SHAKE128[n=256]")); + ASSERT(!hasher.finalise_const(&hasher, MSG1600, 1600/8, 0)); + ASSERT(hasher.hash_size == 256/8); + hex(hexsum, hasher.hash_output, hasher.hash_size); + ASSERT(!strcmp(hexsum, "131ab8d2b594946b9c81333f9bb6e0ce75c3b93104fa3469d3917457385da037")); + + return 0; +} diff --git a/t/shake256.c b/t/shake256.c new file mode 100644 index 0000000..0ddf9b3 --- /dev/null +++ b/t/shake256.c @@ -0,0 +1,89 @@ +/* See LICENSE file for copyright and license details. */ +#ifdef SUPPORT_SHAKE +# define TEST +# include "../common.h" + + +#define MSG5 "\x13" +#define MSG30 "\x53\x58\x7B\x19" +#define MSG1600_32 "\xA3\xA3\xA3\xA3" +#define MSG1600_160 MSG1600_32 MSG1600_32 MSG1600_32 MSG1600_32 MSG1600_32 +#define MSG1600_800 MSG1600_160 MSG1600_160 MSG1600_160 MSG1600_160 MSG1600_160 +#define MSG1600 MSG1600_800 MSG1600_800 +#define MSG1605 MSG1600_800 MSG1600_800 "\x03" +#define MSG1630 MSG1600_800 MSG1600_800 "\xA3\xA3\xA3\x23" + + +static struct testcase testcases[] = { + {1, 0, "", "46b9dd2b0ba88d13233b3feb743eeb243fcd52ea62b81b82b50c27646ed5762f"}, + {1, 5, MSG5, "48a5c11abaeeff092f3646ef0d6b3d3ff76c2f55f9c732ac6470c03764008212"}, + {1, 6, MSG30, "465d081dff875e396200e4481a3e9dcd88d079aa6d66226cb6ba454107cb81a7"}, + {1, 0, MSG1600, "cd8a920ed141aa0407a22d59288652e9d9f1a7ee0c1e7c1ca699424da84a904d"}, + {1, 5, MSG1605, "98d093b067475760124ffb9204a5b327c6bb05c54ff234f0b43fac7240415166"}, + {1, 6, MSG1630, "8a8325079b0fc3265d52f59855cafe655df438aa639f6fec991f2494330ce32f"} +}; + + +#else +# define TEST_UNSUPPORTED +# include "../common.h" +#endif + + +static int +main_test(void) +{ + TEST_MAIN("SHAKE256", SHAKE256); +} + + +int +main(void) +{ +#ifdef SUPPORT_SHAKE + struct libhashsum_hasher hasher; + char hexsum[1024]; +#endif + + int r = main_test(); + if (r) + return r; + + ASSERT(!libhashsum_init_shake256_hasher(&hasher, 8)); + ASSERT(!strcmp(hasher.algorithm_string, "SHAKE256[n=8]")); + ASSERT(!hasher.finalise_const(&hasher, "", 0, 0)); + ASSERT(hasher.hash_size == 1); + hex(hexsum, hasher.hash_output, hasher.hash_size); + ASSERT(!strcmp(hexsum, "46")); + + ASSERT(!libhashsum_init_shake256_hasher(&hasher, 32)); + ASSERT(!strcmp(hasher.algorithm_string, "SHAKE256[n=32]")); + ASSERT(!hasher.finalise_const(&hasher, "", 0, 0)); + ASSERT(hasher.hash_size == 4); + hex(hexsum, hasher.hash_output, hasher.hash_size); + ASSERT(!strcmp(hexsum, "46b9dd2b")); + + ASSERT(!libhashsum_init_shake256_hasher(&hasher, 32)); + ASSERT(!strcmp(hasher.algorithm_string, "SHAKE256[n=32]")); + ASSERT(!hasher.finalise_const(&hasher, MSG1600, 1600/8, 0)); + ASSERT(hasher.hash_size == 4); + hex(hexsum, hasher.hash_output, hasher.hash_size); + ASSERT(!strcmp(hexsum, "cd8a920e")); + + ASSERT(!libhashsum_init_shake256_hasher(&hasher, 256)); + ASSERT(!strcmp(hasher.algorithm_string, "SHAKE256")); + ASSERT(!hasher.finalise_const(&hasher, MSG1600, 1600/8, 0)); + ASSERT(hasher.hash_size == 256/8); + hex(hexsum, hasher.hash_output, hasher.hash_size); + ASSERT(!strcmp(hexsum, "cd8a920ed141aa0407a22d59288652e9d9f1a7ee0c1e7c1ca699424da84a904d")); + + ASSERT(!libhashsum_init_shake256_hasher(&hasher, 512)); + ASSERT(!strcmp(hasher.algorithm_string, "SHAKE256[n=512]")); + ASSERT(!hasher.finalise_const(&hasher, MSG1600, 1600/8, 0)); + ASSERT(hasher.hash_size == 512/8); + hex(hexsum, hasher.hash_output, hasher.hash_size); + ASSERT(!strcmp(hexsum, "cd8a920ed141aa0407a22d59288652e9d9f1a7ee0c1e7c1ca699424da84a904d" + "2d700caae7396ece96604440577da4f3aa22aeb8857f961c4cd8e06f0ae6610b")); + + return 0; +} diff --git a/t/shake512.c b/t/shake512.c new file mode 100644 index 0000000..f9f0a54 --- /dev/null +++ b/t/shake512.c @@ -0,0 +1,88 @@ +/* See LICENSE file for copyright and license details. */ +#ifdef SUPPORT_SHAKE +# define TEST +# include "../common.h" + + +#define MSG1600_32 "\xA3\xA3\xA3\xA3" +#define MSG1600_160 MSG1600_32 MSG1600_32 MSG1600_32 MSG1600_32 MSG1600_32 +#define MSG1600_800 MSG1600_160 MSG1600_160 MSG1600_160 MSG1600_160 MSG1600_160 +#define MSG1600 MSG1600_800 MSG1600_800 + + +static struct testcase testcases[] = { + {1, 0, "", + "ae1b4eea1eaf5ea633e66045f03ff11b8b7d3193119075442117bd786dfd939f" + "25a53a30fae503488d42683c1917b3964f6b1cf5d27c2b40cbaf53c5b749666a"}, + {1, 0, MSG1600, + "9701303d390f51968c25b6eee54816d19ab149a1c06b0625940bb8e04a1ceccd" + "d88010234f53abbbaf181f49761a3ecefaee56de7b59b5aaf0031e3c1552c9ac"} +}; + + +#else +# define TEST_UNSUPPORTED +# include "../common.h" +#endif + + +static int +main_test(void) +{ + TEST_MAIN("SHAKE512", SHAKE512); +} + + +int +main(void) +{ +#ifdef SUPPORT_SHAKE + struct libhashsum_hasher hasher; + char hexsum[1024]; +#endif + + int r = main_test(); + if (r) + return r; + + ASSERT(!libhashsum_init_shake512_hasher(&hasher, 8)); + ASSERT(!strcmp(hasher.algorithm_string, "SHAKE512[n=8]")); + ASSERT(!hasher.finalise_const(&hasher, "", 0, 0)); + ASSERT(hasher.hash_size == 1); + hex(hexsum, hasher.hash_output, hasher.hash_size); + ASSERT(!strcmp(hexsum, "ae")); + + ASSERT(!libhashsum_init_shake512_hasher(&hasher, 32)); + ASSERT(!strcmp(hasher.algorithm_string, "SHAKE512[n=32]")); + ASSERT(!hasher.finalise_const(&hasher, "", 0, 0)); + ASSERT(hasher.hash_size == 4); + hex(hexsum, hasher.hash_output, hasher.hash_size); + ASSERT(!strcmp(hexsum, "ae1b4eea")); + + ASSERT(!libhashsum_init_shake512_hasher(&hasher, 32)); + ASSERT(!strcmp(hasher.algorithm_string, "SHAKE512[n=32]")); + ASSERT(!hasher.finalise_const(&hasher, MSG1600, 1600/8, 0)); + ASSERT(hasher.hash_size == 4); + hex(hexsum, hasher.hash_output, hasher.hash_size); + ASSERT(!strcmp(hexsum, "9701303d")); + + ASSERT(!libhashsum_init_shake512_hasher(&hasher, 512)); + ASSERT(!strcmp(hasher.algorithm_string, "SHAKE512")); + ASSERT(!hasher.finalise_const(&hasher, MSG1600, 1600/8, 0)); + ASSERT(hasher.hash_size == 512/8); + hex(hexsum, hasher.hash_output, hasher.hash_size); + ASSERT(!strcmp(hexsum, "9701303d390f51968c25b6eee54816d19ab149a1c06b0625940bb8e04a1ceccd" + "d88010234f53abbbaf181f49761a3ecefaee56de7b59b5aaf0031e3c1552c9ac")); + + ASSERT(!libhashsum_init_shake512_hasher(&hasher, 1024)); + ASSERT(!strcmp(hasher.algorithm_string, "SHAKE512[n=1024]")); + ASSERT(!hasher.finalise_const(&hasher, MSG1600, 1600/8, 0)); + ASSERT(hasher.hash_size == 1024/8); + hex(hexsum, hasher.hash_output, hasher.hash_size); + ASSERT(!strcmp(hexsum, "9701303d390f51968c25b6eee54816d19ab149a1c06b0625940bb8e04a1ceccd" + "d88010234f53abbbaf181f49761a3ecefaee56de7b59b5aaf0031e3c1552c9ac" + "40dfaf6aac934fd644dbc4a3d753e1f3845a5901f415dff2a88440f6a8f5688f" + "f26e68ecc6ad23acf18e0a54be745db919fab01f77a251d5f66b01e2426bf020")); + + return 0; +} |