oweals/openssl.git
9 years agocrypto/cryptlib.c: make it indent-friendly.
Andy Polyakov [Tue, 20 Jan 2015 14:49:55 +0000 (15:49 +0100)]
crypto/cryptlib.c: make it indent-friendly.

Conflicts:
crypto/cryptlib.c

Reviewed-by: Tim Hudson <tjh@openssl.org>
9 years agobn/bntest.c: make it indent-friendly.
Andy Polyakov [Tue, 20 Jan 2015 14:22:42 +0000 (15:22 +0100)]
bn/bntest.c: make it indent-friendly.

Conflicts:
crypto/bn/bntest.c

Reviewed-by: Tim Hudson <tjh@openssl.org>
9 years agobn/bn_recp.c: make it indent-friendly.
Andy Polyakov [Tue, 20 Jan 2015 14:12:07 +0000 (15:12 +0100)]
bn/bn_recp.c: make it indent-friendly.

Reviewed-by: Tim Hudson <tjh@openssl.org>
9 years agoengines/e_ubsec.c: make it indent-friendly.
Andy Polyakov [Tue, 20 Jan 2015 13:57:46 +0000 (14:57 +0100)]
engines/e_ubsec.c: make it indent-friendly.

Reviewed-by: Tim Hudson <tjh@openssl.org>
9 years agoapps/speed.c: make it indent-friendly.
Andy Polyakov [Tue, 20 Jan 2015 13:15:44 +0000 (14:15 +0100)]
apps/speed.c: make it indent-friendly.

Conflicts:
apps/speed.c

Conflicts:
apps/speed.c

Reviewed-by: Tim Hudson <tjh@openssl.org>
9 years agoFix make errors
Matt Caswell [Wed, 14 Jan 2015 21:26:14 +0000 (21:26 +0000)]
Fix make errors

Reviewed-by: Tim Hudson <tjh@openssl.org>
9 years agoMake the script a little more location agnostic
Richard Levitte [Tue, 20 Jan 2015 15:18:23 +0000 (16:18 +0100)]
Make the script a little more location agnostic

Reviewed-by: Tim Hudson <tjh@openssl.org>
9 years agoProvide script for filtering data initialisers for structs/unions. indent just can...
Matt Caswell [Tue, 20 Jan 2015 12:37:42 +0000 (12:37 +0000)]
Provide script for filtering data initialisers for structs/unions. indent just can't handle it.

Reviewed-by: Tim Hudson <tjh@openssl.org>
9 years agoScript fixes.
Dr. Stephen Henson [Tue, 20 Jan 2015 14:12:10 +0000 (14:12 +0000)]
Script fixes.

Don't use double newline for headers.
Don't interpret ASN1_PCTX as start of an ASN.1 module.

Reviewed-by: Tim Hudson <tjh@openssl.org>
9 years agoRun expand before perl, to make sure things are properly aligned
Richard Levitte [Tue, 20 Jan 2015 14:17:02 +0000 (15:17 +0100)]
Run expand before perl, to make sure things are properly aligned

Reviewed-by: Tim Hudson <tjh@openssl.org>
9 years agoForce the use of our indent profile
Richard Levitte [Tue, 20 Jan 2015 14:14:24 +0000 (15:14 +0100)]
Force the use of our indent profile

Reviewed-by: Tim Hudson <tjh@openssl.org>
9 years agoProvide source reformating script. Requires GNU indent to be
Tim Hudson [Mon, 5 Jan 2015 10:17:50 +0000 (10:17 +0000)]
Provide source reformating script. Requires GNU indent to be
available.

Script written by Tim Hudson, with amendments by Steve Henson, Rich Salz and
Matt Caswell

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoFix source where indent will not be able to cope
Matt Caswell [Mon, 19 Jan 2015 12:42:01 +0000 (12:42 +0000)]
Fix source where indent will not be able to cope

Conflicts:
apps/ciphers.c
ssl/s3_pkt.c

Conflicts:
crypto/ec/ec_curve.c

Reviewed-by: Tim Hudson <tjh@openssl.org>
9 years agoAdditional comment changes for reformat of 1.0.1
Matt Caswell [Fri, 16 Jan 2015 14:43:29 +0000 (14:43 +0000)]
Additional comment changes for reformat of 1.0.1

Reviewed-by: Tim Hudson <tjh@openssl.org>
9 years agoFurther comment changes for reformat
Matt Caswell [Fri, 16 Jan 2015 09:21:50 +0000 (09:21 +0000)]
Further comment changes for reformat

