]> git.codecow.com Git - Monocypher.git/commitdiff
Test vectors no longer depend on Monocypher
authorLoup Vaillant <loup@loup-vaillant.fr>
Sat, 21 Apr 2018 14:26:32 +0000 (16:26 +0200)
committerLoup Vaillant <loup@loup-vaillant.fr>
Sat, 21 Apr 2018 14:26:32 +0000 (16:26 +0200)
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
tests/gen/makefile

index c73f63775ee878123c640f6dce0b26955baa606d..94a00769d1e315ef2c647faaac5c466bd80d796e 100644 (file)
@@ -1,38 +1,23 @@
-#include "monocypher.h"
+#include <sodium.h>
 
-
-#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);
 }
-
-
index 351b84dc4e5562dec38c06d4f85c7fb71c37c956..2c77864df110896932cae81b4c73feaad3747595 100644 (file)
@@ -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 $@