Git Product home page Git Product logo

libkeccak's Introduction

NAME
	libkeccak - Keccak-family hashing library

DESCRIPTION
	libkeccak is a bit-oriented lanewise implementation of
	the Keccak-family with support for extend output size,
	state marshalling, algorithm tuning with implicit parameters,
	secure erasure of sensitive data, and HMAC.

RATIONALE
	Keccak won the SHA-3 competition. We need a library for it,
	and let it be bit-oriented.

SEE ALSO
	sha3sum, libblake(7), libsha2(7), libsha1(7)

libkeccak's People

Contributors

alebcay avatar benwiederhake avatar carlocab avatar hackmod avatar maandree avatar oyheskes avatar traneptora avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libkeccak's Issues

Failed to compile on MacOS

macOS Sierra 10.12.6

Sorry for the long log

cc -fPIC -c -o libkeccak/digest.o libkeccak/digest.c -std=c99 -O3 -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700
In file included from libkeccak/digest.c:2:
In file included from libkeccak/digest.h:5:
libkeccak/state.h:93:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull)))
                                  ^
libkeccak/state.h:131:59: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow, optimize("-O0"))))
                                                          ^
libkeccak/state.h:131:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow, optimize("-O0"))))
                                  ^
libkeccak/state.h:139:59: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow, optimize("-O0"))))
                                                          ^
libkeccak/state.h:139:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow, optimize("-O0"))))
                                  ^
libkeccak/state.h:147:53: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((nonnull, nothrow, optimize("-O0"))))
                                                    ^
libkeccak/state.h:156:43: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((unused, optimize("-O0"))))
                                          ^
libkeccak/state.h:204:43: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((unused, optimize("-O0"))))
                                          ^
libkeccak/state.h:227:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull)))
                                  ^
libkeccak/state.h:270:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow)))
                                  ^
libkeccak/state.h:281:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull)))
                                  ^
libkeccak/state.h:292:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow, warn_unused_result, pure)))
                                  ^
12 warnings generated.
cc -fPIC -c -o libkeccak/files.o libkeccak/files.c -std=c99 -O3 -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700
In file included from libkeccak/files.c:2:
In file included from libkeccak/files.h:5:
In file included from libkeccak/../libkeccak.h:6:
libkeccak/../libkeccak/generalised-spec.h:136:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow)))
                                  ^
In file included from libkeccak/files.c:2:
In file included from libkeccak/files.h:5:
In file included from libkeccak/../libkeccak.h:7:
libkeccak/../libkeccak/state.h:93:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull)))
                                  ^
libkeccak/../libkeccak/state.h:131:59: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow, optimize("-O0"))))
                                                          ^
libkeccak/../libkeccak/state.h:131:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow, optimize("-O0"))))
                                  ^
libkeccak/../libkeccak/state.h:139:59: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow, optimize("-O0"))))
                                                          ^
libkeccak/../libkeccak/state.h:139:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow, optimize("-O0"))))
                                  ^
libkeccak/../libkeccak/state.h:147:53: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((nonnull, nothrow, optimize("-O0"))))
                                                    ^
libkeccak/../libkeccak/state.h:156:43: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((unused, optimize("-O0"))))
                                          ^
libkeccak/../libkeccak/state.h:204:43: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((unused, optimize("-O0"))))
                                          ^
libkeccak/../libkeccak/state.h:227:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull)))
                                  ^
libkeccak/../libkeccak/state.h:270:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow)))
                                  ^
libkeccak/../libkeccak/state.h:281:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull)))
                                  ^
libkeccak/../libkeccak/state.h:292:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow, warn_unused_result, pure)))
                                  ^
In file included from libkeccak/files.c:2:
In file included from libkeccak/files.h:5:
In file included from libkeccak/../libkeccak.h:9:
libkeccak/../libkeccak/hex.h:17:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow)))
                                  ^
libkeccak/../libkeccak/hex.h:28:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow)))
                                  ^
libkeccak/../libkeccak/hex.h:39:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow)))
                                  ^
In file included from libkeccak/files.c:2:
In file included from libkeccak/../libkeccak/files.h:5:
In file included from libkeccak/../libkeccak.h:11:
libkeccak/../libkeccak/mac/hmac.h:152:53: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((nonnull, nothrow, optimize("-O0"))))
                                                    ^
libkeccak/../libkeccak/mac/hmac.h:181:43: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((unused, optimize("-O0"))))
                                          ^
libkeccak/../libkeccak/mac/hmac.h:218:43: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((unused, optimize("-O0"))))
                                          ^
In file included from libkeccak/files.c:2:
libkeccak/../libkeccak/files.h:38:50: warning: unknown attribute 'artificial' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((nonnull(2, 3), artificial, gnu_inline)))
                                                 ^
libkeccak/../libkeccak/files.h:58:47: warning: unknown attribute 'artificial' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((nonnull(2), artificial, gnu_inline)))
                                              ^
libkeccak/../libkeccak/files.h:81:47: warning: unknown attribute 'artificial' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((nonnull(2), artificial, gnu_inline)))
                                              ^
libkeccak/../libkeccak/files.h:104:47: warning: unknown attribute 'artificial' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((nonnull(2), artificial, gnu_inline)))
                                              ^
23 warnings generated.
cc -fPIC -c -o libkeccak/generalised-spec.o libkeccak/generalised-spec.c -std=c99 -O3 -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700
In file included from libkeccak/generalised-spec.c:2:
libkeccak/generalised-spec.h:136:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow)))
                                  ^
libkeccak/generalised-spec.c:6:33: warning: unknown warning group '-Wmaybe-uninitialized', ignored [-Wunknown-warning-option]
# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
                                ^
2 warnings generated.
cc -fPIC -c -o libkeccak/hex.o libkeccak/hex.c -std=c99 -O3 -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700
In file included from libkeccak/hex.c:2:
libkeccak/hex.h:17:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow)))
                                  ^
libkeccak/hex.h:28:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow)))
                                  ^
libkeccak/hex.h:39:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow)))
                                  ^
3 warnings generated.
cc -fPIC -c -o libkeccak/state.o libkeccak/state.c -std=c99 -O3 -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700
In file included from libkeccak/state.c:2:
libkeccak/state.h:93:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull)))
                                  ^
libkeccak/state.h:131:59: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow, optimize("-O0"))))
                                                          ^
libkeccak/state.h:131:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow, optimize("-O0"))))
                                  ^
libkeccak/state.h:139:59: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow, optimize("-O0"))))
                                                          ^
libkeccak/state.h:139:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow, optimize("-O0"))))
                                  ^
libkeccak/state.h:147:53: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((nonnull, nothrow, optimize("-O0"))))
                                                    ^
libkeccak/state.h:156:43: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((unused, optimize("-O0"))))
                                          ^
libkeccak/state.h:204:43: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((unused, optimize("-O0"))))
                                          ^
libkeccak/state.h:227:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull)))
                                  ^
libkeccak/state.h:270:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow)))
                                  ^
libkeccak/state.h:281:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull)))
                                  ^
libkeccak/state.h:292:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow, warn_unused_result, pure)))
                                  ^
12 warnings generated.
cc -fPIC -c -o libkeccak/mac/hmac.o libkeccak/mac/hmac.c -std=c99 -O3 -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700
In file included from libkeccak/mac/hmac.c:2:
In file included from libkeccak/mac/hmac.h:12:
libkeccak/mac/../state.h:93:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull)))
                                  ^
libkeccak/mac/../state.h:131:59: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow, optimize("-O0"))))
                                                          ^
libkeccak/mac/../state.h:131:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow, optimize("-O0"))))
                                  ^
libkeccak/mac/../state.h:139:59: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow, optimize("-O0"))))
                                                          ^
libkeccak/mac/../state.h:139:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow, optimize("-O0"))))
                                  ^
libkeccak/mac/../state.h:147:53: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((nonnull, nothrow, optimize("-O0"))))
                                                    ^
libkeccak/mac/../state.h:156:43: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((unused, optimize("-O0"))))
                                          ^
libkeccak/mac/../state.h:204:43: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((unused, optimize("-O0"))))
                                          ^
libkeccak/mac/../state.h:227:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull)))
                                  ^
libkeccak/mac/../state.h:270:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow)))
                                  ^
libkeccak/mac/../state.h:281:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull)))
                                  ^
libkeccak/mac/../state.h:292:35: warning: unknown attribute 'leaf' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((leaf, nonnull, nothrow, warn_unused_result, pure)))
                                  ^
In file included from libkeccak/mac/hmac.c:2:
libkeccak/mac/hmac.h:152:53: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((nonnull, nothrow, optimize("-O0"))))
                                                    ^
libkeccak/mac/hmac.h:181:43: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((unused, optimize("-O0"))))
                                          ^
libkeccak/mac/hmac.h:218:43: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
LIBKECCAK_GCC_ONLY(__attribute__((unused, optimize("-O0"))))
                                          ^
libkeccak/mac/hmac.c:21:23: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
static __attribute__((optimize("-O0"))) void
                      ^
