diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-03-25 11:49:41 +0100 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-03-31 10:04:44 -0400 |
commit | 38fb651f0d740bef575ad7f95475cc504ea4cb8f (patch) | |
tree | 06d4d6226ee94e8084847abd828ce944106e8dd7 /src/ext/ed25519/donna | |
parent | 3fc4f81de3d68947e5212e349fa0e1d7ed77ef67 (diff) | |
download | tor-38fb651f0d740bef575ad7f95475cc504ea4cb8f.tar.gz tor-38fb651f0d740bef575ad7f95475cc504ea4cb8f.zip |
Make our ed25519 implementations no longer use openssl directly.
Diffstat (limited to 'src/ext/ed25519/donna')
-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); +} + |