13 Commits

Author SHA1 Message Date
Brian Smith
a38d9a4ef9 Verify RSA PKCS#1 1.5 signatures by encode-then-check.
When we first implemented PKCS#1 1.5 signature verification we had not
implemented signature generation, so we implemented verification by
parsing the padding. Now that we have generation we can save some code
and arguably make verification safer. Also, this is the way RFC 3447
recommends to do it.
2016-11-23 09:01:36 -10:00
Brian Smith
f0f9b00e1a Expose RSAEncoding in the public API.
Expose `RSAEncoding` in the public API so that users of *ring* can use
it in type signatures. Add an "RSA" prefix to the exported types, since
they will be exported from `ring::signature`. Modify RSA tests to use
only the public API so as to ensure that enough of the API is public.
2016-11-15 12:02:42 -10:00
Brian Smith
5fb1fc8a5e Add and use PUBLIC_KEY_PUBLIC_MODULUS_MAX_LEN.
`PUBLIC_KEY_PUBLIC_MODULUS_MAX_LEN` is measured in bytes, whereas
`PUBLIC_MODULUS_MAX_LEN` was measured in bits.
2016-11-15 10:43:31 -10:00
Brian Smith
be08baa959 Add BitLength type and use it in RSA padding.
Besides improving type safety generally, this fixes a bug in RSA PSS
signing where the wrong value of `mod_bits` was being passed to
`Encoding::encode()`.
2016-11-15 10:43:30 -10:00
Brian Smith
4c9a9c8751 Refactor PSS encoding. 2016-11-15 10:43:29 -10:00
Brian Smith
eeb99a780e Factor out common metric calculations in PSS padding. 2016-11-15 10:43:27 -10:00
Brian Smith
18ff68f90c Factor out shared digesting logic in PSS padding. 2016-11-15 10:41:18 -10:00
Brian Smith
5be8b7f960 Fix (mod_bits - 1) % 8 == 0 case for PSS encoding.
fix encoding
2016-11-15 10:41:16 -10:00
Sam Scott
2e9ef69c23 Implement RSA-PSS signing.
-  Refactor Encoding trait to be randomised.
 -  Add RSA-PSS signing test cases.

I agree to license my contributions to each file under the terms given
at the top of each file I changed.
2016-11-15 10:39:48 -10:00
Brian Smith
8cb3673417 Factor out common logic in internal RSA padding interface.
Factor out the duplicate checks that `m` is fully consumed.
2016-11-15 10:39:34 -10:00
Brian Smith
7520d283eb Fix (mod_bits - 1) % == 0 case in RSA PSS verification.
Output the extra leading zero byte when necessary.

Rename parameters in the `Encoding` interface to match the
specification and update the implementations to use the updated
variable names.
2016-11-15 10:39:32 -10:00
Sam Scott
4e5145157c Implement RSA-PSS verification.
-  Add tests for RSA-PSS verification from NIST test cases.

I agree to license my contributions to each file under the terms given
at the top of each file I changed.
2016-11-15 10:39:28 -10:00
Sam Scott
cb3ce35061 Refactor RSA padding to new Encoding/Verification traits.
I agree to license my contributions to each file under the terms given
at the top of each file I changed.
2016-09-12 10:42:45 -10:00