briansmith / ring

Safe, fast, small crypto using Rust
Other
3.69k stars 695 forks source link

Add RSA-PSS signing #213

Closed DemiMarie closed 7 years ago

DemiMarie commented 8 years ago

If ring is going to support RSA-PKCS#1.5 signing it should support RSA-PSS signing.

briansmith commented 8 years ago

This should require just simple modifications to whatever is done in #208.

burdges commented 8 years ago

It's maybe worth noting that RSA usage is declining in classical cryptographic applications and increasingly for situations needing homomorphic properties, like Paillier, voting, accumulators, etc., which means lower level access. Yey foot guns!

In Taler (not in Rust) for example, we use RSA blind signatures because Schnorr blind signatures would require an extra round trip and BLS blind signatures employ a Weil pairing. PSS is useless in that setting. Instead, one needs a full domain hash and an entirely different proof of security from different underlying assumption.

briansmith commented 8 years ago

See https://github.com/briansmith/ring/issues/115#issuecomment-227272106 for the details of how to support the various PSS parameters.

It's probably a good idea to implement PSS verification first.

briansmith commented 8 years ago

Regarding how the salts work, the main question is whether we can safely implement a deterministic RSA-PSS scheme that interops with other implementations, particularly implementations that are designed according to TLS 1.3's requirements. For now, I suggest that we always generate a fixed salt that has the same length as the digest's output length, e.g. 32 bytes of zeros for SHA-256 and 48 bytes of zeros for SHA-384. This way, our signatures will be completely deterministic.

Internally, in order to pass the NIST test suite, we'll have to support salts with other values.

References in support of doing this:

briansmith commented 8 years ago

References in support of a randomized salt being useful:

briansmith commented 8 years ago

More support of randomized signatures: Making RSA-PSS Provably Secure Against Non-Random Faults, which also cites other work on the benefits of PSS-style randomization regarding fault attacks. However, it isn't clear that PSS benefits us much regarding fault attacks given that we already verify the result of the modular exponentiation x = nd (mod n) by verifying xe (mod n).

DemiMarie commented 8 years ago

One thought might be to do what deterministic DSA and ECDSA implementations (which leak the private key if the ephemeral key is not. random) do and generate the salt from the private key and message. We know that the private key has enough entropy, so we just need to assume a PDF that is good.

On Aug 9, 2016 5:57 PM, "Brian Smith" notifications@github.com wrote:

More support of randomized signatures: Making RSA-PSS Provably Secure Against Non-Random Faults https://eprint.iacr.org/2014/252, which also cites other work on the benefits of PSS-style randomization regarding fault attacks. However, it isn't clear that PSS benefits us much regarding fault attacks given that we already verify the result of the modular exponentiation x = nd (mod n) by verifying xe (mod n).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/briansmith/ring/issues/213#issuecomment-238704994, or mute the thread https://github.com/notifications/unsubscribe-auth/AGGWB9frAoZ96BkbdmCu-XRZx2fMDAFIks5qePfZgaJpZM4Iyb6p .

briansmith commented 8 years ago

The deterministic RSA-PSS scheme I suggested (just a fixed zero-valued salt) seems too controversial to add just yet. @samscott89 already wrote the randomized-salt version. Let's move the discussion of how to do deterministic RSA-PSS and/or FDH safely to #264.

briansmith commented 7 years ago

The implementation of this landed in master in #262; see https://github.com/briansmith/ring/pull/262#issuecomment-260765364.

The main thing that's missing at this point is the tests for signatures with public key moduli that are {2048, 4096, 8192} ± 1 bit. Unlike for verification, we don't have any tests for that at the padding layer, and like for verification, we don't have tests for that that cover that for the entire signing operation. More generally we should have test vectors for all the checks in the code; in particular, let's look at the code coverage report and verify that every return Err(error::Unspecified); line is either covered or has a note about why it is impossible.

briansmith commented 7 years ago

Again, @samscott89 did an amazing job adding the tests, in addition to doing the implementation work! Thanks!