diff --git a/Makefile b/Makefile index cd9aefd..40e709c 100644 --- a/Makefile +++ b/Makefile @@ -66,12 +66,13 @@ HEADERS= Makefile $(shell find . -name "*.h") build/timestamp LIBCOMPONENTS= build/goldilocks.o build/barrett_field.o build/crandom.o \ build/$(FIELD).o build/ec_point.o build/scalarmul.o build/sha512.o build/magic.o \ - build/f_arithmetic.o build/arithmetic.o build/decaf.o + build/f_arithmetic.o build/arithmetic.o build/decaf.o build/shake.o TESTCOMPONENTS=build/test.o build/test_scalarmul.o build/test_sha512.o \ - build/test_pointops.o build/test_arithmetic.o build/test_goldilocks.o build/magic.o + build/test_pointops.o build/test_arithmetic.o build/test_goldilocks.o build/magic.o \ + build/shake.o -BENCHCOMPONENTS=build/bench.o +BENCHCOMPONENTS=build/bench.o build/shake.o BATBASE=ed448goldilocks-bats-$(TODAY) BATNAME=build/$(BATBASE) diff --git a/include/shake.h b/include/shake.h index e47d2df..22cbd65 100644 --- a/include/shake.h +++ b/include/shake.h @@ -14,6 +14,8 @@ #include +#define API_VIS __attribute__((visibility("default"))) + #ifndef INTERNAL_SPONGE_STRUCT typedef struct keccak_sponge_s { uint64_t opaque[26]; @@ -29,7 +31,7 @@ void sponge_init ( keccak_sponge_t sponge, const struct kparams_s *params -); +) API_VIS; /** * @brief Absorb data into a SHA3 or SHAKE hash context. @@ -41,7 +43,7 @@ void sha3_update ( struct keccak_sponge_s * __restrict__ sponge, const uint8_t *in, size_t len -); +) API_VIS; /** * @brief Squeeze output data from a SHA3 or SHAKE hash context. @@ -56,7 +58,7 @@ void sha3_output ( keccak_sponge_t sponge, uint8_t * __restrict__ out, size_t len -); +) API_VIS; /** * @brief Destroy a SHA3 or SHAKE sponge context by overwriting it with 0. @@ -64,8 +66,7 @@ void sha3_output ( */ void sponge_destroy ( keccak_sponge_t sponge -); - +) API_VIS; /** * @brief Hash (in) to (out) @@ -80,12 +81,12 @@ void sponge_hash ( uint8_t *out, size_t outlen, const struct kparams_s *params -); +) API_VIS; /* TODO: expand/doxygenate individual SHAKE/SHA3 instances? */ #define DECSHAKE(n) \ - extern const struct kparams_s *SHAKE##n##_params; \ + extern const struct kparams_s *SHAKE##n##_params API_VIS; \ static inline void shake##n##_init(keccak_sponge_t sponge) { \ sponge_init(sponge, SHAKE##n##_params); \ } \ @@ -104,7 +105,7 @@ void sponge_hash ( } #define DECSHA3(n) \ - extern const struct kparams_s *SHA3_##n##_params; \ + extern const struct kparams_s *SHA3_##n##_params API_VIS; \ static inline void sha3_##n##_init(keccak_sponge_t sponge) { \ sponge_init(sponge, SHA3_##n##_params); \ } \ @@ -129,4 +130,6 @@ DECSHA3(256) DECSHA3(384) DECSHA3(512) +#undef API_VIS + #endif /* __SHAKE_H__ */ diff --git a/test/bench.c b/test/bench.c index 75b79e1..346329c 100644 --- a/test/bench.c +++ b/test/bench.c @@ -17,6 +17,7 @@ #include "goldilocks.h" #include "sha512.h" #include "decaf.h" +#include "shake.h" static __inline__ void ignore_result ( int result ) { @@ -164,6 +165,13 @@ int main(int argc, char **argv) { when = now() - when; printf("sha512 blk: %5.1fns (%0.2f MB/s)\n", when * 1e9 / i, 128*i/when/1e6); + when = now(); + for (i=0; i