/* 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... */
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...
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));
}