16 warnings generated.
ar rc libkeccak.a libkeccak/digest.o libkeccak/files.o libkeccak/generalised-spec.o libkeccak/hex.o libkeccak/state.o libkeccak/mac/hmac.o
ar -s libkeccak.a
cc -shared -Wl,-soname,libkeccak.so.1 -o libkeccak.so libkeccak/digest.o libkeccak/files.o libkeccak/generalised-spec.o libkeccak/hex.o libkeccak/state.o libkeccak/mac/hmac.o -s
ld: warning: option -s is obsolete and being ignored
ld: unknown option: -soname
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [libkeccak.so] Error 1

Divergence between macOS and Debian from 4096 chars

Hi,

keccak-256sum -x return different results for mac and debian when hashed string is greater or equal to 4096 characters.

Examples :
For 4095 characters. both on debian and mac.

> export HEX=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeeeeeeeee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bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1234567aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa00aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc
> echo $HEX | echo $HEX | keccak-256sum -x -l
ce1c0ecaebd794311e43af288e4c5ffc4a76797a4fbb8f8b19be3fd3d37a7fc4  -

For 4096 characters on macOs

> export HEX=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbb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c
> echo $HEX | echo $HEX | keccak-256sum -x -l
91c47eaa0c2ef2786580f09e84678d29845203e0fed895e676d13e6378529cb7  -

However it seems my geth node only understood the mac hashed transaction. It always returns insufficient funds for gas * price + value when sending debian hashed one.

I would appreciate any clue.

Thank you

Where in the world?

Could you add a fancy option where one could trace the origins of all of the output bits? Like, where in the data source did the first bit originate from? Or, what happened to the first bit in the input? So, let's say it's a zero. Did it become a one or remain a zero and where in the world is it? You can assume that the input size is the same as the output size.

Fails to build with Clang

From the output of make:

ar rc libkeccak.a libkeccak/digest.o libkeccak/files.o libkeccak/generalised-spec.o libkeccak/hex.o libkeccak/state.o libkeccak/mac/hmac.o
ar -s libkeccak.a
cc -shared -Wl,-soname,libkeccak.so.1 -o libkeccak.so libkeccak/digest.o libkeccak/files.o libkeccak/generalised-spec.o libkeccak/hex.o libkeccak/state.o libkeccak/mac/hmac.o -s
ld: warning: option -s is obsolete and being ignored
ld: unknown option: -soname
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [libkeccak.so] Error 1
$ cc --version
Apple LLVM version 9.1.0 (clang-902.0.39.2)
Target: x86_64-apple-darwin17.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
$ uname -a
Darwin Williams-MacBook-Pro.local 17.5.0 Darwin Kernel Version 17.5.0: Fri Apr 13 19:32:32 PDT 2018; root:xnu-4570.51.2~1/RELEASE_X86_64 x86_64

libkeccak.h unusable from C++: restrict

Problem: the restrict keyword is only valid in C, not in C++. Current C++ compilers support __restrict as an extension.
Source code:

#include <libkeccak.h>

Build output:

/usr/include/libkeccak.h:292:53: error: expected ‘,’ or ‘...’ before ‘spec’
  292 | libkeccak_spec_sha3(struct libkeccak_spec *restrict spec, long int x)
      |                                                     ^~~~
/usr/include/libkeccak.h: In function ‘void libkeccak_spec_sha3(libkeccak_spec*)’:
/usr/include/libkeccak.h:294:9: error: ‘spec’ was not declared in this scope
  294 |         spec->bitrate = 1600 - 2 * x;
      |         ^~~~
/usr/include/libkeccak.h:294:36: error: ‘x’ was not declared in this scope
  294 |         spec->bitrate = 1600 - 2 * x;
      |                                    ^
/usr/include/libkeccak.h: At global scope:
/usr/include/libkeccak.h:308:57: error: expected ‘,’ or ‘...’ before ‘spec’
  308 | libkeccak_spec_rawshake(struct libkeccak_spec *restrict spec, long int x, long int d)
      |                                                         ^~~~
/usr/include/libkeccak.h: In function ‘void libkeccak_spec_rawshake(libkeccak_spec*)’:
/usr/include/libkeccak.h:310:9: error: ‘spec’ was not declared in this scope
  310 |         spec->bitrate = 1600 - 2 * x;
      |         ^~~~
/usr/include/libkeccak.h:310:36: error: ‘x’ was not declared in this scope
  310 |         spec->bitrate = 1600 - 2 * x;
      |                                    ^
/usr/include/libkeccak.h:312:24: error: ‘d’ was not declared in this scope
  312 |         spec->output = d;
      |                        ^
/usr/include/libkeccak.h: At global scope:
/usr/include/libkeccak.h:332:60: error: expected ‘,’ or ‘...’ before ‘spec’
  332 | libkeccak_spec_check(const struct libkeccak_spec *restrict spec)
      |                                                            ^~~~
/usr/include/libkeccak.h: In function ‘int libkeccak_spec_check(const libkeccak_spec*)’:
/usr/include/libkeccak.h:334:31: error: ‘spec’ was not declared in this scope
  334 |         long int state_size = spec->capacity + spec->bitrate;
      |                               ^~~~
/usr/include/libkeccak.h: At global scope:
/usr/include/libkeccak.h:363:83: error: expected ‘,’ or ‘...’ before ‘spec’
  363 | libkeccak_generalised_spec_initialise(struct libkeccak_generalised_spec *restrict spec)
      |                                                                                   ^~~~
/usr/include/libkeccak.h: In function ‘void libkeccak_generalised_spec_initialise(libkeccak_generalised_spec*)’:
/usr/include/libkeccak.h:365:9: error: ‘spec’ was not declared in this scope
  365 |         spec->bitrate    = LIBKECCAK_GENERALISED_SPEC_AUTOMATIC;
      |         ^~~~
/usr/include/libkeccak.h: At global scope:
/usr/include/libkeccak.h:380:101: error: conflicting declaration ‘libkeccak_spec* restrict’
  380 | int libkeccak_degeneralise_spec(struct libkeccak_generalised_spec *restrict, struct libkeccak_spec *restrict);
      |                                                                              ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:380:68: note: previous declaration as ‘libkeccak_generalised_spec* restrict’
  380 | int libkeccak_degeneralise_spec(struct libkeccak_generalised_spec *restrict, struct libkeccak_spec *restrict);
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:380:109: error: ‘nonnull’ attribute without arguments on a non-prototype
  380 | int libkeccak_degeneralise_spec(struct libkeccak_generalised_spec *restrict, struct libkeccak_spec *restrict);
      |                                                                                                             ^
/usr/include/libkeccak.h:390:95: error: conflicting declaration ‘const libkeccak_spec* restrict’
  390 | int libkeccak_state_initialise(struct libkeccak_state *restrict, const struct libkeccak_spec *restrict);
      |                                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:390:56: note: previous declaration as ‘libkeccak_state* restrict’
  390 | int libkeccak_state_initialise(struct libkeccak_state *restrict, const struct libkeccak_spec *restrict);
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:390:103: error: ‘nonnull’ attribute without arguments on a non-prototype
  390 | int libkeccak_state_initialise(struct libkeccak_state *restrict, const struct libkeccak_spec *restrict);
      |                                                                                                       ^
/usr/include/libkeccak.h:399:56: error: expected ‘,’ or ‘...’ before ‘state’
  399 | libkeccak_state_reset(struct libkeccak_state *restrict state)
      |                                                        ^~~~~
/usr/include/libkeccak.h: In function ‘void libkeccak_state_reset(libkeccak_state*)’:
/usr/include/libkeccak.h:401:9: error: ‘state’ was not declared in this scope; did you mean ‘static’?
  401 |         state->mptr = 0;
      |         ^~~~~
      |         static
/usr/include/libkeccak.h: At global scope:
/usr/include/libkeccak.h:411:63: error: expected ‘,’ or ‘...’ before ‘state’
  411 | libkeccak_state_fast_destroy(struct libkeccak_state *restrict state)
      |                                                               ^~~~~
