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

Fix and improve SetFIPS #219

Merged
merged 2 commits into from
Nov 13, 2024
Merged

Fix and improve SetFIPS #219

merged 2 commits into from
Nov 13, 2024

Conversation

qmuntal
Copy link
Collaborator

@qmuntal qmuntal commented Nov 13, 2024

#206 introduced a regression where openssl.SetFIPS(false) would always fail if there wasn't any FIPS-capable provider.

This PR fix that issue, adds some tests for SetFIPS, which was previously untested.

A benefit of the new implementation is that OSSL_PROVIDER_try_load is only called if the already loaded providers can't support the desired FIPS mode. It was previously unconditionally called, which was potentially unnecessary and could have undesired side-effects. For example, if the SymCrypt provider was already loaded and the built-in FIPS provider was not loaded but was installed in the system, then it would be loaded when calling SetFIPS(true), ending with two conflicting FIPS providers available.

@qmuntal qmuntal merged commit 4f0359e into v2 Nov 13, 2024
54 checks passed
@qmuntal qmuntal deleted the setfipsfix branch November 13, 2024 11:57
@@ -103,6 +103,7 @@ var (
providerNameFips = C.CString("fips")
providerNameDefault = C.CString("default")
propFIPS = C.CString("fips=yes")
propNoFIPS = C.CString("-fips")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not able to find any docs on -fips, and the lack of symmetry vs. fips=yes is a bit strange. Where does this come from?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why it didn't show up in my initial searches, but found the meaning here: https://docs.openssl.org/3.0/man7/property/

Copy link
Collaborator

@dagood dagood Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arguably the name could be propIgnoreGlobalFIPS to match the docs, but I don't know if that's meaningfully different.

Copy link
Contributor

@derekparker derekparker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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.

5 participants