*/
#include <ccan/crypto/sha256/sha256.h>
#include <ccan/endian/endian.h>
+#include <ccan/compiler/compiler.h>
#include <stdbool.h>
#include <assert.h>
#include <string.h>
#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
}
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);
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;
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(ctx, pad, 1 + ((128 - 8 - (ctx->bytes % 64) - 1) % 64));
/* Add number of bits of data (big endian) */
add(ctx, &sizedesc, 8);
for (i = 0; i < sizeof(ctx->s) / sizeof(ctx->s[0]); i++)