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/ref10 | |
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/ref10')
-rw-r--r-- | src/ext/ed25519/ref10/crypto_hash_sha512.h | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/src/ext/ed25519/ref10/crypto_hash_sha512.h b/src/ext/ed25519/ref10/crypto_hash_sha512.h index 0278571522..e454c4e7ef 100644 --- a/src/ext/ed25519/ref10/crypto_hash_sha512.h +++ b/src/ext/ed25519/ref10/crypto_hash_sha512.h @@ -1,30 +1,32 @@ /* Added for Tor. */ -#include <openssl/sha.h> +#include "crypto.h" /* Set 'out' to the 512-bit SHA512 hash of the 'len'-byte string in 'inp' */ #define crypto_hash_sha512(out, inp, len) \ - SHA512((inp), (len), (out)) + crypto_digest512((char *)(out), (const char *)(inp), (len), DIGEST_SHA512) /* Set 'out' to the 512-bit SHA512 hash of the 'len1'-byte string in 'inp1', * concatenated with the 'len2'-byte string in 'inp2'. */ #define crypto_hash_sha512_2(out, inp1, len1, inp2, len2) \ do { \ - SHA512_CTX sha_ctx_; \ - SHA512_Init(&sha_ctx_); \ - SHA512_Update(&sha_ctx_, (inp1), (len1)); \ - SHA512_Update(&sha_ctx_, (inp2), (len2)); \ - SHA512_Final((out), &sha_ctx_); \ - } while(0) + crypto_digest_t *sha_ctx_; \ + sha_ctx_ = crypto_digest512_new(DIGEST_SHA512); \ + crypto_digest_add_bytes(sha_ctx_, (const char *)(inp1), (len1)); \ + crypto_digest_add_bytes(sha_ctx_, (const char *)(inp2), (len2)); \ + crypto_digest_get_digest(sha_ctx_, (char *)out, 64); \ + crypto_digest_free(sha_ctx_); \ + } while (0) /* Set 'out' to the 512-bit SHA512 hash of the 'len1'-byte string in 'inp1', * concatenated with the 'len2'-byte string in 'inp2', concatenated with * the 'len3'-byte string in 'len3'. */ #define crypto_hash_sha512_3(out, inp1, len1, inp2, len2, inp3, len3) \ do { \ - SHA512_CTX sha_ctx_; \ - SHA512_Init(&sha_ctx_); \ - SHA512_Update(&sha_ctx_, (inp1), (len1)); \ - SHA512_Update(&sha_ctx_, (inp2), (len2)); \ - SHA512_Update(&sha_ctx_, (inp3), (len3)); \ - SHA512_Final((out), &sha_ctx_); \ + crypto_digest_t *sha_ctx_; \ + sha_ctx_ = crypto_digest512_new(DIGEST_SHA512); \ + crypto_digest_add_bytes(sha_ctx_, (const char *)(inp1), (len1)); \ + crypto_digest_add_bytes(sha_ctx_, (const char *)(inp2), (len2)); \ + crypto_digest_add_bytes(sha_ctx_, (const char *)(inp3), (len3)); \ + crypto_digest_get_digest(sha_ctx_, (char *)out, 64); \ + crypto_digest_free(sha_ctx_); \ } while(0) |