-
Notifications
You must be signed in to change notification settings - Fork 838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add introspection for math build and math cleanups #6123
Conversation
Retest this please |
The macro USE_FAST_MATH are defined for lots of platforms by default in settings.h. They should be removed and let user to specify which math library to use. |
This is very good feedback! I will adjust. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is great -- and dovetails with the testwolfcrypt
retval refactor I'm churning through.
#if (defined(WOLFSSL_SP_MATH_ALL) && \ | ||
(defined(USE_FAST_MATH) || defined(USE_INTEGER_HEAP_MATH))) || \ | ||
(defined(USE_FAST_MATH) && defined(USE_INTEGER_HEAP_MATH)) | ||
#error Cannot enable more than one multiple precision math library! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missed an opportunity for a really fun preprocessor construction here (this actually works!)
#if defined(WOLFSSL_SP_MATH_ALL) + defined(USE_FAST_MATH) + defined(USE_INTEGER_HEAP_MATH) > 1
#error nope
#endif
not seriously suggesting... not even sure it's portable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yours is much more elegant, but I cannot guarantee portability. I think they would have to =1 and that is just not a guarantee.
49b4b07
to
65609db
Compare
@@ -2842,6 +2843,10 @@ int benchmark_init(void) | |||
return EXIT_FAILURE; | |||
} | |||
|
|||
#ifdef HAVE_WC_INTROSPECTION | |||
printf("Math: %s\n", wc_GetMathInfo()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have something that will be more embedded-friendly than printf
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
printf
is fine for embedded targets. it even works (more or less) in newlib-nano. troubles arise with fprintf
though, so your point is well taken.
@@ -2033,7 +2025,7 @@ extern void uITRON4_free(void *p) ; | |||
#undef HAVE_ECC_KEY_IMPORT | |||
#define HAVE_ECC_KEY_IMPORT | |||
#endif | |||
#ifndef NO_ECC_KEY_EXPORT | |||
#if !defined(NO_ECC_KEY_EXPORT) && !defined(NO_BIG_INT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is curious logic. Perhaps add a comment as to why !defined(NO_BIG_INT)
is now required for HAVE_ECC_KEY_EXPORT
?
@@ -2503,7 +2495,7 @@ extern void uITRON4_free(void *p) ; | |||
#endif | |||
|
|||
/* warning for not using harden build options (default with ./configure) */ | |||
#ifndef WC_NO_HARDEN | |||
#if !defined(WC_NO_HARDEN) && !defined(NO_BIG_INT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This too is curious. How is !defined(NO_BIG_INT)
related to the !defined(WC_NO_HARDEN)
here?
Retest this please |
retest this please |
Jenkins retest this please |
* Add introspection for math build. * Raise build error if more than one multi-precision math library used. * Fix ESP32 to support using any multi-precision math option. * Refactor math headers to use `wolfmath.h` * Refactor of the opaque math variable type `MATH_INT_T` used by crypto hardware (QuickAssist, SE050, ESP32 and STM32). * Cleanups for building with `WOLFCRYPT_ONLY` and `NO_BIG_INT`. * Stop forcing use of fast math by default for platforms in settings.h. Note: For users that still want to use fast math (tfm.c) they will need to add USE_FAST_MATH to their build settings. Applies To: ``` WOLFSSL_ESPWROOM32 WOLFSSL_ESPWROOM32SE MICROCHIP_PIC32 WOLFSSL_PICOTCP_DEMO WOLFSSL_UTASKER WOLFSSL_NRF5x FREERTOS_TCP WOLFSSL_TIRTOS EBSNET FREESCALE_COMMON FREESCALE_KSDK_BM WOLFSSL_DEOS MICRIUM WOLFSSL_SGX ```
Description
WOLFCRYPT_ONLY
andNO_BIG_INT
.wolfmath.h
MATH_INT_T
used by crypto hardware (QuickAssist, SE050, ESP32 and STM32).settings.h
.Note: For users that still want to use fast math (
tfm.c
) they will need to addUSE_FAST_MATH
to their build settings.Applies To:
Example Output:
Testing
Checklist