boringssl/crypto/x509
Adam Langley ca9a538aa0 Fix various certificate fingerprint issues.
By using non-DER or invalid encodings outside the signed portion of a
certificate the fingerprint can be changed without breaking the signature.
Although no details of the signed portion of the certificate can be changed
this can cause problems with some applications: e.g. those using the
certificate fingerprint for blacklists.

1. Reject signatures with non zero unused bits.

If the BIT STRING containing the signature has non zero unused bits reject the
signature. All current signature algorithms require zero unused bits.

2. Check certificate algorithm consistency.

Check the AlgorithmIdentifier inside TBS matches the one in the certificate
signature. NB: this will result in signature failure errors for some broken
certificates.

3. Check DSA/ECDSA signatures use DER.

Reencode DSA/ECDSA signatures and compare with the original received signature.
Return an error if there is a mismatch.

This will reject various cases including garbage after signature (thanks to
Antti Karjalainen and Tuomo Untinen from the Codenomicon CROSS program for
discovering this case) and use of BER or invalid ASN.1 INTEGERs (negative or
with leading zeroes).

CVE-2014-8275

(Imported from upstream's 85cfc188c06bd046420ae70dd6e302f9efe022a9 and
4c52816d35681c0533c25fdd3abb4b7c6962302d)

Change-Id: Ic901aea8ea6457df27dc542a11c30464561e322b
Reviewed-on: https://boringssl-review.googlesource.com/2783
Reviewed-by: David Benjamin <davidben@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2015-01-09 19:41:59 +00:00
..
a_digest.c Fix a_{digest,verify}.c error codepaths. 2014-10-06 23:50:31 +00:00
a_sign.c Add EVP_DigestVerifyInitFromAlgorithm and EVP_DigestSignAlgorithm. 2014-10-09 21:52:52 +00:00
a_strex.c ASN1_STRING_to_UTF8 missing initializer. 2014-11-10 13:45:32 -08:00
a_verify.c Fix various certificate fingerprint issues. 2015-01-09 19:41:59 +00:00
asn1_gen.c Remove misspelled error code. 2014-10-09 21:03:42 +00:00
by_dir.c Don't compare signed vs. unsigned. 2014-10-01 02:17:38 +00:00
by_file.c
charmap.h
CMakeLists.txt Add PKCS7_bundle_certificates. 2014-08-07 18:12:25 +00:00
i2d_pr.c
pkcs7_test.c Add a CRYPTO_library_init and static-initializer-less build option. 2014-09-12 00:10:53 +00:00
pkcs7.c Rework support for ASN.1 BER. 2014-08-25 21:38:08 +00:00
t_crl.c Shush some dead assignments. 2014-11-06 01:34:33 +00:00
t_x509.c Memory leak and NULL dereference fixes. 2014-07-28 17:05:12 -07:00
t_x509a.c
vpm_int.h Fixes to host checking. 2014-06-20 13:17:40 -07:00
x509_att.c
x509_cmp.c unifdef a bunch of OPENSSL_NO_* ifdefs. 2014-08-28 00:41:34 +00:00
x509_d2.c
x509_def.c
x509_error.c Fix various certificate fingerprint issues. 2015-01-09 19:41:59 +00:00
x509_ext.c
x509_lu.c Add X509_up_ref and use it internally. 2014-08-07 00:06:34 +00:00
x509_obj.c Remove CHARSET_EBCDIC 2014-07-07 19:30:35 +00:00
x509_r2x.c
x509_req.c unifdef a bunch of OPENSSL_NO_* ifdefs. 2014-08-28 00:41:34 +00:00
x509_set.c Omit version for v1 certificates. 2014-11-10 13:45:32 -08:00
x509_trs.c Fix error handling in X509_PURPOSE_add and X509_TRUST_add. 2014-11-06 01:44:43 +00:00
x509_txt.c
x509_v3.c
x509_vfy.c Fix a couple of minor compiler warnings. 2015-01-06 00:27:22 +00:00
x509_vpm.c Fix mis-sized allocation in x509_vpm.c 2014-07-30 00:33:49 +00:00
x509.c
x509cset.c
x509name.c
x509rset.c
x509spki.c Introduce EVP_DecodeBase64. 2014-08-25 23:00:28 +00:00
x509type.c
x_algor.c Fix various certificate fingerprint issues. 2015-01-09 19:41:59 +00:00
x_all.c Fix various certificate fingerprint issues. 2015-01-09 19:41:59 +00:00
x_attrib.c
x_crl.c Move the X509_NAME typedef into x509.h. 2014-10-28 22:38:38 +00:00
x_exten.c
x_info.c
x_name.c Add malloc failure tests. 2014-11-19 01:24:46 +00:00
x_pkey.c Remove i2d_X509_PKEY and d2i_X509_PKEY. 2014-11-10 22:28:23 +00:00
x_pubkey.c unifdef a bunch of OPENSSL_NO_* ifdefs. 2014-08-28 00:41:34 +00:00
x_req.c
x_sig.c
x_spki.c
x_val.c
x_x509.c Add X509_up_ref and use it internally. 2014-08-07 00:06:34 +00:00
x_x509a.c