diff options
Diffstat (limited to 'src/ext/ed25519/donna/ed25519-hash-custom.h')
-rw-r--r-- | src/ext/ed25519/donna/ed25519-hash-custom.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/ext/ed25519/donna/ed25519-hash-custom.h b/src/ext/ed25519/donna/ed25519-hash-custom.h index 7dc249129d..609451abd5 100644 --- a/src/ext/ed25519/donna/ed25519-hash-custom.h +++ b/src/ext/ed25519/donna/ed25519-hash-custom.h @@ -9,3 +9,34 @@ void ed25519_hash(uint8_t *hash, const uint8_t *in, size_t inlen); */ +#include "crypto.h" + +typedef struct ed25519_hash_context { + crypto_digest_t *ctx; +} ed25519_hash_context; + + +static void +ed25519_hash_init(ed25519_hash_context *ctx) +{ + ctx->ctx = crypto_digest512_new(DIGEST_SHA512); +} +static void +ed25519_hash_update(ed25519_hash_context *ctx, const uint8_t *in, size_t inlen) +{ + crypto_digest_add_bytes(ctx->ctx, (const char *)in, inlen); +} +static void +ed25519_hash_final(ed25519_hash_context *ctx, uint8_t *hash) +{ + crypto_digest_get_digest(ctx->ctx, (char *)hash, DIGEST512_LEN); + crypto_digest_free(ctx->ctx); + ctx->ctx = NULL; +} +static void +ed25519_hash(uint8_t *hash, const uint8_t *in, size_t inlen) +{ + crypto_digest512((char *)hash, (const char *)in, inlen, + DIGEST_SHA512); +} + |