More strict aliasing fix.
authorBen Laurie <ben@openssl.org>
Mon, 5 Nov 2012 14:23:55 +0000 (14:23 +0000)
committerBen Laurie <ben@openssl.org>
Mon, 5 Nov 2012 14:23:55 +0000 (14:23 +0000)
crypto/modes/gcm128.c
crypto/modes/modes_lcl.h

index db576aab2f57ae06ba372bc5dfc6940b03bac8dd..8f5ce988585f13ccab0c5f3498db69547e9f58e0 100644 (file)
@@ -962,15 +962,16 @@ int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx,
                    size_t j=GHASH_CHUNK;
 
                    while (j) {
+                       size_t *out_t=(size_t *)out, *ivec_t=(size_t *)ivec;
+                       const size_t *in_t=(const size_t *)in;
                        (*block)(ctx->Yi.c,ctx->EKi.c,key);
                        ++ctr;
                        if (is_endian.little)
                                PUTU32(ctx->Yi.c+12,ctr);
                        else
                                ctx->Yi.d[3] = ctr;
-                       for (i=0; i<16; i+=sizeof(size_t))
-                               *(size_t *)(out+i) =
-                               *(size_t *)(in+i)^*(size_t *)(ctx->EKi.c+i);
+                       for (i=0; i<16/sizeof(size_t); ++i)
+                               out_t[i] = in_t[i] ^ ctx->EKi.t[i];
                        out += 16;
                        in  += 16;
                        j   -= 16;
index b6dc3c336fe09c0c627bc431e7e7089227ebf7d5..40a6d5a6424f5bee3b751a2aabd1c351348266c8 100644 (file)
@@ -101,8 +101,8 @@ typedef struct { u64 hi,lo; } u128;
 
 struct gcm128_context {
        /* Following 6 names follow names in GCM specification */
-       union { u64 u[2]; u32 d[4]; u8 c[16]; } Yi,EKi,EK0,len,
-                                               Xi,H;
+       union { u64 u[2]; u32 d[4]; u8 c[16]; size_t t[16/sizeof(size_t)]; }
+         Yi,EKi,EK0,len,Xi,H;
        /* Relative position of Xi, H and pre-computed Htable is used
         * in some assembler modules, i.e. don't change the order! */
 #if TABLE_BITS==8