Reviewed-by: Tim Hudson <tjh@openssl.org>
9 years agomark all block comments that need format preserving so that
Tim Hudson [Sun, 28 Dec 2014 02:48:40 +0000 (12:48 +1000)]
mark all block comments that need format preserving so that
indent will not alter them when reformatting comments

(cherry picked from commit 1d97c8435171a7af575f73c526d79e1ef0ee5960)

Conflicts:
crypto/bn/bn_lcl.h
crypto/bn/bn_prime.c
crypto/engine/eng_all.c
crypto/rc4/rc4_utl.c
crypto/sha/sha.h
ssl/kssl.c
ssl/t1_lib.c

Conflicts:
crypto/rc4/rc4_enc.c
crypto/x509v3/v3_scts.c
crypto/x509v3/v3nametest.c
ssl/d1_both.c
ssl/s3_srvr.c
ssl/ssl.h
ssl/ssl_locl.h
ssl/ssltest.c
ssl/t1_lib.c

Reviewed-by: Tim Hudson <tjh@openssl.org>
9 years agoPrepare for 1.0.1m-dev OpenSSL_1_0_1-pre-reformat
Matt Caswell [Thu, 15 Jan 2015 14:49:54 +0000 (14:49 +0000)]
Prepare for 1.0.1m-dev

Reviewed-by: Stephen Henson <steve@openssl.org>
9 years agoPrepare for 1.0.1l release OpenSSL_1_0_1l
Matt Caswell [Thu, 15 Jan 2015 14:45:15 +0000 (14:45 +0000)]
Prepare for 1.0.1l release

Reviewed-by: Stephen Henson <steve@openssl.org>
9 years agomake update
Matt Caswell [Thu, 15 Jan 2015 14:45:15 +0000 (14:45 +0000)]
make update

Reviewed-by: Stephen Henson <steve@openssl.org>
9 years agoUpdates to CHANGES and NEWS
Matt Caswell [Thu, 15 Jan 2015 13:04:01 +0000 (13:04 +0000)]
Updates to CHANGES and NEWS

Reviewed-by: Dr Stephen Henson <steve@openssl.org>
9 years agoDefine CFLAGS as cflags on VMS as well
Richard Levitte [Tue, 13 Jan 2015 21:04:58 +0000 (22:04 +0100)]
Define CFLAGS as cflags on VMS as well

Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 43257b9f51de749262258668c77c2f0f99d7a15b)

9 years agoMake output from openssl version -f consistent with previous versions
Matt Caswell [Tue, 13 Jan 2015 10:20:12 +0000 (10:20 +0000)]
Make output from openssl version -f consistent with previous versions

Reviewed-by: Andy Polyakov <appro@openssl.org>
(cherry picked from commit 2d2671790ee12dedd92c97f35b6feb755b8d4374)

9 years agoFix warning where BIO_FLAGS_UPLINK was being redefined.
Matt Caswell [Sat, 10 Jan 2015 23:36:28 +0000 (23:36 +0000)]
Fix warning where BIO_FLAGS_UPLINK was being redefined.
This warning breaks the build in 1.0.0 and 0.9.8

Reviewed-by: Andy Polyakov <appro@openssl.org>
(cherry picked from commit b1ffc6ca1c387efad0772c16dfe426afef45dc4f)

9 years agoAvoid deprecation problems in Visual Studio 13
Matt Caswell [Fri, 9 Jan 2015 14:06:36 +0000 (14:06 +0000)]
Avoid deprecation problems in Visual Studio 13

Reviewed-by: Andy Polyakov <appro@openssl.org>
(cherry picked from commit 86d21d0b9577322ac5da0114c5fac16eb49b4cef)

9 years agoRT3662: Allow leading . in nameConstraints
Dr. Stephen Henson [Tue, 6 Jan 2015 20:29:28 +0000 (15:29 -0500)]
RT3662: Allow leading . in nameConstraints

Change by SteveH from original by John Denker (in the RT)

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 77ff1f3b8bfaa348956c5096a2b829f2e767b4f1)

9 years agoFurther windows specific .gitignore entries
Matt Caswell [Fri, 9 Jan 2015 23:01:20 +0000 (23:01 +0000)]
Further windows specific .gitignore entries

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 41c9cfbc4ee7345547fb98cccb8511f082f0910b)

9 years agoUpdate .gitignore with windows files to be excluded from git
Matt Caswell [Fri, 9 Jan 2015 10:19:10 +0000 (10:19 +0000)]
Update .gitignore with windows files to be excluded from git

Reviewed-by: Tim Hudson <tjh@openssl.org>
Conflicts:
.gitignore

(cherry picked from commit 04f670cf3d8f22e0d197a071d2db536fb7ebd9c7)

9 years agoFix build failure on Windows due to undefined cflags identifier
Matt Caswell [Thu, 8 Jan 2015 19:05:43 +0000 (19:05 +0000)]
Fix build failure on Windows due to undefined cflags identifier

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

9 years agoPrepare for 1.0.1l-dev
Matt Caswell [Thu, 8 Jan 2015 14:07:43 +0000 (14:07 +0000)]
Prepare for 1.0.1l-dev

Reviewed-by: Stephen Henson <steve@openssl.org>
9 years agoPrepare for 1.0.1k release OpenSSL_1_0_1k
Matt Caswell [Thu, 8 Jan 2015 14:03:40 +0000 (14:03 +0000)]
Prepare for 1.0.1k release

Reviewed-by: Stephen Henson <steve@openssl.org>
9 years agomake update
Matt Caswell [Thu, 8 Jan 2015 14:03:39 +0000 (14:03 +0000)]
make update

Reviewed-by: Stephen Henson <steve@openssl.org>
9 years agoCHANGES and NEWS updates for release
Matt Caswell [Thu, 8 Jan 2015 13:07:08 +0000 (13:07 +0000)]
CHANGES and NEWS updates for release

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Steve Henson <steve@openssl.org>
9 years agoA memory leak can occur in dtls1_buffer_record if either of the calls to
Matt Caswell [Wed, 7 Jan 2015 14:18:13 +0000 (14:18 +0000)]
A memory leak can occur in dtls1_buffer_record if either of the calls to
ssl3_setup_buffers or pqueue_insert fail. The former will fail if there is a
malloc failure, whilst the latter will fail if attempting to add a duplicate
record to the queue. This should never happen because duplicate records should
be detected and dropped before any attempt to add them to the queue.
Unfortunately records that arrive that are for the next epoch are not being
recorded correctly, and therefore replays are not being detected.
Additionally, these "should not happen" failures that can occur in
dtls1_buffer_record are not being treated as fatal and therefore an attacker
could exploit this by sending repeated replay records for the next epoch,
eventually causing a DoS through memory exhaustion.

Thanks to Chris Mueller for reporting this issue and providing initial
analysis and a patch. Further analysis and the final patch was performed by
Matt Caswell from the OpenSSL development team.

CVE-2015-0206

Reviewed-by: Dr Stephen Henson <steve@openssl.org>
9 years agoUnauthenticated DH client certificate fix.
Dr. Stephen Henson [Thu, 23 Oct 2014 19:36:17 +0000 (20:36 +0100)]
Unauthenticated DH client certificate fix.

Fix to prevent use of DH client certificates without sending
certificate verify message.

If we've used a client certificate to generate the premaster secret
ssl3_get_client_key_exchange returns 2 and ssl3_get_cert_verify is
never called.

We can only skip the certificate verify message in
ssl3_get_cert_verify if the client didn't send a certificate.

Thanks to Karthikeyan Bhargavan for reporting this issue.
CVE-2015-0205
Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoFollow on from CVE-2014-3571. This fixes the code that was the original source
Matt Caswell [Sat, 3 Jan 2015 00:54:35 +0000 (00:54 +0000)]
Follow on from CVE-2014-3571. This fixes the code that was the original source
of the crash due to p being NULL. Steve's fix prevents this situation from
occuring - however this is by no means obvious by looking at the code for
dtls1_get_record. This fix just makes things look a bit more sane.

Reviewed-by: Dr Steve Henson <steve@openssl.org>
9 years agoFix crash in dtls1_get_record whilst in the listen state where you get two
Dr. Stephen Henson [Sat, 3 Jan 2015 00:45:13 +0000 (00:45 +0000)]
Fix crash in dtls1_get_record whilst in the listen state where you get two
separate reads performed - one for the header and one for the body of the
handshake record.

CVE-2014-3571

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoFix for CVE-2014-3570.
Andy Polyakov [Mon, 5 Jan 2015 13:52:56 +0000 (14:52 +0100)]
Fix for CVE-2014-3570.

Reviewed-by: Emilia Kasper <emilia@openssl.org>
(cherry picked from commit e793809ba50c1e90ab592fb640a856168e50f3de)
(with 1.0.1-specific addendum)

9 years agofix error discrepancy
Dr. Stephen Henson [Wed, 7 Jan 2015 17:36:17 +0000 (17:36 +0000)]
fix error discrepancy

Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 4a4d4158572fd8b3dc641851b8378e791df7972d)

