Commit graph

4351 commits

Author SHA1 Message Date
Matt Caswell
74743418dc Prepare for 0.9.8zi-dev
Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-12-03 15:00:54 +00:00
Matt Caswell
c2ef67100c Prepare for 0.9.8zh release
Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-12-03 15:00:17 +00:00
Dr. Stephen Henson
2cdafc51f0 Fix leak with ASN.1 combine.
When parsing a combined structure pass a flag to the decode routine
so on error a pointer to the parent structure is not zeroed as
this will leak any additional components in the parent.

This can leak memory in any application parsing PKCS#7 or CMS structures.

CVE-2015-3195.

Thanks to Adam Langley (Google/BoringSSL) for discovering this bug using
libFuzzer.

PR#4131

Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-12-02 21:40:20 +01:00
Dr. Stephen Henson
2c02faeecd Fix uninitialised p error.
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 63eb10a07e)
2015-11-24 16:56:02 +00:00
Dr. Stephen Henson
a8731c0cb8 Limit depth of ASN1 parse printing.
Thanks to Guido Vranken <guidovranken@gmail.com> for reporting this issue.

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 158e5207a7)

Conflicts:
	crypto/asn1/asn1_par.c
2015-11-24 15:31:05 +00:00
Dr. Stephen Henson
31172717e8 Typo.
PR#4079

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit c69ce93513)

Conflicts:
	crypto/evp/e_des3.c
2015-10-11 00:39:27 +01:00
Matt Caswell
5e7d583bab Make sure OPENSSL_cleanse checks for NULL
In master we have the function OPENSSL_clear_free(x,y), which immediately
returns if x == NULL. In <=1.0.2 this function does not exist so we have to
do:
OPENSSL_cleanse(x, y);
OPENSSL_free(x);

However, previously, OPENSSL_cleanse did not check that if x == NULL, so
the real equivalent check would have to be:
if (x != NULL)
    OPENSSL_cleanse(x, y);
OPENSSL_free(x);

It would be easy to get this wrong during cherry-picking to other branches
and therefore, for safety, it is best to just ensure OPENSSL_cleanse also
checks for NULL.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 020d8fc83f)
2015-09-17 22:37:21 +01:00
Matt Caswell
2c9dfa18aa Prepare for 0.9.8zh-dev
Reviewed-by: Stephen Henson <steve@openssl.org>
2015-06-11 15:23:16 +01:00
Matt Caswell
0823ddc56e Prepare for 0.9.8zg release
Reviewed-by: Stephen Henson <steve@openssl.org>
2015-06-11 15:20:22 +01:00
Emilia Kasper
582f1f41d4 PKCS#7: Fix NULL dereference with missing EncryptedContent.
CVE-2015-1790

Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-06-11 13:07:49 +01:00
Emilia Kasper
fa57f74a39 Fix length checks in X509_cmp_time to avoid out-of-bounds reads.
Also tighten X509_cmp_time to reject more than three fractional
seconds in the time; and to reject trailing garbage after the offset.

CVE-2015-1789

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-06-11 13:07:49 +01:00
Dr. Stephen Henson
92f9a8bf38 Fix infinite loop in CMS
Fix loop in do_free_upto if cmsbio is NULL: this will happen when attempting
to verify and a digest is not recognised. Reported by Johannes Bauer.

CVE-2015-1792

Reviewed-by: Matt Caswell <matt@openssl.org>
2015-06-11 13:07:42 +01:00
Matt Caswell
50d3049930 EC_POINT_is_on_curve does not return a boolean
The function EC_POINT_is_on_curve does not return a boolean value.
It returns 1 if the point is on the curve, 0 if it is not, and -1
on error. Many usages within OpenSSL were incorrectly using this
function and therefore not correctly handling error conditions.

With thanks to the Open Crypto Audit Project for reporting this issue.

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
(cherry picked from commit 68886be7e2)

Conflicts:
	crypto/ec/ec2_oct.c
	crypto/ec/ecp_oct.c
	crypto/ec/ectest.c
2015-06-10 10:59:20 +01:00
Dr. Stephen Henson
17689e7dc6 return correct NID for undefined object
Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 0fb9990480)
2015-06-08 21:47:41 +01:00
Matt Caswell
9759ff0cd9 Fix off-by-one error in BN_bn2hex
A BIGNUM can have the value of -0. The function BN_bn2hex fails to account
for this and can allocate a buffer one byte too short in the event of -0
being used, leading to a one byte buffer overrun. All usage within the
OpenSSL library is considered safe. Any security risk is considered
negligible.

With thanks to Mateusz Kocielski (LogicalTrust), Marek Kroemeke and
Filip Palian for discovering and reporting this issue.

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit c56353071d)

Conflicts:
	crypto/bn/bn_print.c
2015-06-04 09:33:01 +01:00
Dr. Stephen Henson
f16093d2d6 check for error when creating PKCS#8 structure
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 2849707fa6)
2015-05-28 18:03:04 +01:00
Matt Caswell
f3b555a601 Fix off-by-one in BN_rand
If BN_rand is called with |bits| set to 1 and |top| set to 1 then a 1 byte
buffer overflow can occur. There are no such instances within the OpenSSL at
the moment.

