mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-01 03:34:39 +02:00
add math library runtime settings check
This commit is contained in:
@@ -38,6 +38,13 @@
|
||||
#include <cyassl/ctaocrypt/integer.h>
|
||||
|
||||
|
||||
/* math settings check */
|
||||
word32 CheckRunTimeSettings(void)
|
||||
{
|
||||
return CTC_SETTINGS;
|
||||
}
|
||||
|
||||
|
||||
/* handle up to 6 inits */
|
||||
int mp_init_multi(mp_int* a, mp_int* b, mp_int* c, mp_int* d, mp_int* e,
|
||||
mp_int* f)
|
||||
|
@@ -43,6 +43,12 @@
|
||||
#include <ctaocrypt/src/asm.c> /* will define asm MACROS or C ones */
|
||||
|
||||
|
||||
/* math settings check */
|
||||
word32 CheckRunTimeSettings(void)
|
||||
{
|
||||
return CTC_SETTINGS;
|
||||
}
|
||||
|
||||
|
||||
/* Functions */
|
||||
|
||||
|
@@ -131,6 +131,9 @@ void ctaocrypt_test(void* args)
|
||||
int ret = 0;
|
||||
|
||||
((func_args*)args)->return_code = -1; /* error state */
|
||||
|
||||
if (CheckCtcSettings() != 1)
|
||||
err_sys("Build vs runtime math mismatch\n", -1234);
|
||||
|
||||
if ( (ret = md5_test()) )
|
||||
err_sys("MD5 test failed!\n", ret);
|
||||
|
@@ -190,6 +190,30 @@ enum {
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* settings detection for compile vs runtime math incombatibilities */
|
||||
enum {
|
||||
#if !defined(USE_FAST_MATH) && !defined(SIZEOF_LONG) && !defined(SIZEOF_LONG_LONG)
|
||||
CTC_SETTINGS = 0x0
|
||||
#elif !defined(USE_FAST_MATH) && defined(SIZEOF_LONG)
|
||||
CTC_SETTINGS = 0x1
|
||||
#elif !defined(USE_FAST_MATH) && defined(SIZEOF_LONG_LONG)
|
||||
CTC_SETTINGS = 0x2
|
||||
#elif defined(USE_FAST_MATH) && !defined(SIZEOF_LONG) && !defined(SIZEOF_LONG_LONG)
|
||||
CTC_SETTINGS = 0x4
|
||||
#elif defined(USE_FAST_MATH) && defined(SIZEOF_LONG)
|
||||
CTC_SETTINGS = 0x8
|
||||
#elif defined(USE_FAST_MATH) && defined(SIZEOF_LONG_LONG)
|
||||
CTC_SETTINGS = 0x10
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
CYASSL_API word32 CheckRunTimeSettings(void);
|
||||
|
||||
#define CheckCtcSettings() (CTC_SETTINGS == CheckRunTimeSettings())
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user