Skip to content

Commit

Permalink
Fix build on x32
Browse files Browse the repository at this point in the history
* `CONSTPTR()` must be 32bit.
* `CRYPT_HASH_OVERFLOW` test operates on `unsigned long`, which is only
  32bit wide on x32.

Signed-off-by: Steffen Jaeckel <[email protected]>
  • Loading branch information
sjaeckel committed Dec 11, 2024
1 parent e487f84 commit d96605b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/headers/tomcrypt_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
3 changes: 2 additions & 1 deletion src/headers/tomcrypt_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/multi_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit d96605b

Please sign in to comment.