#include "wimlib/endianness.h"
#include "wimlib/sha1.h"
+#include "wimlib/unaligned.h"
/* Dummy SHA-1 message digest of all 0's. This is used in the WIM format to
* mean "SHA-1 not specified". */
#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
-#define blk0(i) (tmp[i] = be32_to_cpu(((const be32 *)block)[i]))
+#define blk0(i) (tmp[i] = be32_to_cpu(load_be32_unaligned(&(block)[(i) * 4])))
#define blk(i) (tmp[i & 15] = rol(tmp[(i + 13) & 15] ^ \
tmp[(i + 8) & 15] ^ \
* final length is a multiple of the block size. */
static const u8 padding[64] = {0x80, };
be64 finalcount = cpu_to_be64(ctx->bytecount << 3);
- be32 *out = (be32 *)md;
sha1_update(ctx, padding, 64 - ((ctx->bytecount + 8) & 63));
sha1_update(ctx, &finalcount, 8);
for (int i = 0; i < 5; i++)
- out[i] = cpu_to_be32(ctx->state[i]);
+ store_be32_unaligned(cpu_to_be32(ctx->state[i]), &md[i * 4]);
}
/* Calculate the SHA-1 message digest of the specified buffer.