summaryrefslogtreecommitdiffstats
path: root/crypto/rsa/rsa_err.c
diff options
context:
space:
mode:
authorDavid Benjamin <davidben@google.com>2016-08-20 13:35:17 -0400
committerKurt Roeckx <kurt@roeckx.be>2016-11-07 21:06:48 +0100
commitb71079a375116a8a52ed493afcd8f69cb08c195a (patch)
tree8176bcb26fded3ca805b951fc0b11051b9854f6f /crypto/rsa/rsa_err.c
parent929cc3fa6bceba1c6d9c362c56b89cbf2acf40bc (diff)
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 (cherry picked from commit 608a026494c1e7a14f6d6cfcc5e4994fe2728836)
Diffstat (limited to 'crypto/rsa/rsa_err.c')
-rw-r--r--crypto/rsa/rsa_err.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/crypto/rsa/rsa_err.c b/crypto/rsa/rsa_err.c
index 210709e5c9..45e12e0dd3 100644
--- a/crypto/rsa/rsa_err.c
+++ b/crypto/rsa/rsa_err.c
@@ -20,6 +20,7 @@
static ERR_STRING_DATA RSA_str_functs[] = {
{ERR_FUNC(RSA_F_CHECK_PADDING_MD), "check_padding_md"},
+ {ERR_FUNC(RSA_F_ENCODE_PKCS1), "encode_pkcs1"},
{ERR_FUNC(RSA_F_INT_RSA_VERIFY), "int_rsa_verify"},
{ERR_FUNC(RSA_F_OLD_RSA_PRIV_DECODE), "old_rsa_priv_decode"},
{ERR_FUNC(RSA_F_PKEY_RSA_CTRL), "pkey_rsa_ctrl"},