openssl/crypto/rsa
David Benjamin 608a026494 Implement RSASSA-PKCS1-v1_5 as specified.
RFC 3447, section 8.2.2, steps 3 and 4 states that verifiers must encode
the DigestInfo struct and then compare the result against the public key
operation result. This implies that one and only one encoding is legal.

OpenSSL instead parses with crypto/asn1, then checks that the encoding
round-trips, and allows some variations for the parameter. Sufficient
laxness in this area can allow signature forgeries, as described in
https://www.imperialviolet.org/2014/09/26/pkcs1.html

Although there aren't known attacks against OpenSSL's current scheme,
this change makes OpenSSL implement the algorithm as specified. This
avoids the uncertainty and, more importantly, helps grow a healthy
ecosystem. Laxness beyond the spec, particularly in implementations
which enjoy wide use, risks harm to the ecosystem for all. A signature
producer which only tests against OpenSSL may not notice bugs and
accidentally become widely deployed. Thus implementations have a
responsibility to honor the specification as tightly as is practical.

In some cases, the damage is permanent and the spec deviation and
security risk becomes a tax all implementors must forever pay, but not
here. Both BoringSSL and Go successfully implemented and deployed
RSASSA-PKCS1-v1_5 as specified since their respective beginnings, so
this change should be compatible enough to pin down in future OpenSSL
releases.

See also https://tools.ietf.org/html/draft-thomson-postel-was-wrong-00

As a bonus, by not having to deal with sign/verify differences, this
version is also somewhat clearer. It also more consistently enforces
digest lengths in the verify_recover codepath. The NID_md5_sha1 codepath
wasn't quite doing this right.

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Rich Salz <rsalz@openssl.org>

GH: #1474
2016-11-07 21:04:54 +01:00
..
build.info Make the RSA_METHOD structure opaque 2016-04-06 16:19:20 +02:00
rsa_ameth.c Constify private key decode. 2016-08-17 12:01:29 +01:00
rsa_asn1.c Copyright consolidation 08/10 2016-05-17 14:51:34 -04:00
rsa_chk.c RT2676: Reject RSA eponent if even or 1 2016-08-22 11:25:12 -04:00
rsa_crpt.c Deprecate the flags that switch off constant time 2016-06-06 11:09:06 +01:00
rsa_depr.c Copyright consolidation 08/10 2016-05-17 14:51:34 -04:00
rsa_err.c Implement RSASSA-PKCS1-v1_5 as specified. 2016-11-07 21:04:54 +01:00
rsa_gen.c Deprecate the flags that switch off constant time 2016-06-06 11:09:06 +01:00
rsa_lib.c rsa/rsa_lib.c: const-ify RSA_get0_engine(). 2016-06-27 23:31:55 +02:00
rsa_locl.h Copyright consolidation 08/10 2016-05-17 14:51:34 -04:00
rsa_meth.c Remove useless NULL checks 2016-05-23 13:37:02 +01:00
rsa_none.c Useless header include of openssl/rand.h 2016-06-18 16:30:24 -04:00
rsa_null.c Useless header include of openssl/rand.h 2016-06-18 16:30:24 -04:00
rsa_oaep.c Copyright consolidation 08/10 2016-05-17 14:51:34 -04:00
rsa_ossl.c Useless header include of openssl/rand.h 2016-06-18 16:30:24 -04:00
rsa_pk1.c Whitespace cleanup in crypto 2016-06-29 09:56:39 -04:00
rsa_pmeth.c RT2676: Reject RSA eponent if even or 1 2016-08-22 11:25:12 -04:00
rsa_prn.c Copyright consolidation 08/10 2016-05-17 14:51:34 -04:00
rsa_pss.c Copyright consolidation 08/10 2016-05-17 14:51:34 -04:00
rsa_saos.c Copyright consolidation 08/10 2016-05-17 14:51:34 -04:00
rsa_sign.c Implement RSASSA-PKCS1-v1_5 as specified. 2016-11-07 21:04:54 +01:00
rsa_ssl.c Copyright consolidation 08/10 2016-05-17 14:51:34 -04:00
rsa_x931.c Useless header include of openssl/rand.h 2016-06-18 16:30:24 -04:00
rsa_x931g.c Copyright consolidation 08/10 2016-05-17 14:51:34 -04:00