Thanks to Mateusz Kocielski (LogicalTrust), Marek Kroemeke, Filip Palian for
discovering and reporting this issue.

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
2015-05-22 23:48:52 +01:00
Matt Caswell
c0de854c9d Reject negative shifts for BN_rshift and BN_lshift
The functions BN_rshift and BN_lshift shift their arguments to the right or
left by a specified number of bits. Unpredicatable results (including
crashes) can occur if a negative number is supplied for the shift value.

Thanks to Mateusz Kocielski (LogicalTrust), Marek Kroemeke and Filip Palian
for discovering and reporting this issue.

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
(cherry picked from commit 7cc18d8158)

Conflicts:
	crypto/bn/bn.h
	crypto/bn/bn_err.c
2015-05-22 23:25:22 +01:00
Rich Salz
155ca14ea9 Add NULL checks from master
The big "don't check for NULL" cleanup requires backporting some
of the lowest-level functions to actually do nothing if NULL is
given.  This will make it easier to backport fixes to release
branches, where master assumes those lower-level functions are "safe"

This commit addresses those tickets: 3798 3799 3801.

Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit f34b095fab)
(cherry picked from commit 690d040b2e)
2015-05-13 12:56:38 -04:00
Dr. Stephen Henson
303845a3b5 Fix encoding bug in i2c_ASN1_INTEGER
Fix bug where i2c_ASN1_INTEGER mishandles zero if it is marked as
negative.

Thanks to Huzaifa Sidhpurwala <huzaifas@redhat.com> and
Hanno Böck <hanno@hboeck.de> for reporting this issue.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit a0eed48d37)
2015-04-18 14:45:38 +01:00
Viktor Dukhovni
1a38987de0 Code style: space after 'if'
Reviewed-by: Matt Caswell <gitlab@openssl.org>
2015-04-16 13:54:47 -04:00
Dr. Stephen Henson
c5b0f5c463 Don't set *pval to NULL in ASN1_item_ex_new.
While *pval is usually a pointer in rare circumstances it can be a long
value. One some platforms (e.g. WIN64) where
sizeof(long) < sizeof(ASN1_VALUE *) this will write past the field.

*pval is initialised correctly in the rest of ASN1_item_ex_new so setting it
to NULL is unecessary anyway.

Thanks to Julien Kauffmann for reporting this issue.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit f617b4969a)

Conflicts:
	crypto/asn1/tasn_new.c
2015-04-10 19:54:13 +01:00
Dr. Stephen Henson
246b35a96e Make OCSP response verification more flexible.
If a set of certificates is supplied to OCSP_basic_verify use those in
addition to any present in the OCSP response as untrusted CAs when
verifying a certificate chain.

PR#3668

Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 4ca5efc287)
2015-03-24 12:15:17 +00:00
Matt Caswell
79cc5417a4 Prepare for 0.9.8zg-dev
Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-03-19 13:50:06 +00:00
Matt Caswell
db8334be06 Prepare for 0.9.8zf release
Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-03-19 13:47:27 +00:00
Matt Caswell
fcc5e899aa make update
Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-03-19 13:47:27 +00:00
Matt Caswell
c380bff888 Fix a failure to NULL a pointer freed on error.
Reported by the LibreSSL project as a follow on to CVE-2015-0209

Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-03-19 13:00:45 +00:00
Richard Levitte
6655ac4e45 VMS build fix
Reviewed-by: Andy Polyakov <appro@openssl.org>
2015-03-19 13:00:45 +00:00
Emilia Kasper
544e3e3b69 PKCS#7: avoid NULL pointer dereferences with missing content
In PKCS#7, the ASN.1 content component is optional.
This typically applies to inner content (detached signatures),
however we must also handle unexpected missing outer content
correctly.

This patch only addresses functions reachable from parsing,
decryption and verification, and functions otherwise associated
with reading potentially untrusted data.

Correcting all low-level API calls requires further work.

CVE-2015-0289

Thanks to Michal Zalewski (Google) for reporting this issue.

Reviewed-by: Steve Henson <steve@openssl.org>

Conflicts:
	crypto/pkcs7/pk7_doit.c
2015-03-19 13:00:45 +00:00
Dr. Stephen Henson
497d0b00dc Fix ASN1_TYPE_cmp
Fix segmentation violation when ASN1_TYPE_cmp is passed a boolean type. This
can be triggered during certificate verification so could be a DoS attack
against a client or a server enabling client authentication.