9 years agoFix irix-cc build.
Andy Polyakov [Mon, 5 Jan 2015 21:56:47 +0000 (22:56 +0100)]
Fix irix-cc build.

Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit e464403d0bda2f1f74eb68582e4988e591c32433)

9 years agoVMS fixups for 1.0.1
Richard Levitte [Wed, 7 Jan 2015 02:03:37 +0000 (03:03 +0100)]
VMS fixups for 1.0.1

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agouse correct credit in CHANGES
Dr. Stephen Henson [Tue, 6 Jan 2015 21:12:15 +0000 (21:12 +0000)]
use correct credit in CHANGES

Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 4138e3882556c762d77eb827b8be98507cde48df)

9 years agoOnly inherit the session ID context in SSL_set_SSL_CTX if the existing
Emilia Kasper [Tue, 6 Jan 2015 14:41:04 +0000 (15:41 +0100)]
Only inherit the session ID context in SSL_set_SSL_CTX if the existing
context was also inherited (matches that of the existing SSL_CTX).

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

9 years agouse correct function name
Dr. Stephen Henson [Tue, 6 Jan 2015 20:55:38 +0000 (20:55 +0000)]
use correct function name

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit cb62ab4b17818fe66d2fed0a7fe71969131c811b)

9 years agoFix memory leak.
Martin Brejcha [Sun, 16 Nov 2014 17:04:40 +0000 (17:04 +0000)]
Fix memory leak.

Fix memory leak by freeing up saved_message.data if it is not NULL.

PR#3489
Reviewed-by: Stephen Henson <steve@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 41cd41c4416f545a18ead37e09e437c75fa07c95)

9 years agoRemove blank line from start of cflags character array in buildinf.h
Matt Caswell [Tue, 6 Jan 2015 15:32:01 +0000 (15:32 +0000)]
Remove blank line from start of cflags character array in buildinf.h

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

9 years agoOnly allow ephemeral RSA keys in export ciphersuites.
Dr. Stephen Henson [Thu, 23 Oct 2014 16:09:57 +0000 (17:09 +0100)]
Only allow ephemeral RSA keys in export ciphersuites.

OpenSSL clients would tolerate temporary RSA keys in non-export
ciphersuites. It also had an option SSL_OP_EPHEMERAL_RSA which
enabled this server side. Remove both options as they are a
protocol violation.

Thanks to Karthikeyan Bhargavan for reporting this issue.
(CVE-2015-0204)
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 4b4c1fcc88aec8c9e001b0a0077d3cd4de1ed0e6)

Conflicts:
doc/ssl/SSL_CTX_set_options.pod

9 years agoECDH downgrade bug fix.
Dr. Stephen Henson [Fri, 24 Oct 2014 11:30:33 +0000 (12:30 +0100)]
ECDH downgrade bug fix.

Fix bug where an OpenSSL client would accept a handshake using an
ephemeral ECDH ciphersuites with the server key exchange message omitted.

Thanks to Karthikeyan Bhargavan for reporting this issue.

CVE-2014-3572
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit b15f8769644b00ef7283521593360b7b2135cb63)

9 years agoupdate ordinals
Dr. Stephen Henson [Mon, 5 Jan 2015 16:50:31 +0000 (16:50 +0000)]
update ordinals

Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit 31c65a7bc0de7ff1446645d41af388893362f579)

9 years agoEnsure that the session ID context of an SSL* is updated
Adam Langley [Mon, 5 Jan 2015 16:28:33 +0000 (17:28 +0100)]
Ensure that the session ID context of an SSL* is updated
when its SSL_CTX is updated.

From BoringSSL commit
https://boringssl.googlesource.com/boringssl/+/a5dc545bbcffd9c24cebe65e9ab5ce72d4535e3a

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 61aa44ca99473f9cabdfb2d3b35abd0b473437d1)

9 years agoConstify ASN1_TYPE_cmp add X509_ALGOR_cmp.
Dr. Stephen Henson [Sun, 14 Dec 2014 23:14:15 +0000 (23:14 +0000)]
Constify ASN1_TYPE_cmp add X509_ALGOR_cmp.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit 4c52816d35681c0533c25fdd3abb4b7c6962302d)

9 years agoFix various certificate fingerprint issues.
Dr. Stephen Henson [Sat, 20 Dec 2014 15:09:50 +0000 (15:09 +0000)]
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
Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit 684400ce192dac51df3d3e92b61830a6ef90be3e)

9 years agoRT2914: NULL check missing in X509_name_canon
Rich Salz [Sun, 4 Jan 2015 19:51:04 +0000 (14:51 -0500)]
RT2914: NULL check missing in X509_name_canon

