From fcd12528c6bce11de3b6f4a5482422f27d3d497a Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 15 Sep 2024 00:51:36 +0200 Subject: m MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libkeccak/keccak.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/libkeccak/keccak.h b/libkeccak/keccak.h index 0d3cce0..62b2af8 100644 --- a/libkeccak/keccak.h +++ b/libkeccak/keccak.h @@ -166,8 +166,8 @@ LIBKECCAK_GCC_ONLY(__attribute__((__nonnull__, __nothrow__, __warn_unused_result inline int libkeccak_spec_check(const struct libkeccak_spec *spec) { - long int state_size = spec->capacity + spec->bitrate; - int32_t word_size = (int32_t)(state_size / 25); + unsigned long int state_size = (unsigned long int)(spec->capacity + spec->bitrate); + uint32_t word_size = (uint32_t)(state_size / 25U); if (spec->bitrate <= 0) return LIBKECCAK_SPEC_ERROR_BITRATE_NONPOSITIVE; if (spec->bitrate % 8) return LIBKECCAK_SPEC_ERROR_BITRATE_MOD_8; @@ -178,10 +178,6 @@ libkeccak_spec_check(const struct libkeccak_spec *spec) if (state_size % 25) return LIBKECCAK_SPEC_ERROR_STATE_MOD_25; if (word_size % 8) return LIBKECCAK_SPEC_ERROR_WORD_MOD_8; - /* `(x & -x) != x` assumes two's complement, which of course is always - * satisfied by GCC, however C99 guarantees that `int32_t` exists, - * and it is basically the same thing as `long int`; with one important - * difference: it is guaranteed to use two's complement. */ if ((word_size & -word_size) != word_size) return LIBKECCAK_SPEC_ERROR_WORD_NON_2_POTENT; -- cgit v1.2.3-70-g09d2