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

Add Fips module checks to provider key operations #12745

Closed
wants to merge 15 commits into from

Conversation

slontis
Copy link
Member

@slontis slontis commented Aug 29, 2020

For key operations the fips module now checks for approved digests, named curves, safe prime groups, and minimum security strength for keys .
Note that for encryption, signing and exchange operations 112 bits of security strength are required, but lower values are allowed for decryption and verifying for legacy purposes.
These checks are not done by the default providers for backwards compatibility reasons.

Checklist
  • documentation is added or updated
  • tests are added or updated

@slontis slontis added branch: master Merge to master branch approval: review pending This pull request needs review by a committer labels Aug 29, 2020
@slontis slontis added this to the 3.0.0 milestone Aug 29, 2020
@slontis slontis added this to In progress in 3.0 New Core + FIPS via automation Aug 29, 2020
@slontis
Copy link
Member Author

slontis commented Aug 29, 2020

This PR has been broken up into separate commits to hopefully make it easier to review.

crypto/ffc/ffc_params_generate.c Outdated Show resolved Hide resolved
providers/common/check_fips.c Outdated Show resolved Hide resolved
providers/common/check_fips.c Outdated Show resolved Hide resolved
providers/common/digest_to_nid.c Show resolved Hide resolved
providers/common/digest_to_nid.c Outdated Show resolved Hide resolved
providers/implementations/signature/dsa.c Outdated Show resolved Hide resolved
providers/implementations/signature/rsa.c Show resolved Hide resolved
@richsalz
Copy link
Contributor

richsalz commented Sep 2, 2020

So doing these tests is not a FIPS requirement. Are we sure that, for example, they are not invoked in any of these paths?

  • When used in TLS, certificate signatures are checked
  • And signatures are also verified while building a certificate chain
  • When doing OCSP stapling
  • In the verify command, and other apps

I think the safest thing to do is wrap all those checks in a new ifdef. Yes, I really dislike adding a new ifdef, but we are concerned that these checks, which are now required for Common Criteria, but not required for FIPS, will end up being invoked through some codepath that we haven't analyzed. Especially so close to the BETA freeze.

(Of course the absolute safest is to not put this into OpenSSL, which only promises FIPS not Common Criteria.)

@t8m
Copy link
Member

t8m commented Sep 2, 2020

They might not be required by FIPS 140-2, but they will be effectively required by FIPS 140-3. Also they are good idea anyway as they help the application to be FIPS compliant. Once you use such non-approved key sizes you're out of FIPS compliance. If you care about real FIPS compliance and not just paper compliance you need to use approved key sizes.

@richsalz
Copy link
Contributor

richsalz commented Sep 2, 2020

As you say, it is not currently required. I am concerned that it will break some of our deployed customers.

@t8m
Copy link
Member

t8m commented Sep 2, 2020

So they do not really care about FIPS compliance?

@t8m
Copy link
Member

t8m commented Sep 2, 2020

I mean either they care about FIPS compliance and then they cannot use non-approved key sizes. Or they do not, but then why they would be using FIPS provider.

@richsalz
Copy link
Contributor

richsalz commented Sep 2, 2020

We care about FIPS 140-2, not 140-3. If the project wants to do 140-3, then presumably it will discuss this among the OMC and the FIPS project sponsors.

@t8m
Copy link
Member

t8m commented Sep 2, 2020

I am sorry for not being clear. FIPS 140-2 requires you to use approved key sizes, it just does not require the software to enforce the requirement. The compliance can be achieved by simply not using non-approved key sizes by the means of the system administrator (the FIPS module operator) diligence. So if the sysadmin uses wrong key sizes, the resulting operation is not FIPS compliant. And it can even invalidate keys if you for example use properly FIPS compliant RSA key to create signature with non-approved hash (which is even sha1 now for signatures) it invalidates the compliance of the RSA key, even if you would like to later use it with an approved hash. So the key size checks are actually very much useful even with FIPS 140-2.

@richsalz
Copy link
Contributor

richsalz commented Sep 2, 2020

Please see the archives on the fips-sponsors list. 140-2 says nothing about certificates, for example.

@slontis
Copy link
Member Author

slontis commented Sep 2, 2020

Please see the archives on the fips-sponsors list. 140-2 says nothing about certificates, for example.

If you are signing with SHA1 for example - then you are not fips compliant.

Ticking the fips box, and then allowing non secure operations is just sticking your head in the sand.
If you require operations that are not fips then you should be setting up a separate libctx that can handle these operations.

Ideally any cert or key that is not trusted should also be doing a key check also, there are many rules as to what part of the key needs to be validated (especially with key agreement).

https://csrc.nist.gov/projects/cryptographic-module-validation-program/announcements mentions SP800-131A quite a lot.

If you read https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf it does set limits on keysizes, and it also mentions key assurances in section 3.3.

@richsalz
Copy link
Contributor

richsalz commented Sep 2, 2020

I am going to stand by what Ashit said on that list. This is moving decisions that were in policy, to being enforced in code, and it's not for 140-2 but for Common Criteria and 140-3. This will break some of our customers.

@t-j-h
Copy link
Member

t-j-h commented Sep 2, 2020

Having an option to have technical enforcement of items which are allowed to be handled by policy (i.e. passed to the user as their responsibility) is a useful thing to do - however it should also be able to be disabled and such a disabling should not be in violation of the security policy. There are actually contexts in which things are permitted to be used without breaking FIPS requirements which depend on application knowledge that sits outside of the FIPS module itself.

