projects
/
fio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' into gfio
[fio.git]
/
crc
/
sha256.c
diff --git
a/crc/sha256.c
b/crc/sha256.c
index 8ec2943294e48ac2a3e9e22892a0723fa05b4f8e..3a72a5bfb2e14bbcc0d718acfa9e296ec9c48ded 100644
(file)
--- a/
crc/sha256.c
+++ b/
crc/sha256.c
@@
-18,17
+18,10
@@
*/
#include <string.h>
#include <inttypes.h>
*/
#include <string.h>
#include <inttypes.h>
-#include <byteswap.h>
-#include <endian.h>
+#include "../lib/bswap.h"
#include "sha256.h"
#include "sha256.h"
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-#define __be32_to_cpu(x) __bswap_32(x)
-#else
-#define __be32_to_cpu(x) (x)
-#endif
-
#define SHA256_DIGEST_SIZE 32
#define SHA256_HMAC_BLOCK_SIZE 64
#define SHA256_DIGEST_SIZE 32
#define SHA256_HMAC_BLOCK_SIZE 64
@@
-234,7
+227,7
@@
static void sha256_transform(uint32_t *state, const uint8_t *input)
memset(W, 0, 64 * sizeof(uint32_t));
}
memset(W, 0, 64 * sizeof(uint32_t));
}
-void
sha256_init(struct
sha256_ctx *sctx)
+void
fio_sha256_init(struct fio_
sha256_ctx *sctx)
{
sctx->state[0] = H0;
sctx->state[1] = H1;
{
sctx->state[0] = H0;
sctx->state[1] = H1;
@@
-247,13
+240,13
@@
void sha256_init(struct sha256_ctx *sctx)
sctx->count[0] = sctx->count[1] = 0;
}
sctx->count[0] = sctx->count[1] = 0;
}
-void
sha256_update(struct
sha256_ctx *sctx, const uint8_t *data,
- unsigned int len)
+void
fio_sha256_update(struct fio_
sha256_ctx *sctx, const uint8_t *data,
+
unsigned int len)
{
{
- unsigned int i, i
nde
x, part_len;
+ unsigned int i, i
d
x, part_len;
/* Compute number of bytes mod 128 */
/* Compute number of bytes mod 128 */
- i
nde
x = (unsigned int)((sctx->count[0] >> 3) & 0x3f);
+ i
d
x = (unsigned int)((sctx->count[0] >> 3) & 0x3f);
/* Update number of bits */
if ((sctx->count[0] += (len << 3)) < (len << 3)) {
/* Update number of bits */
if ((sctx->count[0] += (len << 3)) < (len << 3)) {
@@
-261,20
+254,20
@@
void sha256_update(struct sha256_ctx *sctx, const uint8_t *data,
sctx->count[1] += (len >> 29);
}
sctx->count[1] += (len >> 29);
}
- part_len = 64 - i
nde
x;
+ part_len = 64 - i
d
x;
/* Transform as many times as possible. */
if (len >= part_len) {
/* Transform as many times as possible. */
if (len >= part_len) {
- memcpy(&sctx->buf[i
nde
x], data, part_len);
+ memcpy(&sctx->buf[i
d
x], data, part_len);
sha256_transform(sctx->state, sctx->buf);
for (i = part_len; i + 63 < len; i += 64)
sha256_transform(sctx->state, &data[i]);
sha256_transform(sctx->state, sctx->buf);
for (i = part_len; i + 63 < len; i += 64)
sha256_transform(sctx->state, &data[i]);
- i
nde
x = 0;
+ i
d
x = 0;
} else {
i = 0;
}
/* Buffer remaining input */
} else {
i = 0;
}
/* Buffer remaining input */
- memcpy(&sctx->buf[i
nde
x], &data[i], len-i);
+ memcpy(&sctx->buf[i
d
x], &data[i], len-i);
}
}