--- mosh-1.1.3/src/crypto/crypto.cc Tue Apr 10 08:56:37 2012 +++ mosh-1.1.3-solaris/src/crypto//crypto.cc Tue Apr 10 17:26:04 2012 @@ -152,10 +152,21 @@ ae_free( ctx ); } +static char *align16( char *bytes_block ) +{ + size_t offset = (size_t)(bytes_block - (char *)NULL); + + if ( (offset & 0xf) == 0 ) + return bytes_block; + else + return bytes_block + 16 - ( offset & 15 ); +} + Nonce::Nonce( uint64_t val ) { uint64_t val_net = htobe64( val ); + bytes = align16( bytes_block ); memset( bytes, 0, 4 ); memcpy( bytes + 4, &val_net, 8 ); } @@ -173,6 +184,7 @@ throw CryptoException( "Nonce representation must be 8 octets long." ); } + bytes = align16( bytes_block ); memset( bytes, 0, 4 ); memcpy( bytes + 4, s_bytes, 8 ); } @@ -198,7 +210,7 @@ memcpy( pt, plaintext.text.data(), plaintext.text.size() ); - if ( (uint64_t( plaintext.nonce.data() ) & 0xf) != 0 ) { + if ( (size_t( plaintext.nonce.data() ) & 0xf) != 0 ) { throw CryptoException( "Bad alignment." ); } --- mosh-1.1.3/src/crypto/crypto.h Tue Apr 3 01:08:49 2012 +++ mosh-1.1.3-solaris/src/crypto//crypto.h Tue Apr 10 17:21:27 2012 @@ -50,7 +50,8 @@ class Nonce { private: - char bytes[ 12 ] __attribute__((__aligned__ (16))); + char bytes_block[ 12 + 16 ]; + char *bytes; public: Nonce( uint64_t val );