Check for NULL return from X509_NAME_ENTRY_new()

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
(cherry picked from commit 2c60925d1ccc0b96287bdc9acb90198e7180d642)

9 years agoClear existing extension state.
Dr. Stephen Henson [Fri, 5 Dec 2014 13:39:14 +0000 (13:39 +0000)]
Clear existing extension state.

When parsing ClientHello clear any existing extension state from
SRP login and SRTP profile.

Thanks to Karthikeyan Bhargavan for reporting this issue.
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 47606dda672a5008168f62d4b7d7f94cd2d31313)

Conflicts:
ssl/t1_lib.c

9 years agotypo in s_client
Dominik Neubauer [Tue, 4 Mar 2014 21:22:29 +0000 (22:22 +0100)]
typo in s_client

Signed-off-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Geoff Thorpe <geoff@openssl.org>
9 years agoMake "run" volatile
Kurt Roeckx [Tue, 16 Dec 2014 11:35:21 +0000 (12:35 +0100)]
Make "run" volatile

RT#3629

Reviewed-by: Richard Levitte <levitte@openssl.org>
9 years agoDocument openssl dgst -hmac option
Thorsten Glaser [Fri, 22 May 2009 16:28:05 +0000 (16:28 +0000)]
Document openssl dgst -hmac option

Signed-off-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Richard Levitte <levitte@openssl.org>
9 years agodlfcn: always define _GNU_SOURCE
Kurt Roeckx [Mon, 23 Dec 2013 18:06:34 +0000 (19:06 +0100)]
dlfcn: always define _GNU_SOURCE

We need this for the freebsd kernel with glibc as used in the Debian kfreebsd
ports.  There shouldn't be a problem defining this on systems not using glibc.

Reviewed-by: Richard Levitte <levitte@openssl.org>
9 years agoFix memory leak in the apps
Kurt Roeckx [Sun, 7 Dec 2014 21:25:39 +0000 (22:25 +0100)]
Fix memory leak in the apps

The BIO_free() allocated ex_data again that we already freed.

Reviewed-by: Richard Levitte <levitte@openssl.org>
9 years agoImproves certificates HOWTO
Alok Menghrajani [Mon, 1 Dec 2014 03:21:31 +0000 (19:21 -0800)]
Improves certificates HOWTO

* adds links to various related documents.
* fixes a few typos.
* rewords a few sentences.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 67472bd82bed9d5e481b0d75926aab93618902be)

9 years agoSmall typo
Richard Levitte [Mon, 22 Dec 2014 13:30:23 +0000 (14:30 +0100)]
Small typo

Reviewed-by: Stephen Henson <steve@openssl.org>
(cherry picked from commit 7cfab40f43afac2f46652886e260d1c4de058806)

9 years agoFix incorrect OPENSSL_assert() usage.
Michael Tuexen [Sun, 16 Nov 2014 17:29:08 +0000 (17:29 +0000)]
Fix incorrect OPENSSL_assert() usage.

Return an error code for I/O errors instead of an assertion failure.

PR#3470
Reviewed-by: Stephen Henson <steve@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 2521fcd8527008ceb3e4748f95b0ed4e2d70cfef)

9 years agoFix a problem if CFLAGS is too long cversion.c fails to compile when config
Matt Caswell [Fri, 19 Dec 2014 10:55:54 +0000 (10:55 +0000)]
Fix a problem if CFLAGS is too long cversion.c fails to compile when config
is run with --strict-warnings.

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

9 years agoReturn error when a bit string indicates an invalid amount of bits left
Kurt Roeckx [Mon, 15 Dec 2014 16:15:16 +0000 (17:15 +0100)]
Return error when a bit string indicates an invalid amount of bits left

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoReject invalid constructed encodings.
Dr. Stephen Henson [Wed, 17 Dec 2014 14:34:36 +0000 (14:34 +0000)]
Reject invalid constructed encodings.

According to X6.90 null, object identifier, boolean, integer and enumerated
types can only have primitive encodings: return an error if any of
these are received with a constructed encoding.
Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit f5e4b6b5b566320a8d774f9475540f7d0e6a704d)

9 years agoAdd a comment noting the padding oracle.
Emilia Kasper [Wed, 17 Dec 2014 11:25:28 +0000 (12:25 +0100)]
Add a comment noting the padding oracle.

Reviewed-by: Andy Polyakov <appro@openssl.org>
(cherry picked from commit 03af843039af758fc9bbb4ae6c09ec2bc715f2c5)

9 years agoRevert "RT3425: constant-time evp_enc"
Emilia Kasper [Wed, 17 Dec 2014 13:49:28 +0000 (14:49 +0100)]
Revert "RT3425: constant-time evp_enc"

Causes more problems than it fixes: even though error codes
are not part of the stable API, several users rely on the
specific error code, and the change breaks them. Conversely,
we don't have any concrete use-cases for constant-time behaviour here.

This reverts commit f2df488a1c7402e48c21c83e937955dfe9f40bee.

Reviewed-by: Andy Polyakov <appro@openssl.org>
9 years agoBuild fixes
Emilia Kasper [Mon, 15 Dec 2014 15:37:13 +0000 (16:37 +0100)]
Build fixes

Various build fixes, mostly uncovered by clang's unused-const-variable
and unused-function errors.

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

9 years agoClear warnings/errors within RL_DEBUG code sections (RL_DEBUG should be renamed)
Richard Levitte [Tue, 16 Dec 2014 10:04:53 +0000 (11:04 +0100)]
Clear warnings/errors within RL_DEBUG code sections (RL_DEBUG should be renamed)

Reviewed-by: Andy Polyakov <appro@openssl.org>
(cherry picked from commit 8bc8450a26329e3c890df60026f969e7caabff3d)

9 years agoClear warnings/errors within TLS_DEBUG code sections
Richard Levitte [Tue, 16 Dec 2014 10:04:19 +0000 (11:04 +0100)]
Clear warnings/errors within TLS_DEBUG code sections

Reviewed-by: Andy Polyakov <appro@openssl.org>
(cherry picked from commit bf68456f538cacc9dcfd00986962aef0e8538289)

9 years agoClear warnings/errors within KSSL_DEBUG code sections
Richard Levitte [Tue, 16 Dec 2014 03:13:41 +0000 (04:13 +0100)]
Clear warnings/errors within KSSL_DEBUG code sections

Reviewed-by: Andy Polyakov <appro@openssl.org>
(cherry picked from commit 53332a75d16a5bb3b9d90c15fcf38d2e87160a52)

9 years agoClear warnings/errors within CIPHER_DEBUG code sections
Richard Levitte [Tue, 16 Dec 2014 01:54:50 +0000 (02:54 +0100)]
Clear warnings/errors within CIPHER_DEBUG code sections

Reviewed-by: Andy Polyakov <appro@openssl.org>
(cherry picked from commit cd387d21daa939862e081f00be0a98dbc5a85351)

9 years agoClear warnings/errors within CIPHER_DEBUG code sections
Richard Levitte [Tue, 16 Dec 2014 01:54:03 +0000 (02:54 +0100)]
Clear warnings/errors within CIPHER_DEBUG code sections

Reviewed-by: Andy Polyakov <appro@openssl.org>
(cherry picked from commit 0c403e80a9952c83a38eab3c8a4ce42e17a2cee0)

9 years agoClear warnings/errors within BN_CTX_DEBUG code sections
Richard Levitte [Tue, 16 Dec 2014 00:38:39 +0000 (01:38 +0100)]
Clear warnings/errors within BN_CTX_DEBUG code sections

Reviewed-by: Andy Polyakov <appro@openssl.org>
(cherry picked from commit 553affbef7bb5dd313514e06dab5cd9b1de1835f)

9 years agoPremaster secret handling fixes
Adam Langley [Tue, 16 Dec 2014 13:03:47 +0000 (14:03 +0100)]
Premaster secret handling fixes

From BoringSSL
- Send an alert when the client key exchange isn't correctly formatted.
- Reject overly short RSA ciphertexts to avoid a (benign) out-of-bounds memory access.

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

9 years agoBackport regression test
Bodo Möller [Thu, 13 Oct 2011 12:35:10 +0000 (12:35 +0000)]
Backport regression test

master branch has a specific regression test for a bug in x86_64-mont5 code,
see commit cdfe0fdde6a966bdb0447de66aa04a85d99a0551.

This code is now in 1.0.2/1.0.1, so also backport the test.

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

9 years agoCheck for invalid divisors in BN_div.
Emilia Kasper [Mon, 15 Dec 2014 13:52:22 +0000 (14:52 +0100)]
Check for invalid divisors in BN_div.

Invalid zero-padding in the divisor could cause a division by 0.

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

9 years agoAdd OPENSSL_NO_ECDH guards
Matt Caswell [Tue, 18 Nov 2014 15:56:50 +0000 (15:56 +0000)]
Add OPENSSL_NO_ECDH guards

