openssl/crypto
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
..
aes x86_64 assembly pack: add Goldmont performance results. 2016-10-24 13:01:13 +02:00
asn1 Convert asn1 selftests (a_strnid and ameth_lib) into internal test 2016-11-03 13:13:31 +01:00
async
bf
bio Try to unify BIO read/write parameter names 2016-10-29 00:56:52 +02:00
blake2
bn ppccap.c: engage new multipplication and squaring subroutines. 2016-10-24 20:00:40 +02:00
buffer
camellia Remove trailing whitespace from some files. 2016-10-10 23:36:21 +01:00
cast Remove trailing whitespace from some files. 2016-10-10 23:36:21 +01:00
chacha x86_64 assembly pack: add Goldmont performance results. 2016-10-24 13:01:13 +02:00
cmac
cms Fix enable-zlib 2016-08-22 09:43:13 +01:00
comp
conf
ct Add -Wswitch-enum 2016-09-22 08:36:26 -04:00
des Remove trailing whitespace from some files. 2016-10-10 23:36:21 +01:00
dh Constify private key decode. 2016-08-17 12:01:29 +01:00
dsa Fix a missing NULL check in dsa_builtin_paramgen 2016-09-21 13:32:30 +01:00
dso Add a DSO_dsobyaddr() function 2016-11-02 23:32:50 +00:00
ec Remove trailing whitespace from some files. 2016-10-10 23:36:21 +01:00
engine Fix support for DragonFly BSD 2016-10-22 04:25:17 -04:00
err Ensure we handle len == 0 in ERR_err_string_n 2016-10-15 11:30:15 +01:00
evp Clean away remaining 'selftest' code 2016-11-03 13:15:40 +01:00
hmac Fix style issues in HMAC_size() 2016-11-04 12:09:46 +00:00
idea
include/internal Remove an useless definition. 2016-09-17 12:32:37 -04:00
kdf
lhash GH1555: Don't bump size on realloc failure 2016-09-21 10:40:27 -04:00
md2
md4
md5 Remove trailing whitespace from some files. 2016-10-10 23:36:21 +01:00
mdc2 Convert mdc2 test print to internal test 2016-11-03 13:13:31 +01:00
modes Convert modes selftests (cts128 and gcm128) to internal test 2016-11-03 13:13:31 +01:00
objects Clean away remaining 'selftest' code 2016-11-03 13:15:40 +01:00
ocsp Add OCSP_RESPID_match() 2016-09-22 09:27:45 +01:00
pem Limit reads in do_b2i_bio() 2016-08-16 00:27:10 +01:00
perlasm Remove trailing whitespace from some files. 2016-10-10 23:36:21 +01:00
pkcs7
pkcs12 Don't switch password formats using global state. 2016-08-25 11:42:33 +01:00
poly1305 Convert poly1305 selftest into internal test 2016-11-03 13:13:31 +01:00
rand rand/randfile.c: treat empty string in RAND_file_name as error. 2016-09-21 21:09:11 +02:00
rc2 Clean away remaining 'selftest' code 2016-11-03 13:15:40 +01:00
rc4 Remove trailing whitespace from some files. 2016-10-10 23:36:21 +01:00
rc5
ripemd Remove trailing whitespace from some files. 2016-10-10 23:36:21 +01:00
rsa Implement RSASSA-PKCS1-v1_5 as specified. 2016-11-07 21:04:54 +01:00
seed
sha sha/keccak1600.c: add couple of soft asserts. 2016-10-31 22:18:07 +01:00
srp SRP code tidy. 2016-10-01 13:46:54 +01:00
stack Don't leak on an OPENSSL_realloc() failure 2016-09-21 20:27:15 +01:00
ts Add error checking, small nit on ouput 2016-10-19 06:37:42 -04:00
txt_db
ui Add -Wswitch-enum 2016-09-22 08:36:26 -04:00
whrlpool Remove trailing whitespace from some files. 2016-10-10 23:36:21 +01:00
x509 Fix X509_NAME decode for malloc failures. 2016-10-11 22:09:31 +01:00
x509v3 Clean away remaining 'selftest' code 2016-11-03 13:15:40 +01:00
alphacpuid.pl
arm64cpuid.pl
arm_arch.h
armcap.c
armv4cpuid.pl
build.info
c64xpluscpuid.pl
cpt_err.c
cryptlib.c
cversion.c
dllmain.c
ebcdic.c
ex_data.c Fix mem leaks during auto-deinit 2016-09-08 12:40:19 +01:00
ia64cpuid.S
init.c Implement GET_MODULE_HANDLE_EX_FLAG_PIN for windows 2016-11-02 23:32:50 +00:00
LPdir_nyi.c
LPdir_unix.c
LPdir_vms.c
LPdir_win32.c
LPdir_win.c
LPdir_wince.c
mem_clr.c Fix some style issues... 2016-08-02 09:59:23 +02:00
mem_dbg.c
mem_sec.c
mem.c
mips_arch.h Remove trailing whitespace from some files. 2016-10-10 23:36:21 +01:00
o_dir.c
o_fips.c
o_fopen.c
o_init.c
o_str.c
o_time.c VSI submisson: make better use of item lists in o_time.c 2016-08-04 16:51:39 +02:00
pariscid.pl
ppc_arch.h
ppccap.c ppccap.c: engage new multipplication and squaring subroutines. 2016-10-24 20:00:40 +02:00
ppccpuid.pl
s390xcap.c Fix strict-warnings build 2016-10-18 17:09:47 +01:00
s390xcpuid.S
sparc_arch.h
sparccpuid.S spelling fixes, just comments and readme. 2016-08-05 19:07:30 -04:00
sparcv9cap.c crypto/sparcv9cap.c: add missing declaration. 2016-08-12 10:26:20 +02:00
threads_none.c
threads_pthread.c CRYPTO_atomic_add(): check that the object is lock free 2016-08-24 14:37:48 +01:00
threads_win.c
uid.c Fix support for DragonFly BSD 2016-10-22 04:25:17 -04:00
vms_rms.h
x86_64cpuid.pl
x86cpuid.pl Remove trailing whitespace from some files. 2016-10-10 23:36:21 +01:00