aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-11-07 01:31:14 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2009-11-07 01:31:14 +0100
commit245a4f84be09505fcac7b2afab00106d65c815df (patch)
tree6d0685158588e69744ec2539d13e2526117da366 /libbb
parent0d8c0b810e02de887abc3a0fbbf6e7d06ace8a85 (diff)
downloadbusybox-245a4f84be09505fcac7b2afab00106d65c815df.tar.gz
big endian warning fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r--libbb/sha1.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/libbb/sha1.c b/libbb/sha1.c
index ea645b735..5f42532cd 100644
--- a/libbb/sha1.c
+++ b/libbb/sha1.c
@@ -408,7 +408,7 @@ void FAST_FUNC sha512_hash(const void *buffer, size_t len, sha512_ctx_t *ctx)
/* Used also for sha256 */
void FAST_FUNC sha1_end(void *resbuf, sha1_ctx_t *ctx)
{
- unsigned i, pad, in_buf;
+ unsigned pad, in_buf;
in_buf = ctx->total64 & 63;
/* Pad the buffer to the next 64-byte boundary with 0x80,0,0,0... */
@@ -434,16 +434,17 @@ void FAST_FUNC sha1_end(void *resbuf, sha1_ctx_t *ctx)
in_buf = (ctx->process_block == sha1_process_block64) ? 5 : 8;
/* This way we do not impose alignment constraints on resbuf: */
-#if BB_LITTLE_ENDIAN
- for (i = 0; i < in_buf; ++i)
- ctx->hash[i] = htonl(ctx->hash[i]);
-#endif
+ if (BB_LITTLE_ENDIAN) {
+ unsigned i;
+ for (i = 0; i < in_buf; ++i)
+ ctx->hash[i] = htonl(ctx->hash[i]);
+ }
memcpy(resbuf, ctx->hash, sizeof(ctx->hash[0]) * in_buf);
}
void FAST_FUNC sha512_end(void *resbuf, sha512_ctx_t *ctx)
{
- unsigned i, pad, in_buf;
+ unsigned pad, in_buf;
in_buf = ctx->total64[0] & 127;
/* Pad the buffer to the next 128-byte boundary with 0x80,0,0,0...
@@ -470,9 +471,10 @@ void FAST_FUNC sha512_end(void *resbuf, sha512_ctx_t *ctx)
break;
}
-#if BB_LITTLE_ENDIAN
- for (i = 0; i < ARRAY_SIZE(ctx->hash); ++i)
- ctx->hash[i] = hton64(ctx->hash[i]);
-#endif
+ if (BB_LITTLE_ENDIAN) {
+ unsigned i;
+ for (i = 0; i < ARRAY_SIZE(ctx->hash); ++i)
+ ctx->hash[i] = hton64(ctx->hash[i]);
+ }
memcpy(resbuf, ctx->hash, sizeof(ctx->hash));
}