CVE-2015-0286

Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-03-19 13:00:44 +00:00
Dr. Stephen Henson
674341f1b0 Free up ADB and CHOICE if already initialised.
CVE-2015-0287

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Emilia Käsper <emilia@openssl.org>
2015-03-18 11:52:58 +00:00
Dr. Stephen Henson
c58f4f73bd Tolerate test_sqr errors for FIPS builds.
Reviewed-by: Tim Hudson <tjh@openssl.org>
2015-03-14 22:21:21 +00:00
Dr. Stephen Henson
01320ad3b9 Fix warnings.
Fix compiler warnings (similar to commit 25012d5e79)

Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-03-08 17:23:40 +00:00
Dr. Stephen Henson
241cff623e Check public key is not NULL.
CVE-2015-0288
PR#3708

Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 28a00bcd8e)
2015-03-02 15:26:57 +00:00
Dr. Stephen Henson
8a8ba07167 Fix format script.
The format script didn't correctly recognise some ASN.1 macros and
didn't reformat some files as a result. Fix script and reformat
affected files.

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 437b14b533)

Conflicts:
	crypto/asn1/x_long.c
2015-03-02 13:50:01 +00:00
Matt Caswell
1b4a8df38f Fix a failure to NULL a pointer freed on error.
Inspired by BoringSSL commit 517073cd4b by Eric Roman <eroman@chromium.org>

CVE-2015-0209

Reviewed-by: Emilia Käsper <emilia@openssl.org>
2015-02-25 20:40:38 +00:00
Andy Polyakov
6d4655c27e Bring objects.pl output even closer to new format.
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 849037169d)
2015-02-09 16:07:51 +01:00
Andy Polyakov
9eca2cbc16 Harmonize objects.pl output with new format.
Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 7ce3862319)
2015-02-09 10:03:30 +01:00
Rich Salz
49fa6b6c2d Fixed bad formatting in crypto/des/spr.h
Reviewed-by: Andy Polyakov <appro@openssl.org>
(cherry picked from commit 7e35f06ea9)
2015-02-05 09:46:24 -05:00
Dr. Stephen Henson
d64a227f1f Check PKCS#8 pkey field is valid before cleansing.
PR:3683
Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 52e028b9de)
2015-02-03 14:02:51 +00:00
Matt Caswell
6844c12968 Fix for reformat problems with e_padlock.c
Reviewed-by: Andy Polyakov <appro@openssl.org>
(cherry picked from commit d3b7cac41b)
2015-01-22 14:17:04 +00:00
Matt Caswell
ead95e760c Fix formatting error in pem.h
Reviewed-by: Andy Polyakov <appro@openssl.org>

Conflicts:
	crypto/pem/pem.h

Conflicts:
	crypto/pem/pem.h
2015-01-22 14:17:02 +00:00
Matt Caswell
02f0c26cea Re-align some comments after running the reformat script.
This should be a one off operation (subsequent invokation of the
script should not move them)

This commit is for the 0.9.8 changes

Reviewed-by: Tim Hudson <tjh@openssl.org>
2015-01-22 09:53:07 +00:00
Matt Caswell
6f1f3c6653 Rerun util/openssl-format-source -v -c .
Reviewed-by: Tim Hudson <tjh@openssl.org>
2015-01-22 09:53:02 +00:00
Matt Caswell
40720ce3ca Run util/openssl-format-source -v -c .
Reviewed-by: Tim Hudson <tjh@openssl.org>
2015-01-22 09:52:55 +00:00
Matt Caswell
9d03aabea3 More comment changes required for indent
Reviewed-by: Tim Hudson <tjh@openssl.org>
2015-01-22 09:52:49 +00:00
Matt Caswell
117e79dd88 Yet more changes to comments
Conflicts:
	ssl/t1_enc.c

Reviewed-by: Tim Hudson <tjh@openssl.org>
2015-01-22 09:52:44 +00:00
Matt Caswell
d26667b28f Tweaks for comments due to indent's inability to handle them
Conflicts:
	ssl/s3_srvr.c

Reviewed-by: Tim Hudson <tjh@openssl.org>
2015-01-22 09:52:28 +00:00
Matt Caswell
13270477f4 Move more comments that confuse indent
Conflicts:
	crypto/dsa/dsa.h
	demos/engines/ibmca/hw_ibmca.c
	ssl/ssl_locl.h

Conflicts:
	crypto/bn/rsaz_exp.c
	crypto/evp/e_aes_cbc_hmac_sha1.c
	crypto/evp/e_aes_cbc_hmac_sha256.c
	ssl/ssl_locl.h

Conflicts:
	crypto/ec/ec2_oct.c
	crypto/ec/ecp_nistp256.c
	crypto/ec/ecp_nistp521.c
	crypto/ec/ecp_nistputil.c
	crypto/ec/ecp_oct.c
	crypto/modes/gcm128.c
	ssl/ssl_locl.h

Conflicts:
	apps/apps.c
	crypto/crypto.h
	crypto/rand/md_rand.c
	ssl/d1_pkt.c
	ssl/ssl.h
	ssl/ssl_locl.h
	ssl/ssltest.c
	ssl/t1_enc.c

Reviewed-by: Tim Hudson <tjh@openssl.org>
2015-01-22 09:52:21 +00:00
Matt Caswell
175af9de89 Fix indent comment corruption issue
Reviewed-by: Tim Hudson <tjh@openssl.org>
2015-01-22 09:51:49 +00:00