1
0
mirror of https://github.com/biergaizi/codecrypt synced 2024-06-25 00:08:20 +00:00

sha2: fix the ugly warning

memcpy() is better than dereferencing a type-punned-pointer for
simulating memcpy()
This commit is contained in:
Mirek Kratochvil 2013-05-25 17:44:27 +02:00
parent 7270e90cf1
commit 0980ee827a

@ -609,7 +609,8 @@ void 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;
MEMCPY_BCOPY (context->buffer + SHA256_SHORT_BLOCK_LENGTH, &context->bitcount, 8);
/* Final transform: */
SHA256_Transform (context, (sha2_word32*) context->buffer);
@ -933,8 +934,8 @@ void SHA512_Last (SHA512_CTX* context)
*context->buffer = 0x80;
}
/* Store the length of input data (in bits): */
* (sha2_word64*) &context->buffer[SHA512_SHORT_BLOCK_LENGTH] = context->bitcount[1];
* (sha2_word64*) &context->buffer[SHA512_SHORT_BLOCK_LENGTH + 8] = context->bitcount[0];
MEMCPY_BCOPY (context->buffer + SHA512_SHORT_BLOCK_LENGTH, context->bitcount+1, 8);
MEMCPY_BCOPY (context->buffer + SHA512_SHORT_BLOCK_LENGTH + 8, context->bitcount, 8);
/* Final transform: */
SHA512_Transform (context, (sha2_word64*) context->buffer);