diff --git a/crypto/fipsmodule/bn/asm/x86_64-gcc.c b/crypto/fipsmodule/bn/asm/x86_64-gcc.c index 12ffc3f6..bfd770f5 100644 --- a/crypto/fipsmodule/bn/asm/x86_64-gcc.c +++ b/crypto/fipsmodule/bn/asm/x86_64-gcc.c @@ -53,8 +53,7 @@ #include // TODO(davidben): Get this file working on Windows x64. -#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && \ - (defined(__GNUC__) || defined(__clang__)) +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__GNUC__) #include "../internal.h" @@ -535,4 +534,4 @@ void bn_sqr_comba4(BN_ULONG *r, const BN_ULONG *a) { #undef mul_add_c2 #undef sqr_add_c2 -#endif // !NO_ASM && X86_64 && (__GNUC__ || __clang__) +#endif // !NO_ASM && X86_64 && __GNUC__ diff --git a/crypto/fipsmodule/bn/div.c b/crypto/fipsmodule/bn/div.c index ded19e2e..1bcff507 100644 --- a/crypto/fipsmodule/bn/div.c +++ b/crypto/fipsmodule/bn/div.c @@ -155,18 +155,18 @@ static inline void bn_div_rem_words(BN_ULONG *quotient_out, BN_ULONG *rem_out, // // These issues aren't specific to x86 and x86_64, so it might be worthwhile // to add more assembly language implementations. -#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && \ - (defined(__GNUC__) || defined(__clang__)) - __asm__ volatile("divl %4" - : "=a"(*quotient_out), "=d"(*rem_out) - : "a"(n1), "d"(n0), "rm"(d0) - : "cc"); -#elif !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && \ - (defined(__GNUC__) || defined(__clang__)) - __asm__ volatile("divq %4" - : "=a"(*quotient_out), "=d"(*rem_out) - : "a"(n1), "d"(n0), "rm"(d0) - : "cc"); +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && defined(__GNUC__) + __asm__ volatile ( + "divl %4" + : "=a"(*quotient_out), "=d"(*rem_out) + : "a"(n1), "d"(n0), "rm"(d0) + : "cc" ); +#elif !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__GNUC__) + __asm__ volatile ( + "divq %4" + : "=a"(*quotient_out), "=d"(*rem_out) + : "a"(n1), "d"(n0), "rm"(d0) + : "cc" ); #else #if defined(BN_ULLONG) BN_ULLONG n = (((BN_ULLONG)n0) << BN_BITS2) | n1; diff --git a/crypto/fipsmodule/bn/generic.c b/crypto/fipsmodule/bn/generic.c index 82124094..b70080f0 100644 --- a/crypto/fipsmodule/bn/generic.c +++ b/crypto/fipsmodule/bn/generic.c @@ -64,8 +64,7 @@ // This file has two other implementations: x86 assembly language in // asm/bn-586.pl and x86_64 inline assembly in asm/x86_64-gcc.c. #if defined(OPENSSL_NO_ASM) || \ - !(defined(OPENSSL_X86) || \ - (defined(OPENSSL_X86_64) && (defined(__GNUC__) || defined(__clang__)))) + !(defined(OPENSSL_X86) || (defined(OPENSSL_X86_64) && defined(__GNUC__))) #ifdef BN_ULLONG #define mul_add(r, a, w, c) \ diff --git a/crypto/fipsmodule/bn/internal.h b/crypto/fipsmodule/bn/internal.h index 4fca3996..ecd7d6cb 100644 --- a/crypto/fipsmodule/bn/internal.h +++ b/crypto/fipsmodule/bn/internal.h @@ -140,7 +140,7 @@ extern "C" { #if defined(OPENSSL_64_BIT) -#if !defined(_MSC_VER) || defined(__clang__) +#if !defined(_MSC_VER) // MSVC doesn't support two-word integers on 64-bit. #define BN_ULLONG uint128_t #endif diff --git a/crypto/fipsmodule/ec/ec.c b/crypto/fipsmodule/ec/ec.c index f432f799..a39ca599 100644 --- a/crypto/fipsmodule/ec/ec.c +++ b/crypto/fipsmodule/ec/ec.c @@ -212,6 +212,13 @@ static const uint8_t kP521Params[6 * 66] = { 0xB7, 0x1E, 0x91, 0x38, 0x64, 0x09, }; +// MSan appears to have a bug that causes code to be miscompiled in opt mode. +// While that is being looked at, don't run the uint128_t code under MSan. +#if defined(OPENSSL_64_BIT) && !defined(OPENSSL_WINDOWS) && \ + !defined(MEMORY_SANITIZER) +#define BORINGSSL_USE_INT128_CODE +#endif + DEFINE_METHOD_FUNCTION(struct built_in_curves, OPENSSL_built_in_curves) { // 1.3.132.0.35 static const uint8_t kOIDP521[] = {0x2b, 0x81, 0x04, 0x00, 0x23}; diff --git a/crypto/fipsmodule/ec/internal.h b/crypto/fipsmodule/ec/internal.h index 3536c786..39c9349a 100644 --- a/crypto/fipsmodule/ec/internal.h +++ b/crypto/fipsmodule/ec/internal.h @@ -79,13 +79,6 @@ extern "C" { #endif -// MSan appears to have a bug that causes code to be miscompiled in opt mode. -// While that is being looked at, don't run the uint128_t code under MSan. -#if defined(OPENSSL_64_BIT) && (!defined(_MSC_VER) || defined(__clang__)) && \ - !defined(MEMORY_SANITIZER) -#define BORINGSSL_USE_INT128_CODE -#endif - struct ec_method_st { int (*group_init)(EC_GROUP *); void (*group_finish)(EC_GROUP *); diff --git a/crypto/fipsmodule/ec/p256-64.c b/crypto/fipsmodule/ec/p256-64.c index ac038c03..f7d1ff11 100644 --- a/crypto/fipsmodule/ec/p256-64.c +++ b/crypto/fipsmodule/ec/p256-64.c @@ -21,6 +21,8 @@ #include +#if defined(OPENSSL_64_BIT) && !defined(OPENSSL_WINDOWS) + #include #include #include @@ -33,8 +35,6 @@ #include "internal.h" -#if defined(BORINGSSL_USE_INT128_CODE) - // The underlying field. P256 operates over GF(2^256-2^224+2^192+2^96-1). We // can serialise an element of this field into 32 bytes. We call this an // felem_bytearray. @@ -1705,4 +1705,4 @@ DEFINE_METHOD_FUNCTION(EC_METHOD, EC_GFp_nistp256_method) { out->field_decode = NULL; }; -#endif // BORINGSSL_USE_INT128_CODE +#endif // 64_BIT && !WINDOWS