Clear alignment warnings on ARM 32-bit platforms

pull/828/head
Jeffrey Walton 2019-04-29 22:40:07 -04:00
parent 6c60e2cd1d
commit b9fe3a3415
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
4 changed files with 76 additions and 25 deletions

View File

@ -43,19 +43,31 @@
# undef CRYPTOPP_ALTIVEC_AVAILABLE # undef CRYPTOPP_ALTIVEC_AVAILABLE
#endif #endif
#if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64)
const unsigned int ALIGN_SPEC32=16;
const unsigned int ALIGN_SPEC64=16;
#elif (CRYPTOPP_CXX11_ALIGNOF)
const unsigned int ALIGN_SPEC32=alignof(CryptoPP::word32);
const unsigned int ALIGN_SPEC64=alignof(CryptoPP::word64);
#else
// Can't use GetAlignmentOf<word64>() because of C++11 constexpr
const unsigned int ALIGN_SPEC32=4;
const unsigned int ALIGN_SPEC64=8;
#endif
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
// Export the tables to the SIMD files // Export the tables to the SIMD files
extern const word32 BLAKE2S_IV[8]; extern const word32 BLAKE2S_IV[8];
extern const word64 BLAKE2B_IV[8]; extern const word64 BLAKE2B_IV[8];
CRYPTOPP_ALIGN_DATA(16) CRYPTOPP_ALIGN_DATA(ALIGN_SPEC32)
const word32 BLAKE2S_IV[8] = { const word32 BLAKE2S_IV[8] = {
0x6A09E667UL, 0xBB67AE85UL, 0x3C6EF372UL, 0xA54FF53AUL, 0x6A09E667UL, 0xBB67AE85UL, 0x3C6EF372UL, 0xA54FF53AUL,
0x510E527FUL, 0x9B05688CUL, 0x1F83D9ABUL, 0x5BE0CD19UL 0x510E527FUL, 0x9B05688CUL, 0x1F83D9ABUL, 0x5BE0CD19UL
}; };
CRYPTOPP_ALIGN_DATA(16) CRYPTOPP_ALIGN_DATA(ALIGN_SPEC64)
const word64 BLAKE2B_IV[8] = { const word64 BLAKE2B_IV[8] = {
W64LIT(0x6a09e667f3bcc908), W64LIT(0xbb67ae8584caa73b), W64LIT(0x6a09e667f3bcc908), W64LIT(0xbb67ae8584caa73b),
W64LIT(0x3c6ef372fe94f82b), W64LIT(0xa54ff53a5f1d36f1), W64LIT(0x3c6ef372fe94f82b), W64LIT(0xa54ff53a5f1d36f1),
@ -72,7 +84,7 @@ using CryptoPP::word32;
using CryptoPP::word64; using CryptoPP::word64;
using CryptoPP::rotrConstant; using CryptoPP::rotrConstant;
CRYPTOPP_ALIGN_DATA(16) CRYPTOPP_ALIGN_DATA(ALIGN_SPEC32)
const byte BLAKE2S_SIGMA[10][16] = { const byte BLAKE2S_SIGMA[10][16] = {
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 }, { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 },
@ -86,7 +98,7 @@ const byte BLAKE2S_SIGMA[10][16] = {
{ 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13 , 0 }, { 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13 , 0 },
}; };
CRYPTOPP_ALIGN_DATA(16) CRYPTOPP_ALIGN_DATA(ALIGN_SPEC32)
const byte BLAKE2B_SIGMA[12][16] = { const byte BLAKE2B_SIGMA[12][16] = {
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 },
{ 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 }, { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 },

View File

@ -37,6 +37,19 @@
// Squash MS LNK4221 and libtool warnings // Squash MS LNK4221 and libtool warnings
extern const char DONNA32_FNAME[] = __FILE__; extern const char DONNA32_FNAME[] = __FILE__;
ANONYMOUS_NAMESPACE_BEGIN
#if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64)
const unsigned int ALIGN_SPEC=16;
#elif (CRYPTOPP_CXX11_ALIGNOF)
const unsigned int ALIGN_SPEC=alignof(CryptoPP::word32);
#else
// Can't use GetAlignmentOf<word32>() because of C++11 constexpr
const unsigned int ALIGN_SPEC=4;
#endif
ANONYMOUS_NAMESPACE_END
#if defined(CRYPTOPP_CURVE25519_32BIT) #if defined(CRYPTOPP_CURVE25519_32BIT)
#include "donna_32.h" #include "donna_32.h"
@ -431,7 +444,7 @@ curve25519_swap_conditional(bignum25519 x, bignum25519 qpx, word32 iswap) {
*/ */
void void
curve25519_pow_two5mtwo0_two250mtwo0(bignum25519 b) { curve25519_pow_two5mtwo0_two250mtwo0(bignum25519 b) {
ALIGN(16) bignum25519 t0,c; ALIGN(ALIGN_SPEC) bignum25519 t0,c;
/* 2^5 - 2^0 */ /* b */ /* 2^5 - 2^0 */ /* b */
/* 2^10 - 2^5 */ curve25519_square_times(t0, b, 5); /* 2^10 - 2^5 */ curve25519_square_times(t0, b, 5);
@ -455,7 +468,7 @@ curve25519_pow_two5mtwo0_two250mtwo0(bignum25519 b) {
*/ */
void void
curve25519_recip(bignum25519 out, const bignum25519 z) { curve25519_recip(bignum25519 out, const bignum25519 z) {
ALIGN(16) bignum25519 a, t0, b; ALIGN(ALIGN_SPEC) bignum25519 a, t0, b;
/* 2 */ curve25519_square(a, z); /* a = 2 */ /* 2 */ curve25519_square(a, z); /* a = 2 */
/* 8 */ curve25519_square_times(t0, a, 2); /* 8 */ curve25519_square_times(t0, a, 2);
@ -967,7 +980,7 @@ curve25519_swap_conditional(bignum25519 a, bignum25519 b, word32 iswap) {
*/ */
void void
curve25519_pow_two5mtwo0_two250mtwo0(bignum25519 b) { curve25519_pow_two5mtwo0_two250mtwo0(bignum25519 b) {
ALIGN(16) bignum25519 t0,c; ALIGN(ALIGN_SPEC) bignum25519 t0,c;
/* 2^5 - 2^0 */ /* b */ /* 2^5 - 2^0 */ /* b */
/* 2^10 - 2^5 */ curve25519_square_times(t0, b, 5); /* 2^10 - 2^5 */ curve25519_square_times(t0, b, 5);
@ -991,7 +1004,7 @@ curve25519_pow_two5mtwo0_two250mtwo0(bignum25519 b) {
*/ */
void void
curve25519_recip(bignum25519 out, const bignum25519 z) { curve25519_recip(bignum25519 out, const bignum25519 z) {
ALIGN(16) bignum25519 a,t0,b; ALIGN(ALIGN_SPEC) bignum25519 a,t0,b;
/* 2 */ curve25519_square_times(a, z, 1); /* a = 2 */ /* 2 */ curve25519_square_times(a, z, 1); /* a = 2 */
/* 8 */ curve25519_square_times(t0, a, 2); /* 8 */ curve25519_square_times(t0, a, 2);
@ -1009,7 +1022,7 @@ curve25519_recip(bignum25519 out, const bignum25519 z) {
*/ */
void void
curve25519_pow_two252m3(bignum25519 two252m3, const bignum25519 z) { curve25519_pow_two252m3(bignum25519 two252m3, const bignum25519 z) {
ALIGN(16) bignum25519 b,c,t0; ALIGN(ALIGN_SPEC) bignum25519 b,c,t0;
/* 2 */ curve25519_square_times(c, z, 1); /* c = 2 */ /* 2 */ curve25519_square_times(c, z, 1); /* c = 2 */
/* 8 */ curve25519_square_times(t0, c, 2); /* t0 = 8 */ /* 8 */ curve25519_square_times(t0, c, 2); /* t0 = 8 */
@ -1865,7 +1878,7 @@ ed25519_publickey_CXX(byte publicKey[32], const byte secretKey[32])
using namespace CryptoPP::Donna::Ed25519; using namespace CryptoPP::Donna::Ed25519;
bignum256modm a; bignum256modm a;
ALIGN(16) ge25519 A; ALIGN(ALIGN_SPEC) ge25519 A;
hash_512bits extsk; hash_512bits extsk;
/* A = aB */ /* A = aB */
@ -1889,7 +1902,7 @@ ed25519_sign_CXX(std::istream& stream, const byte sk[32], const byte pk[32], byt
using namespace CryptoPP::Donna::Ed25519; using namespace CryptoPP::Donna::Ed25519;
bignum256modm r, S, a; bignum256modm r, S, a;
ALIGN(16) ge25519 R; ALIGN(ALIGN_SPEC) ge25519 R;
hash_512bits extsk, hashr, hram; hash_512bits extsk, hashr, hram;
// Unfortunately we need to read the stream twice. The fisrt time calculates // Unfortunately we need to read the stream twice. The fisrt time calculates
@ -1938,7 +1951,7 @@ ed25519_sign_CXX(const byte *m, size_t mlen, const byte sk[32], const byte pk[32
using namespace CryptoPP::Donna::Ed25519; using namespace CryptoPP::Donna::Ed25519;
bignum256modm r, S, a; bignum256modm r, S, a;
ALIGN(16) ge25519 R; ALIGN(ALIGN_SPEC) ge25519 R;
hash_512bits extsk, hashr, hram; hash_512bits extsk, hashr, hram;
ed25519_extsk(extsk, sk); ed25519_extsk(extsk, sk);
@ -1990,7 +2003,7 @@ ed25519_sign_open_CXX(std::istream& stream, const byte pk[32], const byte RS[64]
using namespace CryptoPP::Donna::Ed25519; using namespace CryptoPP::Donna::Ed25519;
ALIGN(16) ge25519 R, A; ALIGN(ALIGN_SPEC) ge25519 R, A;
hash_512bits hash; hash_512bits hash;
bignum256modm hram, S; bignum256modm hram, S;
byte checkR[32]; byte checkR[32];
@ -2018,7 +2031,7 @@ ed25519_sign_open_CXX(const byte *m, size_t mlen, const byte pk[32], const byte
using namespace CryptoPP::Donna::Ed25519; using namespace CryptoPP::Donna::Ed25519;
ALIGN(16) ge25519 R, A; ALIGN(ALIGN_SPEC) ge25519 R, A;
hash_512bits hash; hash_512bits hash;
bignum256modm hram, S; bignum256modm hram, S;
byte checkR[32]; byte checkR[32];

View File

@ -37,6 +37,19 @@
// Squash MS LNK4221 and libtool warnings // Squash MS LNK4221 and libtool warnings
extern const char DONNA64_FNAME[] = __FILE__; extern const char DONNA64_FNAME[] = __FILE__;
ANONYMOUS_NAMESPACE_BEGIN
#if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64)
const unsigned int ALIGN_SPEC=16;
#elif (CRYPTOPP_CXX11_ALIGNOF)
const unsigned int ALIGN_SPEC=alignof(CryptoPP::word64);
#else
// Can't use GetAlignmentOf<word64>() because of C++11 constexpr
const unsigned int ALIGN_SPEC=8;
#endif
ANONYMOUS_NAMESPACE_END
#if defined(CRYPTOPP_CURVE25519_64BIT) #if defined(CRYPTOPP_CURVE25519_64BIT)
#include "donna_64.h" #include "donna_64.h"
@ -359,7 +372,7 @@ curve25519_swap_conditional(bignum25519 x, bignum25519 qpx, word64 iswap) {
*/ */
void void
curve25519_pow_two5mtwo0_two250mtwo0(bignum25519 b) { curve25519_pow_two5mtwo0_two250mtwo0(bignum25519 b) {
ALIGN(16) bignum25519 t0,c; ALIGN(ALIGN_SPEC) bignum25519 t0,c;
/* 2^5 - 2^0 */ /* b */ /* 2^5 - 2^0 */ /* b */
/* 2^10 - 2^5 */ curve25519_square_times(t0, b, 5); /* 2^10 - 2^5 */ curve25519_square_times(t0, b, 5);
@ -383,7 +396,7 @@ curve25519_pow_two5mtwo0_two250mtwo0(bignum25519 b) {
*/ */
void void
curve25519_recip(bignum25519 out, const bignum25519 z) { curve25519_recip(bignum25519 out, const bignum25519 z) {
ALIGN(16) bignum25519 a, t0, b; ALIGN(ALIGN_SPEC) bignum25519 a, t0, b;
/* 2 */ curve25519_square(a, z); /* a = 2 */ /* 2 */ curve25519_square(a, z); /* a = 2 */
/* 8 */ curve25519_square_times(t0, a, 2); /* 8 */ curve25519_square_times(t0, a, 2);
@ -1065,7 +1078,7 @@ contract256_slidingwindow_modm(signed char r[256], const bignum256modm s, int wi
*/ */
void void
curve25519_pow_two5mtwo0_two250mtwo0(bignum25519 b) { curve25519_pow_two5mtwo0_two250mtwo0(bignum25519 b) {
ALIGN(16) bignum25519 t0,c; ALIGN(ALIGN_SPEC) bignum25519 t0,c;
/* 2^5 - 2^0 */ /* b */ /* 2^5 - 2^0 */ /* b */
/* 2^10 - 2^5 */ curve25519_square_times(t0, b, 5); /* 2^10 - 2^5 */ curve25519_square_times(t0, b, 5);
@ -1089,7 +1102,7 @@ curve25519_pow_two5mtwo0_two250mtwo0(bignum25519 b) {
*/ */
void void
curve25519_recip(bignum25519 out, const bignum25519 z) { curve25519_recip(bignum25519 out, const bignum25519 z) {
ALIGN(16) bignum25519 a,t0,b; ALIGN(ALIGN_SPEC) bignum25519 a,t0,b;
/* 2 */ curve25519_square_times(a, z, 1); /* a = 2 */ /* 2 */ curve25519_square_times(a, z, 1); /* a = 2 */
/* 8 */ curve25519_square_times(t0, a, 2); /* 8 */ curve25519_square_times(t0, a, 2);
@ -1107,7 +1120,7 @@ curve25519_recip(bignum25519 out, const bignum25519 z) {
*/ */
void void
curve25519_pow_two252m3(bignum25519 two252m3, const bignum25519 z) { curve25519_pow_two252m3(bignum25519 two252m3, const bignum25519 z) {
ALIGN(16) bignum25519 b,c,t0; ALIGN(ALIGN_SPEC) bignum25519 b,c,t0;
/* 2 */ curve25519_square_times(c, z, 1); /* c = 2 */ /* 2 */ curve25519_square_times(c, z, 1); /* c = 2 */
/* 8 */ curve25519_square_times(t0, c, 2); /* t0 = 8 */ /* 8 */ curve25519_square_times(t0, c, 2); /* t0 = 8 */
@ -1580,7 +1593,7 @@ ed25519_publickey_CXX(byte publicKey[32], const byte secretKey[32])
using namespace CryptoPP::Donna::Ed25519; using namespace CryptoPP::Donna::Ed25519;
bignum256modm a; bignum256modm a;
ALIGN(16) ge25519 A; ALIGN(ALIGN_SPEC) ge25519 A;
hash_512bits extsk; hash_512bits extsk;
/* A = aB */ /* A = aB */
@ -1604,7 +1617,7 @@ ed25519_sign_CXX(std::istream& stream, const byte sk[32], const byte pk[32], byt
using namespace CryptoPP::Donna::Ed25519; using namespace CryptoPP::Donna::Ed25519;
bignum256modm r, S, a; bignum256modm r, S, a;
ALIGN(16) ge25519 R; ALIGN(ALIGN_SPEC) ge25519 R;
hash_512bits extsk, hashr, hram; hash_512bits extsk, hashr, hram;
// Unfortunately we need to read the stream twice. The fisrt time calculates // Unfortunately we need to read the stream twice. The fisrt time calculates
@ -1652,7 +1665,7 @@ ed25519_sign_CXX(const byte *m, size_t mlen, const byte sk[32], const byte pk[32
using namespace CryptoPP::Donna::Ed25519; using namespace CryptoPP::Donna::Ed25519;
bignum256modm r, S, a; bignum256modm r, S, a;
ALIGN(16) ge25519 R; ALIGN(ALIGN_SPEC) ge25519 R;
hash_512bits extsk, hashr, hram; hash_512bits extsk, hashr, hram;
ed25519_extsk(extsk, sk); ed25519_extsk(extsk, sk);
@ -1703,7 +1716,7 @@ ed25519_sign_open_CXX(const byte *m, size_t mlen, const byte pk[32], const byte
using namespace CryptoPP::Donna::Ed25519; using namespace CryptoPP::Donna::Ed25519;
ALIGN(16) ge25519 R, A; ALIGN(ALIGN_SPEC) ge25519 R, A;
hash_512bits hash; hash_512bits hash;
bignum256modm hram, S; bignum256modm hram, S;
byte checkR[32]; byte checkR[32];
@ -1731,7 +1744,7 @@ ed25519_sign_open_CXX(std::istream& stream, const byte pk[32], const byte RS[64]
using namespace CryptoPP::Donna::Ed25519; using namespace CryptoPP::Donna::Ed25519;
ALIGN(16) ge25519 R, A; ALIGN(ALIGN_SPEC) ge25519 R, A;
hash_512bits hash; hash_512bits hash;
bignum256modm hram, S; bignum256modm hram, S;
byte checkR[32]; byte checkR[32];

View File

@ -26,6 +26,19 @@
# undef CRYPTOPP_SSSE3_ASM_AVAILABLE # undef CRYPTOPP_SSSE3_ASM_AVAILABLE
#endif #endif
ANONYMOUS_NAMESPACE_BEGIN
#if (CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64)
const unsigned int ALIGN_SPEC=16;
#elif (CRYPTOPP_CXX11_ALIGNOF)
const unsigned int ALIGN_SPEC=alignof(CryptoPP::word32);
#else
// Can't use GetAlignmentOf<word32>() because of C++11 constexpr
const unsigned int ALIGN_SPEC=4;
#endif
ANONYMOUS_NAMESPACE_END
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
#if defined(CRYPTOPP_DEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) #if defined(CRYPTOPP_DEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
@ -41,7 +54,7 @@ void Salsa20_Core(word32* data, unsigned int rounds)
CRYPTOPP_ASSERT(data != NULLPTR); CRYPTOPP_ASSERT(data != NULLPTR);
CRYPTOPP_ASSERT(rounds % 2 == 0); CRYPTOPP_ASSERT(rounds % 2 == 0);
CRYPTOPP_ALIGN_DATA(16) word32 x[16]; CRYPTOPP_ALIGN_DATA(ALIGN_SPEC) word32 x[16];
for (size_t i = 0; i < 16; ++i) for (size_t i = 0; i < 16; ++i)
x[i] = data[i]; x[i] = data[i];