Silence strict-aliasing warnings

This commit is contained in:
Andrew Bettison 2012-07-10 14:26:19 +09:30
parent 624be364bf
commit 2758af36ee

8
sha2.c
View File

@ -606,7 +606,8 @@ void SHA256_Final(sha2_byte digest[], SHA256_CTX* context) {
*context->buffer = 0x80; *context->buffer = 0x80;
} }
/* Set the bit count: */ /* Set the bit count: */
*(sha2_word64*)&context->buffer[SHA256_SHORT_BLOCK_LENGTH] = context->bitcount; sha2_word64* p = (sha2_word64*) &context->buffer[SHA256_SHORT_BLOCK_LENGTH];
p[0] = context->bitcount;
/* Final transform: */ /* Final transform: */
SHA256_Transform(context, (sha2_word32*)context->buffer); SHA256_Transform(context, (sha2_word32*)context->buffer);
@ -923,8 +924,9 @@ void SHA512_Last(SHA512_CTX* context) {
*context->buffer = 0x80; *context->buffer = 0x80;
} }
/* Store the length of input data (in bits): */ /* Store the length of input data (in bits): */
*(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LENGTH] = context->bitcount[1]; sha2_word64* p = (sha2_word64*) &context->buffer[SHA512_SHORT_BLOCK_LENGTH];
*(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LENGTH+8] = context->bitcount[0]; p[0] = context->bitcount[1];
p[1] = context->bitcount[0];
/* Final transform: */ /* Final transform: */
SHA512_Transform(context, (sha2_word64*)context->buffer); SHA512_Transform(context, (sha2_word64*)context->buffer);