mirror of https://github.com/wolfSSL/wolfssl.git
SP math all: fixes for different compilers and configs
parent
7fe24daf6c
commit
356b419532
|
@ -28,8 +28,9 @@
|
||||||
|
|
||||||
#include <wolfssl/wolfcrypt/cpuid.h>
|
#include <wolfssl/wolfcrypt/cpuid.h>
|
||||||
|
|
||||||
#if defined(WOLFSSL_X86_64_BUILD) || defined(USE_INTEL_SPEEDUP) || \
|
#if (defined(WOLFSSL_X86_64_BUILD) || defined(USE_INTEL_SPEEDUP) || \
|
||||||
defined(WOLFSSL_AESNI) || defined(WOLFSSL_SP_X86_64_ASM)
|
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
|
/* 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
|
* 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)
|
int sp_rand_prime(sp_int* r, int len, WC_RNG* rng, void* heap)
|
||||||
{
|
{
|
||||||
static const int USE_BBS = 1;
|
static const int USE_BBS = 1;
|
||||||
int err = MP_OKAY, type;
|
int err = MP_OKAY;
|
||||||
|
int type = 0;
|
||||||
int isPrime = MP_NO;
|
int isPrime = MP_NO;
|
||||||
#ifdef WOLFSSL_SP_MATH_ALL
|
#ifdef WOLFSSL_SP_MATH_ALL
|
||||||
int bits;
|
int bits = 0;
|
||||||
#endif /* WOLFSSL_SP_MATH_ALL */
|
#endif /* WOLFSSL_SP_MATH_ALL */
|
||||||
|
|
||||||
(void)heap;
|
(void)heap;
|
||||||
|
@ -12988,9 +12989,6 @@ int sp_rand_prime(sp_int* r, int len, WC_RNG* rng, void* heap)
|
||||||
type = USE_BBS;
|
type = USE_BBS;
|
||||||
len = -len;
|
len = -len;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
type = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef WOLFSSL_SP_MATH_ALL
|
#ifndef WOLFSSL_SP_MATH_ALL
|
||||||
/* For minimal maths, support only what's in SP and needed for DH. */
|
/* For minimal maths, support only what's in SP and needed for DH. */
|
||||||
|
|
|
@ -46,12 +46,15 @@
|
||||||
|
|
||||||
#if defined(CURVED448_128BIT)
|
#if defined(CURVED448_128BIT)
|
||||||
typedef int64_t fe448;
|
typedef int64_t fe448;
|
||||||
#ifdef __SIZEOF_INT128__
|
#ifndef WOLFSSL_UINT128_T_DEFINED
|
||||||
typedef __uint128_t uint128_t;
|
#ifdef __SIZEOF_INT128__
|
||||||
typedef __int128_t int128_t;
|
typedef __uint128_t uint128_t;
|
||||||
#else
|
typedef __int128_t int128_t;
|
||||||
typedef unsigned long uint128_t __attribute__ ((mode(TI)));
|
#else
|
||||||
typedef long int128_t __attribute__ ((mode(TI)));
|
typedef unsigned long uint128_t __attribute__ ((mode(TI)));
|
||||||
|
typedef long int128_t __attribute__ ((mode(TI)));
|
||||||
|
#endif
|
||||||
|
#define WOLFSSL_UINT128_T_DEFINED
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
typedef int32_t fe448;
|
typedef int32_t fe448;
|
||||||
|
|
|
@ -206,15 +206,21 @@ extern "C" {
|
||||||
/* Define the types used. */
|
/* Define the types used. */
|
||||||
#ifdef HAVE___UINT128_T
|
#ifdef HAVE___UINT128_T
|
||||||
#ifdef __SIZEOF_INT128__
|
#ifdef __SIZEOF_INT128__
|
||||||
typedef __uint128_t sp_uint128;
|
typedef __uint128_t sp_uint128;
|
||||||
typedef __int128_t sp_int128;
|
typedef __int128_t sp_int128;
|
||||||
typedef __uint128_t uint128_t;
|
|
||||||
typedef __int128_t int128_t;
|
|
||||||
#else
|
#else
|
||||||
typedef unsigned long sp_uint128 __attribute__ ((mode(TI)));
|
typedef unsigned long sp_uint128 __attribute__ ((mode(TI)));
|
||||||
typedef long sp_int128 __attribute__ ((mode(TI)));
|
typedef long sp_int128 __attribute__ ((mode(TI)));
|
||||||
typedef unsigned long uint128_t __attribute__ ((mode(TI)));
|
#endif
|
||||||
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
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue