From 02e707a9636b12c4ae0197b3bdddcc2328bcaa45 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Thu, 15 Jan 2026 23:17:59 +0100 Subject: [PATCH] Remove SHA3 wrapper --- .../msvc/vs2010/libsodium/libsodium.vcxproj | 3 - .../libsodium/libsodium.vcxproj.filters | 12 -- .../msvc/vs2012/libsodium/libsodium.vcxproj | 3 - .../libsodium/libsodium.vcxproj.filters | 12 -- .../msvc/vs2013/libsodium/libsodium.vcxproj | 3 - .../libsodium/libsodium.vcxproj.filters | 12 -- .../msvc/vs2015/libsodium/libsodium.vcxproj | 3 - .../libsodium/libsodium.vcxproj.filters | 12 -- .../msvc/vs2017/libsodium/libsodium.vcxproj | 3 - .../libsodium/libsodium.vcxproj.filters | 12 -- .../msvc/vs2019/libsodium/libsodium.vcxproj | 3 - .../libsodium/libsodium.vcxproj.filters | 12 -- .../msvc/vs2022/libsodium/libsodium.vcxproj | 3 - .../libsodium/libsodium.vcxproj.filters | 12 -- .../msvc/vs2026/libsodium/libsodium.vcxproj | 3 - .../libsodium/libsodium.vcxproj.filters | 12 -- ci/appveyor/libsodium.vcxproj | 3 - ci/appveyor/libsodium.vcxproj.filters | 9 -- src/libsodium/Makefile.am | 2 - src/libsodium/crypto_hash/sha3/hash_sha3.c | 136 +++++++++++++++--- src/libsodium/crypto_hash/sha3/ref/sha3_ref.c | 132 ----------------- src/libsodium/crypto_hash/sha3/ref/sha3_ref.h | 33 ----- 22 files changed, 115 insertions(+), 320 deletions(-) delete mode 100644 src/libsodium/crypto_hash/sha3/ref/sha3_ref.c delete mode 100644 src/libsodium/crypto_hash/sha3/ref/sha3_ref.h diff --git a/builds/msvc/vs2010/libsodium/libsodium.vcxproj b/builds/msvc/vs2010/libsodium/libsodium.vcxproj index dcd2e524..c6fe81c1 100644 --- a/builds/msvc/vs2010/libsodium/libsodium.vcxproj +++ b/builds/msvc/vs2010/libsodium/libsodium.vcxproj @@ -175,7 +175,6 @@ - @@ -224,7 +223,6 @@ - @@ -352,7 +350,6 @@ - diff --git a/builds/msvc/vs2010/libsodium/libsodium.vcxproj.filters b/builds/msvc/vs2010/libsodium/libsodium.vcxproj.filters index ac568c3e..fd9e8f88 100644 --- a/builds/msvc/vs2010/libsodium/libsodium.vcxproj.filters +++ b/builds/msvc/vs2010/libsodium/libsodium.vcxproj.filters @@ -345,9 +345,6 @@ crypto_hash\sha3 - - crypto_hash\sha3\ref - crypto_hash\sha256 @@ -488,9 +485,6 @@ include\sodium - - include\sodium - include\sodium @@ -872,9 +866,6 @@ crypto_stream\salsa20\xmm6 - - crypto_hash\sha3\ref - crypto_aead\aegis128l @@ -1051,9 +1042,6 @@ {6df763e3-9707-3014-8cfe-2f9a8a83a872} - - {11ec7cd9-b861-3226-bf76-510c4ca28c10} - {8fb6a906-dbd6-3746-9b0f-f49e7028daec} diff --git a/builds/msvc/vs2012/libsodium/libsodium.vcxproj b/builds/msvc/vs2012/libsodium/libsodium.vcxproj index 0f4b5982..ccec2101 100644 --- a/builds/msvc/vs2012/libsodium/libsodium.vcxproj +++ b/builds/msvc/vs2012/libsodium/libsodium.vcxproj @@ -175,7 +175,6 @@ - @@ -224,7 +223,6 @@ - @@ -352,7 +350,6 @@ - diff --git a/builds/msvc/vs2012/libsodium/libsodium.vcxproj.filters b/builds/msvc/vs2012/libsodium/libsodium.vcxproj.filters index ac568c3e..fd9e8f88 100644 --- a/builds/msvc/vs2012/libsodium/libsodium.vcxproj.filters +++ b/builds/msvc/vs2012/libsodium/libsodium.vcxproj.filters @@ -345,9 +345,6 @@ crypto_hash\sha3 - - crypto_hash\sha3\ref - crypto_hash\sha256 @@ -488,9 +485,6 @@ include\sodium - - include\sodium - include\sodium @@ -872,9 +866,6 @@ crypto_stream\salsa20\xmm6 - - crypto_hash\sha3\ref - crypto_aead\aegis128l @@ -1051,9 +1042,6 @@ {6df763e3-9707-3014-8cfe-2f9a8a83a872} - - {11ec7cd9-b861-3226-bf76-510c4ca28c10} - {8fb6a906-dbd6-3746-9b0f-f49e7028daec} diff --git a/builds/msvc/vs2013/libsodium/libsodium.vcxproj b/builds/msvc/vs2013/libsodium/libsodium.vcxproj index 2d446790..5b4aafc8 100644 --- a/builds/msvc/vs2013/libsodium/libsodium.vcxproj +++ b/builds/msvc/vs2013/libsodium/libsodium.vcxproj @@ -175,7 +175,6 @@ - @@ -224,7 +223,6 @@ - @@ -352,7 +350,6 @@ - diff --git a/builds/msvc/vs2013/libsodium/libsodium.vcxproj.filters b/builds/msvc/vs2013/libsodium/libsodium.vcxproj.filters index ac568c3e..fd9e8f88 100644 --- a/builds/msvc/vs2013/libsodium/libsodium.vcxproj.filters +++ b/builds/msvc/vs2013/libsodium/libsodium.vcxproj.filters @@ -345,9 +345,6 @@ crypto_hash\sha3 - - crypto_hash\sha3\ref - crypto_hash\sha256 @@ -488,9 +485,6 @@ include\sodium - - include\sodium - include\sodium @@ -872,9 +866,6 @@ crypto_stream\salsa20\xmm6 - - crypto_hash\sha3\ref - crypto_aead\aegis128l @@ -1051,9 +1042,6 @@ {6df763e3-9707-3014-8cfe-2f9a8a83a872} - - {11ec7cd9-b861-3226-bf76-510c4ca28c10} - {8fb6a906-dbd6-3746-9b0f-f49e7028daec} diff --git a/builds/msvc/vs2015/libsodium/libsodium.vcxproj b/builds/msvc/vs2015/libsodium/libsodium.vcxproj index bcc37163..6a77fc52 100644 --- a/builds/msvc/vs2015/libsodium/libsodium.vcxproj +++ b/builds/msvc/vs2015/libsodium/libsodium.vcxproj @@ -175,7 +175,6 @@ - @@ -224,7 +223,6 @@ - @@ -352,7 +350,6 @@ - diff --git a/builds/msvc/vs2015/libsodium/libsodium.vcxproj.filters b/builds/msvc/vs2015/libsodium/libsodium.vcxproj.filters index ac568c3e..fd9e8f88 100644 --- a/builds/msvc/vs2015/libsodium/libsodium.vcxproj.filters +++ b/builds/msvc/vs2015/libsodium/libsodium.vcxproj.filters @@ -345,9 +345,6 @@ crypto_hash\sha3 - - crypto_hash\sha3\ref - crypto_hash\sha256 @@ -488,9 +485,6 @@ include\sodium - - include\sodium - include\sodium @@ -872,9 +866,6 @@ crypto_stream\salsa20\xmm6 - - crypto_hash\sha3\ref - crypto_aead\aegis128l @@ -1051,9 +1042,6 @@ {6df763e3-9707-3014-8cfe-2f9a8a83a872} - - {11ec7cd9-b861-3226-bf76-510c4ca28c10} - {8fb6a906-dbd6-3746-9b0f-f49e7028daec} diff --git a/builds/msvc/vs2017/libsodium/libsodium.vcxproj b/builds/msvc/vs2017/libsodium/libsodium.vcxproj index eb3abecb..28abc9b7 100644 --- a/builds/msvc/vs2017/libsodium/libsodium.vcxproj +++ b/builds/msvc/vs2017/libsodium/libsodium.vcxproj @@ -175,7 +175,6 @@ - @@ -224,7 +223,6 @@ - @@ -352,7 +350,6 @@ - diff --git a/builds/msvc/vs2017/libsodium/libsodium.vcxproj.filters b/builds/msvc/vs2017/libsodium/libsodium.vcxproj.filters index ac568c3e..fd9e8f88 100644 --- a/builds/msvc/vs2017/libsodium/libsodium.vcxproj.filters +++ b/builds/msvc/vs2017/libsodium/libsodium.vcxproj.filters @@ -345,9 +345,6 @@ crypto_hash\sha3 - - crypto_hash\sha3\ref - crypto_hash\sha256 @@ -488,9 +485,6 @@ include\sodium - - include\sodium - include\sodium @@ -872,9 +866,6 @@ crypto_stream\salsa20\xmm6 - - crypto_hash\sha3\ref - crypto_aead\aegis128l @@ -1051,9 +1042,6 @@ {6df763e3-9707-3014-8cfe-2f9a8a83a872} - - {11ec7cd9-b861-3226-bf76-510c4ca28c10} - {8fb6a906-dbd6-3746-9b0f-f49e7028daec} diff --git a/builds/msvc/vs2019/libsodium/libsodium.vcxproj b/builds/msvc/vs2019/libsodium/libsodium.vcxproj index fe2db490..6b1d8677 100644 --- a/builds/msvc/vs2019/libsodium/libsodium.vcxproj +++ b/builds/msvc/vs2019/libsodium/libsodium.vcxproj @@ -199,7 +199,6 @@ - @@ -248,7 +247,6 @@ - @@ -376,7 +374,6 @@ - diff --git a/builds/msvc/vs2019/libsodium/libsodium.vcxproj.filters b/builds/msvc/vs2019/libsodium/libsodium.vcxproj.filters index ac568c3e..fd9e8f88 100644 --- a/builds/msvc/vs2019/libsodium/libsodium.vcxproj.filters +++ b/builds/msvc/vs2019/libsodium/libsodium.vcxproj.filters @@ -345,9 +345,6 @@ crypto_hash\sha3 - - crypto_hash\sha3\ref - crypto_hash\sha256 @@ -488,9 +485,6 @@ include\sodium - - include\sodium - include\sodium @@ -872,9 +866,6 @@ crypto_stream\salsa20\xmm6 - - crypto_hash\sha3\ref - crypto_aead\aegis128l @@ -1051,9 +1042,6 @@ {6df763e3-9707-3014-8cfe-2f9a8a83a872} - - {11ec7cd9-b861-3226-bf76-510c4ca28c10} - {8fb6a906-dbd6-3746-9b0f-f49e7028daec} diff --git a/builds/msvc/vs2022/libsodium/libsodium.vcxproj b/builds/msvc/vs2022/libsodium/libsodium.vcxproj index ffe420d7..c0708797 100644 --- a/builds/msvc/vs2022/libsodium/libsodium.vcxproj +++ b/builds/msvc/vs2022/libsodium/libsodium.vcxproj @@ -199,7 +199,6 @@ - @@ -248,7 +247,6 @@ - @@ -376,7 +374,6 @@ - diff --git a/builds/msvc/vs2022/libsodium/libsodium.vcxproj.filters b/builds/msvc/vs2022/libsodium/libsodium.vcxproj.filters index ac568c3e..fd9e8f88 100644 --- a/builds/msvc/vs2022/libsodium/libsodium.vcxproj.filters +++ b/builds/msvc/vs2022/libsodium/libsodium.vcxproj.filters @@ -345,9 +345,6 @@ crypto_hash\sha3 - - crypto_hash\sha3\ref - crypto_hash\sha256 @@ -488,9 +485,6 @@ include\sodium - - include\sodium - include\sodium @@ -872,9 +866,6 @@ crypto_stream\salsa20\xmm6 - - crypto_hash\sha3\ref - crypto_aead\aegis128l @@ -1051,9 +1042,6 @@ {6df763e3-9707-3014-8cfe-2f9a8a83a872} - - {11ec7cd9-b861-3226-bf76-510c4ca28c10} - {8fb6a906-dbd6-3746-9b0f-f49e7028daec} diff --git a/builds/msvc/vs2026/libsodium/libsodium.vcxproj b/builds/msvc/vs2026/libsodium/libsodium.vcxproj index b4b12242..fbe69650 100644 --- a/builds/msvc/vs2026/libsodium/libsodium.vcxproj +++ b/builds/msvc/vs2026/libsodium/libsodium.vcxproj @@ -199,7 +199,6 @@ - @@ -248,7 +247,6 @@ - @@ -376,7 +374,6 @@ - diff --git a/builds/msvc/vs2026/libsodium/libsodium.vcxproj.filters b/builds/msvc/vs2026/libsodium/libsodium.vcxproj.filters index ac568c3e..fd9e8f88 100644 --- a/builds/msvc/vs2026/libsodium/libsodium.vcxproj.filters +++ b/builds/msvc/vs2026/libsodium/libsodium.vcxproj.filters @@ -345,9 +345,6 @@ crypto_hash\sha3 - - crypto_hash\sha3\ref - crypto_hash\sha256 @@ -488,9 +485,6 @@ include\sodium - - include\sodium - include\sodium @@ -872,9 +866,6 @@ crypto_stream\salsa20\xmm6 - - crypto_hash\sha3\ref - crypto_aead\aegis128l @@ -1051,9 +1042,6 @@ {6df763e3-9707-3014-8cfe-2f9a8a83a872} - - {11ec7cd9-b861-3226-bf76-510c4ca28c10} - {8fb6a906-dbd6-3746-9b0f-f49e7028daec} diff --git a/ci/appveyor/libsodium.vcxproj b/ci/appveyor/libsodium.vcxproj index 414bfcd3..9158cf38 100644 --- a/ci/appveyor/libsodium.vcxproj +++ b/ci/appveyor/libsodium.vcxproj @@ -423,7 +423,6 @@ - @@ -472,7 +471,6 @@ - @@ -600,7 +598,6 @@ - diff --git a/ci/appveyor/libsodium.vcxproj.filters b/ci/appveyor/libsodium.vcxproj.filters index 3e08ed9d..81c1b174 100644 --- a/ci/appveyor/libsodium.vcxproj.filters +++ b/ci/appveyor/libsodium.vcxproj.filters @@ -336,9 +336,6 @@ Source Files - - Source Files - Source Files @@ -479,9 +476,6 @@ Header Files - - Header Files - Header Files @@ -863,9 +857,6 @@ Header Files - - Header Files - Header Files diff --git a/src/libsodium/Makefile.am b/src/libsodium/Makefile.am index 521aa757..1f565e48 100644 --- a/src/libsodium/Makefile.am +++ b/src/libsodium/Makefile.am @@ -51,8 +51,6 @@ libsodium_la_SOURCES = \ crypto_hash/sha512/hash_sha512.c \ crypto_hash/sha512/cp/hash_sha512_cp.c \ crypto_hash/sha3/hash_sha3.c \ - crypto_hash/sha3/ref/sha3_ref.c \ - crypto_hash/sha3/ref/sha3_ref.h \ crypto_ipcrypt/crypto_ipcrypt.c \ crypto_ipcrypt/ipcrypt_soft.c \ crypto_ipcrypt/ipcrypt_soft.h \ diff --git a/src/libsodium/crypto_hash/sha3/hash_sha3.c b/src/libsodium/crypto_hash/sha3/hash_sha3.c index fb2c6122..888555e5 100644 --- a/src/libsodium/crypto_hash/sha3/hash_sha3.c +++ b/src/libsodium/crypto_hash/sha3/hash_sha3.c @@ -1,6 +1,88 @@ +#include +#include + +#include "crypto_core_keccak1600.h" #include "crypto_hash_sha3.h" #include "private/common.h" -#include "ref/sha3_ref.h" +#include "utils.h" + +#define SHA3_256_RATE 136 +#define SHA3_512_RATE 72 +#define SHA3_DOMAIN 0x06 + +typedef enum { SHA3_PHASE_ABSORBING = 0, SHA3_PHASE_FINALIZED = 1 } sha3_phase; + +typedef struct sha3_state_internal_ { + crypto_core_keccak1600_state state; + size_t offset; + size_t rate; + size_t outlen; + uint8_t phase; +} sha3_state_internal; + +static int +sha3_init(sha3_state_internal *state, size_t rate, size_t outlen) +{ + crypto_core_keccak1600_init(&state->state); + state->offset = 0; + state->rate = rate; + state->outlen = outlen; + state->phase = SHA3_PHASE_ABSORBING; + + return 0; +} + +static int +sha3_update(sha3_state_internal *state, const unsigned char *in, size_t inlen) +{ + size_t consumed = 0; + size_t chunk_size; + + while (consumed < inlen) { + if (state->offset == state->rate) { + crypto_core_keccak1600_permute_24(&state->state); + state->offset = 0; + } + chunk_size = state->rate - state->offset; + if (chunk_size > inlen - consumed) { + chunk_size = inlen - consumed; + } + crypto_core_keccak1600_xor_bytes(&state->state, &in[consumed], state->offset, chunk_size); + state->offset += chunk_size; + consumed += chunk_size; + } + + return 0; +} + +static int +sha3_final(sha3_state_internal *state, unsigned char *out) +{ + unsigned char pad; + + if (state->offset == state->rate) { + crypto_core_keccak1600_permute_24(&state->state); + state->offset = 0; + } + + if (state->offset == state->rate - 1) { + pad = (unsigned char) (SHA3_DOMAIN ^ 0x80); + crypto_core_keccak1600_xor_bytes(&state->state, &pad, state->offset, 1); + } else { + pad = SHA3_DOMAIN; + crypto_core_keccak1600_xor_bytes(&state->state, &pad, state->offset, 1); + pad = 0x80; + crypto_core_keccak1600_xor_bytes(&state->state, &pad, state->rate - 1, 1); + } + + crypto_core_keccak1600_permute_24(&state->state); + + crypto_core_keccak1600_extract_bytes(&state->state, out, 0, state->outlen); + + sodium_memzero(state, sizeof *state); + + return 0; +} size_t crypto_hash_sha3256_bytes(void) @@ -14,31 +96,37 @@ crypto_hash_sha3256_statebytes(void) return sizeof(crypto_hash_sha3256_state); } -int -crypto_hash_sha3256(unsigned char *out, const unsigned char *in, unsigned long long inlen) -{ - COMPILER_ASSERT(sizeof(crypto_hash_sha3256_state) >= sizeof(sha3_state_internal)); - return sha3256_ref(out, in, (size_t) inlen); -} - int crypto_hash_sha3256_init(crypto_hash_sha3256_state *state) { COMPILER_ASSERT(sizeof(crypto_hash_sha3256_state) >= sizeof(sha3_state_internal)); - return sha3256_ref_init((sha3_state_internal *) (void *) state); + return sha3_init((sha3_state_internal *) (void *) state, + SHA3_256_RATE, crypto_hash_sha3256_BYTES); } int crypto_hash_sha3256_update(crypto_hash_sha3256_state *state, const unsigned char *in, unsigned long long inlen) { - return sha3256_ref_update((sha3_state_internal *) (void *) state, in, (size_t) inlen); + return sha3_update((sha3_state_internal *) (void *) state, in, (size_t) inlen); } int crypto_hash_sha3256_final(crypto_hash_sha3256_state *state, unsigned char *out) { - return sha3256_ref_final((sha3_state_internal *) (void *) state, out); + return sha3_final((sha3_state_internal *) (void *) state, out); +} + +int +crypto_hash_sha3256(unsigned char *out, const unsigned char *in, unsigned long long inlen) +{ + crypto_hash_sha3256_state state; + + crypto_hash_sha3256_init(&state); + crypto_hash_sha3256_update(&state, in, inlen); + crypto_hash_sha3256_final(&state, out); + + return 0; } size_t @@ -53,29 +141,35 @@ crypto_hash_sha3512_statebytes(void) return sizeof(crypto_hash_sha3512_state); } -int -crypto_hash_sha3512(unsigned char *out, const unsigned char *in, unsigned long long inlen) -{ - COMPILER_ASSERT(sizeof(crypto_hash_sha3512_state) >= sizeof(sha3_state_internal)); - return sha3512_ref(out, in, (size_t) inlen); -} - int crypto_hash_sha3512_init(crypto_hash_sha3512_state *state) { COMPILER_ASSERT(sizeof(crypto_hash_sha3512_state) >= sizeof(sha3_state_internal)); - return sha3512_ref_init((sha3_state_internal *) (void *) state); + return sha3_init((sha3_state_internal *) (void *) state, + SHA3_512_RATE, crypto_hash_sha3512_BYTES); } int crypto_hash_sha3512_update(crypto_hash_sha3512_state *state, const unsigned char *in, unsigned long long inlen) { - return sha3512_ref_update((sha3_state_internal *) (void *) state, in, (size_t) inlen); + return sha3_update((sha3_state_internal *) (void *) state, in, (size_t) inlen); } int crypto_hash_sha3512_final(crypto_hash_sha3512_state *state, unsigned char *out) { - return sha3512_ref_final((sha3_state_internal *) (void *) state, out); + return sha3_final((sha3_state_internal *) (void *) state, out); +} + +int +crypto_hash_sha3512(unsigned char *out, const unsigned char *in, unsigned long long inlen) +{ + crypto_hash_sha3512_state state; + + crypto_hash_sha3512_init(&state); + crypto_hash_sha3512_update(&state, in, inlen); + crypto_hash_sha3512_final(&state, out); + + return 0; } diff --git a/src/libsodium/crypto_hash/sha3/ref/sha3_ref.c b/src/libsodium/crypto_hash/sha3/ref/sha3_ref.c deleted file mode 100644 index c09037fd..00000000 --- a/src/libsodium/crypto_hash/sha3/ref/sha3_ref.c +++ /dev/null @@ -1,132 +0,0 @@ -#include -#include - -#include "crypto_core_keccak1600.h" -#include "crypto_hash_sha3.h" -#include "private/common.h" -#include "sha3_ref.h" -#include "utils.h" - -static int -sha3_ref_init(sha3_state_internal *state, size_t rate, size_t outlen) -{ - crypto_core_keccak1600_init(&state->state); - state->offset = 0; - state->rate = rate; - state->outlen = outlen; - state->phase = SHA3_PHASE_ABSORBING; - - return 0; -} - -static int -sha3_ref_update(sha3_state_internal *state, const unsigned char *in, size_t inlen) -{ - size_t consumed = 0; - size_t chunk_size; - - while (consumed < inlen) { - if (state->offset == state->rate) { - crypto_core_keccak1600_permute_24(&state->state); - state->offset = 0; - } - chunk_size = state->rate - state->offset; - if (chunk_size > inlen - consumed) { - chunk_size = inlen - consumed; - } - crypto_core_keccak1600_xor_bytes(&state->state, &in[consumed], state->offset, chunk_size); - state->offset += chunk_size; - consumed += chunk_size; - } - - return 0; -} - -static int -sha3_ref_final(sha3_state_internal *state, unsigned char *out) -{ - unsigned char pad; - - if (state->offset == state->rate) { - crypto_core_keccak1600_permute_24(&state->state); - state->offset = 0; - } - - if (state->offset == state->rate - 1) { - pad = (unsigned char) (SHA3_DOMAIN ^ 0x80); - crypto_core_keccak1600_xor_bytes(&state->state, &pad, state->offset, 1); - } else { - pad = SHA3_DOMAIN; - crypto_core_keccak1600_xor_bytes(&state->state, &pad, state->offset, 1); - pad = 0x80; - crypto_core_keccak1600_xor_bytes(&state->state, &pad, state->rate - 1, 1); - } - - crypto_core_keccak1600_permute_24(&state->state); - - crypto_core_keccak1600_extract_bytes(&state->state, out, 0, state->outlen); - - sodium_memzero(state, sizeof *state); - - return 0; -} - -int -sha3256_ref_init(sha3_state_internal *state) -{ - return sha3_ref_init(state, SHA3_256_RATE, crypto_hash_sha3256_BYTES); -} - -int -sha3256_ref_update(sha3_state_internal *state, const unsigned char *in, size_t inlen) -{ - return sha3_ref_update(state, in, inlen); -} - -int -sha3256_ref_final(sha3_state_internal *state, unsigned char *out) -{ - return sha3_ref_final(state, out); -} - -int -sha3256_ref(unsigned char *out, const unsigned char *in, size_t inlen) -{ - sha3_state_internal state; - - sha3256_ref_init(&state); - sha3256_ref_update(&state, in, inlen); - sha3256_ref_final(&state, out); - - return 0; -} - -int -sha3512_ref_init(sha3_state_internal *state) -{ - return sha3_ref_init(state, SHA3_512_RATE, crypto_hash_sha3512_BYTES); -} - -int -sha3512_ref_update(sha3_state_internal *state, const unsigned char *in, size_t inlen) -{ - return sha3_ref_update(state, in, inlen); -} - -int -sha3512_ref_final(sha3_state_internal *state, unsigned char *out) -{ - return sha3_ref_final(state, out); -} - -int -sha3512_ref(unsigned char *out, const unsigned char *in, size_t inlen) -{ - sha3_state_internal state; - - sha3512_ref_init(&state); - sha3512_ref_update(&state, in, inlen); - sha3512_ref_final(&state, out); - - return 0; -} diff --git a/src/libsodium/crypto_hash/sha3/ref/sha3_ref.h b/src/libsodium/crypto_hash/sha3/ref/sha3_ref.h deleted file mode 100644 index 5e7d0cf1..00000000 --- a/src/libsodium/crypto_hash/sha3/ref/sha3_ref.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef sha3_ref_H -#define sha3_ref_H - -#include -#include - -#include "crypto_core_keccak1600.h" - -#define SHA3_256_RATE 136 -#define SHA3_512_RATE 72 -#define SHA3_DOMAIN 0x06 - -typedef enum { SHA3_PHASE_ABSORBING = 0, SHA3_PHASE_FINALIZED = 1 } sha3_phase; - -typedef struct sha3_state_internal_ { - crypto_core_keccak1600_state state; - size_t offset; - size_t rate; - size_t outlen; - uint8_t phase; -} sha3_state_internal; - -int sha3256_ref(unsigned char *out, const unsigned char *in, size_t inlen); -int sha3256_ref_init(sha3_state_internal *state); -int sha3256_ref_update(sha3_state_internal *state, const unsigned char *in, size_t inlen); -int sha3256_ref_final(sha3_state_internal *state, unsigned char *out); - -int sha3512_ref(unsigned char *out, const unsigned char *in, size_t inlen); -int sha3512_ref_init(sha3_state_internal *state); -int sha3512_ref_update(sha3_state_internal *state, const unsigned char *in, size_t inlen); -int sha3512_ref_final(sha3_state_internal *state, unsigned char *out); - -#endif