Skip to content

Comments

Replace PKCS#1 v1.5 padding in RSA PCT#23832

Closed
jvdsn wants to merge 4 commits intoopenssl:masterfrom
jvdsn:rsa-pct
Closed

Replace PKCS#1 v1.5 padding in RSA PCT#23832
jvdsn wants to merge 4 commits intoopenssl:masterfrom
jvdsn:rsa-pct

Conversation

@jvdsn
Copy link
Contributor

@jvdsn jvdsn commented Mar 14, 2024

After December 31, 2023, SP 800-131Ar2 0 no longer allows PKCS#1 v1.5 padding for RSA "key-transport" (aka encryption and decryption). There's a few good options to replace this usage in the RSA PCT, but the simplest is verifying m = (m^e)^d mod n, (where 1 < m < (n − 1)). This is specified in SP 800-56Br2 (Section 6.4.1.1) 1 and allowed by FIPS 140-3 IG 10.3.A. In OpenSSL, this corresponds to RSA_NO_PADDING.

Issue: openssl/project#241

@github-actions github-actions bot added the severity: fips change The pull request changes FIPS provider sources label Mar 14, 2024
@slontis
Copy link
Member

slontis commented Mar 14, 2024

Could you please add a comment block in the code about how you selected this as the PCT..

i.e. something similar to your comment above,,

@t8m t8m added branch: master Applies to master branch approval: review pending This pull request needs review by a committer approval: otc review pending triaged: feature The issue/pr requests/adds a feature tests: exempted The PR is exempt from requirements for testing triaged: refactor The issue/pr requests/implements refactoring and removed triaged: feature The issue/pr requests/adds a feature labels Mar 14, 2024
@jvdsn
Copy link
Contributor Author

jvdsn commented Mar 14, 2024

@paulidale after looking at the requirements again, I'm reconsidering a sign/verify PCT.

AS10.35 (and its VEs/TEs) of the FIPS 140-3 standard requires a PCT for every generated key pair. There are 3 options:

  1. If the key pair is to be used for key transport (asymmetric cipher), the PCT consists of encrypting a plaintext, verifying that the result (ciphertext) is not equal to the plaintext, decrypting the ciphertext, and verifying that the result is equal to the plaintext.
  2. If the key pair is to be used for digital signatures, the PCT consists of computing and verifying a signature.
  3. If the key pair is to be used for key agreement, the exact PCT is defined in the applicable standards. For RSA-based schemes, this is defined in SP 800-56Br2 (Section 6.4.1.1) as: "The owner shall perform a pair-wise consistency test by verifying that m = (m^e)^d mod n for some integer m satisfying 1 < m < (n − 1)."

OpenSSL implements all three use cases: RSA-OAEP for key transport, RSA signatures with PKCS#1 v1.5 or PSS padding, and KAS-IFC-SSC (KAS1/KAS2) using RSASVE.

According to FIPS 140-3 IG 10.3.A, if at the time when the PCT is performed the keys' intended usage is not known, then any of the three PCTs described in AS10.35 shall be performed on this key pair.

Because of this allowance from the IG, and because KAS-IFC-SSC is now implemented, OpenSSL could switch to the PCT from SP 800-56Br2, i.e. RSA_public_encrypt and RSA_private_decrypt with RSA_NO_PADDING. That would keep the changes to the test itself to a minimum, and probably be a bit faster even than the sign/verify with PKCS#1 v1.5 padding. However, the main reason I'm not sure about this approach is that right now the test variable is named "OSSL_SELF_TEST_DESC_PCT_RSA_PKCS1", so the name kind of implies that PKCS#1 v1.5 padding will be used.

@slontis
Copy link
Member

slontis commented Mar 15, 2024

I am not against creating another OSSL_SELF_TEST_DESC_PCT_RSA name..

@jvdsn jvdsn changed the title Replace PKCS#1 v1.5 encryption in RSA PCT Replace PKCS#1 v1.5 padding in RSA PCT Mar 15, 2024
@jvdsn
Copy link
Contributor Author

jvdsn commented Mar 15, 2024

@paulidale let me know if you prefer this approach.

@openssl-machine
Copy link
Collaborator

This PR is in a state where it requires action by @openssl/otc but the last update was 30 days ago

@openssl-machine
Copy link
Collaborator

This PR is in a state where it requires action by @openssl/otc but the last update was 61 days ago

@openssl-machine
Copy link
Collaborator

This PR is in a state where it requires action by @openssl/otc but the last update was 92 days ago

@openssl-machine
Copy link
Collaborator

This PR is in a state where it requires action by @openssl/otc but the last update was 123 days ago

@openssl-machine
Copy link
Collaborator

This PR is in a state where it requires action by @openssl/otc but the last update was 154 days ago

@t8m t8m requested review from paulidale and slontis August 20, 2024 09:25
@t8m t8m added the extended tests Run extended tests in CI label Aug 20, 2024
@t8m t8m closed this Aug 20, 2024
@t8m t8m reopened this Aug 20, 2024
@slontis
Copy link
Member

slontis commented Aug 20, 2024

Maybe change whatever notation style check is complaining about.

@paulidale
Copy link
Contributor

paulidale commented Aug 20, 2024

The style issue needs to be fixed. We've had problems with characters in source > 127.
Seems likely it's the quotes at the end but I've not confirmed.

jvdsn added 4 commits August 20, 2024 16:47
After December 31, 2023, SP 800-131Ar2 [0] no longer allows PKCS#1 v1.5
padding for RSA "key-transport" (aka encryption and decryption).
There's a few good options to replace this usage in the RSA PCT, but
signature generation and verification using PKCS#1 v1.5 padding (which
remains approved) is the simplest.

[0]: https://doi.org/10.6028/NIST.SP.800-131Ar2
After December 31, 2023, SP 800-131Ar2 [0] no longer allows PKCS#1 v1.5
padding for RSA "key-transport" (aka encryption and decryption).
There's a few good options to replace this usage in the RSA PCT, but
the simplest is verifying m = (m^e)^d mod n, (where 1 < m < (n − 1)).
This is specified in SP 800-56Br2 (Section 6.4.1.1) [1] and allowed by
FIPS 140-3 IG 10.3.A. In OpenSSL, this corresponds to RSA_NO_PADDING.

[0]: https://doi.org/10.6028/NIST.SP.800-131Ar2
[1]: https://doi.org/10.6028/NIST.SP.800-56Br2
@jvdsn
Copy link
Contributor Author

jvdsn commented Aug 20, 2024

I believe it was the minus sign.

@paulidale
Copy link
Contributor

Thanks, I was about to fix this and you beat me to it.

@paulidale paulidale 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 Aug 20, 2024
@paulidale paulidale mentioned this pull request Aug 20, 2024
61 tasks
@paulidale paulidale added approval: ready to merge The 24 hour grace period has passed, ready to merge and removed approval: done This pull request has the required number of approvals labels Aug 21, 2024
@paulidale
Copy link
Contributor

Merged, thanks for sticking with this one.

@paulidale paulidale closed this Aug 21, 2024
openssl-machine pushed a commit that referenced this pull request Aug 21, 2024
After December 31, 2023, SP 800-131Ar2 [0] no longer allows PKCS#1 v1.5
padding for RSA "key-transport" (aka encryption and decryption).
There's a few good options to replace this usage in the RSA PCT, but
signature generation and verification using PKCS#1 v1.5 padding (which
remains approved) is the simplest.

[0]: https://doi.org/10.6028/NIST.SP.800-131Ar2

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Shane Lontis <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from #23832)
openssl-machine pushed a commit that referenced this pull request Aug 21, 2024
After December 31, 2023, SP 800-131Ar2 [0] no longer allows PKCS#1 v1.5
padding for RSA "key-transport" (aka encryption and decryption).
There's a few good options to replace this usage in the RSA PCT, but
the simplest is verifying m = (m^e)^d mod n, (where 1 < m < (n − 1)).
This is specified in SP 800-56Br2 (Section 6.4.1.1) [1] and allowed by
FIPS 140-3 IG 10.3.A. In OpenSSL, this corresponds to RSA_NO_PADDING.

[0]: https://doi.org/10.6028/NIST.SP.800-131Ar2
[1]: https://doi.org/10.6028/NIST.SP.800-56Br2

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Shane Lontis <[email protected]>
Reviewed-by: Paul Dale <[email protected]>
(Merged from #23832)
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 Applies to master branch extended tests Run extended tests in CI severity: fips change The pull request changes FIPS provider sources tests: exempted The PR is exempt from requirements for testing triaged: feature The issue/pr requests/adds a feature triaged: refactor The issue/pr requests/implements refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants