- Removed code breaking strict-aliasing

This commit is contained in:
Paul Bakker 2012-10-23 11:49:05 +00:00
parent 2b6af2fbf0
commit 67f9d534ee

View File

@ -226,12 +226,6 @@ int gcm_crypt_and_tag( gcm_context *ctx,
{
use_len = ( iv_len < 16 ) ? iv_len : 16;
if( use_len == 16 )
{
((uint64_t *) y)[0] ^= ((uint64_t *) p)[0];
((uint64_t *) y)[1] ^= ((uint64_t *) p)[1];
}
else
for( i = 0; i < use_len; i++ )
y[i] ^= p[i];
@ -241,8 +235,8 @@ int gcm_crypt_and_tag( gcm_context *ctx,
p += use_len;
}
((uint64_t *) y)[0] ^= ((uint64_t *) work_buf)[0];
((uint64_t *) y)[1] ^= ((uint64_t *) work_buf)[1];
for( i = 0; i < 16; i++ )
y[i] ^= work_buf[i];
gcm_mult( ctx, y, y );
}
@ -255,12 +249,6 @@ int gcm_crypt_and_tag( gcm_context *ctx,
{
use_len = ( add_len < 16 ) ? add_len : 16;
if( use_len == 16 )
{
((uint64_t *) buf)[0] ^= ((uint64_t *) p)[0];
((uint64_t *) buf)[1] ^= ((uint64_t *) p)[1];
}
else
for( i = 0; i < use_len; i++ )
buf[i] ^= p[i];
@ -281,17 +269,6 @@ int gcm_crypt_and_tag( gcm_context *ctx,
aes_crypt_ecb( &ctx->aes_ctx, AES_ENCRYPT, y, ectr );
if( use_len == 16 )
{
((uint64_t *) out_p)[0] = ((uint64_t *) ectr)[0] ^
((uint64_t *) p)[0];
((uint64_t *) buf)[0] ^= ((uint64_t *) (*xor_p))[0];
((uint64_t *) out_p)[1] = ((uint64_t *) ectr)[1] ^
((uint64_t *) p)[1];
((uint64_t *) buf)[1] ^= ((uint64_t *) (*xor_p))[1];
}
else
for( i = 0; i < use_len; i++ )
{
out_p[i] = ectr[i] ^ p[i];
@ -312,17 +289,11 @@ int gcm_crypt_and_tag( gcm_context *ctx,
PUT_UINT32_BE( orig_add_len , work_buf, 4 );
PUT_UINT32_BE( orig_len , work_buf, 12 );
((uint64_t *) buf)[0] ^= ((uint64_t *) work_buf)[0];
((uint64_t *) buf)[1] ^= ((uint64_t *) work_buf)[1];
for( i = 0; i < 16; i++ )
buf[i] ^= work_buf[i];
gcm_mult( ctx, buf, buf );
if( tag_len == 16 )
{
((uint64_t *) tag)[0] ^= ((uint64_t *) buf)[0];
((uint64_t *) tag)[1] ^= ((uint64_t *) buf)[1];
}
else
for( i = 0; i < tag_len; i++ )
tag[i] ^= buf[i];
}