Merge pull request #3567 from SparkiDev/sp_math_fix
SP math all: fixes for different compilers and configs
This commit is contained in:
commit
7f44247954
@ -28,8 +28,9 @@
|
||||
|
||||
#include <wolfssl/wolfcrypt/cpuid.h>
|
||||
|
||||
#if defined(WOLFSSL_X86_64_BUILD) || defined(USE_INTEL_SPEEDUP) || \
|
||||
defined(WOLFSSL_AESNI) || defined(WOLFSSL_SP_X86_64_ASM)
|
||||
#if (defined(WOLFSSL_X86_64_BUILD) || defined(USE_INTEL_SPEEDUP) || \
|
||||
defined(WOLFSSL_AESNI) || defined(WOLFSSL_SP_X86_64_ASM)) && \
|
||||
!defined(WOLFSSL_NO_ASM)
|
||||
/* Each platform needs to query info type 1 from cpuid to see if aesni is
|
||||
* supported. Also, let's setup a macro for proper linkage w/o ABI conflicts
|
||||
*/
|
||||
|
@ -12970,10 +12970,11 @@ int sp_radix_size(sp_int* a, int radix, int* size)
|
||||
int sp_rand_prime(sp_int* r, int len, WC_RNG* rng, void* heap)
|
||||
{
|
||||
static const int USE_BBS = 1;
|
||||
int err = MP_OKAY, type;
|
||||
int err = MP_OKAY;
|
||||
int type = 0;
|
||||
int isPrime = MP_NO;
|
||||
#ifdef WOLFSSL_SP_MATH_ALL
|
||||
int bits;
|
||||
int bits = 0;
|
||||
#endif /* WOLFSSL_SP_MATH_ALL */
|
||||
|
||||
(void)heap;
|
||||
@ -12988,9 +12989,6 @@ int sp_rand_prime(sp_int* r, int len, WC_RNG* rng, void* heap)
|
||||
type = USE_BBS;
|
||||
len = -len;
|
||||
}
|
||||
else {
|
||||
type = 0;
|
||||
}
|
||||
|
||||
#ifndef WOLFSSL_SP_MATH_ALL
|
||||
/* For minimal maths, support only what's in SP and needed for DH. */
|
||||
|
@ -46,12 +46,15 @@
|
||||
|
||||
#if defined(CURVED448_128BIT)
|
||||
typedef int64_t fe448;
|
||||
#ifdef __SIZEOF_INT128__
|
||||
typedef __uint128_t uint128_t;
|
||||
typedef __int128_t int128_t;
|
||||
#else
|
||||
typedef unsigned long uint128_t __attribute__ ((mode(TI)));
|
||||
typedef long int128_t __attribute__ ((mode(TI)));
|
||||
#ifndef WOLFSSL_UINT128_T_DEFINED
|
||||
#ifdef __SIZEOF_INT128__
|
||||
typedef __uint128_t uint128_t;
|
||||
typedef __int128_t int128_t;
|
||||
#else
|
||||
typedef unsigned long uint128_t __attribute__ ((mode(TI)));
|
||||
typedef long int128_t __attribute__ ((mode(TI)));
|
||||
#endif
|
||||
#define WOLFSSL_UINT128_T_DEFINED
|
||||
#endif
|
||||
#else
|
||||
typedef int32_t fe448;
|
||||
|
@ -206,15 +206,21 @@ extern "C" {
|
||||
/* Define the types used. */
|
||||
#ifdef HAVE___UINT128_T
|
||||
#ifdef __SIZEOF_INT128__
|
||||
typedef __uint128_t sp_uint128;
|
||||
typedef __int128_t sp_int128;
|
||||
typedef __uint128_t uint128_t;
|
||||
typedef __int128_t int128_t;
|
||||
typedef __uint128_t sp_uint128;
|
||||
typedef __int128_t sp_int128;
|
||||
#else
|
||||
typedef unsigned long sp_uint128 __attribute__ ((mode(TI)));
|
||||
typedef long sp_int128 __attribute__ ((mode(TI)));
|
||||
typedef unsigned long uint128_t __attribute__ ((mode(TI)));
|
||||
typedef long int128_t __attribute__ ((mode(TI)));
|
||||
typedef unsigned long sp_uint128 __attribute__ ((mode(TI)));
|
||||
typedef long sp_int128 __attribute__ ((mode(TI)));
|
||||
#endif
|
||||
#ifndef WOLFSSL_UINT128_T_DEFINED
|
||||
#ifdef __SIZEOF_INT128__
|
||||
typedef __uint128_t uint128_t;
|
||||
typedef __int128_t int128_t;
|
||||
#else
|
||||
typedef unsigned long uint128_t __attribute__ ((mode(TI)));
|
||||
typedef long int128_t __attribute__ ((mode(TI)));
|
||||
#endif
|
||||
#define WOLFSSL_UINT128_T_DEFINED
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user