summaryrefslogtreecommitdiff
path: root/donna_32.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2019-04-29 22:40:07 -0400
committerJeffrey Walton <noloader@gmail.com>2019-04-29 22:40:07 -0400
commitb9fe3a3415e751897fe148dae50dcad92e02e993 (patch)
tree62f08347d4d7bf47fb4666f21346018d0ae22577 /donna_32.cpp
parent6c60e2cd1db2d00c40bbc201786bba07851bfdd1 (diff)
downloadcryptopp-git-b9fe3a3415e751897fe148dae50dcad92e02e993.tar.gz
Clear alignment warnings on ARM 32-bit platforms
Diffstat (limited to 'donna_32.cpp')
-rw-r--r--donna_32.cpp33
1 files changed, 23 insertions, 10 deletions
diff --git a/donna_32.cpp b/donna_32.cpp
index 25227ff7..2fc72e9a 100644
--- a/donna_32.cpp
+++ b/donna_32.cpp
@@ -37,6 +37,19 @@
// Squash MS LNK4221 and libtool warnings
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)
#include "donna_32.h"
@@ -431,7 +444,7 @@ curve25519_swap_conditional(bignum25519 x, bignum25519 qpx, word32 iswap) {
*/
void
curve25519_pow_two5mtwo0_two250mtwo0(bignum25519 b) {
- ALIGN(16) bignum25519 t0,c;
+ ALIGN(ALIGN_SPEC) bignum25519 t0,c;
/* 2^5 - 2^0 */ /* b */
/* 2^10 - 2^5 */ curve25519_square_times(t0, b, 5);
@@ -455,7 +468,7 @@ curve25519_pow_two5mtwo0_two250mtwo0(bignum25519 b) {
*/
void
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 */
/* 8 */ curve25519_square_times(t0, a, 2);
@@ -967,7 +980,7 @@ curve25519_swap_conditional(bignum25519 a, bignum25519 b, word32 iswap) {
*/
void
curve25519_pow_two5mtwo0_two250mtwo0(bignum25519 b) {
- ALIGN(16) bignum25519 t0,c;
+ ALIGN(ALIGN_SPEC) bignum25519 t0,c;
/* 2^5 - 2^0 */ /* b */
/* 2^10 - 2^5 */ curve25519_square_times(t0, b, 5);
@@ -991,7 +1004,7 @@ curve25519_pow_two5mtwo0_two250mtwo0(bignum25519 b) {
*/
void
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 */
/* 8 */ curve25519_square_times(t0, a, 2);
@@ -1009,7 +1022,7 @@ curve25519_recip(bignum25519 out, const bignum25519 z) {
*/
void
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 */
/* 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;
bignum256modm a;
- ALIGN(16) ge25519 A;
+ ALIGN(ALIGN_SPEC) ge25519 A;
hash_512bits extsk;
/* 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;
bignum256modm r, S, a;
- ALIGN(16) ge25519 R;
+ ALIGN(ALIGN_SPEC) ge25519 R;
hash_512bits extsk, hashr, hram;
// 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;
bignum256modm r, S, a;
- ALIGN(16) ge25519 R;
+ ALIGN(ALIGN_SPEC) ge25519 R;
hash_512bits extsk, hashr, hram;
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;
- ALIGN(16) ge25519 R, A;
+ ALIGN(ALIGN_SPEC) ge25519 R, A;
hash_512bits hash;
bignum256modm hram, S;
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;
- ALIGN(16) ge25519 R, A;
+ ALIGN(ALIGN_SPEC) ge25519 R, A;
hash_512bits hash;
bignum256modm hram, S;
byte checkR[32];