Better fix to alignment issue
This commit is contained in:
@@ -178,14 +178,12 @@ string Session::encrypt( Message plaintext )
|
|||||||
|
|
||||||
memcpy( pt, plaintext.text.data(), plaintext.text.size() );
|
memcpy( pt, plaintext.text.data(), plaintext.text.size() );
|
||||||
|
|
||||||
Nonce __attribute__((__aligned__ (16))) nonce( plaintext.nonce );
|
if ( (uint64_t( plaintext.nonce.data() ) & 0xf) != 0 ) {
|
||||||
|
|
||||||
if ( (uint64_t( nonce.data() ) & 0xf) != 0 ) {
|
|
||||||
throw CryptoException( "Bad alignment." );
|
throw CryptoException( "Bad alignment." );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ciphertext_len != ae_encrypt( ctx, /* ctx */
|
if ( ciphertext_len != ae_encrypt( ctx, /* ctx */
|
||||||
nonce.data(), /* nonce */
|
plaintext.nonce.data(), /* nonce */
|
||||||
pt, /* pt */
|
pt, /* pt */
|
||||||
pt_len, /* pt_len */
|
pt_len, /* pt_len */
|
||||||
NULL, /* ad */
|
NULL, /* ad */
|
||||||
|
|||||||
+1
-1
@@ -48,7 +48,7 @@ namespace Crypto {
|
|||||||
|
|
||||||
class Nonce {
|
class Nonce {
|
||||||
private:
|
private:
|
||||||
char bytes[ 12 ];
|
char bytes[ 12 ] __attribute__((__aligned__ (16)));
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Nonce( uint64_t val );
|
Nonce( uint64_t val );
|
||||||
|
|||||||
Reference in New Issue
Block a user