Reviewed-by: Emilia Käsper <emilia@openssl.org>
9 years agoRemove extraneous white space, and add some braces
Matt Caswell [Mon, 15 Dec 2014 20:48:33 +0000 (20:48 +0000)]
Remove extraneous white space, and add some braces

Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit 55e530265a7ea8f264717a4e37338cc04eca2007)

9 years agoDTLS fixes for signed/unsigned issues
Matt Caswell [Fri, 12 Dec 2014 15:32:24 +0000 (15:32 +0000)]
DTLS fixes for signed/unsigned issues

Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit 1904d21123849a65dafde1705e6dd5b7c2f420eb)

9 years agoCheckout return value of dtls1_output_cert_chain
Matt Caswell [Wed, 3 Dec 2014 11:15:40 +0000 (11:15 +0000)]
Checkout return value of dtls1_output_cert_chain

Reviewed-by: Tim Hudson <tjh@openssl.org>
9 years agoCheck return value of ssl3_output_cert_chain
Matt Caswell [Tue, 18 Mar 2014 14:19:22 +0000 (14:19 +0000)]
Check return value of ssl3_output_cert_chain

Based on commit 66f96fe2d519147097c118d4bf60704c69ed0635 by Steve Henson

Reviewed-by: Tim Hudson <tjh@openssl.org>
9 years agoFix unused variable warning
Emilia Kasper [Mon, 15 Dec 2014 12:11:52 +0000 (13:11 +0100)]
Fix unused variable warning

The temporary variable causes unused variable warnings in opt mode with clang,
because the subsequent assert is compiled out.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 6af16ec5eed85390bcbd004806a842d6153d6a31)

9 years agoFix memory leak in s2_srvr.c if BUF_MEM_grow fails
Matt Caswell [Fri, 12 Dec 2014 11:05:21 +0000 (11:05 +0000)]
Fix memory leak in s2_srvr.c if BUF_MEM_grow fails

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
(cherry picked from commit d04a1e0b5beb3329cdf8c4ec35b9113cbc41d2f2)

9 years agoFixed memory leak if BUF_MEM_grow fails
Matt Caswell [Fri, 12 Dec 2014 11:03:00 +0000 (11:03 +0000)]
Fixed memory leak if BUF_MEM_grow fails

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
(cherry picked from commit bb1ddd3d9a0d01656b90693a214b911995a5fe8c)

9 years agoFix use of NULL memory pointer in X509_VERIFY_PARAM_new in the event of a
Matt Caswell [Thu, 4 Dec 2014 10:18:40 +0000 (10:18 +0000)]
Fix use of NULL memory pointer in X509_VERIFY_PARAM_new in the event of a
malloc failure.

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
9 years agoFixed memory leak in the event of a failure of BUF_MEM_grow
Matt Caswell [Thu, 4 Dec 2014 09:56:16 +0000 (09:56 +0000)]
Fixed memory leak in the event of a failure of BUF_MEM_grow

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

9 years agoFix memory leak in SSL_new if errors occur.
Matt Caswell [Thu, 4 Dec 2014 09:46:44 +0000 (09:46 +0000)]
Fix memory leak in SSL_new if errors occur.

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

9 years agoReject elliptic curve lists of odd lengths.
Emilia Kasper [Mon, 1 Dec 2014 14:04:02 +0000 (15:04 +0100)]
Reject elliptic curve lists of odd lengths.

The Supported Elliptic Curves extension contains a vector of NamedCurves
of 2 bytes each, so the total length must be even. Accepting odd-length
lists was observed to lead to a non-exploitable one-byte out-of-bounds
read in the latest development branches (1.0.2 and master). Released
versions of OpenSSL are not affected.

Thanks to Felix Groebert of the Google Security Team for reporting this issue.

Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 33d5ba862939ff8db70a9e36fc9a326fab3e8d98)

9 years agoRemove incorrect code inadvertently introduced through commit 59669b6ab.
Matt Caswell [Thu, 4 Dec 2014 09:22:50 +0000 (09:22 +0000)]
Remove incorrect code inadvertently introduced through commit 59669b6ab.

Reviewed-by: Tim Hudson <tjh@openssl.org>
Conflicts:
ssl/d1_lib.c

9 years agoRemove "#if 0" code
Matt Caswell [Wed, 3 Dec 2014 09:21:09 +0000 (09:21 +0000)]
Remove "#if 0" code

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

9 years agoOnly use the fallback mtu after 2 unsuccessful retransmissions if it is less
Matt Caswell [Tue, 2 Dec 2014 11:16:35 +0000 (11:16 +0000)]
Only use the fallback mtu after 2 unsuccessful retransmissions if it is less
than the mtu we are already using

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

