X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fcrypto%2Fsha256%2Fsha256.c;h=3307e0b76a4b5929de476310f5ae3e71cdfd2ded;hp=4b1f8cdf303af328320691cc4ee8b8403c65fb5a;hb=fe21b246647e4694da5f76e0fd00e9a9f9e8c72e;hpb=f989a43b55795c04a6225b392f3f58afd2cd6543;ds=sidebyside diff --git a/ccan/crypto/sha256/sha256.c b/ccan/crypto/sha256/sha256.c index 4b1f8cdf..3307e0b7 100644 --- a/ccan/crypto/sha256/sha256.c +++ b/ccan/crypto/sha256/sha256.c @@ -8,6 +8,7 @@ */ #include #include +#include #include #include #include @@ -17,16 +18,16 @@ static void invalidate_sha256(struct sha256_ctx *ctx) #ifdef CCAN_CRYPTO_SHA256_USE_OPENSSL ctx->c.md_len = 0; #else - ctx->bytes = -1ULL; + ctx->bytes = (size_t)-1; #endif } -static void check_sha256(struct sha256_ctx *ctx) +static void check_sha256(struct sha256_ctx *ctx UNUSED) { #ifdef CCAN_CRYPTO_SHA256_USE_OPENSSL assert(ctx->c.md_len != 0); #else - assert(ctx->bytes != -1ULL); + assert(ctx->bytes != (size_t)-1); #endif } @@ -36,7 +37,7 @@ void sha256_init(struct sha256_ctx *ctx) SHA256_Init(&ctx->c); } -void sha256_update_bytes(struct sha256_ctx *ctx, const void *p, size_t size) +void sha256_update(struct sha256_ctx *ctx, const void *p, size_t size) { check_sha256(ctx); SHA256_Update(&ctx->c, p, size); @@ -166,7 +167,7 @@ static void Transform(uint32_t *s, const uint32_t *chunk) s[7] += h; } -static bool alignment_ok(const void *p, size_t n) +static bool alignment_ok(const void *p UNUSED, size_t n UNUSED) { #if HAVE_UNALIGNED_ACCESS return true; @@ -228,7 +229,7 @@ void sha256_done(struct sha256_ctx *ctx, struct sha256 *res) uint64_t sizedesc; size_t i; - sizedesc = cpu_to_be64(ctx->bytes << 3); + sizedesc = cpu_to_be64((uint64_t)ctx->bytes << 3); /* Add '1' bit to terminate, then all 0 bits, up to next block - 8. */ add(ctx, pad, 1 + ((119 - (ctx->bytes % 64)) % 64)); /* Add number of bits of data (big endian) */