From b06204e72b6b6759c17f3264b2ff3c5349c3ef78 Mon Sep 17 00:00:00 2001 From: Keith Winstein Date: Sun, 19 Feb 2012 21:48:59 -0500 Subject: [PATCH] Fix alignment problem under clang (per nelhage) --- src/crypto/crypto.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/crypto/crypto.cc b/src/crypto/crypto.cc index e5ee202..49e0852 100644 --- a/src/crypto/crypto.cc +++ b/src/crypto/crypto.cc @@ -178,12 +178,14 @@ string Session::encrypt( Message plaintext ) memcpy( pt, plaintext.text.data(), plaintext.text.size() ); - if ( (uint64_t( plaintext.nonce.data() ) & 0xf) != 0 ) { + Nonce __attribute__((__aligned__ (16))) nonce( plaintext.nonce ); + + if ( (uint64_t( nonce.data() ) & 0xf) != 0 ) { throw CryptoException( "Bad alignment." ); } if ( ciphertext_len != ae_encrypt( ctx, /* ctx */ - plaintext.nonce.data(), /* nonce */ + nonce.data(), /* nonce */ pt, /* pt */ pt_len, /* pt_len */ NULL, /* ad */