You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 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.)
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.
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.
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.
Activity
briansmith commentedon Jun 20, 2016
From the TLS 1.3 draft spec:
briansmith commentedon Aug 7, 2016
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.
briansmith commentedon Nov 15, 2016
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 everyreturn Err(error::Unspecified);line is covered. Also, we should have a test vector to verify that we do theh_hash != h_primecomparison correctly; e.g. vectors that would pass if we didh_hash != h_hashorh_prime != h_prime.Additionally, @samscott89 mentioned refactoring the code a little bit to be more like the refactored encoding code.
briansmith commentedon Dec 21, 2016
@samscott89 Did amazing work on this! Thanks again!