Topic: USE_FAST_MATH required for MakeCertReq?

I'm trying to create a certificate request and started with trying to copy/paste out of test.c (like the manual says).

I have the cert and key initialized with InitCert and InitRsaKey respectively.

Then I call MakeCertReq and it goes into an infinite loop.  Further investigation puts the problem in SetRsaPublicKey where mp_leading_bit is called (and never returns).  It appears the issue is that the mp_int members of the RsaKey structure aren't initialized completely if USE_FAST_MATH isn't defined. mp_leading_bit uses the whole mp_int structure to find the leading bit and InitRsaKey doesn't do that if USE_FAST_MATH isn't defined.

USE_FAST_MATH seems to be a good "default" option to have on (larger) platforms that can handle it (like Windows).  I'm using Windows (for now), so I'm surprised USE_FAST_MATH isn't on by default.  Am I missing something?  Do I have "include header" issues like https://www.wolfssl.com/forums/topic817 … hing.html?

Share

Re: USE_FAST_MATH required for MakeCertReq?

Hi Michael,

I verified that the wolfCrypt test's certificate request generation successfully generates "certreq.pem" using both the normal and fastmath libraries, on my development machine (OSX).

To address your header question, can you first verify that wolfSSL and your application are being compiled with the exact same preprocessor defines?  If these differ it's very possible that you could be seeing problems.  That was the issue the the post you linked to.

Thanks,
Chris

Re: USE_FAST_MATH required for MakeCertReq?

To answer your question about fastmath as the default, we do enable it as the default on Unix/Linux 64-bit platforms.

On some 32-bit platforms users will get an error about a missing register being available because of PIC.  We have a few workarounds for this issue listed in the README, but for out-of-the-box compilation we have opted not to enable it by default on 32-bit platforms.

In general, fastmath is more commonly used over the normal big integer library - both on embedded platforms and desktop/enterprise ones.  It is quite a bit faster on most platforms.

Best Regards,
Chris

Re: USE_FAST_MATH required for MakeCertReq?

chrisc wrote:

To answer your question about fastmath as the default, we do enable it as the default on Unix/Linux 64-bit platforms.

So why not Windows? wink

What's the best way to ensure preprocessors definitions are in sync (on Windows).  Have my application include user_settings.h?

Also, I did not run the test.c, but the wc_MakeCertReq isn't exactly the first API called in that function, so maybe things otherwise get initialized from previous APIs.  My app just has

InitCert
InitRsaKey
MakeCertReq

(which I presume is the minimum API necessary.  If there are more calls needed, please advise)

Share

Re: USE_FAST_MATH required for MakeCertReq?

Hi Michael,

I don't have an exact answer for you regarding fastmath default configuration on Windows.  Ultimately, we leave the math library choice up to the end user.

user_settings.h is the best place for you to maintain your list of custom preprocessor defines and settings, as it is external to the library proper and can be more easily maintained by the user across wolfSSL version updates.

I'll look into the function calls needed for MakeCertReq() and get back to you shortly.

Best Regards,
Chris