/usr/include/libkeccak.h: In function ‘void libkeccak_state_fast_destroy(libkeccak_state*)’:
/usr/include/libkeccak.h:413:13: error: ‘state’ was not declared in this scope; did you mean ‘static’?
  413 |         if (state) {
      |             ^~~~~
      |             static
/usr/include/libkeccak.h: At global scope:
/usr/include/libkeccak.h:450:67: error: expected ‘,’ or ‘...’ before ‘state’
  450 | libkeccak_state_destroy(volatile struct libkeccak_state *restrict state)
      |                                                                   ^~~~~
/usr/include/libkeccak.h: In function ‘void libkeccak_state_destroy(volatile libkeccak_state*)’:
/usr/include/libkeccak.h:452:13: error: ‘state’ was not declared in this scope; did you mean ‘static’?
  452 |         if (state) {
      |             ^~~~~
      |             static
/usr/include/libkeccak.h: At global scope:
/usr/include/libkeccak.h:474:60: error: expected ‘,’ or ‘...’ before ‘state’
  474 | libkeccak_state_fast_free(struct libkeccak_state *restrict state)
      |                                                            ^~~~~
/usr/include/libkeccak.h: In function ‘void libkeccak_state_fast_free(libkeccak_state*)’:
/usr/include/libkeccak.h:476:38: error: ‘state’ was not declared in this scope; did you mean ‘static’?
  476 |         libkeccak_state_fast_destroy(state);
      |                                      ^~~~~
      |                                      static
/usr/include/libkeccak.h: At global scope:
/usr/include/libkeccak.h:487:64: error: expected ‘,’ or ‘...’ before ‘state’
  487 | libkeccak_state_free(volatile struct libkeccak_state *restrict state)
      |                                                                ^~~~~
/usr/include/libkeccak.h: In function ‘void libkeccak_state_free(volatile libkeccak_state*)’:
/usr/include/libkeccak.h:493:33: error: ‘state’ was not declared in this scope; did you mean ‘static’?
  493 |         libkeccak_state_destroy(state);
      |                                 ^~~~~
      |                                 static
/usr/include/libkeccak.h: At global scope:
/usr/include/libkeccak.h:508:90: error: conflicting declaration ‘const libkeccak_state* restrict’
  508 | int libkeccak_state_copy(struct libkeccak_state *restrict, const struct libkeccak_state *restrict);
      |                                                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:508:50: note: previous declaration as ‘libkeccak_state* restrict’
  508 | int libkeccak_state_copy(struct libkeccak_state *restrict, const struct libkeccak_state *restrict);
      |                          ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:508:98: error: ‘nonnull’ attribute without arguments on a non-prototype
  508 | int libkeccak_state_copy(struct libkeccak_state *restrict, const struct libkeccak_state *restrict);
      |                                                                                                  ^
/usr/include/libkeccak.h:527:78: error: conflicting declaration ‘void* restrict’
  527 | size_t libkeccak_state_marshal(const struct libkeccak_state *restrict, void *restrict);
      |                                                                        ~~~~~~^~~~~~~~
/usr/include/libkeccak.h:527:62: note: previous declaration as ‘const libkeccak_state* restrict’
  527 | size_t libkeccak_state_marshal(const struct libkeccak_state *restrict, void *restrict);
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:538:80: error: conflicting declaration ‘const void* restrict’
  538 | size_t libkeccak_state_unmarshal(struct libkeccak_state *restrict, const void *restrict);
      |                                                                    ~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:538:58: note: previous declaration as ‘libkeccak_state* restrict’
  538 | size_t libkeccak_state_unmarshal(struct libkeccak_state *restrict, const void *restrict);
      |                                  ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:549:63: error: expected ‘,’ or ‘...’ before ‘state’
  549 | libkeccak_zerocopy_chunksize(struct libkeccak_state *restrict state)
      |                                                               ^~~~~
/usr/include/libkeccak.h: In function ‘size_t libkeccak_zerocopy_chunksize(libkeccak_state*)’:
/usr/include/libkeccak.h:551:16: error: ‘state’ was not declared in this scope; did you mean ‘static’?
  551 |         return state->r >> 3;
      |                ^~~~~
      |                static
/usr/include/libkeccak.h: At global scope:
/usr/include/libkeccak.h:570:78: error: conflicting declaration ‘const void* restrict’
  570 | void libkeccak_zerocopy_update(struct libkeccak_state *restrict, const void *restrict, size_t);
      |                                                                  ~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:570:56: note: previous declaration as ‘libkeccak_state* restrict’
  570 | void libkeccak_zerocopy_update(struct libkeccak_state *restrict, const void *restrict, size_t);
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:570:94: error: ‘nonnull’ attribute without arguments on a non-prototype
  570 | void libkeccak_zerocopy_update(struct libkeccak_state *restrict, const void *restrict, size_t);
      |                                                                                              ^
/usr/include/libkeccak.h:582:73: error: conflicting declaration ‘const void* restrict’
  582 | int libkeccak_fast_update(struct libkeccak_state *restrict, const void *restrict, size_t);
      |                                                             ~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:582:51: note: previous declaration as ‘libkeccak_state* restrict’
  582 | int libkeccak_fast_update(struct libkeccak_state *restrict, const void *restrict, size_t);
      |                           ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:582:89: error: ‘nonnull’ attribute without arguments on a non-prototype
  582 | int libkeccak_fast_update(struct libkeccak_state *restrict, const void *restrict, size_t);
      |                                                                                         ^
/usr/include/libkeccak.h:594:68: error: conflicting declaration ‘const void* restrict’
  594 | int libkeccak_update(struct libkeccak_state *restrict, const void *restrict, size_t);
      |                                                        ~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:594:46: note: previous declaration as ‘libkeccak_state* restrict’
  594 | int libkeccak_update(struct libkeccak_state *restrict, const void *restrict, size_t);
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:594:84: error: ‘nonnull’ attribute without arguments on a non-prototype
  594 | int libkeccak_update(struct libkeccak_state *restrict, const void *restrict, size_t);
      |                                                                                    ^
/usr/include/libkeccak.h:617:72: error: conflicting declaration ‘void* restrict’
  617 | void libkeccak_zerocopy_digest(struct libkeccak_state *restrict, void *restrict, size_t,
      |                                                                  ~~~~~~^~~~~~~~
/usr/include/libkeccak.h:617:56: note: previous declaration as ‘libkeccak_state* restrict’
  617 | void libkeccak_zerocopy_digest(struct libkeccak_state *restrict, void *restrict, size_t,
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:618:52: error: conflicting declaration ‘const char* restrict’
  618 |                                size_t, const char *restrict, void *restrict);
      |                                        ~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:617:56: note: previous declaration as ‘libkeccak_state* restrict’
  617 | void libkeccak_zerocopy_digest(struct libkeccak_state *restrict, void *restrict, size_t,
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:618:68: error: conflicting declaration ‘void* restrict’
  618 |                                size_t, const char *restrict, void *restrict);
      |                                                              ~~~~~~^~~~~~~~
/usr/include/libkeccak.h:617:56: note: previous declaration as ‘libkeccak_state* restrict’
  617 | void libkeccak_zerocopy_digest(struct libkeccak_state *restrict, void *restrict, size_t,
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:633:73: error: conflicting declaration ‘const void* restrict’
  633 | int libkeccak_fast_digest(struct libkeccak_state *restrict, const void *restrict, size_t,
      |                                                             ~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:633:51: note: previous declaration as ‘libkeccak_state* restrict’
  633 | int libkeccak_fast_digest(struct libkeccak_state *restrict, const void *restrict, size_t,
      |                           ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:634:47: error: conflicting declaration ‘const char* restrict’
  634 |                           size_t, const char *restrict, void *restrict);
      |                                   ~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:633:51: note: previous declaration as ‘libkeccak_state* restrict’
  633 | int libkeccak_fast_digest(struct libkeccak_state *restrict, const void *restrict, size_t,
      |                           ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:634:63: error: conflicting declaration ‘void* restrict’
  634 |                           size_t, const char *restrict, void *restrict);
      |                                                         ~~~~~~^~~~~~~~
/usr/include/libkeccak.h:633:51: note: previous declaration as ‘libkeccak_state* restrict’
  633 | int libkeccak_fast_digest(struct libkeccak_state *restrict, const void *restrict, size_t,
      |                           ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:649:68: error: conflicting declaration ‘const void* restrict’
  649 | int libkeccak_digest(struct libkeccak_state *restrict, const void *restrict, size_t,
      |                                                        ~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:649:46: note: previous declaration as ‘libkeccak_state* restrict’
  649 | int libkeccak_digest(struct libkeccak_state *restrict, const void *restrict, size_t,
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:650:42: error: conflicting declaration ‘const char* restrict’
  650 |                      size_t, const char *restrict, void *restrict);
      |                              ~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:649:46: note: previous declaration as ‘libkeccak_state* restrict’
  649 | int libkeccak_digest(struct libkeccak_state *restrict, const void *restrict, size_t,
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:650:58: error: conflicting declaration ‘void* restrict’
  650 |                      size_t, const char *restrict, void *restrict);
      |                                                    ~~~~~~^~~~~~~~
/usr/include/libkeccak.h:649:46: note: previous declaration as ‘libkeccak_state* restrict’
  649 | int libkeccak_digest(struct libkeccak_state *restrict, const void *restrict, size_t,
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:677:82: error: conflicting declaration ‘void* restrict’
  677 | void libkeccak_squeeze(register struct libkeccak_state *restrict, register void *restrict);
      |                                                                   ~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:677:57: note: previous declaration as ‘libkeccak_state* restrict’
  677 | void libkeccak_squeeze(register struct libkeccak_state *restrict, register void *restrict);
      |                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:677:90: error: ‘nonnull’ attribute without arguments on a non-prototype
  677 | void libkeccak_squeeze(register struct libkeccak_state *restrict, register void *restrict);
      |                                                                                          ^
/usr/include/libkeccak.h:687:56: error: conflicting declaration ‘const void* restrict’
  687 | void libkeccak_behex_lower(char *restrict, const void *restrict, size_t);
      |                                            ~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:687:34: note: previous declaration as ‘char* restrict’
  687 | void libkeccak_behex_lower(char *restrict, const void *restrict, size_t);
      |                            ~~~~~~^~~~~~~~
/usr/include/libkeccak.h:687:72: error: ‘nonnull’ attribute without arguments on a non-prototype
  687 | void libkeccak_behex_lower(char *restrict, const void *restrict, size_t);
      |                                                                        ^
/usr/include/libkeccak.h:697:56: error: conflicting declaration ‘const void* restrict’
  697 | void libkeccak_behex_upper(char *restrict, const void *restrict, size_t);
      |                                            ~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:697:34: note: previous declaration as ‘char* restrict’
  697 | void libkeccak_behex_upper(char *restrict, const void *restrict, size_t);
      |                            ~~~~~~^~~~~~~~
/usr/include/libkeccak.h:697:72: error: ‘nonnull’ attribute without arguments on a non-prototype
  697 | void libkeccak_behex_upper(char *restrict, const void *restrict, size_t);
      |                                                                        ^
/usr/include/libkeccak.h:707:50: error: conflicting declaration ‘const char* restrict’
  707 | void libkeccak_unhex(void *restrict, const char *restrict);
      |                                      ~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:707:28: note: previous declaration as ‘void* restrict’
  707 | void libkeccak_unhex(void *restrict, const char *restrict);
      |                      ~~~~~~^~~~~~~~
/usr/include/libkeccak.h:707:58: error: ‘nonnull’ attribute without arguments on a non-prototype
  707 | void libkeccak_unhex(void *restrict, const char *restrict);
      |                                                          ^
/usr/include/libkeccak.h:722:102: error: conflicting declaration ‘const libkeccak_spec* restrict’
  722 | int libkeccak_generalised_sum_fd(int, struct libkeccak_state *restrict, const struct libkeccak_spec *restrict,
      |                                                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:722:63: note: previous declaration as ‘libkeccak_state* restrict’
  722 | int libkeccak_generalised_sum_fd(int, struct libkeccak_state *restrict, const struct libkeccak_spec *restrict,
      |                                       ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:723:46: error: conflicting declaration ‘const char* restrict’
  723 |                                  const char *restrict, void *restrict);
      |                                  ~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:722:63: note: previous declaration as ‘libkeccak_state* restrict’
  722 | int libkeccak_generalised_sum_fd(int, struct libkeccak_state *restrict, const struct libkeccak_spec *restrict,
      |                                       ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:723:62: error: conflicting declaration ‘void* restrict’
  723 |                                  const char *restrict, void *restrict);
      |                                                        ~~~~~~^~~~~~~~
/usr/include/libkeccak.h:722:63: note: previous declaration as ‘libkeccak_state* restrict’
  722 | int libkeccak_generalised_sum_fd(int, struct libkeccak_state *restrict, const struct libkeccak_spec *restrict,
      |                                       ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:738:65: error: expected ‘,’ or ‘...’ before ‘state’
  738 | libkeccak_keccaksum_fd(int fd, struct libkeccak_state *restrict state,
      |                                                                 ^~~~~
/usr/include/libkeccak.h: In function ‘int libkeccak_keccaksum_fd(int, libkeccak_state*)’:
/usr/include/libkeccak.h:741:49: error: ‘state’ was not declared in this scope; did you mean ‘static’?
  741 |         return libkeccak_generalised_sum_fd(fd, state, spec, NULL, hashsum);
      |                                                 ^~~~~
      |                                                 static
/usr/include/libkeccak.h:741:56: error: ‘spec’ was not declared in this scope
  741 |         return libkeccak_generalised_sum_fd(fd, state, spec, NULL, hashsum);
      |                                                        ^~~~
/usr/include/libkeccak.h:741:68: error: ‘hashsum’ was not declared in this scope
  741 |         return libkeccak_generalised_sum_fd(fd, state, spec, NULL, hashsum);
      |                                                                    ^~~~~~~
/usr/include/libkeccak.h: At global scope:
/usr/include/libkeccak.h:757:63: error: expected ‘,’ or ‘...’ before ‘state’
  757 | libkeccak_sha3sum_fd(int fd, struct libkeccak_state *restrict state, long output, void *restrict hashsum)
      |                                                               ^~~~~
/usr/include/libkeccak.h: In function ‘int libkeccak_sha3sum_fd(int, libkeccak_state*)’:
/usr/include/libkeccak.h:760:36: error: ‘output’ was not declared in this scope
  760 |         libkeccak_spec_sha3(&spec, output);
      |                                    ^~~~~~
/usr/include/libkeccak.h:761:49: error: ‘state’ was not declared in this scope; did you mean ‘static’?
  761 |         return libkeccak_generalised_sum_fd(fd, state, &spec, LIBKECCAK_SHA3_SUFFIX, hashsum);
      |                                                 ^~~~~
      |                                                 static
/usr/include/libkeccak.h:761:86: error: ‘hashsum’ was not declared in this scope
  761 |         return libkeccak_generalised_sum_fd(fd, state, &spec, LIBKECCAK_SHA3_SUFFIX, hashsum);
      |                                                                                      ^~~~~~~
/usr/include/libkeccak.h: At global scope:
/usr/include/libkeccak.h:778:67: error: expected ‘,’ or ‘...’ before ‘state’
  778 | libkeccak_rawshakesum_fd(int fd, struct libkeccak_state *restrict state, long semicapacity, long output, void *restrict hashsum)
      |                                                                   ^~~~~
In file included from <command-line>:
/usr/include/libkeccak.h: In function ‘int libkeccak_rawshakesum_fd(int, libkeccak_state*)’:
/usr/include/libkeccak.h:781:40: error: ‘semicapacity’ was not declared in this scope
  781 |         libkeccak_spec_rawshake(&spec, semicapacity, output);
      |                                        ^~~~~~~~~~~~
/usr/include/libkeccak.h:781:54: error: ‘output’ was not declared in this scope
  781 |         libkeccak_spec_rawshake(&spec, semicapacity, output);
      |                                                      ^~~~~~
/usr/include/libkeccak.h:782:49: error: ‘state’ was not declared in this scope; did you mean ‘static’?
  782 |         return libkeccak_generalised_sum_fd(fd, state, &spec, LIBKECCAK_RAWSHAKE_SUFFIX, hashsum);
      |                                                 ^~~~~
      |                                                 static
/usr/include/libkeccak.h:782:90: error: ‘hashsum’ was not declared in this scope
  782 |         return libkeccak_generalised_sum_fd(fd, state, &spec, LIBKECCAK_RAWSHAKE_SUFFIX, hashsum);
      |                                                                                          ^~~~~~~
/usr/include/libkeccak.h: At global scope:
/usr/include/libkeccak.h:799:64: error: expected ‘,’ or ‘...’ before ‘state’
  799 | libkeccak_shakesum_fd(int fd, struct libkeccak_state *restrict state, long semicapacity, long output, void *restrict hashsum)
      |                                                                ^~~~~
/usr/include/libkeccak.h: In function ‘int libkeccak_shakesum_fd(int, libkeccak_state*)’:
/usr/include/libkeccak.h:802:37: error: ‘semicapacity’ was not declared in this scope
  802 |         libkeccak_spec_shake(&spec, semicapacity, output);
      |                                     ^~~~~~~~~~~~
/usr/include/libkeccak.h:802:51: error: ‘output’ was not declared in this scope
  802 |         libkeccak_spec_shake(&spec, semicapacity, output);
      |                                                   ^~~~~~
/usr/include/libkeccak.h:803:49: error: ‘state’ was not declared in this scope; did you mean ‘static’?
  803 |         return libkeccak_generalised_sum_fd(fd, state, &spec, LIBKECCAK_SHAKE_SUFFIX, hashsum);
      |                                                 ^~~~~
      |                                                 static
/usr/include/libkeccak.h:803:87: error: ‘hashsum’ was not declared in this scope
  803 |         return libkeccak_generalised_sum_fd(fd, state, &spec, LIBKECCAK_SHAKE_SUFFIX, hashsum);
      |                                                                                       ^~~~~~~
/usr/include/libkeccak.h: At global scope:
/usr/include/libkeccak.h:821:24: error: expected ‘;’ at end of member declaration
  821 |         unsigned char *restrict key_opad;
      |                        ^~~~~~~~
      |                                ;
/usr/include/libkeccak.h:821:33: error: ‘key_opad’ does not name a type
  821 |         unsigned char *restrict key_opad;
      |                                 ^~~~~~~~
/usr/include/libkeccak.h:826:24: error: expected ‘;’ at end of member declaration
  826 |         unsigned char *restrict key_ipad;
      |                        ^~~~~~~~
      |                                ;
/usr/include/libkeccak.h:826:24: error: redeclaration of ‘unsigned char* libkeccak_hmac_state::restrict’
/usr/include/libkeccak.h:821:24: note: previous declaration ‘unsigned char* libkeccak_hmac_state::restrict’
  821 |         unsigned char *restrict key_opad;
      |                        ^~~~~~~~
/usr/include/libkeccak.h:826:33: error: ‘key_ipad’ does not name a type
  826 |         unsigned char *restrict key_ipad;
      |                                 ^~~~~~~~
/usr/include/libkeccak.h:844:24: error: expected ‘;’ at end of member declaration
  844 |         unsigned char *restrict buffer;
      |                        ^~~~~~~~
      |                                ;
/usr/include/libkeccak.h:844:24: error: redeclaration of ‘unsigned char* libkeccak_hmac_state::restrict’
/usr/include/libkeccak.h:821:24: note: previous declaration ‘unsigned char* libkeccak_hmac_state::restrict’
  821 |         unsigned char *restrict key_opad;
      |                        ^~~~~~~~
/usr/include/libkeccak.h:844:33: error: ‘buffer’ does not name a type
  844 |         unsigned char *restrict buffer;
      |                                 ^~~~~~
/usr/include/libkeccak.h:869:79: error: conflicting declaration ‘const void* restrict’
  869 | int libkeccak_hmac_set_key(struct libkeccak_hmac_state *restrict, const void *restrict, size_t);
      |                                                                   ~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:869:57: note: previous declaration as ‘libkeccak_hmac_state* restrict’
  869 | int libkeccak_hmac_set_key(struct libkeccak_hmac_state *restrict, const void *restrict, size_t);
      |                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:882:65: error: expected ‘,’ or ‘...’ before ‘state’
  882 | libkeccak_hmac_initialise(struct libkeccak_hmac_state *restrict state, const struct libkeccak_spec *restrict spec,
      |                                                                 ^~~~~
/usr/include/libkeccak.h: In function ‘int libkeccak_hmac_initialise(libkeccak_hmac_state*)’:
/usr/include/libkeccak.h:885:41: error: ‘state’ was not declared in this scope; did you mean ‘static’?
  885 |         if (libkeccak_state_initialise(&state->sponge, spec) < 0)
      |                                         ^~~~~
      |                                         static
/usr/include/libkeccak.h:885:56: error: ‘spec’ was not declared in this scope
  885 |         if (libkeccak_state_initialise(&state->sponge, spec) < 0)
      |                                                        ^~~~
/usr/include/libkeccak.h:887:36: error: ‘state’ was not declared in this scope; did you mean ‘static’?
  887 |         if (libkeccak_hmac_set_key(state, key, key_length) < 0) {
      |                                    ^~~~~
      |                                    static
/usr/include/libkeccak.h:887:43: error: ‘key’ was not declared in this scope; did you mean ‘key_t’?
  887 |         if (libkeccak_hmac_set_key(state, key, key_length) < 0) {
      |                                           ^~~
      |                                           key_t
/usr/include/libkeccak.h:887:48: error: ‘key_length’ was not declared in this scope
  887 |         if (libkeccak_hmac_set_key(state, key, key_length) < 0) {
      |                                                ^~~~~~~~~~
/usr/include/libkeccak.h:891:9: error: ‘state’ was not declared in this scope; did you mean ‘static’?
  891 |         state->leftover = 0;
      |         ^~~~~
      |         static
/usr/include/libkeccak.h: At global scope:
/usr/include/libkeccak.h:907:61: error: expected ‘,’ or ‘...’ before ‘spec’
  907 | libkeccak_hmac_create(const struct libkeccak_spec *restrict spec, const void *restrict key, size_t key_length)
      |                                                             ^~~~
/usr/include/libkeccak.h: In function ‘libkeccak_hmac_state* libkeccak_hmac_create(const libkeccak_spec*)’:
/usr/include/libkeccak.h:909:47: error: expected initializer before ‘state’
  909 |         struct libkeccak_hmac_state *restrict state = malloc(sizeof(struct libkeccak_hmac_state));
      |                                               ^~~~~
/usr/include/libkeccak.h:910:14: error: ‘state’ was not declared in this scope; did you mean ‘static’?
  910 |         if (!state || libkeccak_hmac_initialise(state, spec, key, key_length)) {
      |              ^~~~~
      |              static
/usr/include/libkeccak.h:910:56: error: ‘spec’ was not declared in this scope
  910 |         if (!state || libkeccak_hmac_initialise(state, spec, key, key_length)) {
      |                                                        ^~~~
/usr/include/libkeccak.h:910:62: error: ‘key’ was not declared in this scope; did you mean ‘key_t’?
  910 |         if (!state || libkeccak_hmac_initialise(state, spec, key, key_length)) {
      |                                                              ^~~
      |                                                              key_t
/usr/include/libkeccak.h:910:67: error: ‘key_length’ was not declared in this scope
  910 |         if (!state || libkeccak_hmac_initialise(state, spec, key, key_length)) {
      |                                                                   ^~~~~~~~~~
/usr/include/libkeccak.h:914:16: error: ‘state’ was not declared in this scope; did you mean ‘static’?
  914 |         return state;
      |                ^~~~~
      |                static
/usr/include/libkeccak.h: At global scope:
/usr/include/libkeccak.h:928:60: error: expected ‘,’ or ‘...’ before ‘state’
  928 | libkeccak_hmac_reset(struct libkeccak_hmac_state *restrict state, const void *restrict key, size_t key_length)
      |                                                            ^~~~~
/usr/include/libkeccak.h: In function ‘int libkeccak_hmac_reset(libkeccak_hmac_state*)’:
/usr/include/libkeccak.h:930:32: error: ‘state’ was not declared in this scope; did you mean ‘static’?
  930 |         libkeccak_state_reset(&state->sponge);
      |                                ^~~~~
      |                                static
/usr/include/libkeccak.h:931:16: error: ‘key’ was not declared in this scope; did you mean ‘key_t’?
  931 |         return key ? libkeccak_hmac_set_key(state, key, key_length) : 0;
      |                ^~~
      |                key_t
/usr/include/libkeccak.h:931:57: error: ‘key_length’ was not declared in this scope
  931 |         return key ? libkeccak_hmac_set_key(state, key, key_length) : 0;
      |                                                         ^~~~~~~~~~
/usr/include/libkeccak.h: At global scope:
/usr/include/libkeccak.h:948:67: error: expected ‘,’ or ‘...’ before ‘state’
  948 | libkeccak_hmac_fast_destroy(struct libkeccak_hmac_state *restrict state)
      |                                                                   ^~~~~
/usr/include/libkeccak.h: In function ‘void libkeccak_hmac_fast_destroy(libkeccak_hmac_state*)’:
/usr/include/libkeccak.h:950:14: error: ‘state’ was not declared in this scope; did you mean ‘static’?
  950 |         if (!state)
      |              ^~~~~
      |              static
/usr/include/libkeccak.h:952:14: error: ‘state’ was not declared in this scope; did you mean ‘static’?
  952 |         free(state->key_opad);
      |              ^~~~~
      |              static
/usr/include/libkeccak.h: At global scope:
/usr/include/libkeccak.h:968:71: error: expected ‘,’ or ‘...’ before ‘state’
  968 | libkeccak_hmac_destroy(volatile struct libkeccak_hmac_state *restrict state)
      |                                                                       ^~~~~
/usr/include/libkeccak.h: In function ‘void libkeccak_hmac_destroy(volatile libkeccak_hmac_state*)’:
/usr/include/libkeccak.h:970:14: error: ‘state’ was not declared in this scope; did you mean ‘static’?
  970 |         if (!state)
      |              ^~~~~
      |              static
/usr/include/libkeccak.h:972:29: error: ‘state’ was not declared in this scope; did you mean ‘static’?
  972 |         libkeccak_hmac_wipe(state);
      |                             ^~~~~
      |                             static
/usr/include/libkeccak.h: At global scope:
/usr/include/libkeccak.h:989:64: error: expected ‘,’ or ‘...’ before ‘state’
  989 | libkeccak_hmac_fast_free(struct libkeccak_hmac_state *restrict state)
      |                                                                ^~~~~
/usr/include/libkeccak.h: In function ‘void libkeccak_hmac_fast_free(libkeccak_hmac_state*)’:
/usr/include/libkeccak.h:991:37: error: ‘state’ was not declared in this scope; did you mean ‘static’?
  991 |         libkeccak_hmac_fast_destroy(state);
      |                                     ^~~~~
      |                                     static
/usr/include/libkeccak.h: At global scope:
/usr/include/libkeccak.h:1002:68: error: expected ‘,’ or ‘...’ before ‘state’
 1002 | libkeccak_hmac_free(volatile struct libkeccak_hmac_state *restrict state)
      |                                                                    ^~~~~
/usr/include/libkeccak.h: In function ‘void libkeccak_hmac_free(volatile libkeccak_hmac_state*)’:
/usr/include/libkeccak.h:1008:32: error: ‘state’ was not declared in this scope; did you mean ‘static’?
 1008 |         libkeccak_hmac_destroy(state);
      |                                ^~~~~
      |                                static
/usr/include/libkeccak.h: At global scope:
/usr/include/libkeccak.h:1023:99: error: conflicting declaration ‘const libkeccak_hmac_state* restrict’
 1023 | int libkeccak_hmac_copy(struct libkeccak_hmac_state *restrict, const struct libkeccak_hmac_state *restrict);
      |                                                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:1023:54: note: previous declaration as ‘libkeccak_hmac_state* restrict’
 1023 | int libkeccak_hmac_copy(struct libkeccak_hmac_state *restrict, const struct libkeccak_hmac_state *restrict);
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:1023:107: error: ‘nonnull’ attribute without arguments on a non-prototype
 1023 | int libkeccak_hmac_copy(struct libkeccak_hmac_state *restrict, const struct libkeccak_hmac_state *restrict);
      |                                                                                                           ^
/usr/include/libkeccak.h:1033:70: error: expected ‘,’ or ‘...’ before ‘src’
 1033 | libkeccak_hmac_duplicate(const struct libkeccak_hmac_state *restrict src)
      |                                                                      ^~~
/usr/include/libkeccak.h: In function ‘libkeccak_hmac_state* libkeccak_hmac_duplicate(const libkeccak_hmac_state*)’:
/usr/include/libkeccak.h:1035:47: error: expected initializer before ‘dest’
 1035 |         struct libkeccak_hmac_state *restrict dest = malloc(sizeof(struct libkeccak_hmac_state));
      |                                               ^~~~
/usr/include/libkeccak.h:1036:14: error: ‘dest’ was not declared in this scope
 1036 |         if (!dest || libkeccak_hmac_copy(dest, src)) {
      |              ^~~~
/usr/include/libkeccak.h:1036:48: error: ‘src’ was not declared in this scope
 1036 |         if (!dest || libkeccak_hmac_copy(dest, src)) {
      |                                                ^~~
/usr/include/libkeccak.h:1040:16: error: ‘dest’ was not declared in this scope
 1040 |         return dest;
      |                ^~~~
/usr/include/libkeccak.h: At global scope:
/usr/include/libkeccak.h:1052:68: error: expected ‘,’ or ‘...’ before ‘state’
 1052 | libkeccak_hmac_marshal(const struct libkeccak_hmac_state *restrict state, void *restrict data_)
      |                                                                    ^~~~~
/usr/include/libkeccak.h: In function ‘size_t libkeccak_hmac_marshal(const libkeccak_hmac_state*)’:
/usr/include/libkeccak.h:1054:33: error: expected initializer before ‘data’
 1054 |         unsigned char *restrict data = data_;
      |                                 ^~~~
/usr/include/libkeccak.h:1055:51: error: ‘state’ was not declared in this scope; did you mean ‘static’?
 1055 |         size_t written = libkeccak_state_marshal(&state->sponge, data);
      |                                                   ^~~~~
      |                                                   static
/usr/include/libkeccak.h:1055:66: error: ‘data’ was not declared in this scope
 1055 |         size_t written = libkeccak_state_marshal(&state->sponge, data);
      |                                                                  ^~~~
/usr/include/libkeccak.h: At global scope:
/usr/include/libkeccak.h:1084:84: error: conflicting declaration ‘const void* restrict’
 1084 | size_t libkeccak_hmac_unmarshal(struct libkeccak_hmac_state *restrict, const void *restrict);
      |                                                                        ~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:1084:62: note: previous declaration as ‘libkeccak_hmac_state* restrict’
 1084 | size_t libkeccak_hmac_unmarshal(struct libkeccak_hmac_state *restrict, const void *restrict);
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/libkeccak.h:1096:70: error: expected ‘,’ or ‘...’ before ‘state’
 1096 | int libkeccak_hmac_fast_update(struct libkeccak_hmac_state *restrict state, const void *restrict msg, size_t msglen);
      |                                                                      ^~~~~
/usr/include/libkeccak.h:1108:65: error: expected ‘,’ or ‘...’ before ‘state’
 1108 | int libkeccak_hmac_update(struct libkeccak_hmac_state *restrict state, const void *restrict msg, size_t msglen);
      |                                                                 ^~~~~
/usr/include/libkeccak.h:1125:70: error: expected ‘,’ or ‘...’ before ‘state’
 1125 | int libkeccak_hmac_fast_digest(struct libkeccak_hmac_state *restrict state, const void *restrict msg, size_t msglen,
      |                                                                      ^~~~~
/usr/include/libkeccak.h:1143:65: error: expected ‘,’ or ‘...’ before ‘state’
 1143 | int libkeccak_hmac_digest(struct libkeccak_hmac_state *restrict state, const void *restrict msg, size_t msglen,
      |                                                                 ^~~~~
In file included from /usr/include/libkeccak.h:1147,
                 from <command-line>:
/usr/include/libkeccak-legacy.h:18:52: error: expected ‘,’ or ‘...’ before ‘data’
   18 | libkeccak_hmac_unmarshal_skip(const void *restrict data)
      |                                                    ^~~~
/usr/include/libkeccak-legacy.h: In function ‘size_t libkeccak_hmac_unmarshal_skip(const void*)’:
/usr/include/libkeccak-legacy.h:20:47: error: ‘data’ was not declared in this scope
   20 |         return libkeccak_hmac_unmarshal(NULL, data);
      |                                               ^~~~
/usr/include/libkeccak-legacy.h: At global scope:
/usr/include/libkeccak-legacy.h:25:53: error: expected ‘,’ or ‘...’ before ‘data’
   25 | libkeccak_state_unmarshal_skip(const void *restrict data)
      |                                                     ^~~~
/usr/include/libkeccak-legacy.h: In function ‘size_t libkeccak_state_unmarshal_skip(const void*)’:
/usr/include/libkeccak-legacy.h:27:48: error: ‘data’ was not declared in this scope
   27 |         return libkeccak_state_unmarshal(NULL, data);
      |                                                ^~~~
/usr/include/libkeccak-legacy.h: At global scope:
/usr/include/libkeccak-legacy.h:32:73: error: expected ‘,’ or ‘...’ before ‘state’
   32 | libkeccak_hmac_marshal_size(const struct libkeccak_hmac_state *restrict state)
      |                                                                         ^~~~~
/usr/include/libkeccak-legacy.h: In function ‘size_t libkeccak_hmac_marshal_size(const libkeccak_hmac_state*)’:
/usr/include/libkeccak-legacy.h:34:39: error: ‘state’ was not declared in this scope; did you mean ‘static’?
   34 |         return libkeccak_hmac_marshal(state, NULL);
      |                                       ^~~~~
      |                                       static
/usr/include/libkeccak-legacy.h: At global scope:
/usr/include/libkeccak-legacy.h:39:69: error: expected ‘,’ or ‘...’ before ‘state’
   39 | libkeccak_state_marshal_size(const struct libkeccak_state *restrict state)
      |                                                                     ^~~~~
/usr/include/libkeccak-legacy.h: In function ‘size_t libkeccak_state_marshal_size(const libkeccak_state*)’:
/usr/include/libkeccak-legacy.h:41:40: error: ‘state’ was not declared in this scope; did you mean ‘static’?
   41 |         return libkeccak_state_marshal(state, NULL);
      |                                        ^~~~~
      |                                        static

On Ubuntu, I can't build libkeccak

vikas@vikas-ThinkPad$ git clone https://github.com/maandree/libkeccak
Cloning into 'libkeccak'...
remote: Counting objects: 1204, done.
remote: Total 1204 (delta 0), reused 0 (delta 0), pack-reused 1204
Receiving objects: 100% (1204/1204), 208.50 KiB | 66.00 KiB/s, done.
Resolving deltas: 100% (840/840), done.
Checking connectivity... done.
vikas@vikas-ThinkPad$ cd libkeccak/
vikas@vikas-ThinkPad/libkeccak$ make
cc -std=gnu99 -Wall -Wextra -pedantic -Wdouble-promotion -Wformat=2 -Winit-self -Wmissing-include-dirs -Wtrampolines -Wfloat-equal -Wshadow -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -Wno-variadic-macros -Wswitch-default -Wpadded -Wsync-nand -Wunsafe-loop-optimizations -Wcast-align -Wstrict-overflow -Wdeclaration-after-statement -Wundef -Wbad-function-cast -Wcast-qual -Wwrite-strings -Wlogical-op -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wpacked -Wvector-operation-performance -Wunsuffixed-float-constants -Wsuggest-attribute=const -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wsuggest-attribute=format -Wnormalized=nfkc -falign-functions=0 -fkeep-inline-functions -fmerge-all-constants -Ofast -fPIC -c -o obj/libkeccak/digest.o src/libkeccak/digest.c
cc -std=gnu99 -Wall -Wextra -pedantic -Wdouble-promotion -Wformat=2 -Winit-self -Wmissing-include-dirs -Wtrampolines -Wfloat-equal -Wshadow -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -Wno-variadic-macros -Wswitch-default -Wpadded -Wsync-nand -Wunsafe-loop-optimizations -Wcast-align -Wstrict-overflow -Wdeclaration-after-statement -Wundef -Wbad-function-cast -Wcast-qual -Wwrite-strings -Wlogical-op -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wpacked -Wvector-operation-performance -Wunsuffixed-float-constants -Wsuggest-attribute=const -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wsuggest-attribute=format -Wnormalized=nfkc -falign-functions=0 -fkeep-inline-functions -fmerge-all-constants -Ofast -fPIC -c -o obj/libkeccak/files.o src/libkeccak/files.c
cc -std=gnu99 -Wall -Wextra -pedantic -Wdouble-promotion -Wformat=2 -Winit-self -Wmissing-include-dirs -Wtrampolines -Wfloat-equal -Wshadow -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -Wno-variadic-macros -Wswitch-default -Wpadded -Wsync-nand -Wunsafe-loop-optimizations -Wcast-align -Wstrict-overflow -Wdeclaration-after-statement -Wundef -Wbad-function-cast -Wcast-qual -Wwrite-strings -Wlogical-op -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wpacked -Wvector-operation-performance -Wunsuffixed-float-constants -Wsuggest-attribute=const -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wsuggest-attribute=format -Wnormalized=nfkc -falign-functions=0 -fkeep-inline-functions -fmerge-all-constants -Ofast -fPIC -c -o obj/libkeccak/generalised-spec.o src/libkeccak/generalised-spec.c
cc -std=gnu99 -Wall -Wextra -pedantic -Wdouble-promotion -Wformat=2 -Winit-self -Wmissing-include-dirs -Wtrampolines -Wfloat-equal -Wshadow -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -Wno-variadic-macros -Wswitch-default -Wpadded -Wsync-nand -Wunsafe-loop-optimizations -Wcast-align -Wstrict-overflow -Wdeclaration-after-statement -Wundef -Wbad-function-cast -Wcast-qual -Wwrite-strings -Wlogical-op -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wpacked -Wvector-operation-performance -Wunsuffixed-float-constants -Wsuggest-attribute=const -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wsuggest-attribute=format -Wnormalized=nfkc -falign-functions=0 -fkeep-inline-functions -fmerge-all-constants -Ofast -fPIC -c -o obj/libkeccak/hex.o src/libkeccak/hex.c
cc -std=gnu99 -Wall -Wextra -pedantic -Wdouble-promotion -Wformat=2 -Winit-self -Wmissing-include-dirs -Wtrampolines -Wfloat-equal -Wshadow -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -Wno-variadic-macros -Wswitch-default -Wpadded -Wsync-nand -Wunsafe-loop-optimizations -Wcast-align -Wstrict-overflow -Wdeclaration-after-statement -Wundef -Wbad-function-cast -Wcast-qual -Wwrite-strings -Wlogical-op -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wpacked -Wvector-operation-performance -Wunsuffixed-float-constants -Wsuggest-attribute=const -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wsuggest-attribute=format -Wnormalized=nfkc -falign-functions=0 -fkeep-inline-functions -fmerge-all-constants -Ofast -fPIC -c -o obj/libkeccak/state.o src/libkeccak/state.c
cc -std=gnu99 -Wall -Wextra -pedantic -Wdouble-promotion -Wformat=2 -Winit-self -Wmissing-include-dirs -Wtrampolines -Wfloat-equal -Wshadow -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -Wno-variadic-macros -Wswitch-default -Wpadded -Wsync-nand -Wunsafe-loop-optimizations -Wcast-align -Wstrict-overflow -Wdeclaration-after-statement -Wundef -Wbad-function-cast -Wcast-qual -Wwrite-strings -Wlogical-op -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wpacked -Wvector-operation-performance -Wunsuffixed-float-constants -Wsuggest-attribute=const -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wsuggest-attribute=format -Wnormalized=nfkc -falign-functions=0 -fkeep-inline-functions -fmerge-all-constants -Ofast -fPIC -c -o obj/libkeccak/mac/hmac.o src/libkeccak/mac/hmac.c
cc -std=gnu99 -Wall -Wextra -pedantic -Wdouble-promotion -Wformat=2 -Winit-self -Wmissing-include-dirs -Wtrampolines -Wfloat-equal -Wshadow -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -Wno-variadic-macros -Wswitch-default -Wpadded -Wsync-nand -Wunsafe-loop-optimizations -Wcast-align -Wstrict-overflow -Wdeclaration-after-statement -Wundef -Wbad-function-cast -Wcast-qual -Wwrite-strings -Wlogical-op -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wpacked -Wvector-operation-performance -Wunsuffixed-float-constants -Wsuggest-attribute=const -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wsuggest-attribute=format -Wnormalized=nfkc -shared -Wl,-soname,libkeccak.so.1 -o bin/libkeccak.so.1.1 obj/libkeccak/digest.o obj/libkeccak/files.o obj/libkeccak/generalised-spec.o obj/libkeccak/hex.o obj/libkeccak/state.o obj/libkeccak/mac/hmac.o
ln -sf libkeccak.so.1.1 bin/libkeccak.so.1
ln -sf libkeccak.so.1.1 bin/libkeccak.so
ar rcs bin/libkeccak.a obj/libkeccak/digest.o obj/libkeccak/files.o obj/libkeccak/generalised-spec.o obj/libkeccak/hex.o obj/libkeccak/state.o obj/libkeccak/mac/hmac.o
cc -std=gnu99 -Wall -Wextra -pedantic -Wdouble-promotion -Wformat=2 -Winit-self -Wmissing-include-dirs -Wtrampolines -Wfloat-equal -Wshadow -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -Wno-variadic-macros -Wswitch-default -Wpadded -Wsync-nand -Wunsafe-loop-optimizations -Wcast-align -Wstrict-overflow -Wdeclaration-after-statement -Wundef -Wbad-function-cast -Wcast-qual -Wwrite-strings -Wlogical-op -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wpacked -Wvector-operation-performance -Wunsuffixed-float-constants -Wsuggest-attribute=const -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wsuggest-attribute=format -Wnormalized=nfkc -Isrc -O3 -c -o obj/test.o src/test.c
cc -std=gnu99 -Wall -Wextra -pedantic -Wdouble-promotion -Wformat=2 -Winit-self -Wmissing-include-dirs -Wtrampolines -Wfloat-equal -Wshadow -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -Wno-variadic-macros -Wswitch-default -Wpadded -Wsync-nand -Wunsafe-loop-optimizations -Wcast-align -Wstrict-overflow -Wdeclaration-after-statement -Wundef -Wbad-function-cast -Wcast-qual -Wwrite-strings -Wlogical-op -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wpacked -Wvector-operation-performance -Wunsuffixed-float-constants -Wsuggest-attribute=const -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wsuggest-attribute=format -Wnormalized=nfkc -o bin/test obj/test.o -Lbin -lkeccak
makeinfo doc/info/libkeccak.texinfo
make: makeinfo: Command not found
Makefile:205: recipe for target 'bin/libkeccak.info' failed
make: *** [bin/libkeccak.info] Error 127
vikas@vikas-ThinkPad/libkeccak$

vikas@vikas-ThinkPad/libkeccak$ uname -a
Linux vikas-ThinkPad-L460 4.4.0-87-generic #110-Ubuntu SMP Tue Jul 18 12:55:35 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

vikas@vikas-ThinkPad/libkeccak$ cc -v
Using built-in specs.
COLLECT_GCC=cc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu116.04.4' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1
16.04.4)

vikas@vikas-ThinkPad/libkeccak$ which cc
/usr/bin/cc

Stack-overrun segfault when operating on files with large st_blksize (e.g. in a modern tmpfs which may use hugepage backing)

Initial summary

I was attempting to use the sha3sum utilities (which use libkeccak) today, and every single time I tried to run any of them, I'd get a segfault in libkeccak_generalised_sum_fd.

I traced it back to the alloca call in that function. And the debugger showed blksize = 2097152 (2 MiB).

So clearly what's happening here, is that if the file being operated on reports a large st_blksize when fstat'd, libkeccak will blindly attempt to alloca a giant chunk of memory of that block size, regardless of whether it's super-giant and literally exceeds the stack size given to the thread that the function is executing inside (which is exactly what was happening in my particular case).

Thread stack size considerations

I believe the default thread stack size limits on Linux are 2 MiB for x86_32, and 8 MiB for x86_64. The machine I'm using is 64-bit; however in my /etc/security/limits.conf, I long ago intentionally reduced the soft RLIMIT_STACK value to 2 MiB, in an effort to curtail excess memory usage by highly-threaded programs.

*               soft    stack           2048

Also note that different distributions may well tweak the standard defaults to other values. And additionally that any program that happens to use libkeccak may quite plausibly explicitly call pthread_attr_setstacksize somewhere in its execution to change its own stack size limit for program-specific reasons.

So, to summarize, what I'm saying here is that you can't really assume a whole lot about the upper bound on stack size (other than that on sane systems it'll probably be at least 1 MiB).

File system block size circumstances

Now, as for situations in which st_blksize may plausibly be quite large (too large for it to be safe to simply alloca that amount of memory without worrying about potentially overrunning the stack), there are actually quite a few.

There are many file systems that allow configuring rather large block/cluster sizes for specific use cases. The case I'm most familiar with is ZFS; but I know that many other file systems have similar capabilities.

Additionally, a very common large-block-size situation, that you likely wouldn't immediately think of, is actually Linux tmpfs. Classically, as a RAM-backed filesystem, the block size reported by tmpfs has been equal to the page size (4096 bytes).

However, starting with kernel 4.7.0, tmpfs gained the ability to use THP (transparent hugepages) to facilitate the use of 2 MiB pages on x86-architecture systems, in certain circumstances, for backing larger files. (See the description of mount option huge= in man page tmpfs(5).) One important consequence of this feature is that stat syscalls on tmpfs may very well return st_blksize = 2097152 (2 MiB, the size of a standard x86 hugepage). And that's pretty damn large.

The problematic combination

In my particular use case, I had the following combination:

  1. The file I was hashing was situated on a THP-enabled tmpfs filesystem, and therefore reported st_blksize = 2097152.
  2. The thread stack size limit was 2 MiB, i.e. 2097152 bytes.

Given that some small amount of stack was inevitably going to have already been used by caller stack frames, it was inevitable that libkeccak_generalised_sum_fd would segfault when it hit the alloca call.

Potential solutions

  1. Continue using alloca, but cap the allowable value of the blksize variable after assignment from st_blksize to a "reasonable maximum", like 64 KiB (something in that ballpark)
  2. Get rid of alloca and use malloc for the buffer instead
    • Will need a check-for-NULL-and-return--1 path obviously
    • Requires giving chunk an initial value of NULL at declaration, and then ensuring that all function return paths call free(chunk)
      • Could be made a bit tidier with the goto-label-at-end-of-function-upon-failure idiom
      • Could be made even cleaner still, if able to assume GCC or Clang only, with fancy automatic-destruction-upon-leaving-scope magic by putting __attribute__((cleanup(func))) right after the variable name in the chunk declaration; and then having a static function void func(char **p) { free(*p); }
  3. Dynamically decide whether to use alloca or malloc depending on whether blksize is above or below the "reasonable maximum" size
    • This is nice because it keeps things fast-and-on-the-stack for the "normal" fast-path case of small blksize
    • However this gets slightly hairy, as the way to implement it likely involves:
      • having two pointers (e.g. chunk plus chunk_malloc = NULL)
      • in small blksize case, directly assign chunk = alloca(blksize)
      • in large blksize case, assign chunk = chunk_malloc = malloc(blksize) (with NULL check of course)
      • use chunk as the actual pointer
      • as in (2) above, ensure that all code paths do free(chunk_malloc) one way or another (it'll be NULL if the alloca path was taken, and so free is a no-op)
      • most of the actual hairiness relates to the fact that all the pointers are restrict-qualified, and now there are two pointers that... kinda alias the same thing; I don't think it's actually a problem, since aliasing only really concerns reads/writes through the pointers; but if something here did happen to violate the rules at all, then the gods of Undefined Behavior (a.k.a. compiler optimizer writers, who take sadistic pleasure in exploiting UB to make your life miserable) will silently unleash their wrath upon your soul in various horrific-but-invisible ways
  4. If able to assume C11, you could potentially use a static thread_local buffer I guess... though this is perhaps a generally idiotic idea

Thanks; and apologies if this was excessively over-explained for what it is.

Linking

In order to complete the test binary, I need to change the location of libkeccak.

diff --git a/Makefile b/Makefile
index fce64ae..cf4a92c 100644
--- a/Makefile
+++ b/Makefile
@@ -103,7 +103,7 @@ bin/libkeccak.a: $(foreach O,$(LIB_OBJ),obj/libkeccak/$(O).o
test: bin/test

bin/test: obj/test.o bin/libkeccak.so bin/libkeccak.so.$(LIB_MAJOR) bin/libkecc

  •   $(CC) $(FLAGS) -Lbin -lkeccak -o $@ $< $(LDFLAGS)
    
  •   $(CC) $(FLAGS) -Lbin -o $@ $< $(LDFLAGS) -lkeccak
    

    obj/test.o: src/test.c src/libkeccak/*.h src/libkeccak.h
    @mkdir -p obj

libkeccak.h uses register in parameters

/**
 * Squeeze as much as is needed to get a digest a number of times
 * 
 * @param  state  The hashing state
 * @param  times  The number of digests
 */
LIBKECCAK_GCC_ONLY(__attribute__((__nonnull__, __nothrow__)))
void libkeccak_fast_squeeze(register struct libkeccak_state *restrict, register long int);

/**
 * Squeeze out another digest
 * 
 * @param  state    The hashing state
 * @param  hashsum  Output parameter for the hashsum
 */
LIBKECCAK_GCC_ONLY(__attribute__((__nonnull__, __nothrow__)))
void libkeccak_squeeze(register struct libkeccak_state *restrict, register void *restrict);

That's not useful, because the ABIs will ignore your suggestion. All this does is cause warnings in C++17 mode:

warning: ISO C++17 does not allow ‘register’ storage class specifier [-Wregister]

If you really want to pass parameters as registers, add regparm(3) to your GCC attributes. In my opinion, that's not worth it, because the only platform that still passes parameters on the stack is i386.

sha3_256sum - state_size parameter not read

I am trying to run the command line tool sha3_256sum with custom parameters. However, no matter what value I set the -S flag to, I get the error sha3-256sum: the state size must be a multiple of 25

Using the archlinux aur build 1.2-1 https://aur.archlinux.org/packages/libkeccak

strace:

execve("/usr/bin/sha3-256sum", ["sha3-256sum", "-R", "1008", "-O", "256", "-S", "1600", "foo.txt"], 0x7ffdeaf7afd8 /* 84 vars */) = 0
brk(NULL)                               = 0x55e82d495000
arch_prctl(0x3001 /* ARCH_??? */, 0x7ffde07ab3c0) = -1 EINVAL (Invalid argument)
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=420603, ...}) = 0
mmap(NULL, 420603, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fafcdff4000
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/libkeccak.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\22\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=120904, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fafcdff2000
mmap(NULL, 123168, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fafcdfd3000
mmap(0x7fafcdfd4000, 81920, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1000) = 0x7fafcdfd4000
mmap(0x7fafcdfe8000, 32768, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x15000) = 0x7fafcdfe8000
mmap(0x7fafcdff0000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1c000) = 0x7fafcdff0000
close(3)                                = 0
openat(AT_FDCWD, "/usr/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360o\2\0\0\0\0\0"..., 832) = 832
lseek(3, 64, SEEK_SET)                  = 64
read(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 784) = 784
lseek(3, 848, SEEK_SET)                 = 848
read(3, "\4\0\0\0\20\0\0\0\5\0\0\0GNU\0\2\0\0\300\4\0\0\0\3\0\0\0\0\0\0\0", 32) = 32
lseek(3, 880, SEEK_SET)                 = 880
read(3, "\4\0\0\0\24\0\0\0\3\0\0\0GNU\0\250\257l\201\313(\243{\363\245F\227\v\366B$"..., 68) = 68
fstat(3, {st_mode=S_IFREG|0755, st_size=2133648, ...}) = 0
lseek(3, 64, SEEK_SET)                  = 64
read(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 784) = 784
lseek(3, 848, SEEK_SET)                 = 848
read(3, "\4\0\0\0\20\0\0\0\5\0\0\0GNU\0\2\0\0\300\4\0\0\0\3\0\0\0\0\0\0\0", 32) = 32
lseek(3, 880, SEEK_SET)                 = 880
read(3, "\4\0\0\0\24\0\0\0\3\0\0\0GNU\0\250\257l\201\313(\243{\363\245F\227\v\366B$"..., 68) = 68
mmap(NULL, 1844408, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fafcde10000
mprotect(0x7fafcde35000, 1654784, PROT_NONE) = 0
mmap(0x7fafcde35000, 1351680, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x25000) = 0x7fafcde35000
mmap(0x7fafcdf7f000, 299008, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16f000) = 0x7fafcdf7f000
mmap(0x7fafcdfc9000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1b8000) = 0x7fafcdfc9000
mmap(0x7fafcdfcf000, 13496, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fafcdfcf000
close(3)                                = 0
mmap(NULL, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fafcde0d000
arch_prctl(ARCH_SET_FS, 0x7fafcde0d740) = 0
mprotect(0x7fafcdfc9000, 12288, PROT_READ) = 0
mprotect(0x7fafcdff0000, 4096, PROT_READ) = 0
mprotect(0x55e82d23d000, 4096, PROT_READ) = 0
mprotect(0x7fafce085000, 4096, PROT_READ) = 0
munmap(0x7fafcdff4000, 420603)          = 0
write(2, "sha3-256sum: the state size must"..., 53sha3-256sum: the state size must be a multiple of 25
) = 53
exit_group(2)                           = ?
+++ exited with 2 +++

libkeccak.h unusable from C++: cast from void

If you remove all the restrict (#19), libkeccak.h still doesn't compile in C++ mode:

/usr/include/libkeccak.h: In function ‘libkeccak_hmac_state* libkeccak_hmac_create(const libkeccak_spec*, const void*, size_t)’:
/usr/include/libkeccak.h:909:61: error: invalid conversion from ‘void*’ to ‘libkeccak_hmac_state*’ [-fpermissive]
  909 |         struct libkeccak_hmac_state *restrict state = malloc(sizeof(struct libkeccak_hmac_state));
      |                                                       ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                             |
      |                                                             void*
/usr/include/libkeccak.h: In function ‘libkeccak_hmac_state* libkeccak_hmac_duplicate(const libkeccak_hmac_state*)’:
/usr/include/libkeccak.h:1035:60: error: invalid conversion from ‘void*’ to ‘libkeccak_hmac_state*’ [-fpermissive]
 1035 |         struct libkeccak_hmac_state *restrict dest = malloc(sizeof(struct libkeccak_hmac_state));
      |                                                      ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                            |
      |                                                            void*
/usr/include/libkeccak.h: In function ‘size_t libkeccak_hmac_marshal(const libkeccak_hmac_state*, void*)’:
/usr/include/libkeccak.h:1054:40: error: invalid conversion from ‘void*’ to ‘unsigned char*’ [-fpermissive]
 1054 |         unsigned char *restrict data = data_;
      |                                        ^~~~~
      |                                        |
      |                                        void*

It's also missing the extern "C" wrapper around all functions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.