diff --git a/doc/crypt.tex b/doc/crypt.tex index 0894f229f..b3bcbc3f4 100644 --- a/doc/crypt.tex +++ b/doc/crypt.tex @@ -3143,6 +3143,21 @@ \subsection{TurboSHAKE} The init function \code{turbo\_shake\_init()} is implemented as a macro which calls \code{sha3\_shake\_init()}. +\subsection{KangarooTwelve} +Another variation of SHA3 SHAKE is KangarooTwelve, which has been specified in \href{https://datatracker.ietf.org/doc/rfc9861/}{\texttt{RFC 9861}}. + +The API works equivalent to the one of SHA3 SHAKE, where the APIs only have a different name. Additionally, KangarooTwelve supports customization. You can append any or none customization bytes after all input bytes and before squeezing any output digest bytes. + +\begin{small} +\begin{verbatim} +int kangaroo_twelve_init(hash_state *md, int num); +int kangaroo_twelve_process(hash_state *md, const unsigned char *in, unsigned long inlen); +int kangaroo_twelve_customization(hash_state *md, const unsigned char *in, unsigned long inlen); +int kangaroo_twelve_done(hash_state *md, unsigned char *out, unsigned long outlen); +\end{verbatim} +\end{small} + + \mysection{Extended Tiger API} The Tiger and Tiger2 hash algorithms \url{http://www.cs.technion.ac.il/~biham/Reports/Tiger/} specify the possibility to run the algorithm with diff --git a/src/hashes/sha3.c b/src/hashes/sha3.c index 4756b58da..3646cbae3 100644 --- a/src/hashes/sha3.c +++ b/src/hashes/sha3.c @@ -353,19 +353,19 @@ int keccak_done(hash_state *md, unsigned char *out) #endif #ifdef LTC_SHA3 -static LTC_INLINE int s_sha3_shake_done(hash_state *md, unsigned char *out, unsigned long outlen, process_fn proc_f) +static LTC_INLINE int s_sha3_shake_done(hash_state *md, unsigned char *out, unsigned long outlen, unsigned char domain, process_fn proc_f) { /* IMPORTANT NOTE: sha3_shake_done can be called many times */ unsigned long idx; unsigned i; if (outlen == 0) return CRYPT_OK; /* nothing to do */ - LTC_ARGCHK(md != NULL); + LTC_ARGCHK(md != NULL); LTC_ARGCHK(out != NULL); if (!md->sha3.xof_flag) { /* shake_xof operation must be done only once */ - md->sha3.s[md->sha3.word_index] ^= (md->sha3.saved ^ (CONST64(0x1F) << (md->sha3.byte_index * 8))); + md->sha3.s[md->sha3.word_index] ^= (md->sha3.saved ^ (((ulong64)(domain)) << (md->sha3.byte_index * 8))); md->sha3.s[SHA3_KECCAK_SPONGE_WORDS - md->sha3.capacity_words - 1] ^= CONST64(0x8000000000000000); proc_f(md->sha3.s); /* store sha3.s[] as little-endian bytes into sha3.sb */ @@ -392,13 +392,13 @@ static LTC_INLINE int s_sha3_shake_done(hash_state *md, unsigned char *out, unsi int sha3_shake_done(hash_state *md, unsigned char *out, unsigned long outlen) { - return s_sha3_shake_done(md, out, outlen, s_keccakf); + return s_sha3_shake_done(md, out, outlen, 0x1f, s_keccakf); } #if defined LTC_TURBO_SHAKE int turbo_shake_done(hash_state *md, unsigned char *out, unsigned long outlen) { - return s_sha3_shake_done(md, out, outlen, s_keccak_turbo_f); + return s_sha3_shake_done(md, out, outlen, 0x1f, s_keccak_turbo_f); } #endif @@ -416,4 +416,152 @@ int sha3_shake_memory(int num, const unsigned char *in, unsigned long inlen, uns } #endif +#ifdef LTC_KANGAROO_TWELVE + +static const unsigned char kangaroo_twelve_filler[] = { 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +int kangaroo_twelve_init(hash_state *md, int num) +{ + int err; + + LTC_ARGCHK(md != NULL); + LTC_ARGCHK(num == 128 || num == 256); + + if ((err = sha3_shake_init((hash_state*)&md->kt.outer, num)) != CRYPT_OK) return err; + if ((err = sha3_shake_init((hash_state*)&md->kt.inner, num)) != CRYPT_OK) return err; + md->kt.blocks_count = 0; + md->kt.customization_len = 0; + md->kt.remaining = 8 * 1024; + md->kt.phase = 0; + md->kt.finished = 0; + return CRYPT_OK; +} + +static LTC_INLINE int s_kangaroo_twelve_process(hash_state *md, const unsigned char *in, unsigned long inlen) +{ + unsigned long rem; + unsigned long amount; + int err; + int variant; + int digest_len; + unsigned char digest_buf[64]; + + LTC_ARGCHK(md != NULL); + LTC_ARGCHK(in != NULL || inlen == 0); + + if (md->kt.phase == 0) + { + rem = md->kt.remaining; + amount = rem < inlen ? rem : inlen; + md->kt.remaining -= amount; + if ((err = turbo_shake_process((hash_state*)&md->kt.outer, in, amount)) != CRYPT_OK) return err; + in += amount; + inlen -= amount; + if (md->kt.remaining == 0 && inlen != 0) + { + md->kt.remaining = 8 * 1024; + md->kt.phase = 1; + md->kt.blocks_count += 1; + if ((err = turbo_shake_process((hash_state*)&md->kt.outer, kangaroo_twelve_filler, sizeof(kangaroo_twelve_filler))) != CRYPT_OK) return err; + } + } + if (md->kt.phase == 1) + { + do + { + rem = md->kt.remaining; + amount = rem < inlen ? rem : inlen; + md->kt.remaining -= amount; + if ((err = turbo_shake_process((hash_state*)&md->kt.inner, in, amount)) != CRYPT_OK) return err; + in += amount; + inlen -= amount; + if (md->kt.remaining == 0 && inlen != 0) + { + md->kt.remaining = 8 * 1024; + md->kt.blocks_count += 1; + assert(md->kt.outer.capacity_words == 4 || md->kt.outer.capacity_words == 8); + variant = md->kt.outer.capacity_words == 4 ? 128 : 256; + digest_len = variant == 128 ? 32 : 64; + if ((err = s_sha3_shake_done((hash_state*)&md->kt.inner, digest_buf, digest_len, 0x0b, s_keccak_turbo_f)) != CRYPT_OK) return err; + if ((err = turbo_shake_init((hash_state*)&md->kt.inner, variant)) != CRYPT_OK) return err; + if ((err = turbo_shake_process((hash_state*)&md->kt.outer, digest_buf, digest_len)) != CRYPT_OK) return err; + } + } while (inlen != 0); + } + return CRYPT_OK; +} + +int kangaroo_twelve_process(hash_state *md, const unsigned char *in, unsigned long inlen) +{ + LTC_ARGCHK(md != NULL); + LTC_ARGCHK(in != NULL || inlen == 0); + LTC_ARGCHK(md->kt.customization_len == 0); + LTC_ARGCHK(md->kt.finished == 0); + + return s_kangaroo_twelve_process(md, in, inlen); +} + +int kangaroo_twelve_customization(hash_state *md, const unsigned char *in, unsigned long inlen) +{ + LTC_ARGCHK(md != NULL); + LTC_ARGCHK(in != NULL || inlen == 0); + LTC_ARGCHK(md->kt.finished == 0); + + md->kt.customization_len += inlen; + return s_kangaroo_twelve_process(md, in, inlen); +} + +int kangaroo_twelve_done(hash_state *md, unsigned char *out, unsigned long outlen) +{ + int couner_len; + unsigned char couner_buf[sizeof(ulong64) + 1]; + int err; + int variant; + int digest_len; + unsigned char digest_buf[64]; + unsigned char ffff[2]; + unsigned char domain; + + LTC_ARGCHK(md != NULL); + LTC_ARGCHK(out != NULL || outlen == 0); + + if (md->kt.finished == 0) + { + md->kt.finished = 1; + couner_len = 0; + while (md->kt.customization_len != 0) + { + couner_buf[LTC_ARRAY_SIZE(couner_buf) - 1 - 1 - couner_len] = md->kt.customization_len & 0xff; + md->kt.customization_len >>= 8; + ++couner_len; + } + couner_buf[LTC_ARRAY_SIZE(couner_buf) - 1] = couner_len; + if ((err = s_kangaroo_twelve_process(md, &couner_buf[LTC_ARRAY_SIZE(couner_buf) - 1 - couner_len], couner_len + 1)) != CRYPT_OK) return err; + if(md->kt.phase != 0) + { + assert(md->kt.outer.capacity_words == 4 || md->kt.outer.capacity_words == 8); + variant = md->kt.outer.capacity_words == 4 ? 128 : 256; + digest_len = variant == 128 ? 32 : 64; + if ((err = s_sha3_shake_done((hash_state*)&md->kt.inner, digest_buf, digest_len, 0x0b, s_keccak_turbo_f)) != CRYPT_OK) return err; + if ((err = turbo_shake_process((hash_state*)&md->kt.outer, digest_buf, digest_len)) != CRYPT_OK) return err; + couner_len = 0; + while (md->kt.blocks_count != 0) + { + couner_buf[LTC_ARRAY_SIZE(couner_buf) - 1 - 1 - couner_len] = md->kt.blocks_count & 0xff; + md->kt.blocks_count >>= 8; + ++couner_len; + } + couner_buf[LTC_ARRAY_SIZE(couner_buf) - 1] = couner_len; + if ((err = turbo_shake_process((hash_state*)&md->kt.outer, &couner_buf[LTC_ARRAY_SIZE(couner_buf) - 1 - couner_len], couner_len + 1)) != CRYPT_OK) return err; + ffff[0] = 0xff; + ffff[1] = 0xff; + if ((err = turbo_shake_process((hash_state*)&md->kt.outer, ffff, LTC_ARRAY_SIZE(ffff))) != CRYPT_OK) return err; + } + } + domain = md->kt.phase == 0 ? 0x07 : 0x06; + return s_sha3_shake_done(md, out, outlen, domain, s_keccak_turbo_f); +} + +#endif + #endif diff --git a/src/hashes/sha3_test.c b/src/hashes/sha3_test.c index e052df9ea..80a3285bf 100644 --- a/src/hashes/sha3_test.c +++ b/src/hashes/sha3_test.c @@ -388,6 +388,84 @@ int sha3_shake_test(void) #endif } +#if defined LTC_TURBO_SHAKE || defined LTC_KANGAROO_TWELVE +static LTC_INLINE int s_turbo_shake_generate_ptn(unsigned char* buffer, long offset, long amount) +{ + long i; + + LTC_ARGCHK(buffer != NULL || amount == 0); + LTC_ARGCHK(offset >= 0); + LTC_ARGCHK(amount >= 0); + + for(i = 0; i != amount; ++i) + { + buffer[i] = ((unsigned char)(((offset + i) % 0xfb) & 0xff)); + } + return CRYPT_OK; +} +#endif + +#ifdef LTC_TURBO_SHAKE +typedef struct turbo_shake_test_case { + int bits_count; + unsigned long input_bytes_count, skip_digest_bytes, digest_bytes_count; + const char *expected_digest_hex; +} turbo_shake_test_case; + +static LTC_INLINE int s_turbo_shake_test_one(const turbo_shake_test_case *testcase, int counter) +{ + int err; + hash_state md; + unsigned long offset; + unsigned long rem; + unsigned long count; + unsigned char input[1024]; + unsigned char digest[64]; + const char *expected_hex; + unsigned char expected_digest_bin[sizeof(digest)]; + unsigned long decoded; + + LTC_ARGCHK(testcase != NULL); + LTC_ARGCHK(testcase->bits_count == 128 || testcase->bits_count == 256); + LTC_ARGCHK(testcase->digest_bytes_count >= 1); + LTC_ARGCHK(testcase->expected_digest_hex && testcase->expected_digest_hex[0] != '\0'); + LTC_ARGCHK(counter >= 0); + + if ((err = turbo_shake_init(&md, testcase->bits_count)) != CRYPT_OK) return err; + offset = 0; + rem = testcase->input_bytes_count; + do + { + count = rem < sizeof(input) ? rem : sizeof(input); + if ((err = s_turbo_shake_generate_ptn(input, offset, count)) != CRYPT_OK) return err; + if ((err = turbo_shake_process(&md, input, count)) != CRYPT_OK) return err; + offset += count; + rem -= count; + }while(rem != 0); + rem = testcase->skip_digest_bytes; + do + { + count = rem < sizeof(digest) ? rem : sizeof(digest); + if ((err = turbo_shake_done(&md, digest, count)) != CRYPT_OK) return err; + rem -= count; + }while(rem != 0); + rem = testcase->digest_bytes_count; + expected_hex = testcase->expected_digest_hex; + do + { + count = rem < sizeof(digest) ? rem : sizeof(digest); + decoded = count; + if ((err = base16_decode(expected_hex, count * 2, expected_digest_bin, &decoded)) != CRYPT_OK) return err; + if (decoded != (unsigned long)count) return CRYPT_ERROR; + if ((err = turbo_shake_done(&md, digest, count)) != CRYPT_OK) return err; + LTC_COMPARE_TESTVECTOR(digest, count, expected_digest_bin, count, "TurboSHAKE", counter); + rem -= count; + expected_hex += count * 2; + }while(rem != 0); + return CRYPT_OK; +} +#endif + #ifdef LTC_TURBO_SHAKE int turbo_shake_test(void) { @@ -395,154 +473,176 @@ int turbo_shake_test(void) return CRYPT_NOP; #else int counter; - unsigned char hash[64]; - hash_state c; - int i; + int err; /* https://datatracker.ietf.org/doc/html/rfc9861#name-test-vectors */ /* https://www.rfc-editor.org/rfc/rfc9861.txt */ - const unsigned char turbo_shake_input_single_zero[] = { - 0x00, - }; - const unsigned char turbo_shake_input_ptn_17_pow_1[] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, - }; - const unsigned char turbo_shake_input_ptn_17_pow_2[] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, - 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, - 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, - 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, - 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, - 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, - 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, - }; - const unsigned char turbo_shake_128_empty[64] = { - 0x1e, 0x41, 0x5f, 0x1c, 0x59, 0x83, 0xaf, 0xf2, 0x16, 0x92, 0x17, 0x27, 0x7d, 0x17, 0xbb, 0x53, - 0x8c, 0xd9, 0x45, 0xa3, 0x97, 0xdd, 0xec, 0x54, 0x1f, 0x1c, 0xe4, 0x1a, 0xf2, 0xc1, 0xb7, 0x4c, - 0x3e, 0x8c, 0xca, 0xe2, 0xa4, 0xda, 0xe5, 0x6c, 0x84, 0xa0, 0x4c, 0x23, 0x85, 0xc0, 0x3c, 0x15, - 0xe8, 0x19, 0x3b, 0xdf, 0x58, 0x73, 0x73, 0x63, 0x32, 0x16, 0x91, 0xc0, 0x54, 0x62, 0xc8, 0xdf, - }; - const unsigned char turbo_shake_128_empty_10032[32] = { - 0xa3, 0xb9, 0xb0, 0x38, 0x59, 0x00, 0xce, 0x76, 0x1f, 0x22, 0xae, 0xd5, 0x48, 0xe7, 0x54, 0xda, - 0x10, 0xa5, 0x24, 0x2d, 0x62, 0xe8, 0xc6, 0x58, 0xe3, 0xf3, 0xa9, 0x23, 0xa7, 0x55, 0x56, 0x07, - }; - const unsigned char turbo_shake_128_single_zero_byte[32] = { - 0x55, 0xce, 0xdd, 0x6f, 0x60, 0xaf, 0x7b, 0xb2, 0x9a, 0x40, 0x42, 0xae, 0x83, 0x2e, 0xf3, 0xf5, - 0x8d, 0xb7, 0x29, 0x9f, 0x89, 0x3e, 0xbb, 0x92, 0x47, 0x24, 0x7d, 0x85, 0x69, 0x58, 0xda, 0xa9, - }; - const unsigned char turbo_shake_128_ptn_pow_1[32] = { - 0x9c, 0x97, 0xd0, 0x36, 0xa3, 0xba, 0xc8, 0x19, 0xdb, 0x70, 0xed, 0xe0, 0xca, 0x55, 0x4e, 0xc6, - 0xe4, 0xc2, 0xa1, 0xa4, 0xff, 0xbf, 0xd9, 0xec, 0x26, 0x9c, 0xa6, 0xa1, 0x11, 0x16, 0x12, 0x33, - }; - const unsigned char turbo_shake_128_ptn_pow_2[32] = { - 0x96, 0xc7, 0x7c, 0x27, 0x9e, 0x01, 0x26, 0xf7, 0xfc, 0x07, 0xc9, 0xb0, 0x7f, 0x5c, 0xda, 0xe1, - 0xe0, 0xbe, 0x60, 0xbd, 0xbe, 0x10, 0x62, 0x00, 0x40, 0xe7, 0x5d, 0x72, 0x23, 0xa6, 0x24, 0xd2, + const turbo_shake_test_case testcases[] = { + { 128, 0, 0, 32, "1e415f1c5983aff2169217277d17bb538cd945a397ddec541f1ce41af2c1b74c" }, + { 128, 0, 0, 64, "1e415f1c5983aff2169217277d17bb538cd945a397ddec541f1ce41af2c1b74c3e8ccae2a4dae56c84a04c2385c03c15e8193bdf58737363321691c05462c8df" }, + { 128, 0, 10000, 32, "a3b9b0385900ce761f22aed548e754da10a5242d62e8c658e3f3a923a7555607" }, + { 128, 1, 0, 32, "55cedd6f60af7bb29a4042ae832ef3f58db7299f893ebb9247247d856958daa9" }, + { 128, 17, 0, 32, "9c97d036a3bac819db70ede0ca554ec6e4c2a1a4ffbfd9ec269ca6a111161233" }, + { 128, 17*17, 0, 32, "96c77c279e0126f7fc07c9b07f5cdae1e0be60bdbe10620040e75d7223a624d2" }, + { 128, 17*17*17, 0, 32, "d4976eb56bcf118520582b709f73e1d6853e001fdaf80e1b13e0d0599d5fb372" }, + { 128, 17*17*17*17, 0, 32, "da67c7039e98bf530cf7a37830c6664e14cbab7f540f58403b1b82951318ee5c" }, + { 128, 17*17*17*17*17, 0, 32, "b97a906fbf83ef7c812517abf3b2d0aea0c4f60318ce11cf103925127f59eecd" }, + { 128, 17*17*17*17*17*17, 0, 32, "35cd494adeded2f25239af09a7b8ef0c4d1ca4fe2d1ac370fa63216fe7b4c2b1" }, + { 256, 0, 0, 64, "367a329dafea871c7802ec67f905ae13c57695dc2c6663c61035f59a18f8e7db11edc0e12e91ea60eb6b32df06dd7f002fbafabb6e13ec1cc20d995547600db0" }, + { 256, 0, 10000, 32, "abefa11630c661269249742685ec082f207265dccf2f43534e9c61ba0c9d1d75" }, + { 256, 1, 0, 64, "3e1712f928f8eaf1054632b2aa0a246ed8b0c378728f60bc970410155c28820e90cc90d8a3006aa2372c5c5ea176b0682bf22bae7467ac94f74d43d39b0482e2" }, + { 256, 17, 0, 64, "b3bab0300e6a191fbe6137939835923578794ea54843f5011090fa2f3780a9e5cb22c59d78b40a0fbff9e672c0fbe0970bd2c845091c6044d687054da5d8e9c7" }, + { 256, 17*17, 0, 64, "66b810db8e90780424c0847372fdc95710882fde31c6df75beb9d4cd9305cfcae35e7b83e8b7e6eb4b78605880116316fe2c078a09b94ad7b8213c0a738b65c0" }, + { 256, 17*17*17, 0, 64, "c74ebc919a5b3b0dd1228185ba02d29ef442d69d3d4276a93efe0bf9a16a7dc0cd4eabadab8cd7a5edd96695f5d360abe09e2c6511a3ec397da3b76b9e1674fb" }, + { 256, 17*17*17*17, 0, 64, "02cc3a8897e6f4f6ccb6fd46631b1f5207b66c6de9c7b55b2d1a23134a170afdac234eaba9a77cff88c1f020b73724618c5687b362c430b248cd38647f848a1d" }, + { 256, 17*17*17*17*17, 0, 64, "add53b06543e584b5823f626996aee50fe45ed15f20243a7165485acb4aa76b4ffda75cedf6d8cdc95c332bd56f4b986b58bb17d1778bfc1b1a97545cdf4ec9f" }, + { 256, 17*17*17*17*17*17, 0, 64, "9e11bc59c24e73993c1484ec66358ef71db74aefd84e123f7800ba9c4853e02cfe701d9e6bb765a304f0dc34a4ee3ba82c410f0da70e86bfbd90ea877c2d6104" }, }; + for (counter = 0; counter < (int)LTC_ARRAY_SIZE(testcases); counter++) { + if ((err = s_turbo_shake_test_one(&testcases[counter], counter)) != CRYPT_OK) { + return err; + } + } + return CRYPT_OK; +#endif +} +#endif - const unsigned char turbo_shake_256_empty[64] = { - 0x36, 0x7a, 0x32, 0x9d, 0xaf, 0xea, 0x87, 0x1c, 0x78, 0x02, 0xec, 0x67, 0xf9, 0x05, 0xae, 0x13, - 0xc5, 0x76, 0x95, 0xdc, 0x2c, 0x66, 0x63, 0xc6, 0x10, 0x35, 0xf5, 0x9a, 0x18, 0xf8, 0xe7, 0xdb, - 0x11, 0xed, 0xc0, 0xe1, 0x2e, 0x91, 0xea, 0x60, 0xeb, 0x6b, 0x32, 0xdf, 0x06, 0xdd, 0x7f, 0x00, - 0x2f, 0xba, 0xfa, 0xbb, 0x6e, 0x13, 0xec, 0x1c, 0xc2, 0x0d, 0x99, 0x55, 0x47, 0x60, 0x0d, 0xb0, - }; - const unsigned char turbo_shake_256_empty_10032[32] = { - 0xab, 0xef, 0xa1, 0x16, 0x30, 0xc6, 0x61, 0x26, 0x92, 0x49, 0x74, 0x26, 0x85, 0xec, 0x08, 0x2f, - 0x20, 0x72, 0x65, 0xdc, 0xcf, 0x2f, 0x43, 0x53, 0x4e, 0x9c, 0x61, 0xba, 0x0c, 0x9d, 0x1d, 0x75, - }; - const unsigned char turbo_shake_256_single_zero_byte[64] = { - 0x3e, 0x17, 0x12, 0xf9, 0x28, 0xf8, 0xea, 0xf1, 0x05, 0x46, 0x32, 0xb2, 0xaa, 0x0a, 0x24, 0x6e, - 0xd8, 0xb0, 0xc3, 0x78, 0x72, 0x8f, 0x60, 0xbc, 0x97, 0x04, 0x10, 0x15, 0x5c, 0x28, 0x82, 0x0e, - 0x90, 0xcc, 0x90, 0xd8, 0xa3, 0x00, 0x6a, 0xa2, 0x37, 0x2c, 0x5c, 0x5e, 0xa1, 0x76, 0xb0, 0x68, - 0x2b, 0xf2, 0x2b, 0xae, 0x74, 0x67, 0xac, 0x94, 0xf7, 0x4d, 0x43, 0xd3, 0x9b, 0x04, 0x82, 0xe2, - }; - const unsigned char turbo_shake_256_ptn_pow_1[64] = { - 0xb3, 0xba, 0xb0, 0x30, 0x0e, 0x6a, 0x19, 0x1f, 0xbe, 0x61, 0x37, 0x93, 0x98, 0x35, 0x92, 0x35, - 0x78, 0x79, 0x4e, 0xa5, 0x48, 0x43, 0xf5, 0x01, 0x10, 0x90, 0xfa, 0x2f, 0x37, 0x80, 0xa9, 0xe5, - 0xcb, 0x22, 0xc5, 0x9d, 0x78, 0xb4, 0x0a, 0x0f, 0xbf, 0xf9, 0xe6, 0x72, 0xc0, 0xfb, 0xe0, 0x97, - 0x0b, 0xd2, 0xc8, 0x45, 0x09, 0x1c, 0x60, 0x44, 0xd6, 0x87, 0x05, 0x4d, 0xa5, 0xd8, 0xe9, 0xc7, - }; - const unsigned char turbo_shake_256_ptn_pow_2[64] = { - 0x66, 0xb8, 0x10, 0xdb, 0x8e, 0x90, 0x78, 0x04, 0x24, 0xc0, 0x84, 0x73, 0x72, 0xfd, 0xc9, 0x57, - 0x10, 0x88, 0x2f, 0xde, 0x31, 0xc6, 0xdf, 0x75, 0xbe, 0xb9, 0xd4, 0xcd, 0x93, 0x05, 0xcf, 0xca, - 0xe3, 0x5e, 0x7b, 0x83, 0xe8, 0xb7, 0xe6, 0xeb, 0x4b, 0x78, 0x60, 0x58, 0x80, 0x11, 0x63, 0x16, - 0xfe, 0x2c, 0x07, 0x8a, 0x09, 0xb9, 0x4a, 0xd7, 0xb8, 0x21, 0x3c, 0x0a, 0x73, 0x8b, 0x65, 0xc0, - }; +#ifdef LTC_KANGAROO_TWELVE +typedef struct kangaroo_twelve_test_case { + int bits_count, is_ptn; + unsigned long input_bytes_count, customization_bytes_count, skip_digest_bytes, digest_bytes_count; + const char *expected_digest_hex; +} kangaroo_twelve_test_case; + +static LTC_INLINE int s_kangaroo_twelve_test_one(const kangaroo_twelve_test_case *testcase, int counter) +{ + int err; + hash_state md; + unsigned long offset; + unsigned long rem; + unsigned long count; + unsigned char input[1024]; + unsigned char digest[64]; + const char *expected_hex; + unsigned char expected_digest_bin[sizeof(digest)]; + unsigned long decoded; + + LTC_ARGCHK(testcase != NULL); + LTC_ARGCHK(testcase->bits_count == 128 || testcase->bits_count == 256); + LTC_ARGCHK(testcase->is_ptn == 0 || testcase->is_ptn == 1); + LTC_ARGCHK(testcase->digest_bytes_count >= 1); + LTC_ARGCHK(testcase->expected_digest_hex && testcase->expected_digest_hex[0] != '\0'); + LTC_ARGCHK(counter >= 0); + + if ((err = kangaroo_twelve_init(&md, testcase->bits_count)) != CRYPT_OK) return err; + offset = 0; + rem = testcase->input_bytes_count; + do + { + count = rem < sizeof(input) ? rem : sizeof(input); + if (testcase->is_ptn) + { + if ((err = s_turbo_shake_generate_ptn(input, offset, count)) != CRYPT_OK) return err; + } + else + { + XMEMSET(input, 0xff, count); + } + if ((err = kangaroo_twelve_process(&md, input, count)) != CRYPT_OK) return err; + offset += count; + rem -= count; + }while(rem != 0); + offset = 0; + rem = testcase->customization_bytes_count; + do + { + count = rem < sizeof(input) ? rem : sizeof(input); + if ((err = s_turbo_shake_generate_ptn(input, offset, count)) != CRYPT_OK) return err; + if ((err = kangaroo_twelve_customization(&md, input, count)) != CRYPT_OK) return err; + offset += count; + rem -= count; + }while(rem != 0); + rem = testcase->skip_digest_bytes; + do + { + count = rem < sizeof(digest) ? rem : sizeof(digest); + if ((err = kangaroo_twelve_done(&md, digest, count)) != CRYPT_OK) return err; + rem -= count; + }while(rem != 0); + rem = testcase->digest_bytes_count; + expected_hex = testcase->expected_digest_hex; + do + { + count = rem < sizeof(digest) ? rem : sizeof(digest); + decoded = count; + if ((err = base16_decode(expected_hex, count * 2, expected_digest_bin, &decoded)) != CRYPT_OK) return err; + if (decoded != (unsigned long)count) return CRYPT_ERROR; + if ((err = kangaroo_twelve_done(&md, digest, count)) != CRYPT_OK) return err; + LTC_COMPARE_TESTVECTOR(digest, count, expected_digest_bin, count, "KangarooTwelve", counter); + rem -= count; + expected_hex += count * 2; + }while(rem != 0); + return CRYPT_OK; +} +#endif + +#ifdef LTC_KANGAROO_TWELVE +int kangaroo_twelve_test(void) +{ +#ifndef LTC_TEST + return CRYPT_NOP; +#else + int counter; + int err; - counter = 0; - - /* TurboSHAKE128 on an empty buffer */ - turbo_shake_init(&c, 128); - turbo_shake_done(&c, hash, 64); - LTC_COMPARE_TESTVECTOR(hash, 64, turbo_shake_128_empty, sizeof(turbo_shake_128_empty), "TurboSHAKE128", counter++); - - /* TurboSHAKE128 on an empty buffer, digest length 10032 bytes, test last 32 bytes */ - turbo_shake_init(&c, 128); - for(i = 0; i != 10000 / 10; ++i){ turbo_shake_done(&c, hash, 10); } - turbo_shake_done(&c, hash, 32); - LTC_COMPARE_TESTVECTOR(hash, 32, turbo_shake_128_empty_10032, sizeof(turbo_shake_128_empty_10032), "TurboSHAKE128", counter++); - - /* TurboSHAKE128 on single zero byte */ - turbo_shake_init(&c, 128); - turbo_shake_process(&c, turbo_shake_input_single_zero, sizeof(turbo_shake_input_single_zero)); - turbo_shake_done(&c, hash, 32); - LTC_COMPARE_TESTVECTOR(hash, 32, turbo_shake_128_single_zero_byte, sizeof(turbo_shake_128_single_zero_byte), "TurboSHAKE128", counter++); - - /* TurboSHAKE128 on ptn(17**1) */ - turbo_shake_init(&c, 128); - turbo_shake_process(&c, turbo_shake_input_ptn_17_pow_1, sizeof(turbo_shake_input_ptn_17_pow_1)); - turbo_shake_done(&c, hash, 32); - LTC_COMPARE_TESTVECTOR(hash, 32, turbo_shake_128_ptn_pow_1, sizeof(turbo_shake_128_ptn_pow_1), "TurboSHAKE128", counter++); - - /* TurboSHAKE128 on ptn(17**2) */ - turbo_shake_init(&c, 128); - turbo_shake_process(&c, turbo_shake_input_ptn_17_pow_2, sizeof(turbo_shake_input_ptn_17_pow_2)); - turbo_shake_done(&c, hash, 32); - LTC_COMPARE_TESTVECTOR(hash, 32, turbo_shake_128_ptn_pow_2, sizeof(turbo_shake_128_ptn_pow_2), "TurboSHAKE128", counter++); - - - /* TurboSHAKE256 on an empty buffer */ - turbo_shake_init(&c, 256); - turbo_shake_done(&c, hash, 64); - LTC_COMPARE_TESTVECTOR(hash, 64, turbo_shake_256_empty, sizeof(turbo_shake_256_empty), "TurboSHAKE256", counter++); - - /* TurboSHAKE256 on an empty buffer, digest length 10032 bytes, test last 32 bytes */ - turbo_shake_init(&c, 256); - for(i = 0; i != 10000 / 10; ++i){ turbo_shake_done(&c, hash, 10); } - turbo_shake_done(&c, hash, 32); - LTC_COMPARE_TESTVECTOR(hash, 32, turbo_shake_256_empty_10032, sizeof(turbo_shake_256_empty_10032), "TurboSHAKE256", counter++); - - /* TurboSHAKE256 on single zero byte */ - turbo_shake_init(&c, 256); - turbo_shake_process(&c, turbo_shake_input_single_zero, sizeof(turbo_shake_input_single_zero)); - turbo_shake_done(&c, hash, 64); - LTC_COMPARE_TESTVECTOR(hash, 64, turbo_shake_256_single_zero_byte, sizeof(turbo_shake_256_single_zero_byte), "TurboSHAKE256", counter++); - - /* TurboSHAKE256 on ptn(17**1) */ - turbo_shake_init(&c, 256); - turbo_shake_process(&c, turbo_shake_input_ptn_17_pow_1, sizeof(turbo_shake_input_ptn_17_pow_1)); - turbo_shake_done(&c, hash, 64); - LTC_COMPARE_TESTVECTOR(hash, 64, turbo_shake_256_ptn_pow_1, sizeof(turbo_shake_256_ptn_pow_1), "TurboSHAKE256", counter++); - - /* TurboSHAKE256 on ptn(17**2) */ - turbo_shake_init(&c, 256); - turbo_shake_process(&c, turbo_shake_input_ptn_17_pow_2, sizeof(turbo_shake_input_ptn_17_pow_2)); - turbo_shake_done(&c, hash, 64); - LTC_COMPARE_TESTVECTOR(hash, 64, turbo_shake_256_ptn_pow_2, sizeof(turbo_shake_256_ptn_pow_2), "TurboSHAKE256", counter++); + /* https://datatracker.ietf.org/doc/html/rfc9861#name-test-vectors */ + /* https://www.rfc-editor.org/rfc/rfc9861.txt */ + const kangaroo_twelve_test_case testcases[] = { + { 128, 1, 0, 0, 0, 32, "1ac2d450fc3b4205d19da7bfca1b37513c0803577ac7167f06fe2ce1f0ef39e5" }, + { 128, 1, 0, 0, 0, 64, "1ac2d450fc3b4205d19da7bfca1b37513c0803577ac7167f06fe2ce1f0ef39e54269c056b8c82e48276038b6d292966cc07a3d4645272e31ff38508139eb0a71" }, + { 128, 1, 0, 0, 10000, 32, "e8dc563642f7228c84684c898405d3a834799158c079b12880277a1d28e2ff6d" }, + { 128, 1, 1, 0, 0, 32, "2bda92450e8b147f8a7cb629e784a058efca7cf7d8218e02d345dfaa65244a1f" }, + { 128, 1, 17, 0, 0, 32, "6bf75fa2239198db4772e36478f8e19b0f371205f6a9a93a273f51df37122888" }, + { 128, 1, 17*17, 0, 0, 32, "0c315ebcdedbf61426de7dcf8fb725d1e74675d7f5327a5067f367b108ecb67c" }, + { 128, 1, 17*17*17, 0, 0, 32, "cb552e2ec77d9910701d578b457ddf772c12e322e4ee7fe417f92c758f0d59d0" }, + { 128, 1, 17*17*17*17, 0, 0, 32, "8701045e22205345ff4dda05555cbb5c3af1a771c2b89baef37db43d9998b9fe" }, + { 128, 1, 17*17*17*17*17, 0, 0, 32, "844d610933b1b9963cbdeb5ae3b6b05cc7cbd67ceedf883eb678a0a8e0371682" }, + { 128, 1, 17*17*17*17*17*17, 0, 0, 32, "3c390782a8a4e89fa6367f72feaaf13255c8d95878481d3cd8ce85f58e880af8" }, + { 128, 1, 0, 1, 0, 32, "fab658db63e94a246188bf7af69a133045f46ee984c56e3c3328caaf1aa1a583" }, + { 128, 0, 1, 41, 0, 32, "d848c5068ced736f4462159b9867fd4c20b808acc3d5bc48e0b06ba0a3762ec4" }, + { 128, 0, 3, 41*41, 0, 32, "c389e5009ae57120854c2e8c64670ac01358cf4c1baf89447a724234dc7ced74" }, + { 128, 0, 7, 41*41*41, 0, 32, "75d2f86a2e644566726b4fbcfc5657b9dbcf070c7b0dca06450ab291d7443bcf" }, + { 128, 1, 8191, 0, 0, 32, "1b577636f723643e990cc7d6a659837436fd6a103626600eb8301cd1dbe553d6" }, + { 128, 1, 8192, 0, 0, 32, "48f256f6772f9edfb6a8b661ec92dc93b95ebd05a08a17b39ae3490870c926c3" }, + { 128, 1, 8192, 8189, 0, 32, "3ed12f70fb05ddb58689510ab3e4d23c6c6033849aa01e1d8c220a297fedcd0b" }, + { 128, 1, 8192, 8190, 0, 32, "6a7c1b6a5cd0d8c9ca943a4a216cc64604559a2ea45f78570a15253d67ba00ae" }, + { 256, 1, 0, 0, 0, 64, "b23d2e9cea9f4904e02bec06817fc10ce38ce8e93ef4c89e6537076af8646404e3e8b68107b8833a5d30490aa33482353fd4adc7148ecb782855003aaebde4a9" }, + { 256, 1, 0, 0, 0, 128, "b23d2e9cea9f4904e02bec06817fc10ce38ce8e93ef4c89e6537076af8646404e3e8b68107b8833a5d30490aa33482353fd4adc7148ecb782855003aaebde4a9b0925319d8ea1e121a609821ec19efea89e6d08daee1662b69c840289f188ba860f55760b61f82114c030c97e5178449608ccd2cd2d919fc7829ff69931ac4d0" }, + { 256, 1, 0, 0, 10000, 64, "ad4a1d718cf950506709a4c33396139b4449041fc79a05d68da35f1e453522e056c64fe94958e7085f2964888259b9932752f3ccd855288efee5fcbb8b563069" }, + { 256, 1, 1, 0, 0, 64, "0d005a194085360217128cf17f91e1f71314efa5564539d444912e3437efa17f82db6f6ffe76e781eaa068bce01f2bbf81eacb983d7230f2fb02834a21b1ddd0" }, + { 256, 1, 17, 0, 0, 64, "1ba3c02b1fc514474f06c8979978a9056c8483f4a1b63d0dccefe3a28a2f323e1cdcca40ebf006ac76ef0397152346837b1277d3e7faa9c9653b19075098527b" }, + { 256, 1, 17*17, 0, 0, 64, "de8ccbc63e0f133ebb4416814d4c66f691bbf8b6a61ec0a7700f836b086cb029d54f12ac7159472c72db118c35b4e6aa213c6562caaa9dcc518959e69b10f3ba" }, + { 256, 1, 17*17*17, 0, 0, 64, "647efb49fe9d717500171b41e7f11bd491544443209997ce1c2530d15eb1ffbb598935ef954528ffc152b1e4d731ee2683680674365cd191d562bae753b84aa5" }, + { 256, 1, 17*17*17*17, 0, 0, 64, "b06275d284cd1cf205bcbe57dccd3ec1ff6686e3ed15776383e1f2fa3c6ac8f08bf8a162829db1a44b2a43ff83dd89c3cf1ceb61ede659766d5ccf817a62ba8d" }, + { 256, 1, 17*17*17*17*17, 0, 0, 64, "9473831d76a4c7bf77ace45b59f1458b1673d64bcd877a7c66b2664aa6dd149e60eab71b5c2bab858c074ded81ddce2b4022b5215935c0d4d19bf511aeeb0772" }, + { 256, 1, 17*17*17*17*17*17, 0, 0, 64, "0652b740d78c5e1f7c8dcc1777097382768b7ff38f9a7a20f29f413bb1b3045b31a5578f568f911e09cf44746da84224a5266e96a4a535e871324e4f9c7004da" }, + { 256, 1, 0, 1, 0, 64, "9280f5cc39b54a5a594ec63de0bb99371e4609d44bf845c2f5b8c316d72b159811f748f23e3fabbe5c3226ec96c62186df2d33e9df74c5069ceecbb4dd10eff6" }, + { 256, 0, 1, 41, 0, 64, "47ef96dd616f200937aa7847e34ec2feae8087e3761dc0f8c1a154f51dc9ccf845d7adbce57ff64b639722c6a1672e3bf5372d87e00aff89be97240756998853" }, + { 256, 0, 3, 41*41, 0, 64, "3b48667a5051c5966c53c5d42b95de451e05584e7806e2fb765eda959074172cb438a9e91dde337c98e9c41bed94c4e0aef431d0b64ef2324f7932caa6f54969" }, + { 256, 0, 7, 41*41*41, 0, 64, "e0911cc00025e1540831e266d94add9b98712142b80d2629e643aac4efaf5a3a30a88cbf4ac2a91a2432743054fbcc9897670e86ba8cec2fc2ace9c966369724" }, + { 256, 1, 8191, 0, 0, 64, "3081434d93a4108d8d8a3305b89682cebedc7ca4ea8a3ce869fbb73cbe4a58eef6f24de38ffc170514c70e7ab2d01f03812616e863d769afb3753193ba045b20" }, + { 256, 1, 8192, 0, 0, 64, "c6ee8e2ad3200c018ac87aaa031cdac22121b412d07dc6e0dccbb53423747e9a1c18834d99df596cf0cf4b8dfafb7bf02d139d0c9035725adc1a01b7230a41fa" }, + { 256, 1, 8192, 8189, 0, 64, "74e47879f10a9c5d11bd2da7e194fe57e86378bf3c3f7448eff3c576a0f18c5caae0999979512090a7f348af4260d4de3c37f1ecaf8d2c2c96c1d16c64b12496" }, + { 256, 1, 8192, 8190, 0, 64, "f4b5908b929ffe01e0f79ec2f21243d41a396b2e7303a6af1d6399cd6c7a0a2dd7c4f607e8277f9c9b1cb4ab9ddc59d4b92d1fc7558441f1832c3279a4241b8b" }, + }; + for (counter = 0; counter < (int)LTC_ARRAY_SIZE(testcases); counter++) { + if ((err = s_kangaroo_twelve_test_one(&testcases[counter], counter)) != CRYPT_OK) { + return err; + } + } return CRYPT_OK; #endif } diff --git a/src/headers/tomcrypt_custom.h b/src/headers/tomcrypt_custom.h index 3fc51c750..740506f03 100644 --- a/src/headers/tomcrypt_custom.h +++ b/src/headers/tomcrypt_custom.h @@ -259,6 +259,7 @@ #define LTC_SHA3 #define LTC_KECCAK #define LTC_TURBO_SHAKE +#define LTC_KANGAROO_TWELVE #define LTC_SHA512 #define LTC_SHA512_256 #define LTC_SHA512_224 @@ -709,6 +710,14 @@ #error LTC_SPRNG requires LTC_RNG_GET_BYTES #endif +#if defined(LTC_TURBO_SHAKE) && !defined(LTC_SHA3) + #error LTC_TURBO_SHAKE requires LTC_SHA3 +#endif + +#if defined(LTC_KANGAROO_TWELVE) && !defined(LTC_TURBO_SHAKE) + #error LTC_KANGAROO_TWELVE requires LTC_TURBO_SHAKE +#endif + #if defined(LTC_NO_MATH) && (defined(LTM_DESC) || defined(TFM_DESC) || defined(GMP_DESC)) #error LTC_NO_MATH defined, but also a math descriptor #endif diff --git a/src/headers/tomcrypt_hash.h b/src/headers/tomcrypt_hash.h index 7dc43a441..9996245a8 100644 --- a/src/headers/tomcrypt_hash.h +++ b/src/headers/tomcrypt_hash.h @@ -14,6 +14,18 @@ struct sha3_state { }; #endif +#ifdef LTC_KANGAROO_TWELVE +struct kangaroo_twelve_state { + struct sha3_state outer; + struct sha3_state inner; + ulong64 blocks_count; + ulong64 customization_len; + unsigned short remaining; /* bytes out of 8kB block */ + unsigned char phase; /* 0 -- initial, 1 -- additional */ + unsigned char finished; /* 0 -- false, 1 -- true */ +}; +#endif + #ifdef LTC_SHA512 struct sha512_state { ulong64 length, state[8]; @@ -152,6 +164,9 @@ typedef union Hash_state { #if defined(LTC_SHA3) || defined(LTC_KECCAK) struct sha3_state sha3; #endif +#ifdef LTC_KANGAROO_TWELVE + struct kangaroo_twelve_state kt; +#endif #ifdef LTC_SHA512 struct sha512_state sha512; #endif @@ -309,6 +324,14 @@ int turbo_shake_done(hash_state *md, unsigned char *out, unsigned long outlen); int turbo_shake_test(void); #endif +#ifdef LTC_KANGAROO_TWELVE +int kangaroo_twelve_init(hash_state *md, int num); +int kangaroo_twelve_process(hash_state *md, const unsigned char *in, unsigned long inlen); +int kangaroo_twelve_customization(hash_state *md, const unsigned char *in, unsigned long inlen); +int kangaroo_twelve_done(hash_state *md, unsigned char *out, unsigned long outlen); +int kangaroo_twelve_test(void); +#endif + #ifdef LTC_SHA512 int sha512_init(hash_state * md); int sha512_process(hash_state * md, const unsigned char *in, unsigned long inlen); diff --git a/src/misc/crypt/crypt.c b/src/misc/crypt/crypt.c index 97065a3fc..90120bff3 100644 --- a/src/misc/crypt/crypt.c +++ b/src/misc/crypt/crypt.c @@ -160,6 +160,9 @@ const char *crypt_build_settings = #if defined(LTC_TURBO_SHAKE) " TurboSHAKE\n" #endif +#if defined(LTC_KANGAROO_TWELVE) + " KangarooTwelve\n" +#endif #if defined(LTC_KECCAK) " KECCAK\n" #endif diff --git a/tests/cipher_hash_test.c b/tests/cipher_hash_test.c index a33e4f1e7..92e082307 100644 --- a/tests/cipher_hash_test.c +++ b/tests/cipher_hash_test.c @@ -63,6 +63,9 @@ int cipher_hash_test(void) #ifdef LTC_TURBO_SHAKE DO(turbo_shake_test()); #endif +#ifdef LTC_KANGAROO_TWELVE + DO(kangaroo_twelve_test()); +#endif return 0; }