Fixed gcc warnings for the sha2 driver.
authorFranck Joncourt <franck@debian.org>
Mon, 28 Jan 2013 20:47:57 +0000 (21:47 +0100)
committerFranck Joncourt <franck@debian.org>
Mon, 28 Jan 2013 20:47:57 +0000 (21:47 +0100)
lib/sha2.c

index 6c07934..997c824 100644 (file)
@@ -624,7 +624,7 @@ void SHA256_Final(sha2_byte digest[], SHA256_CTX* context) {
                        *context->buffer = 0x80;
                }
                /* Set the bit count: */
-               *(sha2_word64*)&context->buffer[SHA256_SHORT_BLOCK_LEN] = context->bitcount;
+                memcpy(&(context->buffer[SHA256_SHORT_BLOCK_LEN]), &(context->bitcount), sizeof(sha2_word64));
 
                /* Final transform: */
                SHA256_Transform(context, (sha2_word32*)context->buffer);
@@ -941,8 +941,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_LEN] = context->bitcount[1];
-       *(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LEN+8] = context->bitcount[0];
+        memcpy(&(context->buffer[SHA512_SHORT_BLOCK_LEN]),   &(context->bitcount[1]), sizeof(sha2_word64));
+        memcpy(&(context->buffer[SHA512_SHORT_BLOCK_LEN+8]), &(context->bitcount[0]), sizeof(sha2_word64));
 
        /* Final transform: */
        SHA512_Transform(context, (sha2_word64*)context->buffer);