aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2017-10-14 01:01:14 +0200
committerMattias Andrée <maandree@kth.se>2017-10-14 01:01:14 +0200
commit3e1864aa14a33a3c917537a241f6a032cfcacf78 (patch)
tree25297b1363fa88c9f45b5102afa5e95d08e986c1
parentChange style and license (diff)
downloadlibkeccak-3e1864aa14a33a3c917537a241f6a032cfcacf78.tar.gz
libkeccak-3e1864aa14a33a3c917537a241f6a032cfcacf78.tar.bz2
libkeccak-3e1864aa14a33a3c917537a241f6a032cfcacf78.tar.xz
General improvements
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rw-r--r--.gitignore8
-rw-r--r--DEPENDENCIES7
-rw-r--r--Makefile502
-rwxr-xr-xbenchmark-flags (renamed from src/benchmark-flags)0
-rw-r--r--benchmark.c (renamed from src/benchmark.c)16
-rw-r--r--config.mk13
-rw-r--r--doc/info/libkeccak.texinfo1069
-rw-r--r--doc/info/macros.texinfo10
-rw-r--r--libkeccak.h (renamed from src/libkeccak.h)0
-rw-r--r--libkeccak.texinfo403
-rw-r--r--libkeccak/digest.c (renamed from src/libkeccak/digest.c)24
-rw-r--r--libkeccak/digest.h (renamed from src/libkeccak/digest.h)0
-rw-r--r--libkeccak/files.c (renamed from src/libkeccak/files.c)0
-rw-r--r--libkeccak/files.h (renamed from src/libkeccak/files.h)0
-rw-r--r--libkeccak/generalised-spec.c (renamed from src/libkeccak/generalised-spec.c)0
-rw-r--r--libkeccak/generalised-spec.h (renamed from src/libkeccak/generalised-spec.h)0
-rw-r--r--libkeccak/hex.c (renamed from src/libkeccak/hex.c)0
-rw-r--r--libkeccak/hex.h (renamed from src/libkeccak/hex.h)0
-rw-r--r--libkeccak/internal.h (renamed from src/libkeccak/internal.h)0
-rw-r--r--libkeccak/mac/hmac.c (renamed from src/libkeccak/mac/hmac.c)0
-rw-r--r--libkeccak/mac/hmac.h (renamed from src/libkeccak/mac/hmac.h)0
-rw-r--r--libkeccak/spec.h (renamed from src/libkeccak/spec.h)0
-rw-r--r--libkeccak/state.c (renamed from src/libkeccak/state.c)0
-rw-r--r--libkeccak/state.h (renamed from src/libkeccak/state.h)0
-rw-r--r--man/libkeccak.7 (renamed from doc/man/libkeccak.7)0
-rw-r--r--man/libkeccak_behex_lower.3 (renamed from doc/man/libkeccak_behex_lower.3)0
-rw-r--r--man/libkeccak_behex_upper.3 (renamed from doc/man/libkeccak_behex_upper.3)0
-rw-r--r--man/libkeccak_degeneralise_spec.3 (renamed from doc/man/libkeccak_degeneralise_spec.3)0
-rw-r--r--man/libkeccak_digest.3 (renamed from doc/man/libkeccak_digest.3)0
-rw-r--r--man/libkeccak_fast_digest.3 (renamed from doc/man/libkeccak_fast_digest.3)0
-rw-r--r--man/libkeccak_fast_squeeze.3 (renamed from doc/man/libkeccak_fast_squeeze.3)0
-rw-r--r--man/libkeccak_fast_update.3 (renamed from doc/man/libkeccak_fast_update.3)0
-rw-r--r--man/libkeccak_generalised_spec_initialise.3 (renamed from doc/man/libkeccak_generalised_spec_initialise.3)0
-rw-r--r--man/libkeccak_generalised_sum_fd.3 (renamed from doc/man/libkeccak_generalised_sum_fd.3)0
-rw-r--r--man/libkeccak_hmac_copy.3 (renamed from doc/man/libkeccak_hmac_copy.3)0
-rw-r--r--man/libkeccak_hmac_create.3 (renamed from doc/man/libkeccak_hmac_create.3)0
-rw-r--r--man/libkeccak_hmac_destroy.3 (renamed from doc/man/libkeccak_hmac_destroy.3)0
-rw-r--r--man/libkeccak_hmac_digest.3 (renamed from doc/man/libkeccak_hmac_digest.3)0
-rw-r--r--man/libkeccak_hmac_duplicate.3 (renamed from doc/man/libkeccak_hmac_duplicate.3)0
-rw-r--r--man/libkeccak_hmac_fast_destroy.3 (renamed from doc/man/libkeccak_hmac_fast_destroy.3)0
-rw-r--r--man/libkeccak_hmac_fast_digest.3 (renamed from doc/man/libkeccak_hmac_fast_digest.3)0
-rw-r--r--man/libkeccak_hmac_fast_free.3 (renamed from doc/man/libkeccak_hmac_fast_free.3)0
-rw-r--r--man/libkeccak_hmac_fast_update.3 (renamed from doc/man/libkeccak_hmac_fast_update.3)0
-rw-r--r--man/libkeccak_hmac_free.3 (renamed from doc/man/libkeccak_hmac_free.3)0
-rw-r--r--man/libkeccak_hmac_initialise.3 (renamed from doc/man/libkeccak_hmac_initialise.3)0
-rw-r--r--man/libkeccak_hmac_marshal.3 (renamed from doc/man/libkeccak_hmac_marshal.3)0
-rw-r--r--man/libkeccak_hmac_marshal_size.3 (renamed from doc/man/libkeccak_hmac_marshal_size.3)0
-rw-r--r--man/libkeccak_hmac_reset.3 (renamed from doc/man/libkeccak_hmac_reset.3)0
-rw-r--r--man/libkeccak_hmac_set_key.3 (renamed from doc/man/libkeccak_hmac_set_key.3)0
-rw-r--r--man/libkeccak_hmac_unmarshal.3 (renamed from doc/man/libkeccak_hmac_unmarshal.3)0
-rw-r--r--man/libkeccak_hmac_unmarshal_skip.3 (renamed from doc/man/libkeccak_hmac_unmarshal_skip.3)0
-rw-r--r--man/libkeccak_hmac_update.3 (renamed from doc/man/libkeccak_hmac_update.3)0
-rw-r--r--man/libkeccak_hmac_wipe.3 (renamed from doc/man/libkeccak_hmac_wipe.3)0
-rw-r--r--man/libkeccak_keccaksum_fd.3 (renamed from doc/man/libkeccak_keccaksum_fd.3)0
-rw-r--r--man/libkeccak_rawshakesum_fd.3 (renamed from doc/man/libkeccak_rawshakesum_fd.3)0
-rw-r--r--man/libkeccak_sha3sum_fd.3 (renamed from doc/man/libkeccak_sha3sum_fd.3)0
-rw-r--r--man/libkeccak_shakesum_fd.3 (renamed from doc/man/libkeccak_shakesum_fd.3)0
-rw-r--r--man/libkeccak_simple_squeeze.3 (renamed from doc/man/libkeccak_simple_squeeze.3)0
-rw-r--r--man/libkeccak_spec_check.3 (renamed from doc/man/libkeccak_spec_check.3)0
-rw-r--r--man/libkeccak_spec_rawshake.3 (renamed from doc/man/libkeccak_spec_rawshake.3)0
-rw-r--r--man/libkeccak_spec_sha3.3 (renamed from doc/man/libkeccak_spec_sha3.3)0
-rw-r--r--man/libkeccak_spec_shake.3 (renamed from doc/man/libkeccak_spec_shake.3)0
-rw-r--r--man/libkeccak_squeeze.3 (renamed from doc/man/libkeccak_squeeze.3)0
-rw-r--r--man/libkeccak_state_copy.3 (renamed from doc/man/libkeccak_state_copy.3)0
-rw-r--r--man/libkeccak_state_create.3 (renamed from doc/man/libkeccak_state_create.3)0
-rw-r--r--man/libkeccak_state_destroy.3 (renamed from doc/man/libkeccak_state_destroy.3)0
-rw-r--r--man/libkeccak_state_duplicate.3 (renamed from doc/man/libkeccak_state_duplicate.3)0
-rw-r--r--man/libkeccak_state_fast_destroy.3 (renamed from doc/man/libkeccak_state_fast_destroy.3)0
-rw-r--r--man/libkeccak_state_fast_free.3 (renamed from doc/man/libkeccak_state_fast_free.3)0
-rw-r--r--man/libkeccak_state_free.3 (renamed from doc/man/libkeccak_state_free.3)0
-rw-r--r--man/libkeccak_state_initialise.3 (renamed from doc/man/libkeccak_state_initialise.3)0
-rw-r--r--man/libkeccak_state_marshal.3 (renamed from doc/man/libkeccak_state_marshal.3)0
-rw-r--r--man/libkeccak_state_marshal_size.3 (renamed from doc/man/libkeccak_state_marshal_size.3)0
-rw-r--r--man/libkeccak_state_reset.3 (renamed from doc/man/libkeccak_state_reset.3)0
-rw-r--r--man/libkeccak_state_unmarshal.3 (renamed from doc/man/libkeccak_state_unmarshal.3)0
-rw-r--r--man/libkeccak_state_unmarshal_skip.3 (renamed from doc/man/libkeccak_state_unmarshal_skip.3)0
-rw-r--r--man/libkeccak_state_wipe.3 (renamed from doc/man/libkeccak_state_wipe.3)0
-rw-r--r--man/libkeccak_state_wipe_message.3 (renamed from doc/man/libkeccak_state_wipe_message.3)0
-rw-r--r--man/libkeccak_state_wipe_sponge.3 (renamed from doc/man/libkeccak_state_wipe_sponge.3)0
-rw-r--r--man/libkeccak_unhex.3 (renamed from doc/man/libkeccak_unhex.3)0
-rw-r--r--man/libkeccak_update.3 (renamed from doc/man/libkeccak_update.3)0
-rw-r--r--test.c (renamed from src/test.c)0
82 files changed, 626 insertions, 1426 deletions
diff --git a/.gitignore b/.gitignore
index 292c1b2..e98a781 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,15 +1,19 @@
*~
*\#*
-bin/
-obj/
*.o
*.out
*.so
+*.so.*
*.su
*.gch
*.a
+*.dylib
+*.dylib.*
*.info
*.pdf
*.ps
*.dvi
*.test
+/benchmark
+/test
+/benchfile
diff --git a/DEPENDENCIES b/DEPENDENCIES
index 87e6858..5cd97da 100644
--- a/DEPENDENCIES
+++ b/DEPENDENCIES
@@ -6,7 +6,7 @@ RUNTIME DEPENDENCIES:
BUILD DEPENDENCIES:
libc
- gcc
+ c99
make
coreutils
binutils
@@ -26,12 +26,11 @@ BENCHMARK DEPENDENCIES:
make
coreutils
median
- grep (only needed for src/benchmark-flags)
- sed (only needed for src/benchmark-flags)
+ grep (only needed for ./benchmark-flags)
+ sed (only needed for ./benchmark-flags)
INSTALL DEPENDENCIES:
make
coreutils
-
diff --git a/Makefile b/Makefile
index 74a95f0..43cc089 100644
--- a/Makefile
+++ b/Makefile
@@ -1,39 +1,16 @@
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-# The package path prefix, if you want to install to another root, set DESTDIR to that root.
-PREFIX = /usr
-# The library path excluding prefix.
-LIB = /lib
-# The library header path excluding prefix.
-INCLUDE = /include
-# The resource path excluding prefix.
-DATA = /share
-# The library path including prefix.
-LIBDIR = $(PREFIX)$(LIB)
-# The library header including prefix.
-INCLUDEDIR = $(PREFIX)$(INCLUDE)
-# The resource path including prefix.
-DATADIR = $(PREFIX)$(DATA)
-# The generic documentation path including prefix.
-DOCDIR = $(DATADIR)/doc
-# The info manual documentation path including prefix.
-INFODIR = $(DATADIR)/info
-# The man pages path including prefix.
-MANDIR = $(DATADIR)/man
-# The section 3 man pages path including prefix.
-MAN3DIR = $(MANDIR)/man3
-# The section 7 man pages path including prefix.
-MAN7DIR = $(MANDIR)/man7
-# The license base path including prefix.
-LICENSEDIR = $(DATADIR)/licenses
-
-# The name of the package as it should be installed.
-PKGNAME = libkeccak
+.NONPOSIX:
+CONFIGFILE = config.mk
+
+
+# for Linux
+LIBEXT = so
+LIBFLAGS = -shared -Wl,-soname,libkeccak.$(LIBEXT).$(LIB_MAJOR)
+# for Mac OS
+# LIBEXT = dylib
+# LIBFLAGS = -dynamiclib
+
+include $(CONFIGFILE)
# The version of the library.
@@ -43,313 +20,188 @@ LIB_VERSION = $(LIB_MAJOR).$(LIB_MINOR)
-WARN = -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
-
-# These have not been extensively tested but appear to:
-# * Produce produce false warnings
-# * Slowdown the library's performance
-# -flto -flto-compression-level -flto-partition={1to1,balanced,mix,none} -flto-report -flto-report-wpa -fwpa
-COPTIMISE = -falign-functions=0 -fkeep-inline-functions -fmerge-all-constants -Ofast
-LDOPTIMISE =
-
-FLAGS = -std=gnu99 $(WARN)
+OBJ =\
+ libkeccak/digest.o\
+ libkeccak/files.o\
+ libkeccak/generalised-spec.o\
+ libkeccak/hex.o\
+ libkeccak/state.o\
+ libkeccak/mac/hmac.o
-
-LIB_OBJ = digest files generalised-spec hex state mac/hmac
+HDR =\
+ libkeccak.h\
+ libkeccak/digest.h\
+ libkeccak/files.h\
+ libkeccak/generalised-spec.h\
+ libkeccak/hex.h\
+ libkeccak/spec.h\
+ libkeccak/state.h\
+ libkeccak/internal.h\
+ libkeccak/mac/hmac.h
MAN3 =\
- libkeccak_behex_lower\
- libkeccak_behex_upper\
- libkeccak_degeneralise_spec\
- libkeccak_digest\
- libkeccak_fast_digest\
- libkeccak_fast_squeeze\
- libkeccak_fast_update\
- libkeccak_generalised_spec_initialise\
- libkeccak_generalised_sum_fd\
- libkeccak_hmac_copy\
- libkeccak_hmac_create\
- libkeccak_hmac_destroy\
- libkeccak_hmac_digest\
- libkeccak_hmac_duplicate\
- libkeccak_hmac_fast_destroy\
- libkeccak_hmac_fast_digest\
- libkeccak_hmac_fast_free\
- libkeccak_hmac_fast_update\
- libkeccak_hmac_free\
- libkeccak_hmac_initialise\
- libkeccak_hmac_marshal\
- libkeccak_hmac_marshal_size\
- libkeccak_hmac_reset\
- libkeccak_hmac_set_key\
- libkeccak_hmac_unmarshal\
- libkeccak_hmac_unmarshal_skip\
- libkeccak_hmac_update\
- libkeccak_hmac_wipe\
- libkeccak_keccaksum_fd\
- libkeccak_rawshakesum_fd\
- libkeccak_sha3sum_fd\
- libkeccak_shakesum_fd\
- libkeccak_simple_squeeze\
- libkeccak_spec_check\
- libkeccak_spec_rawshake\
- libkeccak_spec_sha3\
- libkeccak_spec_shake\
- libkeccak_squeeze\
- libkeccak_state_copy\
- libkeccak_state_create\
- libkeccak_state_destroy\
- libkeccak_state_duplicate\
- libkeccak_state_fast_destroy\
- libkeccak_state_fast_free\
- libkeccak_state_free\
- libkeccak_state_initialise\
- libkeccak_state_marshal\
- libkeccak_state_marshal_size\
- libkeccak_state_reset\
- libkeccak_state_unmarshal\
- libkeccak_state_unmarshal_skip\
- libkeccak_state_wipe\
- libkeccak_state_wipe_message\
- libkeccak_state_wipe_sponge\
- libkeccak_unhex\
- libkeccak_update
-
-
-.PHONY: default
-default: lib test info
-
-.PHONY: all
-all: lib test benchmark doc
-
-
-.PHONY: lib
-lib: so a
-
-
-.PHONY: so
-so: bin/libkeccak.so.$(LIB_VERSION) bin/libkeccak.so.$(LIB_MAJOR) bin/libkeccak.so
-
-obj/libkeccak/%.o: src/libkeccak/%.c src/libkeccak.h src/libkeccak/*.h src/libkeccak/*/*.h
- @mkdir -p $$(dirname $@)
- $(CC) $(FLAGS) $(COPTIMISE) -fPIC -c -o $@ $< $(CFLAGS) $(CPPFLAGS)
-
-bin/libkeccak.so.$(LIB_VERSION): $(foreach O,$(LIB_OBJ),obj/libkeccak/$(O).o)
- @mkdir -p bin
- $(CC) $(FLAGS) $(LDOPTIMISE) -shared -Wl,-soname,libkeccak.so.$(LIB_MAJOR) -o $@ $^ $(LDFLAGS)
-
-bin/libkeccak.so.$(LIB_MAJOR):
- @mkdir -p bin
- ln -sf libkeccak.so.$(LIB_VERSION) $@
-
-bin/libkeccak.so:
- @mkdir -p bin
- ln -sf libkeccak.so.$(LIB_VERSION) $@
-
-
-.PHONY: a
-a: bin/libkeccak.a
-
-bin/libkeccak.a: $(foreach O,$(LIB_OBJ),obj/libkeccak/$(O).o)
- @mkdir -p bin
- ar rcs $@ $^
-
-
-.PHONY: test
-test: bin/test
-
-bin/test: obj/test.o bin/libkeccak.so bin/libkeccak.so.$(LIB_MAJOR) bin/libkeccak.so.$(LIB_VERSION)
- $(CC) $(FLAGS) -o $@ $< -Lbin -lkeccak $(LDFLAGS)
-
-obj/test.o: src/test.c src/libkeccak/*.h src/libkeccak.h
- @mkdir -p obj
- $(CC) $(FLAGS) -Isrc -O3 -c -o $@ $< $(CFLAGS) $(CPPFLAGS)
-
-
-.PHONY: benchmark
-benchmark: bin/benchmark
-
-bin/benchmark: obj/benchmark.o bin/libkeccak.so bin/libkeccak.so.$(LIB_MAJOR) bin/libkeccak.so.$(LIB_VERSION)
- $(CC) $(FLAGS) -o $@ $< -Lbin -lkeccak $(LDFLAGS)
-
-obj/benchmark.o: src/benchmark.c src/libkeccak/*.h src/libkeccak.h
- @mkdir -p obj
- $(CC) $(FLAGS) -Isrc -O3 -c -o $@ $< $(CFLAGS) $(CPPFLAGS)
-
-
-.PHONY: doc
-doc: info pdf ps dvi
-
-.PHONY: info
-info: bin/libkeccak.info
-
-.PHONY: pdf
-pdf: bin/libkeccak.pdf
-
-.PHONY: ps
-ps: bin/libkeccak.ps
-
-.PHONY: dvi
-dvi: bin/libkeccak.dvi
-
-
-bin/%.info: doc/info/%.texinfo doc/info/*.texinfo
- @mkdir -p bin
- $(MAKEINFO) $(TEXIFLAGS) $<
- mv $*.info bin
-
-bin/%.pdf: doc/info/%.texinfo doc/info/*.texinfo
+ libkeccak_behex_lower.3\
+ libkeccak_behex_upper.3\
+ libkeccak_degeneralise_spec.3\
+ libkeccak_digest.3\
+ libkeccak_fast_digest.3\
+ libkeccak_fast_squeeze.3\
+ libkeccak_fast_update.3\
+ libkeccak_generalised_spec_initialise.3\
+ libkeccak_generalised_sum_fd.3\
+ libkeccak_hmac_copy.3\
+ libkeccak_hmac_create.3\
+ libkeccak_hmac_destroy.3\
+ libkeccak_hmac_digest.3\
+ libkeccak_hmac_duplicate.3\
+ libkeccak_hmac_fast_destroy.3\
+ libkeccak_hmac_fast_digest.3\
+ libkeccak_hmac_fast_free.3\
+ libkeccak_hmac_fast_update.3\
+ libkeccak_hmac_free.3\
+ libkeccak_hmac_initialise.3\
+ libkeccak_hmac_marshal.3\
+ libkeccak_hmac_marshal_size.3\
+ libkeccak_hmac_reset.3\
+ libkeccak_hmac_set_key.3\
+ libkeccak_hmac_unmarshal.3\
+ libkeccak_hmac_unmarshal_skip.3\
+ libkeccak_hmac_update.3\
+ libkeccak_hmac_wipe.3\
+ libkeccak_keccaksum_fd.3\
+ libkeccak_rawshakesum_fd.3\
+ libkeccak_sha3sum_fd.3\
+ libkeccak_shakesum_fd.3\
+ libkeccak_simple_squeeze.3\
+ libkeccak_spec_check.3\
+ libkeccak_spec_rawshake.3\
+ libkeccak_spec_sha3.3\
+ libkeccak_spec_shake.3\
+ libkeccak_squeeze.3\
+ libkeccak_state_copy.3\
+ libkeccak_state_create.3\
+ libkeccak_state_destroy.3\
+ libkeccak_state_duplicate.3\
+ libkeccak_state_fast_destroy.3\
+ libkeccak_state_fast_free.3\
+ libkeccak_state_free.3\
+ libkeccak_state_initialise.3\
+ libkeccak_state_marshal.3\
+ libkeccak_state_marshal_size.3\
+ libkeccak_state_reset.3\
+ libkeccak_state_unmarshal.3\
+ libkeccak_state_unmarshal_skip.3\
+ libkeccak_state_wipe.3\
+ libkeccak_state_wipe_message.3\
+ libkeccak_state_wipe_sponge.3\
+ libkeccak_unhex.3\
+ libkeccak_update.3
+
+MAN7 =\
+ libkeccak_update.7
+
+
+all: libkeccak.a libkeccak.$(LIBEXT) test benchmark
+
+$(OBJ): $(HDR)
+.c.o:
+ $(CC) -fPIC -c -o $@ $< $(CFLAGS) $(CPPFLAGS)
+
+libkeccak.$(LIBEXT): $(OBJ)
+ $(CC) -shared -Wl,-soname,libkeccak.$(LIBEXT).$(LIB_MAJOR) -o $@ $^ $(LDFLAGS)
+
+libkeccak.a: $(OBJ)
+ $(AR) rc $@ $?
+ $(AR) -s $@
+
+
+test: test.o libkeccak.a
+ $(CC) $(FLAGS) -o $@ $^ $(LDFLAGS)
+
+test.o: test.c $(HDR)
+ $(CC) $(FLAGS) -O3 -c -o $@ test.c $(CFLAGS) $(CPPFLAGS)
+
+benchmark: benchmark.o libkeccak.a
+ $(CC) $(FLAGS) -o $@ $^ $(LDFLAGS)
+
+benchmark.o: benchmark.c $(HDR)
+ $(CC) $(FLAGS) -O3 -c -o $@ benchmark.c $(CFLAGS) $(CPPFLAGS)
+
+
+info: libkeccak.info
+libkeccak.info: libkeccak.texinfo
+ $(MAKEINFO) $(TEXIFLAGS) libkeccak.texinfo
+
+pdf: libkeccak.pdf
+libkeccak.pdf: libkeccak.texinfo
@! test -d obj/pdf || rm -rf obj/pdf
- @mkdir -p obj/pdf bin
- cd obj/pdf && texi2pdf $(TEXIFLAGS) ../../$< < /dev/null
- mv obj/pdf/$*.pdf $@
+ @mkdir -p obj/pdf
+ cd obj/pdf && texi2pdf $(TEXIFLAGS) ../../libkeccak.texinfo < /dev/null
+ mv obj/pdf/$@ $@
-bin/%.dvi: doc/info/%.texinfo doc/info/*.texinfo
+dvi: libkeccak.dvi
+libkeccak.dvi: libkeccak.texinfo
@! test -d obj/dvi || rm -rf obj/dvi
- @mkdir -p obj/dvi bin
- cd obj/dvi && $(TEXI2DVI) $(TEXIFLAGS) ../../$< < /dev/null
- mv obj/dvi/$*.dvi $@
+ @mkdir -p obj/dvi
+ cd obj/dvi && $(TEXI2DVI) $(TEXIFLAGS) ../../libkeccak.texinfo < /dev/null
+ mv obj/dvi/$@ $@
-bin/%.ps: doc/info/%.texinfo doc/info/*.texinfo
+ps: libkeccak.ps
+libkeccak.ps: libkeccak.texinfo
@! test -d obj/ps || rm -rf obj/ps
- @mkdir -p obj/ps bin
- cd obj/ps && texi2pdf $(TEXIFLAGS) --ps ../../$< < /dev/null
- mv obj/ps/$*.ps $@
-
+ @mkdir -p obj/ps
+ cd obj/ps && texi2pdf $(TEXIFLAGS) --ps ../../libkeccak.texinfo < /dev/null
+ mv obj/ps/$@ $@
-.PHONY: check
-check: bin/test bin/libkeccak.so bin/libkeccak.so.$(LIB_MAJOR) bin/libkeccak.so.$(LIB_VERSION)
+check: test
@test $$(sha256sum .testfile | cut -d ' ' -f 1) = \
e21d814d21ca269246849cc105faec1a71ac7d1cdb1a86023254f49d51b47231 || \
( echo 'The file .testfile is incorrect, test will fail!' ; false )
- env LD_LIBRARY_PATH=bin valgrind --leak-check=full bin/test
- test $$(env LD_LIBRARY_PATH=bin valgrind bin/test 2>&1 >/dev/null | wc -l) = 14
+ valgrind --leak-check=full ./test
+ test $$(valgrind ./test 2>&1 >/dev/null | wc -l) = 14
# Using valgrind 3.10.0, its output to standard error should consist of 14 lines,
# the test itself never prints to standard error.
+benchfile:
+ dd if=/dev/urandom bs=1000 count=50 > $@
+
+run-benchmark: benchmark benchfile
+ for i in $$(seq 7) ; do ./benchmark ; done | median
+
+install: libkeccak.$(LIBEXT) libkeccak.a
+ mkdir -p -- "$(DESTDIR)$(PREFIX)/lib"
+ cp -- libkeccak.$(LIBEXT) "$(DESTDIR)$(PREFIX)/lib/libkeccak.$(LIBEXT).$(LIB_VERSION)"
+ ln -sf -- libkeccak.$(LIBEXT).$(LIB_VERSION) "$(DESTDIR)$(PREFIX)/lib/libkeccak.$(LIBEXT).$(LIB_MAJOR)"
+ ln -sf -- libkeccak.$(LIBEXT).$(LIB_VERSION) "$(DESTDIR)$(PREFIX)/lib/libkeccak.$(LIBEXT)"
+ cp -- libkeccak.a "$(DESTDIR)$(PREFIX)/lib/libkeccak.a"
+ mkdir -p -- "$(DESTDIR)$(PREFIX)/include/libkeccak/mac"
+ for f in $(HDR); do cp -- "$$f" "$(DESTDIR)$(PREFIX)/include/$$f" || exit 1; done
+ mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man3"
+ mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man7"
+ cd man && cp -- $(MAN3) "$(DESTDIR)$(MANPREFIX)/man3"
+ cd man && cp -- $(MAN7) "$(DESTDIR)$(MANPREFIX)/man7"
+ mkdir -p -- "$(DESTDIR)$(PREFIX)/share/licenses/libkeccak"
+ cp -- LICENSE "$(DESTDIR)$(PREFIX)/share/licenses/libkeccak/"
-.PHONY: run-benchmark
-run-benchmark: bin/benchmark bin/libkeccak.so bin/libkeccak.so.$(LIB_MAJOR) bin/libkeccak.so.$(LIB_VERSION)
- for i in $$(seq 7) ; do env LD_LIBRARY_PATH=bin bin/benchmark ; done | median
-
-
-
-.PHONY: install
-install: install-base install-info install-man
-
-.PHONY: install-all
-install-all: install-base install-doc
-
-.PHONY: install-base
-install-base: install-lib install-copyright
-
-.PHONY: install-lib
-install-lib: install-headers install-dynamic-lib install-static-lib
-
-.PHONY: install-headers
-install-headers:
- install -dm755 -- "$(DESTDIR)$(INCLUDEDIR)"
- install -dm755 -- "$(DESTDIR)$(INCLUDEDIR)/libkeccak"
- install -dm755 -- "$(DESTDIR)$(INCLUDEDIR)/libkeccak/mac"
- install -m644 -- src/libkeccak.h "$(DESTDIR)$(INCLUDEDIR)/libkeccak.h"
- install -m644 -- src/libkeccak/digest.h "$(DESTDIR)$(INCLUDEDIR)/libkeccak/digest.h"
- install -m644 -- src/libkeccak/files.h "$(DESTDIR)$(INCLUDEDIR)/libkeccak/files.h"
- install -m644 -- src/libkeccak/generalised-spec.h "$(DESTDIR)$(INCLUDEDIR)/libkeccak/generalised-spec.h"
- install -m644 -- src/libkeccak/hex.h "$(DESTDIR)$(INCLUDEDIR)/libkeccak/hex.h"
- install -m644 -- src/libkeccak/spec.h "$(DESTDIR)$(INCLUDEDIR)/libkeccak/spec.h"
- install -m644 -- src/libkeccak/state.h "$(DESTDIR)$(INCLUDEDIR)/libkeccak/state.h"
- install -m644 -- src/libkeccak/internal.h "$(DESTDIR)$(INCLUDEDIR)/libkeccak/internal.h"
- install -m644 -- src/libkeccak/mac/hmac.h "$(DESTDIR)$(INCLUDEDIR)/libkeccak/mac/hmac.h"
-
-.PHONY: install-dynamic-lib
-install-dynamic-lib: bin/libkeccak.so.$(LIB_VERSION)
- install -dm755 -- "$(DESTDIR)$(LIBDIR)"
- install -m755 -- bin/libkeccak.so.$(LIB_VERSION) "$(DESTDIR)$(LIBDIR)/libkeccak.so.$(LIB_VERSION)"
- ln -sf -- libkeccak.so.$(LIB_VERSION) "$(DESTDIR)$(LIBDIR)/libkeccak.so.$(LIB_MAJOR)"
- ln -sf -- libkeccak.so.$(LIB_VERSION) "$(DESTDIR)$(LIBDIR)/libkeccak.so"
-
-.PHONY: install-static-lib
-install-static-lib: bin/libkeccak.a
- install -dm755 -- "$(DESTDIR)$(LIBDIR)"
- install -m644 -- bin/libkeccak.a "$(DESTDIR)$(LIBDIR)/libkeccak.a"
-
-.PHONY: install-copyright
-install-copyright: install-license
-
-.PHONY: install-license
-install-license:
- install -dm755 -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)"
- install -m644 -- LICENSE "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/LICENSE"
-
-.PHONY: install-doc
-install-doc: install-info install-pdf install-ps install-dvi install-man
-
-.PHONY: install-info
-install-info: bin/libkeccak.info
- install -dm755 -- "$(DESTDIR)$(INFODIR)"
- install -m644 -- $< "$(DESTDIR)$(INFODIR)/libkeccak.info"
-
-.PHONY: install-pdf
-install-pdf: bin/libkeccak.pdf
- install -dm755 -- "$(DESTDIR)$(DOCDIR)"
- install -m644 -- $< "$(DESTDIR)$(DOCDIR)/libkeccak.pdf"
-
-.PHONY: install-ps
-install-ps: bin/libkeccak.ps
- install -dm755 -- "$(DESTDIR)$(DOCDIR)"
- install -m644 -- $< "$(DESTDIR)$(DOCDIR)/libkeccak.ps"
-
-.PHONY: install-dvi
-install-dvi: bin/libkeccak.dvi
- install -dm755 -- "$(DESTDIR)$(DOCDIR)"
- install -m644 -- $< "$(DESTDIR)$(DOCDIR)/libkeccak.dvi"
-
-.PHONY: install-man
-install-man:
- install -dm755 -- "$(DESTDIR)$(MAN7DIR)"
- install -m644 -- doc/man/libkeccak.7 "$(DESTDIR)$(MAN7DIR)/libkeccak.7"
- install -dm755 -- "$(DESTDIR)$(MAN3DIR)"
- install -m644 -- $(foreach P,$(MAN3),doc/man/$(P).3) "$(DESTDIR)$(MAN3DIR)"
-
-.PHONY: uninstall
uninstall:
- -rm -- "$(DESTDIR)$(INCLUDEDIR)/libkeccak.h"
- -rm -- "$(DESTDIR)$(INCLUDEDIR)/libkeccak/digest.h"
- -rm -- "$(DESTDIR)$(INCLUDEDIR)/libkeccak/files.h"
- -rm -- "$(DESTDIR)$(INCLUDEDIR)/libkeccak/generalised-spec.h"
- -rm -- "$(DESTDIR)$(INCLUDEDIR)/libkeccak/hex.h"
- -rm -- "$(DESTDIR)$(INCLUDEDIR)/libkeccak/spec.h"
- -rm -- "$(DESTDIR)$(INCLUDEDIR)/libkeccak/state.h"
- -rm -- "$(DESTDIR)$(INCLUDEDIR)/libkeccak/internal.h"
- -rm -- "$(DESTDIR)$(INCLUDEDIR)/libkeccak/mac/hmac.h"
- -rmdir -- "$(DESTDIR)$(INCLUDEDIR)/libkeccak/mac"
- -rmdir -- "$(DESTDIR)$(INCLUDEDIR)/libkeccak"
- -rm -- "$(DESTDIR)$(LIBDIR)/libkeccak.so.$(LIB_VERSION)"
- -rm -- "$(DESTDIR)$(LIBDIR)/libkeccak.so.$(LIB_MAJOR)"
- -rm -- "$(DESTDIR)$(LIBDIR)/libkeccak.so"
- -rm -- "$(DESTDIR)$(LIBDIR)/libkeccak.a"
- -rm -- "$(DESTDIR)$(INFODIR)/libkeccak.info"
- -rm -- "$(DESTDIR)$(DOCDIR)/libkeccak.pdf"
- -rm -- "$(DESTDIR)$(DOCDIR)/libkeccak.ps"
- -rm -- "$(DESTDIR)$(DOCDIR)/libkeccak.dvi"
- -rm -- "$(DESTDIR)$(MAN7DIR)/libkeccak.7"
- -rm -- $(foreach P,$(MAN3),"$(DESTDIR)$(MAN3DIR)/$(P).3")
- -rm -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/COPYING"
- -rm -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/LICENSE"
- -rmdir -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)"
-
-
-
-.PHONY: clean
+ -rm -- "$(DESTDIR)$(PREFIX)/lib/libkeccak.$(LIBEXT).$(LIB_VERSION)"
+ -rm -- "$(DESTDIR)$(PREFIX)/lib/libkeccak.$(LIBEXT).$(LIB_MAJOR)"
+ -rm -- "$(DESTDIR)$(PREFIX)/lib/libkeccak.$(LIBEXT)"
+ -rm -- "$(DESTDIR)$(PREFIX)/lib/libkeccak.a"
+ -cd "$(DESTDIR)$(PREFIX)/include" && rm -- $(HDR)
+ -rmdir -- "$(DESTDIR)$(PREFIX)/include/libkeccak/mac"
+ -rmdir -- "$(DESTDIR)$(PREFIX)/include/libkeccak"
+ -cd -- "$(DESTDIR)$(MANPREFIX)/man3" && rm -- $(MAN3)
+ -cd -- "$(DESTDIR)$(MANPREFIX)/man7" && rm -- $(MAN7)
+ -rm -- "$(DESTDIR)$(PREFIX)/share/licenses/libkeccak/LICENSE"
+ -rmdir -- "$(DESTDIR)$(PREFIX)/share/licenses/libkeccak"
+
clean:
- -rm -r obj bin
+ -rm -r -- *.o libkeccak/*.o libkeccak/mac/*.o
+ -rm -r -- *.su libkeccak/*.su libkeccak/mac/*.su
+ -rm -- *.info *.pdf *.ps *.dvi *.a libkeccak.$(LIBEXT)* test benchmark benchfile
+
+.SUFFIXES: .c.o
+.PHONY: all info pdf ps dvi check run-benchmark install uninstall clean
diff --git a/src/benchmark-flags b/benchmark-flags
index 1168ec0..1168ec0 100755
--- a/src/benchmark-flags
+++ b/benchmark-flags
diff --git a/src/benchmark.c b/benchmark.c
index 1ce7da9..20344d9 100644
--- a/src/benchmark.c
+++ b/benchmark.c
@@ -9,10 +9,10 @@
#ifndef MESSAGE_FILE
-# define MESSAGE_FILE "LICENSE"
+# define MESSAGE_FILE "benchfile"
#endif
#ifndef MESSAGE_LEN
-# define MESSAGE_LEN 34520
+# define MESSAGE_LEN 50000
#endif
@@ -20,23 +20,23 @@
# define BITRATE 1024
#endif
#ifndef CAPACITY
-# define CAPACITY 576
+# define CAPACITY 576
#endif
#ifndef OUTPUT
-# define OUTPUT 512
+# define OUTPUT 512
#endif
#ifndef UPDATE_RUNS
-# define UPDATE_RUNS 100
+# define UPDATE_RUNS 100
#endif
#ifndef FAST_SQUEEZE_RUNS
-# define FAST_SQUEEZE_RUNS 100
+# define FAST_SQUEEZE_RUNS 100
#endif
#ifndef SLOW_SQUEEZE_RUNS
-# define SLOW_SQUEEZE_RUNS 100
+# define SLOW_SQUEEZE_RUNS 100
#endif
#ifndef RERUNS
-# define RERUNS 50
+# define RERUNS 50
#endif
diff --git a/config.mk b/config.mk
new file mode 100644
index 0000000..fee0853
--- /dev/null
+++ b/config.mk
@@ -0,0 +1,13 @@
+PREFIX = /usr
+MANPREFIX = $(DATADIR)/man
+
+# These have not been extensively tested but appear to:
+# * Produce produce false warnings
+# * Slowdown the library's performance
+# -flto -flto-compression-level -flto-partition={1to1,balanced,mix,none} -flto-report -flto-report-wpa -fwpa
+CCOPTIMISE = -falign-functions=0 -fkeep-inline-functions -fmerge-all-constants -Ofast
+LDOPTIMISE =
+
+CFLAGS = -std=c99 -Wall -Wextra $(CCOPTIMISE)
+CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700
+LDFLAGS = $(LDOPTIMISE)
diff --git a/doc/info/libkeccak.texinfo b/doc/info/libkeccak.texinfo
deleted file mode 100644
index 68bf147..0000000
--- a/doc/info/libkeccak.texinfo
+++ /dev/null
@@ -1,1069 +0,0 @@
-\input texinfo @c -*-texinfo-*-
-@c %**start of header
-@documentencoding UTF-8
-@include macros.texinfo
-@copying
-@c --------------------------------------------------------------------------------
-Copyright @copyright{} 2015, 2017 @w{Mattias Andrée @e{maandree@@kth.se}}
-
-@quotation
-Permission to use, copy, modify, and/or distribute this document for any purpose
-with or without fee is hereby granted, provided that the above copyright notice
-and this permission notice appear in all copies.
-@end quotation
-@c --------------------------------------------------------------------------------
-@end copying
-
-
-@setfilename libkeccak.info
-@settitle libkeccak -- Library for the Keccak-family hash functions
-@documentlanguage en_GB
-@finalout
-@frenchspacing on
-@afourpaper
-
-@c @paragraphindent asis
-@c @firstparagraphindent none
-@c @exampleindent asis
-
-@dircategory Libraries
-@direntry
-* libkeccak: (libkeccak). Library for the Keccak-family hash functions.
-@end direntry
-
-@documentdescription
-Developer reference manual for libkeccak, a library
-for hashing with Keccak, SHA-3 RawSHAKE and SHAKE,
-with support for bit-oriented data.
-@end documentdescription
-@c %**end of header
-
-
-
-@ifnottex
-@node Top
-@top libkeccak -- Library for the Keccak-family hash functions
-@insertcopying
-@end ifnottex
-
-@titlepage
-@title libkeccak
-@subtitle Library for the Keccak-family hash functions
-
-@author by Mattias Andrée (maandree)
-
-@page
-@center `Kecak! Kecak! Kecak! Kecak! Kecak! Kecak! Kecak! Kecak! …'
-@vskip 0pt plus 1filll
-@insertcopying
-@end titlepage
-
-@contents
-
-
-
-@menu
-* Overview:: Brief overview of libkeccak.
-* Linking:: How to use libkeccak in your software.
-* Selecting hash function:: Selecting and tuning the function.
-* State of the hashing:: The structure used to keep track of the hashing process.
-* Hashing messages:: Functions used to hash a message.
-* Hexadecimal hashes:: Converting between binary and hexadecimal.
-* Hashing files:: Functions used to hash entire files.
-* Message authentication:: Functions used for message authentication codes.
-* Examples:: Examples of how to use libkeccak.
-
-* Concept index:: Index of concepts.
-* Data type index:: Index of data types.
-* Function index:: Index of functions.
-@end menu
-
-
-
-@node Overview
-@chapter Overview
-
-@cpindex Orientation
-libkeccak is a free software bit-oriented implementation
-of the cryptographic hash function Keccak and its subsets
-SHA-3 (Secure Hash Algorithm@tie{}3), RawSHAKE and SHAKE.
-
-Being bit-oriented means that it supports messages of length
-consisting of a non-whole number of bytes.
-
-@cpindex Uses
-Keccak is a generic and tunable cryptographic hash function
-that can be used for all customary tasks that required a
-cryptographic hash function:
-@itemize @bullet{}
-@item
-Password verification@footnote{Using additional squeezes, but not using iterated hashing.}
-@item
-Proof-of-work
-@item
-File and data identification
-@item
-Data integrity
-@item
-Pseudorandom number generation@footnote{Although not too random, since entropi is not utilised.}
-@item
-Key derivation
-@end itemize
-
-libkeccak support secure erasure of sensitive data,
-marshalling of hashing state, and indefinite output length.
-It also has builting functions for hashing files and
-wrapping the hash functions with HMAC@footnote{Although
-doing so is unnecessary because the key can securely be
-prepended to the message when using Keccak to produce
-a message authentication code.}. This library implements
-the Keccak algorithm using a lanewise implementation.
-
-@cpindex Limitations
-This implementation is limited to state sizes up to,
-and including, 1600 bits.
-
-
-
-@node Linking
-@chapter Linking
-
-@cpindex Compiling
-libkeccak's API is C standard library independent. This means
-that libkeccak does not need to be compiled with the same
-C standard library as software using it. However, the header
-files contain @code{__attributes__}:s for GCC, if these are
-incompatible with your compiler, your should temporarily define
-a macro named @code{__attributes__} to remove all attributes.
-
-@cpindex @command{pkg-config}
-@cpindex Linking
-Because of libkeccak's simplicity it does not have a pkg-config
-file. Instead, you only need to specify the flag @code{-lkeccak}
-when linking your binaries. No flags are required during compilation
-(of object files.)
-
-To make libkeccak's API available, include the header file
-@file{<libkeccak.h>} in your source files.
-
-
-
-@node Selecting hash function
-@chapter Selecting hash function
-
-@cpindex Parameters
-@cpindex Tuning
-Keccak-based hash functions have three parameters:
-@itemize @bullet{}
-@item
-the bitrate,
-@item
-the capacity, and
-@item
-the output size.
-@end itemize
-@noindent
-Selecting these is the first step when using the library.
-
-@tpindex libkeccak_spec_t
-@tpindex struct libkeccak_spec
-The structure @code{libkeccak_spec_t} (@code{struct libkeccak_spec}),
-is to specify these parameters. For the less tunable functions
-SHA-3, RawSHAKE and SHAKE, these values can be set with the functions
-@table @code
-@item libkeccak_spec_sha3
-@fnindex libkeccak_spec_sha3
-@cpindex SHA-3
-@cpindex Secure Hash Algorithm 3
-Sets the parameters for SHA-3. It has two parameters:
-@itemize @bullet{}
-@item
-Pointer to the @code{libkeccak_spec_t} where the settings shall be stored.
-@item
-The output size, that is the value appended to the name.
-@end itemize
-
-@item libkeccak_spec_rawshake
-@fnindex libkeccak_spec_rawshake
-@cpindex RawSHAKE
-Sets the parameters for RawSHAKE (or SHAKE). It has three parameters:
-@itemize @bullet{}
-@item
-Pointer to the @code{libkeccak_spec_t} where the settings shall be stored.
-@item
-The semicapacity, that is the value appended to the name.
-@item
-The output size.
-@end itemize
-
-@item libkeccak_spec_shake
-@fnindex libkeccak_spec_shake
-@cpindex SHAKE
-Identical to @code{libkeccak_spec_rawshake}. Intended for SHAKE
-rather than RawSHAKE.
-@end table
-
-@fnindex libkeccak_spec_check
-@cpindex Keccak
-For Keccak, these values shall be selected individually by hand.
-Once the values have been selected, they can be checked for errors
-with the function @code{libkeccak_spec_check}. It takes a pointer
-to the specifications as its only parameters and returns zero if
-there are no errors. If however there are errors, one of the values,
-with somewhat self-explanatory names,@footnote{Their meaning is
-documented in the header file @file{<libkeccak/spec.h>}.} will
-be returned:
-@itemize @bullet{}
-@item
-@code{LIBKECCAK_SPEC_ERROR_BITRATE_NONPOSITIVE}
-@item
-@code{LIBKECCAK_SPEC_ERROR_BITRATE_MOD_8}
-@item
-@code{LIBKECCAK_SPEC_ERROR_CAPACITY_NONPOSITIVE}
-@item
-@code{LIBKECCAK_SPEC_ERROR_CAPACITY_MOD_8}
-@item
-@code{LIBKECCAK_SPEC_ERROR_OUTPUT_NONPOSITIVE}
-@item
-@code{LIBKECCAK_SPEC_ERROR_STATE_TOO_LARGE}
-@item
-@code{LIBKECCAK_SPEC_ERROR_STATE_MOD_25}
-@item
-@code{LIBKECCAK_SPEC_ERROR_WORD_NON_2_POTENT}
-@item
-@code{LIBKECCAK_SPEC_ERROR_WORD_MOD_8}
-@end itemize
-
-@tpindex libkeccak_spec_t
-@tpindex struct libkeccak_spec
-@code{libkeccak_spec_t}'s members are:
-@table @code
-@item bitrate
-The bitrate, in bits.
-@item capacity
-The capacity, in bits.
-@item output
-The output size, in bits.
-@end table
-
-@tpindex libkeccak_generalised_spec_t
-@tpindex struct libkeccak_generalised_spec
-It is also possible to select some but not all of the parameters.
-For this, the structure @code{libkeccak_generalised_spec_t}
-(@code{struct libkeccak_generalised_spec}) is used. It extends
-@code{libkeccak_spec_t} with two additional parameters
-@table @code
-@item state_size
-The state size, in bits.
-@item word_size
-The word size, in bits.
-@end table
-
-@fnindex libkeccak_generalised_spec_initialise
-By feeding a pointer to a @code{libkeccak_generalised_spec_t},
-to the function @code{libkeccak_generalised_spec_initialise},
-all its members are set to @code{LIBKECCAK_GENERALISED_SPEC_AUTOMATIC},
-a sentinel value that specifies that the parameter shall be
-set automatically, to its default that depends on the other
-parameters.
-
-Once the members of a @code{libkeccak_generalised_spec_t} has
-been set, it can be converted to a @code{libkeccak_spec_t},
-which is necessary for using the specifications. When doing
-so, automatic values will be given a proper value.
-
-@fnindex libkeccak_degeneralise_spec
-To do this, the function @code{libkeccak_degeneralise_spec}
-is used. It takes two parameters:
-@itemize @bullet{}
-@item
-Input pointer to the @code{libkeccak_generalised_spec_t}.
-@item
-Output pointer to a @code{libkeccak_spec_t}.
-@end itemize
-@noindent
-On success, zero is returned, otherwise one of the values, with
-somewhat self-explanatory names,@footnote{Their meaning is documented
-in the header file @file{<libkeccak/generalised-spec.h>}.} will be
-returned:
-@itemize @bullet{}
-@item
-@code{LIBKECCAK_GENERALISED_SPEC_ERROR_STATE_NONPOSITIVE}
-@item
-@code{LIBKECCAK_GENERALISED_SPEC_ERROR_STATE_TOO_LARGE}
-@item
-@code{LIBKECCAK_GENERALISED_SPEC_ERROR_STATE_MOD_25}
-@item
-@code{LIBKECCAK_GENERALISED_SPEC_ERROR_WORD_NONPOSITIVE}
-@item
-@code{LIBKECCAK_GENERALISED_SPEC_ERROR_WORD_TOO_LARGE}
-@item
-@code{LIBKECCAK_GENERALISED_SPEC_ERROR_STATE_WORD_INCOHERENCY}
-@item
-@code{LIBKECCAK_GENERALISED_SPEC_ERROR_CAPACITY_NONPOSITIVE}
-@item
-@code{LIBKECCAK_GENERALISED_SPEC_ERROR_CAPACITY_MOD_8}
-@item
-@code{LIBKECCAK_GENERALISED_SPEC_ERROR_BITRATE_NONPOSITIVE}
-@item
-@code{LIBKECCAK_GENERALISED_SPEC_ERROR_BITRATE_MOD_8}
-@item
-@code{LIBKECCAK_GENERALISED_SPEC_ERROR_OUTPUT_NONPOSITIVE}
-@end itemize
-
-
-
-@node State of the hashing
-@chapter State of the hashing
-
-@tpindex libkeccak_state_t
-@tpindex struct libkeccak_state
-@cpindex Hashing
-@cpindex State
-Hashing of a message is done by feeding segments of the
-message to functions until all of the message has been
-processed, and than the users may repeat the last phase
-any number of times. Because functions are called multiple
-times, the state of the process need to be stored in
-a state structure. The structure used in libkeccak to
-keep track of the state is called @code{libkeccak_state_t}
-(@code{struct libkeccak_state}).
-
-@fnindex libkeccak_state_initialise
-@cpindex Initialise
-Before you can use the functions for hashing a message,
-you must allocate a state and initialise it.
-To initialise a state, use the function
-@code{libkeccak_state_initialise}. Its first argument
-should be a pointer to the state variable, that is,
-a @code{libkeccak_state_t*}. The second argument should
-be a pointer to the specifications, that is, a
-@code{const libkeccak_spec_t*}, see @ref{Selecting hash function}.
-@code{libkeccak_state_initialise} till return zero
-upon successful completion, and otherwise set
-@code{errno} to describe the error and return @code{-1}.
-
-@fnindex libkeccak_state_destroy
-@fnindex libkeccak_state_fast_destroy
-@fnindex libkeccak_state_wipe
-@fnindex libkeccak_state_wipe_sponge
-@fnindex libkeccak_state_wipe_message
-@cpindex Cleanup
-Once done with a state structure, you should release
-allocated resources that are stored in the structure.
-This can be done either by calling the function
-@code{libkeccak_state_destroy} or by calling the function
-@code{libkeccak_state_fast_destroy}. These two functions
-are almost identical, both takes a pointer to the
-state as its only parameter, and neither return a value.
-However, @code{libkeccak_state_fast_destroy} will only
-release allocations used by the state; @code{libkeccak_state_destroy}
-will also securely release all sensitive information
-in the state, by calling the function @code{libkeccak_state_wipe}:
-the state of the sponge, by calling the function
-@code{libkeccak_state_wipe_sponge}, and the message
-buffer, by calling the function @code{libkeccak_state_wipe_message}.
-@code{libkeccak_state_wipe}, @code{libkeccak_state_wipe_sponge}
-and @code{libkeccak_state_wipe_message} takes a
-pointer to the state as their only parameter, and
-none of them have a return value.
-
-@fnindex libkeccak_state_reset
-@cpindex Reuse
-An alternative to destroying a state, you can reset
-it if you want to reuse it to hash another message
-using the same hashing function specifications.
-This is done by calling @code{libkeccak_state_reset}
-instead of @code{libkeccak_state_fast_destroy}.
-It takes a pointer to the state as its only parameter
-and does not return a value.
-
-@cpindex Initialise
-@cpindex Cleanup
-@cpindex Allocation
-If you want to use dynamic instead of static allocation
-for the state, instead of calling @code{malloc} and
-@code{free} yourself, libkeccak offers functions that
-does this for you:
-@table @code
-@item libkeccak_state_create
-@fnindex libkeccak_state_create
-@fnindex libkeccak_state_initialise
-Identical to @code{libkeccak_state_initialise}, except
-it does have the first parameter, but it has the second
-parameter (the specifications). It returns a pointer
-to the allocate state upon successful completion, and
-returns @code{NULL} on error, in which case, @code{errno}
-is set to describe the error.
-
-@item libkeccak_state_fast_free
-@fnindex libkeccak_state_fast_free
-@fnindex libkeccak_state_fast_destroy
-Identical to @code{libkeccak_state_fast_destroy}, except
-it also frees the allocation of the state.
-
-@item libkeccak_state_free
-@fnindex libkeccak_state_free
-@fnindex libkeccak_state_destroy
-Identical to @code{libkeccak_state_destroy}, except
-it also frees the allocation of the state.
-@end table
-
-@cpindex Duplication
-@cpindex Allocation
-libkeccak also has two functions for copying a state:
-@table @code
-@item libkeccak_state_copy
-@fnindex libkeccak_state_copy
-Takes an output pointer to a state as its first parameter,
-and a pointer to the state to copy as its second parameter.
-The content of the second parameter will be duplicated into
-the first parameter. The state passed in the first parameter
-must not be initialised, lest you will suffer a memory leak.
-The function returns zero upon successful completion, and
-on error, sets @code{errno} to describe the error and returns
-@code{-1}.
-
-@item libkeccak_state_duplicate
-@fnindex libkeccak_state_duplicate
-Identical to @code{libkeccak_state_copy}, except it only
-has one parameter, a pointer to the state to copy, and
-returns a pointer to a state it has allocated and copied
-the state to. On error, @code{errno} is set to describe the
-error and @code{NULL} is returned.
-@end table
-
-@cpindex Marshal
-@cpindex Serialisation
-@cpindex Unmarshal
-@cpindex Deserialisation
-The library also offers functions for marshalling a state,
-which can be useful when implementing programs that can
-reexecuted into updated version of itself.
-@table @code
-@item libkeccak_state_marshal_size
-@fnindex libkeccak_state_marshal_size
-Takes a pointer to a state to marshal as its only parameter,
-and returns the number of bytes required to marshal it.
-
-@item libkeccak_state_marshal
-@fnindex libkeccak_state_marshal
-Takes a pointer to a state to marshal as its first parameter,
-and the buffer, to where the state shall be marshalled, as
-its second parameter. The function will marshal the state
-into the buffer and return the number of bytes written,
-which will be the same as @code{libkeccak_state_marshal_size}
-returns for the state.
-
-@item libkeccak_state_unmarshal
-@fnindex libkeccak_state_unmarshal
-Takes an output pointer for the unmarshalled state as its
-first parameter, and the buffer where the state is marshalled
-as its second parameter. The function will unmarshal the
-state from the buffer and store it into the pointer passed
-to the first parameter. The function will then return the
-number of read bytes, which will be the same as
-@code{libkeccak_state_marshal_size} and @code{libkeccak_state_marshal}
-returned for the state when it was marshalled, as what they
-will return if called again with the unmarshalled function.
-On error, @code{errno} is set to describe the error and zero
-is returned.
-
-@item libkeccak_state_unmarshal_skip
-@fnindex libkeccak_state_unmarshal_skip
-Figures out how many bytes the marshalled state uses,
-so that the buffers pointer can be incremented with
-this value to skip pass the marshalled state.
-@end table
-
-
-
-@node Hashing messages
-@chapter Hashing messages
-
-@fnindex libkeccak_update
-@fnindex libkeccak_digest
-@fnindex libkeccak_fast_update
-@fnindex libkeccak_fast_digest
-@cpindex Hashing
-Once a state has been initialised, a message can be hashed.
-To hash a message the functions @code{libkeccak_update} and
-@code{libkeccak_digest} are used, or its variants that do
-not securely release sensitive information:
-@code{libkeccak_fast_update} and @code{libkeccak_fast_digest},
-these are otherwise identical to @code{libkeccak_update}
-and @code{libkeccak_fast_update}, respectively.
-@table @code
-@item libkeccak_update
-@fnindex libkeccak_update
-@fnindex libkeccak_fast_update
-This function shall be called while you do not know that
-you have reached the end of the message. It has three
-parameters:
-@itemize @bullet{}
-@item
-A pointer to the state. See @ref{State of the hashing}.
-@item
-The beginning of the chunk of the message to process.
-@item
-The number of bytes in the message to process.
-@end itemize
-Note that a part of the message is input, not necessarily
-the entire message. The chunks must be input sequentially.
-The function returns zero upon success completion. On error,
-@code{errno} is set to describe the error and @code{-1} is
-returned. The input chunk should not be empty.
-
-@item libkeccak_digest
-@fnindex libkeccak_digest
-@fnindex libkeccak_fast_digest
-This function shall be called either with the last chunk
-of the message, or when all chunks as been input to
-@code{libkeccak_update} or @code{libkeccak_fast_update}.
-The function's first three parameters are the same as
-for @code{libkeccak_update}, however, the chunk may be
-@code{NULL} and then length zero if all chunks have
-been processed by @code{libkeccak_update} or @code{libkeccak_fast_update}.
-However, it also has three additional parameters:
-@itemize @bullet{}
-@item
-The number of bits at the end of the message that
-are not covered by the third argument. This enables
-messages of non-whole byte length.
-@item
-A NUL-terminated string of ASCII ones and zeroes,
-describing the additional bits to suffix the message;
-or @code{NULL} if none. This is used to select between
-Keccak, SHA-3, RawSHAKE and SHAKE. Use one of the constants:
-@table @asis
-@item @code{LIBKECCAK_SHA3_SUFFIX} or @code{"01"}
-@cpindex SHA-3
-@cpindex Secure Hash Algorithm 3
-For SHA-3.
-@item @code{LIBKECCAK_RAWSHAKE_SUFFIX} or @code{"11"}
-@cpindex RawSHAKE
-For RawSHAKE.
-@item @code{LIBKECCAK_SHAKE_SUFFIX} or @code{"1111"}
-@cpindex SHAKE
-For SHAKE.
-@item @code{NULL} or @code{""}
-@cpindex Keccak
-For Keccak.
-@end table
-@item
-@cpindex Output size
-@cpindex Hash size
-@cpindex Size, hash
-Output buffer for the hash, in binary. Should be
-allocated to fit @code{(state.n + 7) / 8} @w{@code{char}:s},
-where @code{state} is the state variable. Alternatively
-it may be @code{NULL}, in which case the hash is not
-retrieved.
-@end itemize
-The function returns zero upon success completion. On error,
-@code{errno} is set to describe the error and @code{-1} is
-returned. The input chunk should not be empty.
-@end table
-
-@cpindex Key derivation
-@cpindex Pseudorandom number generation
-@cpindex Random number generation
-@cpindex Output, extended
-@cpindex Extended output
-libkeccak also has three functions for repeating the squeeze
-phase. Neither of these function have a return value, and
-their first parameter is a pointer to the state.
-@table @code
-@item libkeccak_simple_squeeze
-@fnindex libkeccak_simple_squeeze
-Perform a number of additional rounds of @w{@sc{Keccak}--@i{f}}.
-The number of rounds is specified in the second parameter.
-@item libkeccak_fast_squeeze
-@fnindex libkeccak_fast_squeeze
-Perform a number of additional rounds of @w{@sc{Keccak}--@i{f}}.
-The number will be exactly enough to get a number of additional
-digests. The number of digests is specified in the second parameter.
-@item libkeccak_squeeze
-@fnindex libkeccak_squeeze
-Squeeze out another digest. The hash will be stored in the
-second parameter, which should be allocated to fit
-@code{(state.n + 7) / 8} @w{@code{char}:s}.
-@end table
-
-
-
-@node Hexadecimal hashes
-@chapter Hexadecimal hashes
-
-@fnindex libkeccak_digest
-@fnindex libkeccak_fast_digest
-@fnindex libkeccak_squeeze
-@cpindex Conversion
-@cpindex Binary hash
-@cpindex Hexadecimal hash
-@cpindex Presentation, hash
-@cpindex Hash, presentation
-The functions that return hashes: @code{libkeccak_digest},
-@code{libkeccak_fast_digest} and @code{libkeccak_squeeze},
-store the hashes in binary format. However, it must often
-preferred to have hashes in hexadecimal, so that they are
-human-readable. This library hash two functions for
-converting from binary to hexadecimal, and one function
-for converting from hexadecimal to binary. Neither of
-these functions have a return value.
-@table @code
-@item libkeccak_behex_lower
-@itemx libkeccak_behex_upper
-@fnindex libkeccak_behex_lower
-@fnindex libkeccak_behex_upper
-Convert from binary to hexadecimal. @code{libkeccak_behex_lower}
-converts to lowercase hexadecimal, and @code{libkeccak_behex_upper}
-converts to uppercase hexadecimal. Their first parameter
-is the output buffer for the hexadecimal representation,
-which will be NUL-terminated, it should be allocated to
-fit @code{2 * n + 1} @w{@code{char}:s}, where @code{n} is
-the length of the input hash. The second parameter is
-the input hash, in binary. The third, and final, parameter
-is the length of the input bash.
-
-@item libkeccak_unhex
-@fnindex libkeccak_unhex
-Convert from hexadecimal to binary. Both uppercase and
-lowercase, as well as mixed case, is supported as input.
-The first parameter is the output buffer for the binary
-representation, it should be allocated to fit
-@code{strlen(hashsum) / 2} @w{@code{char}:s}, where
-@code{hashsum} is the hash in hexadecimal, the input;
-this is the number of bytes that will be stored in
-the output. The second, and final, parameter is the
-hash in hexadecimal, with must be NUL-terminated,
-and have an even length.
-@end table
-
-
-
-@node Hashing files
-@chapter Hashing files
-
-@cpindex Files
-@cpindex Hash files
-libkeccak provides functions for calculating
-hashes of files directly, from a file descriptor.
-
-@fnindex libkeccak_generalised_sum_fd
-The generalised function is named
-@code{libkeccak_generalised_sum_fd}. It has
-five parameters:
-@itemize @bullet{}
-@item
-The file descriptor.
-@item
-A pointer to a state variable. Must not be
-initalised, lest you will suffer a memory leak.
-@item
-The specifications for the hashing functions.
-@item
-The message suffix.
-@item
-The output buffer for the binary hash.
-It must have an allocation size of at least
-@code{(spec->output / 8) * sizeof(char)},
-where @code{spec} is the third argument, or
-be @code{NULL}.
-@end itemize
-@code{libkeccak_generalised_sum_fd} returns
-zero upon successful completion. On error,
-@code{errno} is set to describe the error,
-and @code{-1} is returned.
-
-There are also algorithm specific functions.
-@table @code
-@item libkeccak_keccaksum_fd
-@fnindex libkeccak_keccaksum_fd
-This function is used for Keccak without message
-suffix. It is identical to @code{libkeccak_generalised_sum_fd}
-sans the fourth parameter (the message suffix.)
-
-@item libkeccak_sha3sum_fd
-@fnindex libkeccak_sha3sum_fd
-This function is used for SHA-3. It is similar
-to @code{libkeccak_generalised_sum_fd}, however
-it does not have the fourth parameter, and the
-third parameter is simple the the output size.
-The output buffer must have and allocation size
-of at least @code{(output / 8) * sizeof(char)},
-where @code{output} is the third parameter, or
-be @code{NULL}.
-
-@item libkeccak_rawshakesum_fd
-@fnindex libkeccak_rawshakesum_fd
-This function is used for RawSHAKE, it is
-otherwise identical to @code{libkeccak_sha3sum_fd},
-except it as a parameter for the semicapacity
-before the output size, that is to say, as its
-third parameter.
-
-@item libkeccak_shakesum_fd
-@fnindex libkeccak_shakesum_fd
-This function is used for SHAKE, it is
-otherwise identical to @code{libkeccak_rawshakesum_fd}.
-@end table
-
-
-
-@node Message authentication
-@chapter Message authentication
-
-@cpindex Message authentication code
-@cpindex MAC
-@cpindex HMAC
-@cpindex Keyed-hash message authentication code
-libkeccak supports HMAC. Note that secure message
-authentication codes can be trivially be created
-with Keccak by simple prepending the key to the
-message; although it will not be HMAC. This makes
-Keccak a good hash function alternative for people
-who knows next to nothing about cryptography.
-
-@tpindex libkeccak_hmac_state_t
-@tpindex struct libkeccak_hmac_state
-To keep track of the hashing state, the structure
-@code{libkeccak_hmac_state_t} (@code{struct libkeccak_hmac_state})
-is used. It has a number of methods analogous to
-those for @code{libkeccak_state_t}:
-@table @code
-@item libkeccak_hmac_initialise
-@fnindex libkeccak_hmac_initialise
-Has for parameters: pointer to a @code{libkeccak_hmac_state_t}
-to initialise, hashing specifications (@code{const libkeccak_spec_t*}),
-binary key, and the length of the key.
-
-@item libkeccak_hmac_create
-@fnindex libkeccak_hmac_create
-Similar to @code{libkeccak_hmac_initialise}. It does
-not have a @code{libkeccak_hmac_state_t*} as an output
-parameter, rather it returns one.
-
-@item libkeccak_hmac_reset
-@fnindex libkeccak_hmac_reset
-Resets the sponge and the sets the key, by
-calling @code{libkeccak_hmac_set_key}. It
-has three parameters: pointer to the
-@code{libkeccak_hmac_state_t}, the binary key,
-and the length of the key.
-The key will not be set if the second
-argument is @code{NULL}.
-
-@item libkeccak_hmac_wipe
-@fnindex libkeccak_hmac_wipe
-Perfectly analogous to the @code{libkeccak_state_t} counterpart.
-
-@item libkeccak_hmac_fast_destroy
-@fnindex libkeccak_hmac_fast_destroy
-Perfectly analogous to the @code{libkeccak_state_t} counterpart.
-
-@item libkeccak_hmac_destroy
-@fnindex libkeccak_hmac_destroy
-Perfectly analogous to the @code{libkeccak_state_t} counterpart.
-
-@item libkeccak_hmac_fast_free
-@fnindex libkeccak_hmac_fast_free
-Perfectly analogous to the @code{libkeccak_state_t} counterpart.
-
-@item libkeccak_hmac_free
-@fnindex libkeccak_hmac_free
-Perfectly analogous to the @code{libkeccak_state_t} counterpart.
-
-@item libkeccak_hmac_copy
-@fnindex libkeccak_hmac_copy
-Perfectly analogous to the @code{libkeccak_state_t} counterpart.
-
-@item libkeccak_hmac_duplicate
-@fnindex libkeccak_hmac_duplicate
-Perfectly analogous to the @code{libkeccak_state_t} counterpart.
-
-@item libkeccak_hmac_marshal_size
-@fnindex libkeccak_hmac_marshal_size
-Perfectly analogous to the @code{libkeccak_state_t} counterpart.
-
-@item libkeccak_hmac_marshal
-@fnindex libkeccak_hmac_marshal
-Perfectly analogous to the @code{libkeccak_state_t} counterpart.
-
-@item libkeccak_hmac_unmarshal
-@fnindex libkeccak_hmac_unmarshal
-Perfectly analogous to the @code{libkeccak_state_t} counterpart.
-
-@item libkeccak_hmac_unmarshal_skip
-@fnindex libkeccak_hmac_unmarshal_skip
-Perfectly analogous to the @code{libkeccak_state_t} counterpart.
-
-@item libkeccak_hmac_fast_update
-@fnindex libkeccak_hmac_fast_update
-Perfectly analogous to the @code{libkeccak_state_t} counterpart.
-
-@item libkeccak_hmac_update
-@fnindex libkeccak_hmac_update
-Perfectly analogous to the @code{libkeccak_state_t} counterpart.
-
-@item libkeccak_hmac_fast_digest
-@fnindex libkeccak_hmac_fast_digest
-Perfectly analogous to the @code{libkeccak_state_t} counterpart.
-
-@item libkeccak_hmac_digest
-@fnindex libkeccak_hmac_digest
-Perfectly analogous to the @code{libkeccak_state_t} counterpart.
-@end table
-
-@fnindex libkeccak_hmac_set_key
-It also has the method @code{libkeccak_hmac_set_key} which
-can be used set the key. This function is identical to
-@code{libkeccak_hmac_reset}, except it will not reset the
-sponge, and the second argument must not be @code{NULL}.
-
-
-
-@node Examples
-@chapter Examples
-@cpindex Example
-
-@cartouche
-@cpindex Configure state
-@tpindex libkeccak_spec_t
-@tpindex libkeccak_generalised_spec_t
-@fnindex libkeccak_generalised_spec_initialise
-@fnindex libkeccak_degeneralise_spec
-@fnindex libkeccak_spec_check
-This examples configure a @code{libkeccak_spec_t} to specify settings for Keccak[c = 512].
-@example
-int r;
-libkeccak_spec_t spec;
-libkeccak_generalised_spec_t gspec;
-libkeccak_generalised_spec_initialise(&gspec);
-gspec.capacity = 512;
-if ((r = libkeccak_degeneralise_spec(&gspec, &spec)))
- goto fail_degeneralise_spec;
-if ((r = libkeccak_spec_check(&spec)));
- goto fail_spec_check;
-@end example
-@end cartouche
-
-@cartouche
-@cpindex Calculate hash
-@cpindex Hash, calculate
-@cpindex Configure state
-@cpindex Hexadecimal hash
-@tpindex libkeccak_state_t
-@tpindex libkeccak_spec_t
-@fnindex libkeccak_state_initialise
-@fnindex libkeccak_update
-@fnindex libkeccak_digest
-@fnindex libkeccak_behex_lower
-@fnindex libkeccak_state_destroy
-This example calculates the Keccak[b = 1024, c = 576, n = 256]
-hash of the input from stdin, and prints the hash, in
-hexadecimal form, to stdout.
-@example
-libkeccak_state_t state;
-libkeccak_spec_t spec;
-char binhash[256 / 8];
-char hexhash[256 / 8 * 2 + 1];
-char chunk[4 << 10];
-ssize_t len;
-
-spec.bitrate = 1024;
-spec.capacity = 576;
-spec.output = 256;
-if (libkeccak_state_initialise(&state, &spec) < 0)
- goto fail;
-
-for (;;) @{
- len = read(STDIN_FILENO, chunk, sizeof(chunk));
-
- if ((len < 0) && (errno == EINTR))
- continue;
- if (len < 0)
- goto fail;
- if (len == 0)
- break;
-
- if (libkeccak_update(&state, chunk, (size_t)len) < 0)
- goto fail;
-@}
-if (libkeccak_digest(&state, NULL, 0, 0, "", binhash) < 0)
- goto fail;
-
-libkeccak_behex_lower(hexhash, binhash, sizeof(binhash));
-printf("%s\n", hexhash);
-libkeccak_state_destroy(&state);
-@end example
-@end cartouche
-
-@cartouche
-@cpindex Configure state, RawSHAKE
-@cpindex RawSHAKE, configure state
-@tpindex libkeccak_spec_t
-@fnindex libkeccak_spec_rawshake
-This example configure a @code{libkeccak_spec_t} to specify
-the Keccak parameters used for RawSHAKE256(, 512).
-@example
-libkeccak_spec_t spec;
-libkeccak_spec_rawshake(&spec, 256, 512);
-@end example
-@end cartouche
-
-@cartouche
-@cpindex Configure state, SHA-3
-@cpindex SHA-3, configure state
-@tpindex libkeccak_spec_t
-@fnindex libkeccak_spec_sha3
-This example configure a @code{libkeccak_spec_t} to specify
-the Keccak parameters used for SHA3-256.
-@example
-libkeccak_spec_t spec;
-libkeccak_spec_sha3(&spec, 256);
-@end example
-@end cartouche
-
-@cartouche
-@cpindex Configure state, SHAKE
-@cpindex SHAKE, configure state
-@tpindex libkeccak_spec_t
-@fnindex libkeccak_spec_shake
-This example configure a @code{libkeccak_spec_t} to specify
-the Keccak parameters used for SHAKE256(, 512).
-@example
-libkeccak_spec_t spec;
-libkeccak_spec_shake(&spec, 256, 512);
-@end example
-@end cartouche
-
-@cartouche
-@cpindex Calculate hash, SHA-3, from file
-@cpindex Hash, calculate, SHA-3, from file
-@cpindex SHA-3, calculate hash, from file
-@cpindex File, calculate hash, SHA-3
-@fnindex libkeccak_sha3sum_fd
-This example calculates the SHA3-256 hash of the input from
-stdin, and prints the hash, in hexadecimal form, to stdout.
-@example
-libkeccak_state_t state;
-if (libkeccak_sha3sum_fd(STDIN_FILENO, &state, 256, binhash) < 0)
- goto fail;
-libkeccak_behex_lower(hexhash, binhash, sizeof(binhash));
-printf("%s\n", hexhash);
-libkeccak_state_destroy(&state);
-@end example
-@end cartouche
-
-@cartouche
-@cpindex Calculate hash, RawSHAKE, from file
-@cpindex Hash, calculate, RawSHAKE, from file
-@cpindex RawSHAKE, calculate hash, from file
-@cpindex File, calculate hash, RawSHAKE
-@fnindex libkeccak_rawshakesum_fd
-This example calculates the RawSHAKE256(, 512) hash of the input
-from stdin, and prints the hash, in hexadecimal form, to stdout.
-@example
-libkeccak_state_t state;
-if (libkeccak_rawshakesum_fd(STDIN_FILENO, &state, 256, 512, binhash) < 0)
- goto fail;
-libkeccak_behex_lower(hexhash, binhash, sizeof(binhash));
-printf("%s\n", hexhash);
-libkeccak_state_destroy(&state);
-@end example
-@end cartouche
-
-@cartouche
-@cpindex Calculate hash, SHAKE, from file
-@cpindex Hash, calculate, SHAKE, from file
-@cpindex SHAKE, calculate hash, from file
-@cpindex File, calculate hash, SHAKE
-@fnindex libkeccak_shakesum_fd
-This example calculates the SHAKE256(, 512) hash of the input
-from stdin, and prints the hash, in hexadecimal form, to stdout.
-@example
-libkeccak_state_t state;
-if (libkeccak_shakesum_fd(STDIN_FILENO, &state, 256, 512, binhash) < 0)
- goto fail;
-libkeccak_behex_lower(hexhash, binhash, sizeof(binhash));
-printf("%s\n", hexhash);
-libkeccak_state_destroy(&state);
-@end example
-@end cartouche
-
-@cartouche
-@cpindex Calculate hash, Keccak, from file
-@cpindex Hash, calculate, Keccak, from file
-@cpindex Keccak, calculate hash, from file
-@cpindex File, calculate hash, Keccak
-@tpindex libkeccak_spec_t
-@fnindex libkeccak_keccaksum_fd
-@fnindex libkeccak_behex_lower
-This example calculates the Keccak[b = 1024, c = 576, n = 256]
-hash of the input from stdin, and prints the hash, in hexadecimal
-form, to stdout.
-@example
-libkeccak_state_t state;
-libkeccak_spec_t spec;
-char binhash[256 / 8];
-char hexhash[256 / 8 * 2 + 1];
-
-spec.bitrate = 1024;
-spec.capacity = 576;
-spec.output = 256;
-
-if (libkeccak_keccaksum_fd(STDIN_FILENO, &state, &spec, binhash) < 0)
- goto fail;
-libkeccak_behex_lower(hexhash, binhash, sizeof(binhash));
-printf("%s\n", hexhash);
-libkeccak_state_destroy(&state);
-@end example
-@end cartouche
-
-@cartouche
-@cpindex Calculate hash, from file
-@cpindex Hash, calculate, from file
-@cpindex Calculate hash, from file
-@cpindex File, calculate hash
-@tpindex libkeccak_spec_t
-@fnindex libkeccak_generalised_sum_fd
-@fnindex libkeccak_behex_lower
-This example calculates the Keccak[b = 1024, c = 576, n = 256]
-hash of the input from stdin, and prints the hash, in hexadecimal
-form, to stdout.
-@example
-libkeccak_state_t state;
-libkeccak_spec_t spec;
-char binhash[256 / 8];
-char hexhash[256 / 8 * 2 + 1];
-
-spec.bitrate = 1024;
-spec.capacity = 576;
-spec.output = 256;
-
-if (libkeccak_generalised_sum_fd(STDIN_FILENO, &state,
- &spec, NULL, binhash) < 0)
- goto fail;
-libkeccak_behex_lower(hexhash, binhash, sizeof(binhash));
-printf("%s\n", hexhash);
-libkeccak_state_destroy(&state);
-@end example
-@end cartouche
-
-
-
-@node Concept index
-@unnumbered Concept index
-@printindex cp
-
-@node Data type index
-@unnumbered Data type index
-@printindex tp
-
-@node Function index
-@unnumbered Function index
-@printindex fn
-
-
-@bye
diff --git a/doc/info/macros.texinfo b/doc/info/macros.texinfo
deleted file mode 100644
index 4ec5d68..0000000
--- a/doc/info/macros.texinfo
+++ /dev/null
@@ -1,10 +0,0 @@
-@iftex
-@macro e{a}
-(@email{\a\})
-@end macro
-@end iftex
-@ifnottex
-@macro e{a}
-@email{\a\}
-@end macro
-@end ifnottex
diff --git a/src/libkeccak.h b/libkeccak.h
index 7c71801..7c71801 100644
--- a/src/libkeccak.h
+++ b/libkeccak.h
diff --git a/libkeccak.texinfo b/libkeccak.texinfo
new file mode 100644
index 0000000..7640da9
--- /dev/null
+++ b/libkeccak.texinfo
@@ -0,0 +1,403 @@
+\input texinfo @c -*-texinfo-*-
+@c %**start of header
+@documentencoding UTF-8
+@iftex
+@macro e{a}
+(@email{\a\})
+@end macro
+@end iftex
+@ifnottex
+@macro e{a}
+@email{\a\}
+@end macro
+@end ifnottex
+@copying
+@c --------------------------------------------------------------------------------
+Copyright @copyright{} 2015, 2017 @w{Mattias Andrée @e{maandree@@kth.se}}
+
+@quotation
+Permission to use, copy, modify, and/or distribute this document for any purpose
+with or without fee is hereby granted, provided that the above copyright notice
+and this permission notice appear in all copies.
+@end quotation
+@c --------------------------------------------------------------------------------
+@end copying
+
+
+@setfilename libkeccak.info
+@settitle libkeccak -- Library for the Keccak-family hash functions
+@documentlanguage en_GB
+@finalout
+@frenchspacing on
+@afourpaper
+
+@c @paragraphindent asis
+@c @firstparagraphindent none
+@c @exampleindent asis
+
+@dircategory Libraries
+@direntry
+* libkeccak: (libkeccak). Library for the Keccak-family hash functions.
+@end direntry
+
+@documentdescription
+Developer reference manual for libkeccak, a library
+for hashing with Keccak, SHA-3 RawSHAKE and SHAKE,
+with support for bit-oriented data.
+@end documentdescription
+@c %**end of header
+
+
+
+@ifnottex
+@node Top
+@top libkeccak -- Library for the Keccak-family hash functions
+@insertcopying
+@end ifnottex
+
+@titlepage
+@title libkeccak
+@subtitle Library for the Keccak-family hash functions
+
+@author by Mattias Andrée (maandree)
+
+@page
+@center `Kecak! Kecak! Kecak! Kecak! Kecak! Kecak! Kecak! Kecak! …'
+@vskip 0pt plus 1filll
+@insertcopying
+@end titlepage
+
+@contents
+
+
+
+@menu
+* Overview:: Brief overview of libkeccak.
+* Linking:: How to use libkeccak in your software.
+* Selecting hash function:: Selecting and tuning the function.
+* State of the hashing:: The structure used to keep track of the hashing process.
+* Hashing messages:: Functions used to hash a message.
+* Hexadecimal hashes:: Converting between binary and hexadecimal.
+* Hashing files:: Functions used to hash entire files.
+* Message authentication:: Functions used for message authentication codes.
+* Examples:: Examples of how to use libkeccak.
+
+* Concept index:: Index of concepts.
+* Data type index:: Index of data types.
+* Function index:: Index of functions.
+@end menu
+
+
+
+@node Overview
+@chapter Overview
+
+@cpindex Orientation
+libkeccak is a free software bit-oriented implementation
+of the cryptographic hash function Keccak and its subsets
+SHA-3 (Secure Hash Algorithm@tie{}3), RawSHAKE and SHAKE.
+
+Being bit-oriented means that it supports messages of length
+consisting of a non-whole number of bytes.
+
+@cpindex Uses
+Keccak is a generic and tunable cryptographic hash function
+that can be used for all customary tasks that required a
+cryptographic hash function:
+@itemize @bullet{}
+@item
+Password verification@footnote{Using additional squeezes, but not using iterated hashing.}
+@item
+Proof-of-work
+@item
+File and data identification
+@item
+Data integrity
+@item
+Pseudorandom number generation@footnote{Although not too random, since entropi is not utilised.}
+@item
+Key derivation
+@end itemize
+
+libkeccak support secure erasure of sensitive data,
+marshalling of hashing state, and indefinite output length.
+It also has builting functions for hashing files and
+wrapping the hash functions with HMAC@footnote{Although
+doing so is unnecessary because the key can securely be
+prepended to the message when using Keccak to produce
+a message authentication code.}. This library implements
+the Keccak algorithm using a lanewise implementation.
+
+@cpindex Limitations
+This implementation is limited to state sizes up to,
+and including, 1600 bits.
+
+
+
+@node Linking
+@chapter Linking
+
+@cpindex Compiling
+libkeccak's API is C standard library independent. This means
+that libkeccak does not need to be compiled with the same
+C standard library as software using it. However, the header
+files contain @code{__attributes__}:s for GCC, therefore it
+can be beneficial to use GCC, however any C99 compiler will work.
+
+@cpindex @command{pkg-config}
+@cpindex Linking
+Because of libkeccak's simplicity it does not have a pkg-config
+file. Instead, you only need to specify the flag @code{-lkeccak}
+when linking your binaries. No flags are required during compilation
+(of object files.)
+
+To make libkeccak's API available, include the header file
+@file{<libkeccak.h>} in your source files.
+
+
+
+@node Selecting hash function
+@chapter Selecting hash function
+
+@cpindex Parameters
+@cpindex Tuning
+Keccak-based hash functions have three parameters:
+@itemize @bullet{}
+@item
+the bitrate,
+@item
+the capacity, and
+@item
+the output size.
+@end itemize
+@noindent
+Selecting these is the first step when using the library.
+
+@tpindex libkeccak_spec_t
+@tpindex struct libkeccak_spec
+The structure @code{libkeccak_spec_t} (@code{struct libkeccak_spec}),
+is to specify these parameters. For the less tunable functions
+SHA-3, RawSHAKE and SHAKE, these values can be set with the functions
+@table @code
+@item libkeccak_spec_sha3
+@fnindex libkeccak_spec_sha3
+@cpindex SHA-3
+@cpindex Secure Hash Algorithm 3
+Sets the parameters for SHA-3. It has two parameters:
+@itemize @bullet{}
+@item
+Pointer to the @code{libkeccak_spec_t} where the settings shall be stored.
+@item
+The output size, that is the value appended to the name.
+@end itemize
+
+@item libkeccak_spec_rawshake
+@fnindex libkeccak_spec_rawshake
+@cpindex RawSHAKE
+Sets the parameters for RawSHAKE (or SHAKE). It has three parameters:
+@itemize @bullet{}
+@item
+Pointer to the @code{libkeccak_spec_t} where the settings shall be stored.
+@item
+The semicapacity, that is the value appended to the name.
+@item
+The output size.
+@end itemize
+
+@item libkeccak_spec_shake
+@fnindex libkeccak_spec_shake
+@cpindex SHAKE
+Identical to @code{libkeccak_spec_rawshake}. Intended for SHAKE
+rather than RawSHAKE.
+@end table
+
+@fnindex libkeccak_spec_check
+@cpindex Keccak
+For Keccak, these values shall be selected individually by hand.
+Once the values have been selected, they can be checked for errors
+with the function @code{libkeccak_spec_check}. It takes a pointer
+to the specifications as its only parameters and returns zero if
+there are no errors. If however there are errors, one of the values,
+with somewhat self-explanatory names,@footnote{Their meaning is
+documented in the header file @file{<libkeccak/spec.h>}.} will
+be returned:
+@itemize @bullet{}
+@item
+@code{LIBKECCAK_SPEC_ERROR_BITRATE_NONPOSITIVE}
+@item
+@code{LIBKECCAK_SPEC_ERROR_BITRATE_MOD_8}
+@item
+@code{LIBKECCAK_SPEC_ERROR_CAPACITY_NONPOSITIVE}
+@item
+@code{LIBKECCAK_SPEC_ERROR_CAPACITY_MOD_8}
+@item
+@code{LIBKECCAK_SPEC_ERROR_OUTPUT_NONPOSITIVE}
+@item
+@code{LIBKECCAK_SPEC_ERROR_STATE_TOO_LARGE}
+@item
+@code{LIBKECCAK_SPEC_ERROR_STATE_MOD_25}
+@item
+@code{LIBKECCAK_SPEC_ERROR_WORD_NON_2_POTENT}
+@item
+@code{LIBKECCAK_SPEC_ERROR_WORD_MOD_8}
+@end itemize
+
+@tpindex libkeccak_spec_t
+@tpindex struct libkeccak_spec
+@code{libkeccak_spec_t}'s members are:
+@table @code
+@item bitrate
+The bitrate, in bits.
+@item capacity
+The capacity, in bits.
+@item output
+The output size, in bits.
+@end table
+
+@tpindex libkeccak_generalised_spec_t
+@tpindex struct libkeccak_generalised_spec
+It is also possible to select some but not all of the parameters.
+For this, the structure @code{libkeccak_generalised_spec_t}
+(@code{struct libkeccak_generalised_spec}) is used. It extends
+@code{libkeccak_spec_t} with two additional parameters
+@table @code
+@item state_size
+The state size, in bits.
+@item word_size
+The word size, in bits.
+@end table
+
+@fnindex libkeccak_generalised_spec_initialise
+By feeding a pointer to a @code{libkeccak_generalised_spec_t},
+to the function @code{libkeccak_generalised_spec_initialise},
+all its members are set to @code{LIBKECCAK_GENERALISED_SPEC_AUTOMATIC},
+a sentinel value that specifies that the parameter shall be
+set automatically, to its default that depends on the other
+parameters.
+
+Once the members of a @code{libkeccak_generalised_spec_t} has
+been set, it can be converted to a @code{libkeccak_spec_t},
+which is necessary for using the specifications. When doing
+so, automatic values will be given a proper value.
+
+@fnindex libkeccak_degeneralise_spec
+To do this, the function @code{libkeccak_degeneralise_spec}
+is used. It takes two parameters:
+@itemize @bullet{}
+@item
+Input pointer to the @code{libkeccak_generalised_spec_t}.
+@item
+Output pointer to a @code{libkeccak_spec_t}.
+@end itemize
+@noindent
+On success, zero is returned, otherwise one of the values, with
+somewhat self-explanatory names,@footnote{Their meaning is documented
+in the header file @file{<libkeccak/generalised-spec.h>}.} will be
+returned:
+@itemize @bullet{}
+@item
+@code{LIBKECCAK_GENERALISED_SPEC_ERROR_STATE_NONPOSITIVE}
+@item
+@code{LIBKECCAK_GENERALISED_SPEC_ERROR_STATE_TOO_LARGE}
+@item
+@code{LIBKECCAK_GENERALISED_SPEC_ERROR_STATE_MOD_25}
+@item
+@code{LIBKECCAK_GENERALISED_SPEC_ERROR_WORD_NONPOSITIVE}
+@item
+@code{LIBKECCAK_GENERALISED_SPEC_ERROR_WORD_TOO_LARGE}
+@item
+@code{LIBKECCAK_GENERALISED_SPEC_ERROR_STATE_WORD_INCOHERENCY}
+@item
+@code{LIBKECCAK_GENERALISED_SPEC_ERROR_CAPACITY_NONPOSITIVE}
+@item
+@code{LIBKECCAK_GENERALISED_SPEC_ERROR_CAPACITY_MOD_8}
+@item
+@code{LIBKECCAK_GENERALISED_SPEC_ERROR_BITRATE_NONPOSITIVE}
+@item
+@code{LIBKECCAK_GENERALISED_SPEC_ERROR_BITRATE_MOD_8}
+@item
+@code{LIBKECCAK_GENERALISED_SPEC_ERROR_OUTPUT_NONPOSITIVE}
+@end itemize
+
+
+
+@node State of the hashing
+@chapter State of the hashing
+
+@tpindex libkeccak_state_t
+@tpindex struct libkeccak_state
+@cpindex Hashing
+@cpindex State
+Hashing of a message is done by feeding segments of the
+message to functions until all of the message has been
+processed, and than the users may repeat the last phase
+any number of times. Because functions are called multiple
+times, the state of the process need to be stored in
+a state structure. The structure used in libkeccak to
+keep track of the state is called @code{libkeccak_state_t}
+(@code{struct libkeccak_state}).
+
+@fnindex libkeccak_state_initialise
+@cpindex Initialise
+Before you can use the functions for hashing a message,
+you must allocate a state and initialise it.
+To initialise a state, use the function
+@code{libkeccak_state_initialise}. Its first argument
+should be a pointer to the state variable, that is,
+a @code{libkeccak_state_t*}. The second argument should
+be a pointer to the specifications, that is, a
+@code{const libkeccak_spec_t*}, see @ref{Selecting hash function}.
+@code{libkeccak_state_initialise} till return zero
+upon successful completion, and otherwise set
+@code{errno} to describe the error and return @code{-1}.
+
+@fnindex libkeccak_state_destroy
+@fnindex libkeccak_state_fast_destroy
+@fnindex libkeccak_state_wipe
+@fnindex libkeccak_state_wipe_sponge
+@fnindex libkeccak_state_wipe_message
+@cpindex Cleanup
+Once done with a state structure, you should release
+allocated resources that are stored in the structure.
+This can be done either by calling the function
+@code{libkeccak_state_destroy} or by calling the function
+@code{libkeccak_state_fast_destroy}. These two functions
+are almost identical, both takes a pointer to the
+state as its only parameter, and neither return a value.
+However, @code{libkeccak_state_fast_destroy} will only
+release allocations used by the state; @code{libkeccak_state_destroy}
+will also securely release all sensitive information
+in the state, by calling the function @code{libkeccak_state_wipe}:
+the state of the sponge, by calling the function
+@code{libkeccak_state_wipe_sponge}, and the message
+buffer, by calling the function @code{libkeccak_state_wipe_message}.
+@code{libkeccak_state_wipe}, @code{libkeccak_state_wipe_sponge}
+and @code{libkeccak_state_wipe_message} takes a
+pointer to the state as their only parameter, and
+none of them have a return value.
+
+@fnindex libkeccak_state_reset
+@cpindex Reuse
+An alternative to destroying a state, you can reset
+it if you want to reuse it to hash another message
+using the same hashing function specifications.
+This is done by calling @code{libkeccak_state_reset}
+instead of @code{libkeccak_state_fast_destroy}.
+It takes a pointer to the state as its only parameter
+and does not return a value.
+
+@cpindex Initialise
+@cpindex Cleanup
+@cpindex Allocation
+If you want to use dynamic instead of static allocation
+for the state, instead of calling @code{malloc} and
+@code{free} yourself, libkeccak offers functions that
+does this for you:
+@table @code
+@item libkeccak_state_create
+@fnindex libkeccak_state_create
+@fnindex libkeccak_state_initialise
+Identical to @code{libkeccak_state_initialise}, except
+it does have the first parameter, but it has the second
+parameter (the specifications). It returns a pointer
+to the allocate state upon successful completion, and
diff --git a/src/libkeccak/digest.c b/libkeccak/digest.c
index 5f7a32c..26a2587 100644
--- a/src/libkeccak/digest.c
+++ b/libkeccak/digest.c
@@ -79,7 +79,8 @@ static const uint_fast64_t RC[] = {
* @param state The hashing state
* @param rc The round contant for this round
*/
-static __attribute__((nonnull, nothrow, hot)) void
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull, nothrow, hot)))
+static void
libkeccak_f_round(register libkeccak_state_t *restrict state, register int_fast64_t rc)
{
int_fast64_t *restrict A = state->S;
@@ -126,7 +127,8 @@ libkeccak_f_round(register libkeccak_state_t *restrict state, register int_fast6
* @param state The hashing state
* @param rc The round contant for this round
*/
-static __attribute__((nonnull, nothrow, hot)) void
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull, nothrow, hot)))
+static void
libkeccak_f_round64(register libkeccak_state_t *restrict state, register int_fast64_t rc)
{
int_fast64_t *restrict A = state->S;
@@ -170,7 +172,8 @@ libkeccak_f_round64(register libkeccak_state_t *restrict state, register int_fas
*
* @param state The hashing state
*/
-static inline __attribute__((nonnull, nothrow, gnu_inline)) void
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull, nothrow, gnu_inline)))
+static inline void
libkeccak_f(register libkeccak_state_t *restrict state)
{
register long i = 0;
@@ -196,7 +199,8 @@ libkeccak_f(register libkeccak_state_t *restrict state)
* @param off The offset in the message
* @return The lane
*/
-static inline __attribute__((nonnull, nothrow, pure, warn_unused_result, gnu_inline)) int_fast64_t
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull, nothrow, pure, warn_unused_result, gnu_inline)))
+static inline int_fast64_t
libkeccak_to_lane(register const char *restrict message, register size_t msglen,
register long rr, register long ww, size_t off)
{
@@ -220,7 +224,8 @@ libkeccak_to_lane(register const char *restrict message, register size_t msglen,
* @param off The offset in the message
* @return The lane
*/
-static inline __attribute__((nonnull, nothrow, pure, hot, warn_unused_result, gnu_inline)) int_fast64_t
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull, nothrow, pure, hot, warn_unused_result, gnu_inline)))
+static inline int_fast64_t
libkeccak_to_lane64(register const char* restrict message, register size_t msglen,
register long rr, size_t off)
{
@@ -242,7 +247,8 @@ libkeccak_to_lane64(register const char* restrict message, register size_t msgle
* `state->M` should have `state->r / 8` bytes left over at the end
* @param bits The number of bits in the end of the message that does not make a whole byte
*/
-static inline __attribute__((nonnull, nothrow, gnu_inline)) void
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull, nothrow, gnu_inline)))
+static inline void
libkeccak_pad10star1(register libkeccak_state_t *restrict state, register size_t bits)
{
register size_t r = (size_t)(state->r);
@@ -272,7 +278,8 @@ libkeccak_pad10star1(register libkeccak_state_t *restrict state, register size_t
* @param state The hashing state
* @param len The number of bytes from `state->M` to absorb
*/
-static __attribute__((nonnull, nothrow)) void
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull, nothrow)))
+static void
libkeccak_absorption_phase(register libkeccak_state_t *restrict state, register size_t len)
{
register long rr = state->r >> 3;
@@ -310,7 +317,8 @@ libkeccak_absorption_phase(register libkeccak_state_t *restrict state, register
* @param ww The word size in bytes
* @param hashsum Output parameter for the hashsum
*/
-static __attribute__((nonnull, nothrow, hot)) void
+LIBKECCAK_GCC_ONLY(__attribute__((nonnull, nothrow, hot)))
+static void
libkeccak_squeezing_phase(register libkeccak_state_t *restrict state, long rr,
long nn, long ww, register char *restrict hashsum)
{
diff --git a/src/libkeccak/digest.h b/libkeccak/digest.h
index 832f0c0..832f0c0 100644
--- a/src/libkeccak/digest.h
+++ b/libkeccak/digest.h
diff --git a/src/libkeccak/files.c b/libkeccak/files.c
index 22d12f3..22d12f3 100644
--- a/src/libkeccak/files.c
+++ b/libkeccak/files.c
diff --git a/src/libkeccak/files.h b/libkeccak/files.h
index 92038fb..92038fb 100644
--- a/src/libkeccak/files.h
+++ b/libkeccak/files.h
diff --git a/src/libkeccak/generalised-spec.c b/libkeccak/generalised-spec.c
index 9dfa918..9dfa918 100644
--- a/src/libkeccak/generalised-spec.c
+++ b/libkeccak/generalised-spec.c
diff --git a/src/libkeccak/generalised-spec.h b/libkeccak/generalised-spec.h
index 2725961..2725961 100644
--- a/src/libkeccak/generalised-spec.h
+++ b/libkeccak/generalised-spec.h
diff --git a/src/libkeccak/hex.c b/libkeccak/hex.c
index 7531223..7531223 100644
--- a/src/libkeccak/hex.c
+++ b/libkeccak/hex.c
diff --git a/src/libkeccak/hex.h b/libkeccak/hex.h
index 25375d5..25375d5 100644
--- a/src/libkeccak/hex.h
+++ b/libkeccak/hex.h
diff --git a/src/libkeccak/internal.h b/libkeccak/internal.h
index 466abf9..466abf9 100644
--- a/src/libkeccak/internal.h
+++ b/libkeccak/internal.h
diff --git a/src/libkeccak/mac/hmac.c b/libkeccak/mac/hmac.c
index ee3bc6a..ee3bc6a 100644
--- a/src/libkeccak/mac/hmac.c
+++ b/libkeccak/mac/hmac.c
diff --git a/src/libkeccak/mac/hmac.h b/libkeccak/mac/hmac.h
index 2681e61..2681e61 100644
--- a/src/libkeccak/mac/hmac.h
+++ b/libkeccak/mac/hmac.h
diff --git a/src/libkeccak/spec.h b/libkeccak/spec.h
index 8d73c52..8d73c52 100644
--- a/src/libkeccak/spec.h
+++ b/libkeccak/spec.h
diff --git a/src/libkeccak/state.c b/libkeccak/state.c
index c6360b7..c6360b7 100644
--- a/src/libkeccak/state.c
+++ b/libkeccak/state.c
diff --git a/src/libkeccak/state.h b/libkeccak/state.h
index 1c4b24e..1c4b24e 100644
--- a/src/libkeccak/state.h
+++ b/libkeccak/state.h
diff --git a/doc/man/libkeccak.7 b/man/libkeccak.7
index 0a6ef04..0a6ef04 100644
--- a/doc/man/libkeccak.7
+++ b/man/libkeccak.7
diff --git a/doc/man/libkeccak_behex_lower.3 b/man/libkeccak_behex_lower.3
index 85bc843..85bc843 100644
--- a/doc/man/libkeccak_behex_lower.3
+++ b/man/libkeccak_behex_lower.3
diff --git a/doc/man/libkeccak_behex_upper.3 b/man/libkeccak_behex_upper.3
index 7925efc..7925efc 100644
--- a/doc/man/libkeccak_behex_upper.3
+++ b/man/libkeccak_behex_upper.3
diff --git a/doc/man/libkeccak_degeneralise_spec.3 b/man/libkeccak_degeneralise_spec.3
index 38a1b73..38a1b73 100644
--- a/doc/man/libkeccak_degeneralise_spec.3
+++ b/man/libkeccak_degeneralise_spec.3
diff --git a/doc/man/libkeccak_digest.3 b/man/libkeccak_digest.3
index 33b0479..33b0479 100644
--- a/doc/man/libkeccak_digest.3
+++ b/man/libkeccak_digest.3
diff --git a/doc/man/libkeccak_fast_digest.3 b/man/libkeccak_fast_digest.3
index d5c55a5..d5c55a5 100644
--- a/doc/man/libkeccak_fast_digest.3
+++ b/man/libkeccak_fast_digest.3
diff --git a/doc/man/libkeccak_fast_squeeze.3 b/man/libkeccak_fast_squeeze.3
index d782a95..d782a95 100644
--- a/doc/man/libkeccak_fast_squeeze.3
+++ b/man/libkeccak_fast_squeeze.3
diff --git a/doc/man/libkeccak_fast_update.3 b/man/libkeccak_fast_update.3
index c619e7d..c619e7d 100644
--- a/doc/man/libkeccak_fast_update.3
+++ b/man/libkeccak_fast_update.3
diff --git a/doc/man/libkeccak_generalised_spec_initialise.3 b/man/libkeccak_generalised_spec_initialise.3
index 42bd62f..42bd62f 100644
--- a/doc/man/libkeccak_generalised_spec_initialise.3
+++ b/man/libkeccak_generalised_spec_initialise.3
diff --git a/doc/man/libkeccak_generalised_sum_fd.3 b/man/libkeccak_generalised_sum_fd.3
index 98e6329..98e6329 100644
--- a/doc/man/libkeccak_generalised_sum_fd.3
+++ b/man/libkeccak_generalised_sum_fd.3
diff --git a/doc/man/libkeccak_hmac_copy.3 b/man/libkeccak_hmac_copy.3
index f3939f5..f3939f5 100644
--- a/doc/man/libkeccak_hmac_copy.3
+++ b/man/libkeccak_hmac_copy.3
diff --git a/doc/man/libkeccak_hmac_create.3 b/man/libkeccak_hmac_create.3
index fcb99cb..fcb99cb 100644
--- a/doc/man/libkeccak_hmac_create.3
+++ b/man/libkeccak_hmac_create.3
diff --git a/doc/man/libkeccak_hmac_destroy.3 b/man/libkeccak_hmac_destroy.3
index 2f3bbf8..2f3bbf8 100644
--- a/doc/man/libkeccak_hmac_destroy.3
+++ b/man/libkeccak_hmac_destroy.3
diff --git a/doc/man/libkeccak_hmac_digest.3 b/man/libkeccak_hmac_digest.3
index 66d35d4..66d35d4 100644
--- a/doc/man/libkeccak_hmac_digest.3
+++ b/man/libkeccak_hmac_digest.3
diff --git a/doc/man/libkeccak_hmac_duplicate.3 b/man/libkeccak_hmac_duplicate.3
index 70c994c..70c994c 100644
--- a/doc/man/libkeccak_hmac_duplicate.3
+++ b/man/libkeccak_hmac_duplicate.3
diff --git a/doc/man/libkeccak_hmac_fast_destroy.3 b/man/libkeccak_hmac_fast_destroy.3
index d2af66e..d2af66e 100644
--- a/doc/man/libkeccak_hmac_fast_destroy.3
+++ b/man/libkeccak_hmac_fast_destroy.3
diff --git a/doc/man/libkeccak_hmac_fast_digest.3 b/man/libkeccak_hmac_fast_digest.3
index 008477c..008477c 100644
--- a/doc/man/libkeccak_hmac_fast_digest.3
+++ b/man/libkeccak_hmac_fast_digest.3
diff --git a/doc/man/libkeccak_hmac_fast_free.3 b/man/libkeccak_hmac_fast_free.3
index b4817ce..b4817ce 100644
--- a/doc/man/libkeccak_hmac_fast_free.3
+++ b/man/libkeccak_hmac_fast_free.3
diff --git a/doc/man/libkeccak_hmac_fast_update.3 b/man/libkeccak_hmac_fast_update.3
index 43077d3..43077d3 100644
--- a/doc/man/libkeccak_hmac_fast_update.3
+++ b/man/libkeccak_hmac_fast_update.3
diff --git a/doc/man/libkeccak_hmac_free.3 b/man/libkeccak_hmac_free.3
index d1f9c84..d1f9c84 100644
--- a/doc/man/libkeccak_hmac_free.3
+++ b/man/libkeccak_hmac_free.3
diff --git a/doc/man/libkeccak_hmac_initialise.3 b/man/libkeccak_hmac_initialise.3
index de514e9..de514e9 100644
--- a/doc/man/libkeccak_hmac_initialise.3
+++ b/man/libkeccak_hmac_initialise.3
diff --git a/doc/man/libkeccak_hmac_marshal.3 b/man/libkeccak_hmac_marshal.3
index b7270f6..b7270f6 100644
--- a/doc/man/libkeccak_hmac_marshal.3
+++ b/man/libkeccak_hmac_marshal.3
diff --git a/doc/man/libkeccak_hmac_marshal_size.3 b/man/libkeccak_hmac_marshal_size.3
index 5195b81..5195b81 100644
--- a/doc/man/libkeccak_hmac_marshal_size.3
+++ b/man/libkeccak_hmac_marshal_size.3
diff --git a/doc/man/libkeccak_hmac_reset.3 b/man/libkeccak_hmac_reset.3
index d5634d9..d5634d9 100644
--- a/doc/man/libkeccak_hmac_reset.3
+++ b/man/libkeccak_hmac_reset.3
diff --git a/doc/man/libkeccak_hmac_set_key.3 b/man/libkeccak_hmac_set_key.3
index 2f4682d..2f4682d 100644
--- a/doc/man/libkeccak_hmac_set_key.3
+++ b/man/libkeccak_hmac_set_key.3
diff --git a/doc/man/libkeccak_hmac_unmarshal.3 b/man/libkeccak_hmac_unmarshal.3
index 64e8f24..64e8f24 100644
--- a/doc/man/libkeccak_hmac_unmarshal.3
+++ b/man/libkeccak_hmac_unmarshal.3
diff --git a/doc/man/libkeccak_hmac_unmarshal_skip.3 b/man/libkeccak_hmac_unmarshal_skip.3
index 30e7ccf..30e7ccf 100644
--- a/doc/man/libkeccak_hmac_unmarshal_skip.3
+++ b/man/libkeccak_hmac_unmarshal_skip.3
diff --git a/doc/man/libkeccak_hmac_update.3 b/man/libkeccak_hmac_update.3
index daaf3fb..daaf3fb 100644
--- a/doc/man/libkeccak_hmac_update.3
+++ b/man/libkeccak_hmac_update.3
diff --git a/doc/man/libkeccak_hmac_wipe.3 b/man/libkeccak_hmac_wipe.3
index bad351b..bad351b 100644
--- a/doc/man/libkeccak_hmac_wipe.3
+++ b/man/libkeccak_hmac_wipe.3
diff --git a/doc/man/libkeccak_keccaksum_fd.3 b/man/libkeccak_keccaksum_fd.3
index 2fc1b21..2fc1b21 100644
--- a/doc/man/libkeccak_keccaksum_fd.3
+++ b/man/libkeccak_keccaksum_fd.3
diff --git a/doc/man/libkeccak_rawshakesum_fd.3 b/man/libkeccak_rawshakesum_fd.3
index 27c4f45..27c4f45 100644
--- a/doc/man/libkeccak_rawshakesum_fd.3
+++ b/man/libkeccak_rawshakesum_fd.3
diff --git a/doc/man/libkeccak_sha3sum_fd.3 b/man/libkeccak_sha3sum_fd.3
index e8c4fc0..e8c4fc0 100644
--- a/doc/man/libkeccak_sha3sum_fd.3
+++ b/man/libkeccak_sha3sum_fd.3
diff --git a/doc/man/libkeccak_shakesum_fd.3 b/man/libkeccak_shakesum_fd.3
index 0d89f39..0d89f39 100644
--- a/doc/man/libkeccak_shakesum_fd.3
+++ b/man/libkeccak_shakesum_fd.3
diff --git a/doc/man/libkeccak_simple_squeeze.3 b/man/libkeccak_simple_squeeze.3
index 52605ed..52605ed 100644
--- a/doc/man/libkeccak_simple_squeeze.3
+++ b/man/libkeccak_simple_squeeze.3
diff --git a/doc/man/libkeccak_spec_check.3 b/man/libkeccak_spec_check.3
index 9fc70f6..9fc70f6 100644
--- a/doc/man/libkeccak_spec_check.3
+++ b/man/libkeccak_spec_check.3
diff --git a/doc/man/libkeccak_spec_rawshake.3 b/man/libkeccak_spec_rawshake.3
index 6f60c36..6f60c36 100644
--- a/doc/man/libkeccak_spec_rawshake.3
+++ b/man/libkeccak_spec_rawshake.3
diff --git a/doc/man/libkeccak_spec_sha3.3 b/man/libkeccak_spec_sha3.3
index 8e07a7d..8e07a7d 100644
--- a/doc/man/libkeccak_spec_sha3.3
+++ b/man/libkeccak_spec_sha3.3
diff --git a/doc/man/libkeccak_spec_shake.3 b/man/libkeccak_spec_shake.3
index 9e2d763..9e2d763 100644
--- a/doc/man/libkeccak_spec_shake.3
+++ b/man/libkeccak_spec_shake.3
diff --git a/doc/man/libkeccak_squeeze.3 b/man/libkeccak_squeeze.3
index c6c8d01..c6c8d01 100644
--- a/doc/man/libkeccak_squeeze.3
+++ b/man/libkeccak_squeeze.3
diff --git a/doc/man/libkeccak_state_copy.3 b/man/libkeccak_state_copy.3
index c9283ca..c9283ca 100644
--- a/doc/man/libkeccak_state_copy.3
+++ b/man/libkeccak_state_copy.3
diff --git a/doc/man/libkeccak_state_create.3 b/man/libkeccak_state_create.3
index 77880a3..77880a3 100644
--- a/doc/man/libkeccak_state_create.3
+++ b/man/libkeccak_state_create.3
diff --git a/doc/man/libkeccak_state_destroy.3 b/man/libkeccak_state_destroy.3
index 0a78215..0a78215 100644
--- a/doc/man/libkeccak_state_destroy.3
+++ b/man/libkeccak_state_destroy.3
diff --git a/doc/man/libkeccak_state_duplicate.3 b/man/libkeccak_state_duplicate.3
index 54c9be3..54c9be3 100644
--- a/doc/man/libkeccak_state_duplicate.3
+++ b/man/libkeccak_state_duplicate.3
diff --git a/doc/man/libkeccak_state_fast_destroy.3 b/man/libkeccak_state_fast_destroy.3
index e04ca86..e04ca86 100644
--- a/doc/man/libkeccak_state_fast_destroy.3
+++ b/man/libkeccak_state_fast_destroy.3
diff --git a/doc/man/libkeccak_state_fast_free.3 b/man/libkeccak_state_fast_free.3
index e617e21..e617e21 100644
--- a/doc/man/libkeccak_state_fast_free.3
+++ b/man/libkeccak_state_fast_free.3
diff --git a/doc/man/libkeccak_state_free.3 b/man/libkeccak_state_free.3
index e6dd3f8..e6dd3f8 100644
--- a/doc/man/libkeccak_state_free.3
+++ b/man/libkeccak_state_free.3
diff --git a/doc/man/libkeccak_state_initialise.3 b/man/libkeccak_state_initialise.3
index 2620686..2620686 100644
--- a/doc/man/libkeccak_state_initialise.3
+++ b/man/libkeccak_state_initialise.3
diff --git a/doc/man/libkeccak_state_marshal.3 b/man/libkeccak_state_marshal.3
index f5d5e05..f5d5e05 100644
--- a/doc/man/libkeccak_state_marshal.3
+++ b/man/libkeccak_state_marshal.3
diff --git a/doc/man/libkeccak_state_marshal_size.3 b/man/libkeccak_state_marshal_size.3
index 8ebb16a..8ebb16a 100644
--- a/doc/man/libkeccak_state_marshal_size.3
+++ b/man/libkeccak_state_marshal_size.3
diff --git a/doc/man/libkeccak_state_reset.3 b/man/libkeccak_state_reset.3
index 60bb778..60bb778 100644
--- a/doc/man/libkeccak_state_reset.3
+++ b/man/libkeccak_state_reset.3
diff --git a/doc/man/libkeccak_state_unmarshal.3 b/man/libkeccak_state_unmarshal.3
index 5a9e59b..5a9e59b 100644
--- a/doc/man/libkeccak_state_unmarshal.3
+++ b/man/libkeccak_state_unmarshal.3
diff --git a/doc/man/libkeccak_state_unmarshal_skip.3 b/man/libkeccak_state_unmarshal_skip.3
index b87386c..b87386c 100644
--- a/doc/man/libkeccak_state_unmarshal_skip.3
+++ b/man/libkeccak_state_unmarshal_skip.3
diff --git a/doc/man/libkeccak_state_wipe.3 b/man/libkeccak_state_wipe.3
index 664cd51..664cd51 100644
--- a/doc/man/libkeccak_state_wipe.3
+++ b/man/libkeccak_state_wipe.3
diff --git a/doc/man/libkeccak_state_wipe_message.3 b/man/libkeccak_state_wipe_message.3
index c734560..c734560 100644
--- a/doc/man/libkeccak_state_wipe_message.3
+++ b/man/libkeccak_state_wipe_message.3
diff --git a/doc/man/libkeccak_state_wipe_sponge.3 b/man/libkeccak_state_wipe_sponge.3
index 4651fc0..4651fc0 100644
--- a/doc/man/libkeccak_state_wipe_sponge.3
+++ b/man/libkeccak_state_wipe_sponge.3
diff --git a/doc/man/libkeccak_unhex.3 b/man/libkeccak_unhex.3
index 93cde63..93cde63 100644
--- a/doc/man/libkeccak_unhex.3
+++ b/man/libkeccak_unhex.3
diff --git a/doc/man/libkeccak_update.3 b/man/libkeccak_update.3
index d83f74b..d83f74b 100644
--- a/doc/man/libkeccak_update.3
+++ b/man/libkeccak_update.3
diff --git a/src/test.c b/test.c
index 8394568..8394568 100644
--- a/src/test.c
+++ b/test.c