From b737103a9187e0191dbc1995da3399ab3dbcdc66 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Sun, 4 Jan 2015 14:19:23 +0100 Subject: [PATCH] Use void pointers for opaque data blobs in the SHA512 code. --- src/ed25519/sha512.c | 12 +++++++----- src/ed25519/sha512.h | 8 ++++---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/ed25519/sha512.c b/src/ed25519/sha512.c index afe98e5..e1db1e5 100644 --- a/src/ed25519/sha512.c +++ b/src/ed25519/sha512.c @@ -88,7 +88,7 @@ static const uint64_t K[80] = { #endif /* compress 1024-bits */ -static int sha512_compress(sha512_context *md, unsigned char *buf) +static int sha512_compress(sha512_context *md, const unsigned char *buf) { uint64_t S[8], W[80], t0, t1; int i; @@ -168,8 +168,9 @@ int sha512_init(sha512_context * md) { @param inlen The length of the data (octets) @return 0 if successful */ -int sha512_update(sha512_context *md, const unsigned char *in, size_t inlen) +int sha512_update(sha512_context *md, const void *vin, size_t inlen) { + const unsigned char *in = vin; size_t n; size_t i; int err; @@ -180,7 +181,7 @@ int sha512_update(sha512_context *md, const unsigned char *in, size_t inlen) } while (inlen > 0) { if (md->curlen == 0 && inlen >= 128) { - if ((err = sha512_compress (md, (unsigned char *)in)) != 0) { + if ((err = sha512_compress (md, in)) != 0) { return err; } md->length += 128 * 8; @@ -215,9 +216,10 @@ int sha512_update(sha512_context *md, const unsigned char *in, size_t inlen) @param out [out] The destination of the hash (64 bytes) @return 0 if successful */ -int sha512_final(sha512_context * md, unsigned char *out) +int sha512_final(sha512_context * md, void *vout) { int i; + unsigned char *out = vout; if (md == NULL) return 1; if (out == NULL) return 1; @@ -264,7 +266,7 @@ int sha512_final(sha512_context * md, unsigned char *out) return 0; } -int sha512(const unsigned char *message, size_t message_len, unsigned char *out) +int sha512(const void *message, size_t message_len, void *out) { sha512_context ctx; int ret; diff --git a/src/ed25519/sha512.h b/src/ed25519/sha512.h index e56b00e..e23f8db 100644 --- a/src/ed25519/sha512.h +++ b/src/ed25519/sha512.h @@ -14,8 +14,8 @@ typedef struct sha512_context_ { int sha512_init(sha512_context * md); -int sha512_final(sha512_context * md, unsigned char *out); -int sha512_update(sha512_context * md, const unsigned char *in, size_t inlen); -int sha512(const unsigned char *message, size_t message_len, unsigned char *out); +int sha512_final(sha512_context * md, void *out); +int sha512_update(sha512_context * md, const void *in, size_t inlen); +int sha512(const void *message, size_t message_len, void *out); -#endif \ No newline at end of file +#endif -- 2.25.1