9 years agoUpdates to s_client and s_server to remove the constant 28 (for IPv4 header
Matt Caswell [Mon, 1 Dec 2014 23:57:44 +0000 (23:57 +0000)]
Updates to s_client and s_server to remove the constant 28 (for IPv4 header
and UDP header) when setting an mtu. This constant is not always correct (e.g.
if using IPv6). Use the new DTLS_CTRL functions instead.

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

9 years agoIf we really get a situation where the underlying mtu is less than the minimum
Matt Caswell [Tue, 2 Dec 2014 00:16:55 +0000 (00:16 +0000)]
If we really get a situation where the underlying mtu is less than the minimum
we will support then dtls1_do_write can go into an infinite loop. This commit
fixes that.

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

9 years agoFix dtls_query_mtu so that it will always either complete with an mtu that is
Matt Caswell [Mon, 1 Dec 2014 22:18:18 +0000 (22:18 +0000)]
Fix dtls_query_mtu so that it will always either complete with an mtu that is
at least the minimum or it will fail.
There were some instances in dtls1_query_mtu where the final mtu can end up
being less than the minimum, i.e. where the user has set an mtu manually. This
shouldn't be allowed. Also remove dtls1_guess_mtu that, despite having
logic for guessing an mtu, was actually only ever used to work out the minimum
mtu to use.

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

9 years agoRemove instances in libssl of the constant 28 (for size of IPv4 header + UDP)
Matt Caswell [Mon, 1 Dec 2014 23:58:05 +0000 (23:58 +0000)]
Remove instances in libssl of the constant 28 (for size of IPv4 header + UDP)
and instead use the value provided by the underlying BIO. Also provide some
new DTLS_CTRLs so that the library user can set the mtu without needing to
know this constant. These new DTLS_CTRLs provide the capability to set the
link level mtu to be used (i.e. including this IP/UDP overhead). The previous
DTLS_CTRLs required the library user to subtract this overhead first.

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

Conflicts:
ssl/d1_both.c
ssl/ssl_lib.c

9 years agoThere are a number of instances throughout the code where the constant 28 is
Matt Caswell [Mon, 1 Dec 2014 23:49:47 +0000 (23:49 +0000)]
There are a number of instances throughout the code where the constant 28 is
used with no explanation. Some of this was introduced as part of RT#1929. The
value 28 is the length of the IP header (20 bytes) plus the UDP header (8
bytes). However use of this constant is incorrect because there may be
instances where a different value is needed, e.g. an IPv4 header is 20 bytes
but an IPv6 header is 40. Similarly you may not be using UDP (e.g. SCTP).
This commit introduces a new BIO_CTRL that provides the value to be used for
this mtu "overhead". It will be used by subsequent commits.

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

Conflicts:
crypto/bio/bss_dgram.c

9 years agoThe first call to query the mtu in dtls1_do_write correctly checks that the
Matt Caswell [Mon, 1 Dec 2014 11:41:25 +0000 (11:41 +0000)]
The first call to query the mtu in dtls1_do_write correctly checks that the
mtu that we have received is not less than the minimum. If its less it uses the
minimum instead. The second call to query the mtu does not do that, but
instead uses whatever comes back. We have seen an instance in RT#3592 where we
have got an unreasonably small mtu come back. This commit makes both query
checks consistent.

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

9 years agoThe SSL_OP_NO_QUERY_MTU option is supposed to stop the mtu from being
Matt Caswell [Mon, 1 Dec 2014 11:13:15 +0000 (11:13 +0000)]
The SSL_OP_NO_QUERY_MTU option is supposed to stop the mtu from being
automatically updated, and we should use the one provided instead.
Unfortunately there are a couple of locations where this is not respected.

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

9 years agoVerify that we have a sensible message len and fail if not
Matt Caswell [Mon, 1 Dec 2014 11:10:38 +0000 (11:10 +0000)]
Verify that we have a sensible message len and fail if not
RT#3592 provides an instance where the OPENSSL_assert that this commit
replaces can be hit. I was able to recreate this issue by forcing the
underlying BIO to misbehave and come back with very small mtu values. This
happens the second time around the while loop after we have detected that the
MTU has been exceeded following the call to dtls1_write_bytes.

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

9 years agoUse the SSLv23 method by default
Kurt Roeckx [Sat, 29 Nov 2014 15:17:54 +0000 (16:17 +0100)]
Use the SSLv23 method by default

If SSLv2 and SSLv3 are both disabled we still support SSL/TLS.

Reviewed-by: Richard Levitte <levitte@openssl.org>