diff options
author | Amitay Isaacs <amitay@ozlabs.org> | 2021-03-29 18:20:53 +1100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2021-04-08 12:18:09 +0100 |
commit | 5de32f22e731ea151e1c5aac7703cde2573cb4a4 (patch) | |
tree | 19a9a93e24ec4ca4f516e248391dcb3e87801c44 /crypto/ec | |
parent | bbed0d1cbd436af6797d7837e270bff4ca4d5a10 (diff) |
Use numbers definition of int128_t and uint128_t
Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14784)
Diffstat (limited to 'crypto/ec')
-rw-r--r-- | crypto/ec/curve25519.c | 6 | ||||
-rw-r--r-- | crypto/ec/curve448/curve448utils.h | 6 | ||||
-rw-r--r-- | crypto/ec/curve448/word.h | 4 | ||||
-rw-r--r-- | crypto/ec/ecp_nistp224.c | 8 | ||||
-rw-r--r-- | crypto/ec/ecp_nistp256.c | 9 | ||||
-rw-r--r-- | crypto/ec/ecp_nistp521.c | 8 |
6 files changed, 19 insertions, 22 deletions
diff --git a/crypto/ec/curve25519.c b/crypto/ec/curve25519.c index 3f24215047..a291e6f472 100644 --- a/crypto/ec/curve25519.c +++ b/crypto/ec/curve25519.c @@ -19,6 +19,8 @@ #include <openssl/evp.h> #include <openssl/sha.h> +#include "internal/numbers.h" + #if defined(X25519_ASM) && (defined(__x86_64) || defined(__x86_64__) || \ defined(_M_AMD64) || defined(_M_X64)) @@ -260,7 +262,7 @@ static void x25519_scalar_mulx(uint8_t out[32], const uint8_t scalar[32], #endif #if defined(X25519_ASM) \ - || ( (defined(__SIZEOF_INT128__) && __SIZEOF_INT128__ == 16) \ + || ( defined(INT128_MAX) \ && !defined(__sparc__) \ && (!defined(__SIZEOF_LONG__) || (__SIZEOF_LONG__ == 8)) \ && !(defined(__ANDROID__) && !defined(__clang__)) ) @@ -393,7 +395,7 @@ void x25519_fe51_mul121666(fe51 h, fe51 f); # define fe51_mul121666 x25519_fe51_mul121666 # else -typedef __uint128_t u128; +typedef uint128_t u128; static void fe51_mul(fe51 h, const fe51 f, const fe51 g) { diff --git a/crypto/ec/curve448/curve448utils.h b/crypto/ec/curve448/curve448utils.h index fa06cb02ec..fd8ae4de70 100644 --- a/crypto/ec/curve448/curve448utils.h +++ b/crypto/ec/curve448/curve448utils.h @@ -15,6 +15,8 @@ # include <openssl/e_os2.h> +# include "internal/numbers.h" + /* * Internal word types. Somewhat tricky. This could be decided separately per * platform. However, the structs do need to be all the same size and @@ -41,9 +43,9 @@ typedef int64_t c448_sword_t; /* "Boolean" type, will be set to all-zero or all-one (i.e. -1u) */ typedef uint64_t c448_bool_t; /* Double-word size for internal computations */ -typedef __uint128_t c448_dword_t; +typedef uint128_t c448_dword_t; /* Signed double-word size for internal computations */ -typedef __int128_t c448_dsword_t; +typedef int128_t c448_dsword_t; # elif C448_WORD_BITS == 32 /* Word size for internal computations */ typedef uint32_t c448_word_t; diff --git a/crypto/ec/curve448/word.h b/crypto/ec/curve448/word.h index d3e6ff863b..6e007c3735 100644 --- a/crypto/ec/curve448/word.h +++ b/crypto/ec/curve448/word.h @@ -22,10 +22,10 @@ # if (ARCH_WORD_BITS == 64) typedef uint64_t word_t, mask_t; -typedef __uint128_t dword_t; +typedef uint128_t dword_t; typedef int32_t hsword_t; typedef int64_t sword_t; -typedef __int128_t dsword_t; +typedef int128_t dsword_t; # elif (ARCH_WORD_BITS == 32) typedef uint32_t word_t, mask_t; typedef uint64_t dword_t; diff --git a/crypto/ec/ecp_nistp224.c b/crypto/ec/ecp_nistp224.c index c3dc0d9b7d..47f33825ad 100644 --- a/crypto/ec/ecp_nistp224.c +++ b/crypto/ec/ecp_nistp224.c @@ -43,11 +43,9 @@ #include <openssl/err.h> #include "ec_local.h" -#if defined(__SIZEOF_INT128__) && __SIZEOF_INT128__==16 - /* even with gcc, the typedef won't work for 32-bit platforms */ -typedef __uint128_t uint128_t; /* nonstandard; implemented by gcc on 64-bit - * platforms */ -#else +#include "internal/numbers.h" + +#ifndef INT128_MAX # error "Your compiler doesn't appear to support 128-bit integer types" #endif diff --git a/crypto/ec/ecp_nistp256.c b/crypto/ec/ecp_nistp256.c index c865cd7766..67d2dce9b7 100644 --- a/crypto/ec/ecp_nistp256.c +++ b/crypto/ec/ecp_nistp256.c @@ -44,12 +44,9 @@ #include <openssl/err.h> #include "ec_local.h" -#if defined(__SIZEOF_INT128__) && __SIZEOF_INT128__==16 - /* even with gcc, the typedef won't work for 32-bit platforms */ -typedef __uint128_t uint128_t; /* nonstandard; implemented by gcc on 64-bit - * platforms */ -typedef __int128_t int128_t; -#else +#include "internal/numbers.h" + +#ifndef INT128_MAX # error "Your compiler doesn't appear to support 128-bit integer types" #endif diff --git a/crypto/ec/ecp_nistp521.c b/crypto/ec/ecp_nistp521.c index 72468a1d42..694031b45d 100644 --- a/crypto/ec/ecp_nistp521.c +++ b/crypto/ec/ecp_nistp521.c @@ -43,11 +43,9 @@ #include <openssl/err.h> #include "ec_local.h" -#if defined(__SIZEOF_INT128__) && __SIZEOF_INT128__==16 - /* even with gcc, the typedef won't work for 32-bit platforms */ -typedef __uint128_t uint128_t; /* nonstandard; implemented by gcc on 64-bit - * platforms */ -#else +#include "internal/numbers.h" + +#ifndef INT128_MAX # error "Your compiler doesn't appear to support 128-bit integer types" #endif |