aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/modes/ccm128.c
diff options
context:
space:
mode:
authorAndy Polyakov <appro@openssl.org>2011-04-18 19:17:28 +0000
committerAndy Polyakov <appro@openssl.org>2011-04-18 19:17:28 +0000
commit5f1b10ed2eec3978d374151287ef4f50c3ebf2d5 (patch)
tree193febb368da6d4cc09626308be30acdfd32c407 /crypto/modes/ccm128.c
parent62dc7ed67c00a81801c7a3a7d37e54b2b7b04106 (diff)
downloadopenssl-5f1b10ed2eec3978d374151287ef4f50c3ebf2d5.tar.gz
ccm128.c: fix STRICT_ALIGNMENT another bug in CRYPTO_ccm128_decrypt.
Diffstat (limited to 'crypto/modes/ccm128.c')
-rw-r--r--crypto/modes/ccm128.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/crypto/modes/ccm128.c b/crypto/modes/ccm128.c
index 943b8bab91..ad822c8fa8 100644
--- a/crypto/modes/ccm128.c
+++ b/crypto/modes/ccm128.c
@@ -262,13 +262,16 @@ int CRYPTO_ccm128_decrypt(CCM128_CONTEXT *ctx,
if (n!=len) return -1;
while (len>=16) {
+#if defined(STRICT_ALIGNMENT)
+ union { u64 u[2]; u8 c[16]; } temp;
+#endif
(*block)(ctx->nonce.c,scratch.c,ctx->key);
ctr128_inc(ctx->nonce.c);
#if defined(STRICT_ALIGNMENT)
- memcpy (ctx->inp.c,inp,16);
- for (i=0; i<16/sizeof(size_t); ++i)
- ctx->cmac.s[i] ^= (scratch.s[i] ^= ctx->inp.s[i]);
- memcpy (out,scratch,16);
+ memcpy (temp.c,inp,16);
+ ctx->cmac.u[0] ^= (scratch.u[0] ^= temp.u[0]);
+ ctx->cmac.u[1] ^= (scratch.u[1] ^= temp.u[1]);
+ memcpy (out,scratch.c,16);
#else
ctx->cmac.u[0] ^= (((u64*)out)[0] = scratch.u[0]^((u64*)inp)[0]);
ctx->cmac.u[1] ^= (((u64*)out)[1] = scratch.u[1]^((u64*)inp)[1]);