Enable 64-bit compilation with ARM Compiler 6

This patch fixes the conditional preprocessor directives in
include/mbedtls/bignum.h to enable 64-bit compilation with ARM
Compiler 6.
This commit is contained in:
Andres Amaya Garcia 2017-05-04 11:05:55 +01:00 committed by Simon Butcher
parent 9469919447
commit b820bf8e45
2 changed files with 43 additions and 27 deletions

View File

@ -27,6 +27,8 @@ Bugfix
Found by redplait #590 Found by redplait #590
* Add MBEDTLS_MPI_CHK to check for error value of mbedtls_mpi_fill_random. * Add MBEDTLS_MPI_CHK to check for error value of mbedtls_mpi_fill_random.
Reported and fix suggested by guidovranken in #740 Reported and fix suggested by guidovranken in #740
* Fix conditional preprocessor directives in bignum.h to enable 64-bit
compilation when using ARM Compiler 6.
Security Security
* Fix authentication bypass in SSL/TLS: when auth_mode is set to optional, * Fix authentication bypass in SSL/TLS: when auth_mode is set to optional,

View File

@ -106,33 +106,47 @@
* 32-bit integers can be forced on 64-bit arches (eg. for testing purposes) * 32-bit integers can be forced on 64-bit arches (eg. for testing purposes)
* by defining MBEDTLS_HAVE_INT32 and undefining MBEDTLS_HAVE_ASM * by defining MBEDTLS_HAVE_INT32 and undefining MBEDTLS_HAVE_ASM
*/ */
#if ( ! defined(MBEDTLS_HAVE_INT32) && \ #if !defined(MBEDTLS_HAVE_INT32)
defined(_MSC_VER) && defined(_M_AMD64) ) #if defined(_MSC_VER) && defined(_M_AMD64)
#define MBEDTLS_HAVE_INT64 /* Always choose 64-bit when using MSC */
typedef int64_t mbedtls_mpi_sint; #define MBEDTLS_HAVE_INT64
typedef uint64_t mbedtls_mpi_uint; typedef int64_t mbedtls_mpi_sint;
#else typedef uint64_t mbedtls_mpi_uint;
#if ( ! defined(MBEDTLS_HAVE_INT32) && \ #elif defined(__GNUC__) && ( \
defined(__GNUC__) && ( \ defined(__amd64__) || defined(__x86_64__) || \
defined(__amd64__) || defined(__x86_64__) || \ defined(__ppc64__) || defined(__powerpc64__) || \
defined(__ppc64__) || defined(__powerpc64__) || \ defined(__ia64__) || defined(__alpha__) || \
defined(__ia64__) || defined(__alpha__) || \ ( defined(__sparc__) && defined(__arch64__) ) || \
(defined(__sparc__) && defined(__arch64__)) || \ defined(__s390x__) || defined(__mips64) )
defined(__s390x__) || defined(__mips64) ) ) #define MBEDTLS_HAVE_INT64
#define MBEDTLS_HAVE_INT64 typedef int64_t mbedtls_mpi_sint;
typedef int64_t mbedtls_mpi_sint; typedef uint64_t mbedtls_mpi_uint;
typedef uint64_t mbedtls_mpi_uint; /* mbedtls_t_udbl defined as 128-bit unsigned int */
/* mbedtls_t_udbl defined as 128-bit unsigned int */ typedef unsigned int mbedtls_t_udbl __attribute__((mode(TI)));
typedef unsigned int mbedtls_t_udbl __attribute__((mode(TI))); #define MBEDTLS_HAVE_UDBL
#define MBEDTLS_HAVE_UDBL #elif defined(__ARMCC_VERSION) && defined(__aarch64__)
#else /* __ARMCC_VERSION is defined for both armcc and armclang and
#define MBEDTLS_HAVE_INT32 * __aarch64__ is only defined by armclang when compiling 64-bit code
typedef int32_t mbedtls_mpi_sint; */
typedef uint32_t mbedtls_mpi_uint; #define MBEDTLS_HAVE_INT64
typedef uint64_t mbedtls_t_udbl; typedef int64_t mbedtls_mpi_sint;
#define MBEDTLS_HAVE_UDBL typedef uint64_t mbedtls_mpi_uint;
#endif /* !MBEDTLS_HAVE_INT32 && __GNUC__ && 64-bit platform */ /* mbedtls_t_udbl defined as 128-bit unsigned int */
#endif /* !MBEDTLS_HAVE_INT32 && _MSC_VER && _M_AMD64 */ typedef __uint128_t mbedtls_t_udbl;
#define MBEDTLS_HAVE_UDBL
#endif
#endif /* !MBEDTLS_HAVE_INT32 */
#if !defined(MBEDTLS_HAVE_INT64)
/* Default to 32-bit compilation */
#if !defined(MBEDTLS_HAVE_INT32)
#define MBEDTLS_HAVE_INT32
#endif /* !MBEDTLS_HAVE_INT32 */
typedef int32_t mbedtls_mpi_sint;
typedef uint32_t mbedtls_mpi_uint;
typedef uint64_t mbedtls_t_udbl;
#define MBEDTLS_HAVE_UDBL
#endif /* !MBEDTLS_HAVE_INT64 */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {