Skip to content

Implement RSASSA-PSS signature verification #115

Closed

Description

@briansmith

BoringSSL already implemented PSS, but it did so using the C digest API that we removed, so the PSS code was removed. We need to implement the PSS digest calculations in Rust using the ring digest API.

The IETF spec for PSS is at https://tools.ietf.org/html/rfc3447#section-8.

The commit that removed the BoringSSL PSS code is 4f3535e#diff-03f44f4ac02526e7db1f33340b4642e3L519. Don't transliterate the BoringSSL code, as it is under the OpenSSL license and new Rust code is only be accepted under the ISC license.

It would probably be a good idea to refactor the existing RSA PKCS#1 code in ring (the Rust code and the C code) in order to make this work better.

The webpki project contains some test vectors for PSS that should be enabled once this is working. (Though, that requires modifying webpki to parse PSS keys.)

Activity

  1. briansmith commented on Jun 20, 2016

    @briansmith
    OwnerAuthor

    From the TLS 1.3 draft spec:

    RSASSA-PSS algorithms
          Indicates a signature algorithm using RSASSA-PSS [RFC3447] with
          MGF1.  The digest used in the mask generation function and the
          digest being signed are both the corresponding hash algorithm as
          defined in [SHS].  When used in signed TLS handshake messages (see
          Section 4.8.1), the length of the salt MUST be equal to the length
          of the digest output.
    
  2. briansmith commented on Aug 7, 2016

    @briansmith
    OwnerAuthor

    An update on the salt recommendations from above:

    See #213 (comment). It seems like we don't gain anything by requiring a salt. Therefore, it would be nice of the implementation of verification could accept all salts from length 0 up to and including the digest output length, but not salts longer than the digest output length. Unfortunately, the way that PSS is used in X.509, the salt length is specified in a parameter of the RSA-PSS public key and/or signature, and according to the spec "For a given hashAlgorithm, the recommended value of saltLength is the number of octets in the hash value. Unlike the other fields of type RSASSA-PSS-params, saltLength does not need to be fixed for a given RSA key pair; a different value could be used for each RSASSA-PSS signature generated." The above-quoted TLS 1.3 text mandates that that recommendation be followed. Thus, unless something changes at IETF, we should accept only salts that are exactly the same length as the digest output length, even though such salts are overkill.

  3. briansmith commented on Nov 15, 2016

    @briansmith
    OwnerAuthor

    The implementation of this landed in master in #262 (See #262 (comment)).

    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. We have such test vectors that test the padding part, but we need test vectors that cover that for the entire signature verification. Also, we should have some negative test vectors. In particular, we should have a test vector for the case where the leading 0x00 byte is not present in the case where em_len < k. 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 covered. Also, we should have a test vector to verify that we do the h_hash != h_prime comparison correctly; e.g. vectors that would pass if we did h_hash != h_hash or h_prime != h_prime.

    Additionally, @samscott89 mentioned refactoring the code a little bit to be more like the refactored encoding code.

  4. added this to the 0.6 milestone on Nov 15, 2016
  5. briansmith commented on Dec 21, 2016

    @briansmith
    OwnerAuthor

    @samscott89 Did amazing work on this! Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions