summaryrefslogtreecommitdiff
path: root/random/unix/sha2.c
diff options
context:
space:
mode:
Diffstat (limited to 'random/unix/sha2.c')
-rw-r--r--random/unix/sha2.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/random/unix/sha2.c b/random/unix/sha2.c
index 1f5c1b2e8..12c257d1f 100644
--- a/random/unix/sha2.c
+++ b/random/unix/sha2.c
@@ -465,7 +465,14 @@ void apr__SHA256_Final(sha2_byte digest[], SHA256_CTX* context) {
*context->buffer = 0x80;
}
/* Set the bit count: */
- *(sha2_word64*)&context->buffer[SHA256_SHORT_BLOCK_LENGTH] = context->bitcount;
+ {
+ union dummy {
+ apr_uint64_t bitcount;
+ apr_byte_t bytes[8];
+ } bitcount;
+ bitcount.bitcount = context->bitcount;
+ MEMCPY_BCOPY(&context->buffer[SHA256_SHORT_BLOCK_LENGTH], bitcount.bytes, 8);
+ }
/* Final transform: */
apr__SHA256_Transform(context, (sha2_word32*)context->buffer);