X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=crc%2Fsha512.c;h=e069a4489e5816dfcd817bf1c32fab2d6acb5504;hb=2b34ccadbe56eca1d41cf8eb3ddfb32d8f28dd73;hp=1f9ebb434baf2707f909d33c63b48ae84ed06a64;hpb=eef6eea1b935a67f1ae26b38e06a69d4410a12aa;p=fio.git diff --git a/crc/sha512.c b/crc/sha512.c index 1f9ebb43..e069a448 100644 --- a/crc/sha512.c +++ b/crc/sha512.c @@ -13,17 +13,10 @@ #include #include -#include -#include +#include "../lib/bswap.h" #include "sha512.h" -#if __BYTE_ORDER == __LITTLE_ENDIAN -#define __be64_to_cpu(x) __bswap_64(x) -#else -#define __be64_to_cpu(x) (x) -#endif - #define SHA384_DIGEST_SIZE 48 #define SHA512_DIGEST_SIZE 64 #define SHA384_HMAC_BLOCK_SIZE 128 @@ -153,7 +146,7 @@ static void sha512_transform(uint64_t *state, uint64_t *W, const uint8_t *input) a = b = c = d = e = f = g = h = t1 = t2 = 0; } -void sha512_init(struct sha512_ctx *sctx) +void fio_sha512_init(struct fio_sha512_ctx *sctx) { sctx->state[0] = H0; sctx->state[1] = H1; @@ -166,13 +159,13 @@ void sha512_init(struct sha512_ctx *sctx) sctx->count[0] = sctx->count[1] = sctx->count[2] = sctx->count[3] = 0; } -void sha512_update(struct sha512_ctx *sctx, const uint8_t *data, - unsigned int len) +void fio_sha512_update(struct fio_sha512_ctx *sctx, const uint8_t *data, + unsigned int len) { - unsigned int i, index, part_len; + unsigned int i, idx, part_len; /* Compute number of bytes mod 128 */ - index = (unsigned int)((sctx->count[0] >> 3) & 0x7F); + idx = (unsigned int)((sctx->count[0] >> 3) & 0x7F); /* Update number of bits */ if ((sctx->count[0] += (len << 3)) < (len << 3)) { @@ -182,23 +175,23 @@ void sha512_update(struct sha512_ctx *sctx, const uint8_t *data, sctx->count[1] += (len >> 29); } - part_len = 128 - index; + part_len = 128 - idx; /* Transform as many times as possible. */ if (len >= part_len) { - memcpy(&sctx->buf[index], data, part_len); + memcpy(&sctx->buf[idx], data, part_len); sha512_transform(sctx->state, sctx->W, sctx->buf); for (i = part_len; i + 127 < len; i+=128) sha512_transform(sctx->state, sctx->W, &data[i]); - index = 0; + idx = 0; } else { i = 0; } /* Buffer remaining input */ - memcpy(&sctx->buf[index], &data[i], len - i); + memcpy(&sctx->buf[idx], &data[i], len - i); /* erase our data */ memset(sctx->W, 0, sizeof(sctx->W));