mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-02 12:14:38 +02:00
add math library runtime settings check
This commit is contained in:
@@ -38,6 +38,13 @@
|
|||||||
#include <cyassl/ctaocrypt/integer.h>
|
#include <cyassl/ctaocrypt/integer.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* math settings check */
|
||||||
|
word32 CheckRunTimeSettings(void)
|
||||||
|
{
|
||||||
|
return CTC_SETTINGS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* handle up to 6 inits */
|
/* handle up to 6 inits */
|
||||||
int mp_init_multi(mp_int* a, mp_int* b, mp_int* c, mp_int* d, mp_int* e,
|
int mp_init_multi(mp_int* a, mp_int* b, mp_int* c, mp_int* d, mp_int* e,
|
||||||
mp_int* f)
|
mp_int* f)
|
||||||
|
@@ -43,6 +43,12 @@
|
|||||||
#include <ctaocrypt/src/asm.c> /* will define asm MACROS or C ones */
|
#include <ctaocrypt/src/asm.c> /* will define asm MACROS or C ones */
|
||||||
|
|
||||||
|
|
||||||
|
/* math settings check */
|
||||||
|
word32 CheckRunTimeSettings(void)
|
||||||
|
{
|
||||||
|
return CTC_SETTINGS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Functions */
|
/* Functions */
|
||||||
|
|
||||||
|
@@ -132,6 +132,9 @@ void ctaocrypt_test(void* args)
|
|||||||
|
|
||||||
((func_args*)args)->return_code = -1; /* error state */
|
((func_args*)args)->return_code = -1; /* error state */
|
||||||
|
|
||||||
|
if (CheckCtcSettings() != 1)
|
||||||
|
err_sys("Build vs runtime math mismatch\n", -1234);
|
||||||
|
|
||||||
if ( (ret = md5_test()) )
|
if ( (ret = md5_test()) )
|
||||||
err_sys("MD5 test failed!\n", ret);
|
err_sys("MD5 test failed!\n", ret);
|
||||||
else
|
else
|
||||||
|
@@ -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
|
#ifdef __cplusplus
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user