boringssl/crypto/asn1
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_bitstr.c Inital import. 2014-06-20 13:17:32 -07:00
a_bool.c Inital import. 2014-06-20 13:17:32 -07:00
a_bytes.c Inital import. 2014-06-20 13:17:32 -07:00
a_d2i_fp.c Inital import. 2014-06-20 13:17:32 -07:00
a_dup.c Inital import. 2014-06-20 13:17:32 -07:00
a_enum.c Inital import. 2014-06-20 13:17:32 -07:00
a_gentm.c Remove CHARSET_EBCDIC 2014-07-07 19:30:35 +00:00
a_i2d_fp.c Inital import. 2014-06-20 13:17:32 -07:00
a_int.c Inital import. 2014-06-20 13:17:32 -07:00
a_mbstr.c Remove CHARSET_EBCDIC 2014-07-07 19:30:35 +00:00
a_object.c Fix OID handling. 2014-08-07 21:09:47 +00:00
a_octet.c Inital import. 2014-06-20 13:17:32 -07:00
a_print.c Remove CHARSET_EBCDIC 2014-07-07 19:30:35 +00:00
a_strnid.c Convert all zero-argument functions to '(void)' 2014-08-21 01:06:07 +00:00
a_time.c Remove CHARSET_EBCDIC 2014-07-07 19:30:35 +00:00
a_type.c Fix various certificate fingerprint issues. 2015-01-09 19:41:59 +00:00
a_utctm.c Memory leak and NULL dereference fixes. 2014-07-28 17:05:12 -07:00
a_utf8.c Inital import. 2014-06-20 13:17:32 -07:00
asn1_error.c Don't mix and match libraries and errors. 2014-10-13 22:56:28 +00:00
asn1_lib.c Add visibility rules. 2014-07-31 22:03:11 +00:00
asn1_locl.h Move the X509_NAME typedef into x509.h. 2014-10-28 22:38:38 +00:00
asn1_par.c Inital import. 2014-06-20 13:17:32 -07:00
asn_pack.c Remove some dead code. 2014-08-19 19:00:49 +00:00
bio_asn1.c Memory leak and NULL dereference fixes. 2014-07-28 17:05:12 -07:00
bio_ndef.c Inital import. 2014-06-20 13:17:32 -07:00
charmap.pl Add license to charmap.pl. 2014-06-30 16:48:53 -07:00
CMakeLists.txt Inital import. 2014-06-20 13:17:32 -07:00
f_enum.c Fix a2i_ASN1_* leak on failure. 2014-11-06 01:29:59 +00:00
f_int.c Fix a2i_ASN1_* leak on failure. 2014-11-06 01:29:59 +00:00
f_string.c Fix a2i_ASN1_* leak on failure. 2014-11-06 01:29:59 +00:00
t_bitst.c Inital import. 2014-06-20 13:17:32 -07:00
t_pkey.c Inital import. 2014-06-20 13:17:32 -07:00
tasn_dec.c Shush some dead assignments. 2014-11-06 01:34:33 +00:00
tasn_enc.c Memory leak and NULL dereference fixes. 2014-07-28 17:05:12 -07:00
tasn_fre.c Inital import. 2014-06-20 13:17:32 -07:00
tasn_new.c Inital import. 2014-06-20 13:17:32 -07:00
tasn_prn.c Const correctness. 2014-06-20 13:17:36 -07:00
tasn_typ.c Inital import. 2014-06-20 13:17:32 -07:00
tasn_utl.c Inital import. 2014-06-20 13:17:32 -07:00
x_bignum.c Add malloc failure tests. 2014-11-19 01:24:46 +00:00
x_long.c Inital import. 2014-06-20 13:17:32 -07:00