From c92ec5dcfd53c9381902e82ebe453de6ab391ef3 Mon Sep 17 00:00:00 2001 From: Loup Vaillant Date: Sat, 21 Apr 2018 16:26:32 +0200 Subject: [PATCH] Test vectors no longer depend on Monocypher Test vectors for EdDSA used to use Moncoypher's Blake2b hash. This didn't make much sense, and could even conceivably be construed as circular. Blake2b vectors were properly generated, so it wasn't really circular, but that's still ugly. Now the test vectors only depend on Libsodium and ed25519-donna. --- tests/ed25519-donna/ed25519-hash-custom.h | 33 +++++++---------------- tests/gen/makefile | 7 +---- 2 files changed, 10 insertions(+), 30 deletions(-) diff --git a/tests/ed25519-donna/ed25519-hash-custom.h b/tests/ed25519-donna/ed25519-hash-custom.h index c73f637..94a0076 100644 --- a/tests/ed25519-donna/ed25519-hash-custom.h +++ b/tests/ed25519-donna/ed25519-hash-custom.h @@ -1,38 +1,23 @@ -#include "monocypher.h" +#include - -#ifdef ED25519_SHA512 - #include "rename_sha512.h" - #define HASH rename_sha512 -#else - #define HASH crypto_blake2b -#endif -#define COMBINE1(x, y) x ## y -#define COMBINE2(x, y) COMBINE1(x, y) -#define HASH_CTX COMBINE2(HASH, _ctx) -#define HASH_INIT COMBINE2(HASH, _init) -#define HASH_UPDATE COMBINE2(HASH, _update) -#define HASH_FINAL COMBINE2(HASH, _final) - -typedef struct { - HASH_CTX ctx; -} ed25519_hash_context; +typedef crypto_generichash_state ed25519_hash_context; void ed25519_hash_init(ed25519_hash_context *ctx) { - HASH_INIT(&(ctx->ctx)); + crypto_generichash_init(ctx, 0, 0, 64); } + void ed25519_hash_update(ed25519_hash_context *ctx, const uint8_t *in, size_t inlen) { - HASH_UPDATE(&(ctx->ctx), in, inlen); + crypto_generichash_update(ctx, in, inlen); } + void ed25519_hash_final(ed25519_hash_context *ctx, uint8_t *hash) { - HASH_FINAL(&(ctx->ctx), hash); + crypto_generichash_final(ctx, hash, 64); } + void ed25519_hash(uint8_t *hash, const uint8_t *in, size_t inlen) { - HASH(hash, in, inlen); + crypto_generichash(hash, 64, in, inlen, 0, 0); } - - diff --git a/tests/gen/makefile b/tests/gen/makefile index 351b84d..2c77864 100644 --- a/tests/gen/makefile +++ b/tests/gen/makefile @@ -29,7 +29,7 @@ clean: -I ../../src/optional \ $$(pkg-config --cflags libsodium) -%.out: %.o monocypher.o ed25519.o +%.out: %.o ed25519.o $(CC) $(CFLAGS) -o $@ $^ \ $$(pkg-config --libs libsodium) @@ -43,11 +43,6 @@ ed25519.o: ../ed25519-donna/ed25519.c $(wildcard ../ed25519-donna/*.h) -DED25519_NO_INLINE_ASM \ -DED25519_FORCE_32BIT -monocypher.o: ../../src/monocypher.c ../../src/monocypher.h -m_sha512.o : ../../src/optional/sha512.c ../../src/optional/sha512.h -monocypher.o m_sha512.o: - $(CC) $(CFLAGS) -c $< -I ../../src -I ../../src/optional - vector_to_header.out: ../vector_to_header.c $(CC) $(CFLAGS) $< -o $@ -- 2.47.3