More strict aliasing fix.

This commit is contained in:
Ben Laurie 2012-11-05 14:23:55 +00:00
parent 7c43ea50fd
commit da01515c40
2 changed files with 6 additions and 5 deletions

View File

@ -962,15 +962,16 @@ int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx,
size_t j=GHASH_CHUNK; size_t j=GHASH_CHUNK;
while (j) { 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); (*block)(ctx->Yi.c,ctx->EKi.c,key);
++ctr; ++ctr;
if (is_endian.little) if (is_endian.little)
PUTU32(ctx->Yi.c+12,ctr); PUTU32(ctx->Yi.c+12,ctr);
else else
ctx->Yi.d[3] = ctr; ctx->Yi.d[3] = ctr;
for (i=0; i<16; i+=sizeof(size_t)) for (i=0; i<16/sizeof(size_t); ++i)
*(size_t *)(out+i) = out_t[i] = in_t[i] ^ ctx->EKi.t[i];
*(size_t *)(in+i)^*(size_t *)(ctx->EKi.c+i);
out += 16; out += 16;
in += 16; in += 16;
j -= 16; j -= 16;

View File

@ -101,8 +101,8 @@ typedef struct { u64 hi,lo; } u128;
struct gcm128_context { struct gcm128_context {
/* Following 6 names follow names in GCM specification */ /* Following 6 names follow names in GCM specification */
union { u64 u[2]; u32 d[4]; u8 c[16]; } Yi,EKi,EK0,len, union { u64 u[2]; u32 d[4]; u8 c[16]; size_t t[16/sizeof(size_t)]; }
Xi,H; Yi,EKi,EK0,len,Xi,H;
/* Relative position of Xi, H and pre-computed Htable is used /* Relative position of Xi, H and pre-computed Htable is used
* in some assembler modules, i.e. don't change the order! */ * in some assembler modules, i.e. don't change the order! */
#if TABLE_BITS==8 #if TABLE_BITS==8