-#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);
}
-
-
-I ../../src/optional \
$$(pkg-config --cflags libsodium)
-%.out: %.o monocypher.o ed25519.o
+%.out: %.o ed25519.o
$(CC) $(CFLAGS) -o $@ $^ \
$$(pkg-config --libs libsodium)
-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 $@