From d96605b4b90d72012a21400cac54ff1b5d94611f Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Tue, 3 Dec 2024 21:13:31 +0100 Subject: [PATCH] Fix build on x32 * `CONSTPTR()` must be 32bit. * `CRYPT_HASH_OVERFLOW` test operates on `unsigned long`, which is only 32bit wide on x32. Signed-off-by: Steffen Jaeckel --- src/headers/tomcrypt_cfg.h | 3 +++ src/headers/tomcrypt_private.h | 3 ++- tests/multi_test.c | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/headers/tomcrypt_cfg.h b/src/headers/tomcrypt_cfg.h index 294b6bd44..c6c1fe13c 100644 --- a/src/headers/tomcrypt_cfg.h +++ b/src/headers/tomcrypt_cfg.h @@ -91,6 +91,9 @@ LTC_EXPORT int LTC_CALL XSTRCMP(const char *s1, const char *s2); #define ENDIAN_LITTLE #define ENDIAN_64BITWORD #define LTC_FAST + #if defined(_ILP32) || defined(__ILP32__) + #define ENDIAN_64BITWORD_X32 + #endif #endif /* detect PPC32 */ diff --git a/src/headers/tomcrypt_private.h b/src/headers/tomcrypt_private.h index de9f81ccc..8c6d8a7ba 100644 --- a/src/headers/tomcrypt_private.h +++ b/src/headers/tomcrypt_private.h @@ -11,7 +11,8 @@ #define LTC_PAD_MASK (0xF000U) -#if defined(ENDIAN_64BITWORD) +/* only real 64bit, not x32 */ +#if defined(ENDIAN_64BITWORD) && !defined(ENDIAN_64BITWORD_X32) #define CONSTPTR(n) CONST64(n) #else #define CONSTPTR(n) n ## uL diff --git a/tests/multi_test.c b/tests/multi_test.c index dc4649804..99b055a54 100644 --- a/tests/multi_test.c +++ b/tests/multi_test.c @@ -15,7 +15,7 @@ int multi_test(void) /* HASH testing */ len = sizeof(buf[0]); -#if defined(ENDIAN_32BITWORD) || defined(_WIN32) +#if defined(ENDIAN_32BITWORD) || defined(_WIN32) || defined(ENDIAN_64BITWORD_X32) len2 = 0x80000000UL; #else /* Check against the max. input limit of SHA-1 as of RFC8017 */