Yes - I'm agreeing with both @slontis and @richsalz at the same time - with the modification that it should be able to be configured on or off in the configuration file. That enables meeting both objectives which apply to different situations.

@richsalz
Copy link
Contributor

richsalz commented Sep 2, 2020

I can acccept @t-j-h's proposal. I'd add that the default should be settable via the fipsinstall program.

@slontis
Copy link
Member Author

slontis commented Sep 3, 2020 via email

@richsalz
Copy link
Contributor

richsalz commented Sep 3, 2020

My personal opinion is that the security policy would need to state that you are not fips compliant if you disable it - i.e you are allowing non secure operations (which may be required by P11 devices for example)

I disagree. It should state that compliance is determined via administrative guidance. Just like other guidances we're going to have.

I am unsure if this option should be in the fips config file that is produced from fipsinstall -

Without that, how does someone change from admin-style guidance to code-enforcement? Rewrite their app? Install a differently-built module?

@slontis
Copy link
Member Author

slontis commented Sep 3, 2020

It will be up to whoever writes the security policy to determine what to do with this.
I will make it optional - if people chose to abuse it then that is their choice.
The consequence will be that it will be disabled by people because something doesn't work instead of actually addressing the problem.

@t-j-h
Copy link
Member

t-j-h commented Sep 3, 2020

I see nothing wrong with on-by-default for the checks.

However it defeats the point if you basically add a requirement in the security policy for this setting to always be on - FIPS allows for non-technical enforcement - if it didn't then all modules would be required to enforce.

There are good reasons why this is the case for FIPS but that is a longer conversation that needed for this threat.

Simple summary:
a) add checks
b) checks on by default
c) can be disabled in config file or compile time or fipsinstall time
d) no mandated specific setting of the config file mechanism in the security policy or other referenced documents in the security policy

@richsalz
Copy link
Contributor

richsalz commented Sep 3, 2020

@t-j-h's comments in #12745 (comment) meet our needs and also seem to meet the FIPS requirements as well.

I can help with the config file stuff, and wiring it through to the checks if you want.

@slontis
Copy link
Member Author

slontis commented Sep 4, 2020

I can help with the config file stuff, and wiring it through to the checks if you want.

Yes that would be helpful if you could..
I am re-jigging the code now to handle it.
I just need to separate out the dependant evp_tests somehow so they dont fall over if the option is disabled.

@slontis
Copy link
Member Author

slontis commented Sep 4, 2020

@richsalz - I have added a config option 'fips-securitychecks'..

If you look in security_check_fips.c you will see a TODO(3.0) item where the check should be placed..
evp_test.c would also need the check where I put the #ifdef for this also in this PR.

@richsalz
Copy link
Contributor

richsalz commented Sep 4, 2020

I mailed you a patch.

@slontis
Copy link
Member Author

slontis commented Sep 5, 2020

I mailed you a patch.

Thanks for that.. I did not quite know how to put the global variable in either, I was interested to see what you would do :)
I have modified it a bit.

@slontis
Copy link
Member Author

slontis commented Sep 17, 2020

rebased to fix commit message..

Copy link
Member

@t8m t8m left a comment

Choose a reason for hiding this comment

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

LGTM, good work!

@t8m t8m added approval: done This pull request has the required number of approvals and removed approval: review pending This pull request needs review by a committer labels Sep 17, 2020
@openssl-machine openssl-machine removed the approval: done This pull request has the required number of approvals label Sep 18, 2020
@openssl-machine
Copy link
Collaborator

This pull request is ready to merge

@openssl-machine openssl-machine added the approval: ready to merge The 24 hour grace period has passed, ready to merge label Sep 18, 2020
openssl-machine pushed a commit that referenced this pull request Sep 18, 2020
In fips mode SHA1 should not be allowed for signing, but may be present for verifying.
Add keysize check.
Add missing 'ossl_unused' to gettable and settable methods.
Update fips related tests that have these restrictions.

Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from #12745)
openssl-machine pushed a commit that referenced this pull request Sep 18, 2020
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from #12745)
openssl-machine pushed a commit that referenced this pull request Sep 18, 2020
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from #12745)
openssl-machine pushed a commit that referenced this pull request Sep 18, 2020
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from #12745)
openssl-machine pushed a commit that referenced this pull request Sep 18, 2020
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from #12745)
openssl-machine pushed a commit that referenced this pull request Sep 18, 2020
For key agreement only NIST curves that have a security strength of 112 bits or more are allowed.
Fixed tests so they obey these restrictions when testing in fips mode.

Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from #12745)
openssl-machine pushed a commit that referenced this pull request Sep 18, 2020
The ordering of this option is important so inform the user if they do it incorrectly.

Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from #12745)
openssl-machine pushed a commit that referenced this pull request Sep 18, 2020
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from #12745)
openssl-machine pushed a commit that referenced this pull request Sep 18, 2020
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from #12745)
openssl-machine pushed a commit that referenced this pull request Sep 18, 2020
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from #12745)
openssl-machine pushed a commit that referenced this pull request Sep 18, 2020
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from #12745)
openssl-machine pushed a commit that referenced this pull request Sep 18, 2020
…checks

Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from #12745)
openssl-machine pushed a commit that referenced this pull request Sep 18, 2020
Changes merged from a patch by @richsalz.

Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from #12745)
@mattcaswell
Copy link
Member

Pushed.

3.0 New Core + FIPS automation moved this from Needs review to Done Sep 18, 2020
@paulnelsontx paulnelsontx added this to Ready to merge in 3.0.0 estimator Dec 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approval: ready to merge The 24 hour grace period has passed, ready to merge branch: master Merge to master branch
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

7 participants