Skip to content
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

Run FIPS CASTs once up front to avoid runtime FIPS errors in threaded applications #84

Merged
merged 2 commits into from
Dec 13, 2024

Conversation

cconlon
Copy link
Member

@cconlon cconlon commented Dec 4, 2024

This PR includes changes relevant to wolfCrypt FIPS users and changes how the FIPS CASTs are run.

Prior to this PR, the FIPS CASTs were run when a class that extended the com.wolfssl.wolfcrypt.WolfObject was created. This could lead to the case where multiple objects created simultaneously in separate threads would both try to run the CASTs at the same time, resulting in one of them getting a native wolfCrypt FIPS not allowed error.

This PR changes this behavior and runs the CASTs:

  • JCE: once up front when WolfCryptProvider is created
  • JNI: once up front when the first class that extends WolfObject is created

CAST run logic has been encapsulated into the new Fips class method: public static int runAllCast_fips(). This is called from WolfObject during initialization, and from WolfCryptProvider during creation. This method contains synchronization to ensure not more than one thread tries to run the CASTs at one time.

NOTE: FIPS PRB tests will be added as part of a separate PR.

@cconlon
Copy link
Member Author

cconlon commented Dec 13, 2024

Noticed a few spurious printf's left in the code. Assigning back to myself for a quick cleanup.

@JacobBarthelmeh JacobBarthelmeh merged commit d063bb6 into wolfSSL:master Dec 13, 2024
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants