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 RSA PSS salt lengths #422

Conversation

trishankatdatadog
Copy link
Contributor

@trishankatdatadog trishankatdatadog commented Aug 4, 2022

Fixes: #421

Description of the changes being introduced by the pull request:

This PR does two things:

  1. Use the maximum salt length by default when creating RSA PSS signatures.
  2. Use the automatic salt length inferred from RSA PSS signatures when verifying them.

This should be the simplest, most backwards-compatible, and yet most secure way to verify cross-platform RSA PSS signatures.

Missing tests

  • Can automatically verify RSA PSS signatures regardless of the input salt length

Please verify and check that the pull request fulfils the following requirements:

  • The code follows the Code Style Guidelines
  • Tests have been added for the bug fix or new feature
  • Docs have been added for the bug fix or new feature

Copy link
Member

@lukpueh lukpueh left a comment

Choose a reason for hiding this comment

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

Thanks, @trishankatdatadog. Great patch and issue/pr description!

Can automatically verify RSA PSS signatures regardless of the input salt length

Testing that would indeed be great. Do you have capacities?

@trishankatdatadog trishankatdatadog marked this pull request as ready for review August 9, 2022 04:07
@trishankatdatadog
Copy link
Contributor Author

Testing that would indeed be great. Do you have capacities?

Done. PTAL?

Copy link
Member

@lukpueh lukpueh left a comment

Choose a reason for hiding this comment

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

Thanks for adding tests, @trishankatdatadog! Left two non-blocking comments inline.

tests/test_rsa_keys.py Outdated Show resolved Hide resolved
tests/test_rsa_keys.py Show resolved Hide resolved
tests/test_rsa_keys.py Outdated Show resolved Hide resolved
@trishankatdatadog
Copy link
Contributor Author

@lukpueh OK, done, simplified tests, PTAL, thx!

- use maximum salt length by default when creating sigs
- use automatic salt length inferred from sigs when verifying

this should be the simplest, backwards-compatible, and secure
way to verify cross-platform RSA PSS signatures, especially with
Golang crypto/rsa
@trishankatdatadog trishankatdatadog force-pushed the trishankatdatadog/rsassa-pss-salt-lengths branch from 2b94e8e to 1811500 Compare September 2, 2022 04:39
Copy link
Member

@lukpueh lukpueh left a comment

Choose a reason for hiding this comment

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

💯

@lukpueh lukpueh merged commit 9e23bd2 into secure-systems-lab:master Sep 5, 2022
@trishankatdatadog trishankatdatadog deleted the trishankatdatadog/rsassa-pss-salt-lengths branch September 6, 2022 15:51
@trishankatdatadog
Copy link
Contributor Author

Thanks, Lukas! Could we please get a release?

Cc @yzhan289

lukpueh added a commit to lukpueh/securesystemslib that referenced this pull request Oct 13, 2022
In secure-systems-lab#422 we changed `create_rsa_signature` to use the maximum salt
length available, instead of the digest length, when creating
rsassa-pss signatures, and adapted `verify_rsa_signature` to infer
the salt length automatically.

This made it impossible for users of the old verify function, which
could only handle digest sized salts, to verify signatures created
by users of the new signing function (see secure-systems-lab#430).

Since the advantage of max salt lengths is mostly academic, this
patch reverts  `create_rsa_signature` to use digest sized salts.

Note that we now use the `padding.PSS.DIGEST_LENGTH` constant
instead of passing the actual digest length, as we did before.
Using the constant has the same result, but is recommended by the
library documentation.

Also note that the patch does not revert the `verify_rsa_signature`
part of secure-systems-lab#422. This allows verifying signatures created with the
securesystemslib release that used max salt lengths, or created
outside of securesystemslib.

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
lukpueh added a commit to lukpueh/securesystemslib that referenced this pull request Oct 13, 2022
In secure-systems-lab#422 we changed `create_rsa_signature` to use the maximum salt
length available, instead of the digest length, when creating
rsassa-pss signatures, and adapted `verify_rsa_signature` to infer
the salt length automatically.

This made it impossible for users of the old verify function, which
could only handle digest sized salts, to verify signatures created
by users of the new signing function (see secure-systems-lab#430).

Since the advantage of max salt lengths is mostly academic, this
patch reverts  `create_rsa_signature` to use digest sized salts (as
agreed in secure-systems-lab#431).

Note that we now use the `padding.PSS.DIGEST_LENGTH` constant
instead of passing the actual digest length, as we did before.
Using the constant has the same result, but is recommended by the
library documentation.

Also note that the patch does not revert the `verify_rsa_signature`
part of secure-systems-lab#422. This allows verifying signatures created with the
securesystemslib release that used max salt lengths, or created
outside of securesystemslib.

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
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.

Cross-platform verification of RSA PSS signatures
2 participants