oweals/openssl.git
9 years agoAdd an example .dir-locals.el
Richard Levitte [Mon, 31 Aug 2015 15:25:17 +0000 (17:25 +0200)]
Add an example .dir-locals.el

This file, when copied to .dir-locals.el in the OpenSSL source top,
will make sure that the CC mode style "OpenSSL-II" will be used for
all C files.

Additionally, I makes sure that tabs are never used as indentation
character, regardless of the emacs mode, and that the fill column is
78.

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

9 years agoAdd emacs CC mode style for OpenSSL
Richard Levitte [Mon, 31 Aug 2015 15:12:37 +0000 (17:12 +0200)]
Add emacs CC mode style for OpenSSL

This hopefully conforms closely enough to the current code style.

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

9 years agobntest: don't dereference the |d| array for a zero BIGNUM.
Emilia Kasper [Mon, 31 Aug 2015 11:57:44 +0000 (13:57 +0200)]
bntest: don't dereference the |d| array for a zero BIGNUM.

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

9 years agoRemove the "times" directory.
Rich Salz [Fri, 28 Aug 2015 21:49:30 +0000 (17:49 -0400)]
Remove the "times" directory.

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

9 years agoGH354: Memory leak fixes
Alessandro Ghedini [Fri, 28 Aug 2015 03:07:07 +0000 (23:07 -0400)]
GH354: Memory leak fixes

Fix more potential leaks in X509_verify_cert()
Fix memory leak in ClientHello test
Fix memory leak in gost2814789 test
Fix potential memory leak in PKCS7_verify()
Fix potential memory leaks in X509_add1_reject_object()
Refactor to use "goto err" in cleanup.

Signed-off-by: Rich Salz <rsalz@akamai.com>
Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit 55500ea7c46c27a150a46832e1260891aaad8e52)

9 years agoGH367: Fix dsa keygen for too-short seed
Ismo Puustinen [Sat, 8 Aug 2015 02:14:47 +0000 (22:14 -0400)]
GH367: Fix dsa keygen for too-short seed

If the seed value for dsa key generation is too short (< qsize),
return an error. Also update the documentation.

Signed-off-by: Rich Salz <rsalz@akamai.com>
Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit f00a10b89734e84fe80f98ad9e2e77b557c701ae)

9 years agoGH351: -help text for some s_client/s_server flags
Hubert Kario [Fri, 31 Jul 2015 17:02:07 +0000 (19:02 +0200)]
GH351: -help text for some s_client/s_server flags

add -help descriptions of -curves, -sigalgs, -client_sigalgs
to s_client and s_server

Signed-off-by: Rich Salz <rsalz@akamai.com>
Reviewed-by: Tim Hudson <tjh@openssl.org>
9 years agoFixed problem with multiple load-unload of comp zlib
David Brodski [Tue, 13 May 2014 16:06:27 +0000 (18:06 +0200)]
Fixed problem with multiple load-unload of comp zlib

Signed-off-by: Rich Salz <rsalz@akamai.com>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 8cbb153357896c4b224e0678550944f7851bc3b2)

9 years agoGH correct organizationalUnitName
Viktor Dukhovni [Thu, 24 Apr 2014 01:58:30 +0000 (21:58 -0400)]
GH correct organizationalUnitName

Signed-off-by: Rich Salz <rsalz@akamai.com>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 208b2d541dcb3b8f62639d2a8cc5771af4ba8755)

9 years agoGH371: Print debug info for ALPN extension
Alessandro Ghedini [Wed, 19 Aug 2015 15:12:31 +0000 (17:12 +0200)]
GH371: Print debug info for ALPN extension

Also known as RT 4106
Signed-off-by: Rich Salz <rsalz@akamai.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit b48357d9953decc43333979ca11ebc1500040f4e)

9 years agoFix DTLS session ticket renewal
Matt Caswell [Thu, 13 Aug 2015 09:06:30 +0000 (10:06 +0100)]
Fix DTLS session ticket renewal

A DTLS client will abort a handshake if the server attempts to renew the
session ticket. This is caused by a state machine discrepancy between DTLS
and TLS discovered during the state machine rewrite work.

The bug can be demonstrated as follows:

Start a DTLS s_server instance:
openssl s_server -dtls

Start a client and obtain a session but no ticket:
openssl s_client -dtls -sess_out session.pem -no_ticket

Now start a client reusing the session, but allow a ticket:
openssl s_client -dtls -sess_in session.pem

The client will abort the handshake.

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

Conflicts:
ssl/d1_clnt.c

9 years agoRT4019: Duplicate -hmac flag in dgst.pod
Markus Rinne [Mon, 24 Aug 2015 20:20:13 +0000 (16:20 -0400)]
RT4019: Duplicate -hmac flag in dgst.pod

Signed-off-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit 86de216da3ebea7f876a096e258cf4c9d219bc0a)

9 years agoGH372: Remove duplicate flags
Rich Salz [Mon, 24 Aug 2015 19:25:14 +0000 (15:25 -0400)]
GH372: Remove duplicate flags

Signed-off-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit 32c5e0ba0f9097e9c788ed8402fcbf6646cd2c2d)

9 years agoAdd new types to indent.pro
Richard Levitte [Mon, 17 Aug 2015 16:10:16 +0000 (18:10 +0200)]
Add new types to indent.pro

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

9 years agoGH345: Remove stderr output
Rich Salz [Mon, 17 Aug 2015 01:09:45 +0000 (21:09 -0400)]
GH345: Remove stderr output

Manually-cherry-picked since master varied a lot.
Reviewed-by: Tim Hudson <tjh@openssl.org>
9 years agoMove FAQ to the web.
Rich Salz [Sun, 16 Aug 2015 22:38:24 +0000 (18:38 -0400)]
Move FAQ to the web.

Best hope of keeping current.

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

9 years agoUpdate docs.
Dr. Stephen Henson [Wed, 17 Jun 2015 00:13:40 +0000 (01:13 +0100)]
Update docs.

Clarify and update documention for extra chain certificates.

PR#3878.

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

9 years agoDocumentation for SSL_check_chain()
Dr. Stephen Henson [Thu, 23 Jul 2015 15:38:58 +0000 (16:38 +0100)]
Documentation for SSL_check_chain()

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

9 years agoFix 1.0.2 build break
Rich Salz [Fri, 14 Aug 2015 12:21:19 +0000 (08:21 -0400)]
Fix 1.0.2 build break

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoGH364: Free memory on an error path
Ismo Puustinen [Sat, 8 Aug 2015 02:11:28 +0000 (22:11 -0400)]
GH364: Free memory on an error path

Part of RT 3997
Per Ben, just jump to common exit code.

Signed-off-by: Rich Salz <rsalz@akamai.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit cc2829e6641092abed8360433dbe67e883fd1cc6)

9 years agoReturn error for unsupported modes.
Dr. Stephen Henson [Sat, 1 Aug 2015 14:38:11 +0000 (15:38 +0100)]
Return error for unsupported modes.

PR#3974
PR#3975

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoFix memory leak if setup fails.
Dr. Stephen Henson [Sat, 1 Aug 2015 14:37:44 +0000 (15:37 +0100)]
Fix memory leak if setup fails.

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

Conflicts:
crypto/cms/cms_enc.c

9 years agoErr isn't always malloc failure.
Dr. Stephen Henson [Sat, 1 Aug 2015 14:37:01 +0000 (15:37 +0100)]
Err isn't always malloc failure.

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

Conflicts:
crypto/cms/cms_smime.c

9 years agoFix "make test" seg fault with SCTP enabled
Matt Caswell [Tue, 11 Aug 2015 18:38:39 +0000 (19:38 +0100)]
Fix "make test" seg fault with SCTP enabled

When config'd with "sctp" running "make test" causes a seg fault. This is
actually due to the way ssltest works - it dives under the covers and frees
up BIOs manually and so some BIOs are NULL when the SCTP code does not
expect it. The simplest fix is just to add some sanity checks to make sure
the BIOs aren't NULL before we use them.

This problem occurs in master and 1.0.2. The fix has also been applied to
1.0.1 to keep the code in sync.

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

9 years agoFix missing return value checks in SCTP
Matt Caswell [Tue, 11 Aug 2015 18:36:43 +0000 (19:36 +0100)]
Fix missing return value checks in SCTP

There are some missing return value checks in the SCTP code. In master this
was causing a compilation failure when config'd with
"--strict-warnings sctp".

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

9 years agoCheck for 0 modulus in BN_MONT_CTX_set
Matt Caswell [Mon, 10 Aug 2015 11:00:29 +0000 (12:00 +0100)]
Check for 0 modulus in BN_MONT_CTX_set

The function BN_MONT_CTX_set was assuming that the modulus was non-zero
and therefore that |mod->top| > 0. In an error situation that may not be
the case and could cause a seg fault.

This is a follow on from CVE-2015-1794.

Reviewed-by: Richard Levitte <levitte@openssl.org>
9 years agoFix seg fault with 0 p val in SKE
Guy Leaver (guleaver) [Fri, 7 Aug 2015 14:45:21 +0000 (15:45 +0100)]
Fix seg fault with 0 p val in SKE

If a client receives a ServerKeyExchange for an anon DH ciphersuite with the
value of p set to 0 then a seg fault can occur. This commits adds a test to
reject p, g and pub key parameters that have a 0 value (in accordance with
RFC 5246)

The security vulnerability only affects master and 1.0.2, but the fix is
additionally applied to 1.0.1 for additional confidence.

CVE-2015-1794

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoRT3998: fix X509_check_host.pod release to 1.0.2
David Woodhouse [Sat, 8 Aug 2015 02:18:26 +0000 (22:18 -0400)]
RT3998: fix X509_check_host.pod release to 1.0.2

Signed-off-by: Rich Salz <rsalz@akamai.com>
Reviewed-by: Ben Laurie <ben@openssl.org>
(cherry picked from commit 2bfbeb264573342bea475f6dbb5b4c7fec8fdb0a)

9 years agoRT3990: Fix #include path.
Anton Blanchard [Thu, 6 Aug 2015 01:48:35 +0000 (21:48 -0400)]
RT3990: Fix #include path.

Signed-off-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 1125245997dac232a0c0867b6c858cda4e549c6d)

9 years agoFix warning when compiling with no-ec2m
Matt Caswell [Thu, 9 Jul 2015 15:37:54 +0000 (16:37 +0100)]
Fix warning when compiling with no-ec2m

EC_KEY_set_public_key_affine_coordinates was using some variables that only
apply if OPENSSL_NO_EC2M is not defined.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
(cherry picked from commit 8d11b7c7ee84ad0aa243476088285d15b22c5470)

9 years agoGH336: Return an exit code if report fails
Dirk Wetter [Fri, 31 Jul 2015 17:02:51 +0000 (13:02 -0400)]
GH336: Return an exit code if report fails

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

9 years agoClear BN-mont values when free'ing it.
Loganaden Velvindron [Fri, 31 Jul 2015 17:20:16 +0000 (13:20 -0400)]
Clear BN-mont values when free'ing it.

From a CloudFlare patch.

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
9 years agoVarious doc fixes from GH pull requests
Rich Salz [Fri, 31 Jul 2015 16:34:24 +0000 (12:34 -0400)]
Various doc fixes from GH pull requests

Thanks, folks!
        348 Benjamin Kaduk
        317 Christian Brueffer
        254 Erik Tews
        253 Erik Tews
        219 Carl Mehner
        155 (ghost)
        95 mancha
        51 DominikNeubauer

(Manually picked from 59c554b36e39256ac2cfc34dca052453e10c6d9c)
Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
9 years agoRT3959: Fix misleading comment
Nicholas Cooper [Fri, 31 Jul 2015 15:08:18 +0000 (11:08 -0400)]
RT3959: Fix misleading comment

Manual cherry-pick from main branch, since the header file
moved in master.
Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agouse X9.31 keygen by default in FIPS mode
Dr. Stephen Henson [Wed, 29 Jul 2015 15:16:02 +0000 (16:16 +0100)]
use X9.31 keygen by default in FIPS mode

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoFix write failure handling in DTLS1.2
Matt Caswell [Wed, 29 Jul 2015 22:20:56 +0000 (23:20 +0100)]
Fix write failure handling in DTLS1.2

The DTLS code is supposed to drop packets if we try to write them out but
the underlying BIO write buffers are full. ssl3_write_pending() contains
an incorrect test for DTLS that controls this. The test only checks for
DTLS1 so DTLS1.2 does not correctly clear the internal OpenSSL buffer which
can later cause an assert to be hit. This commit changes the test to cover
all DTLS versions.

RT#3967

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

9 years agoRT3774: double-free in DSA
Martin Vejnar [Wed, 29 Jul 2015 21:28:19 +0000 (17:28 -0400)]
RT3774: double-free in DSA

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

9 years agoTweak README about rt and bug reporting.
Rich Salz [Tue, 28 Jul 2015 16:41:36 +0000 (12:41 -0400)]
Tweak README about rt and bug reporting.

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

9 years agoFix SSL_set_session_ticket_ext when used with SSLv23_method
Matt Caswell [Mon, 27 Jul 2015 12:30:43 +0000 (13:30 +0100)]
Fix SSL_set_session_ticket_ext when used with SSLv23_method

The function SSL_set_session_ticket_ext can be used to set custom session
ticket data passed in the initial ClientHello. This can be particularly
useful for EAP-FAST. However, when using SSLv23_method, the session does
not get created until the ServerHello has been received. The extension code
will only add the SessionTicket data to the ClientHello if a session already
exists. Therefore SSL_set_session_ticket_ext has no impact when used in
conjunction with SSLv23_method. The solution is to simply create the session
during creation of the ClientHello instead of waiting for the ServerHello.

This commit fixes the test failure introduced by the previous commit.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
9 years agoAdd test for SSL_set_session_ticket_ext
Matt Caswell [Mon, 27 Jul 2015 11:04:47 +0000 (12:04 +0100)]
Add test for SSL_set_session_ticket_ext

The function SSL_set_session_ticket_ext sets the ticket data to be sent in
the ClientHello. This is useful for EAP-FAST. This commit adds a test to
ensure that when this function is called the expected ticket data actually
appears in the ClientHello.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
9 years agorsaz_exp.h: align license with the rest of the contribution
Emilia Kasper [Thu, 23 Jul 2015 11:20:21 +0000 (13:20 +0200)]
rsaz_exp.h: align license with the rest of the contribution

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

9 years agoFix author credit for e5c0bc6
mancha [Wed, 15 Jul 2015 08:54:28 +0000 (04:54 -0400)]
Fix author credit for e5c0bc6

Reviewed-by: Richard Levitte <levitte@openssl.org>
9 years agoRevert "Missing perldoc markup around < literal"
Rich Salz [Wed, 15 Jul 2015 08:52:51 +0000 (04:52 -0400)]
Revert "Missing perldoc markup around < literal"

This reverts commit e5c0bc6cc49a23b50a272801c4bd53639c25fca4.
Reviewed-by: Richard Levitte <levitte@openssl.org>
9 years agoGH322: Fix typo in generated comment.
Ernie Hershey [Wed, 15 Jul 2015 03:08:44 +0000 (23:08 -0400)]
GH322: Fix typo in generated comment.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
(cherry picked from commit ad282e638b6824325fb83ecf7cde2e7996f52b79)

9 years agoMissing perldoc markup around < literal
GitHub User [Thu, 9 Jul 2015 19:02:29 +0000 (15:02 -0400)]
Missing perldoc markup around < literal

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

9 years agoConversion to UTF-8 where needed
Richard Levitte [Mon, 13 Jul 2015 23:15:49 +0000 (01:15 +0200)]
Conversion to UTF-8 where needed

This leaves behind files with names ending with '.iso-8859-1'.  These
should be safe to remove.  If something went wrong when re-encoding,
there will be some files with names ending with '.utf8' left behind.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoSmall script to re-encode files that need it to UTF-8
Richard Levitte [Mon, 13 Jul 2015 14:50:16 +0000 (16:50 +0200)]
Small script to re-encode files that need it to UTF-8

This requires 'iconv' and that 'file' can take the options '-b' and '-i'.

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

9 years agoRemove extra '; \' in apps/Makefile
Richard Levitte [Mon, 13 Jul 2015 13:48:57 +0000 (15:48 +0200)]
Remove extra '; \' in apps/Makefile

Fixes GH#330

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

Conflicts:
apps/Makefile

9 years agoSet numeric IDs for tar as well
Richard Levitte [Fri, 10 Jul 2015 16:29:17 +0000 (18:29 +0200)]
Set numeric IDs for tar as well

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

9 years agoStop using tardy
Richard Levitte [Fri, 10 Jul 2015 13:40:53 +0000 (15:40 +0200)]
Stop using tardy

Instead of piping through tardy, and possibly suffering from bugs in certain
versions, use --transform, --owner and --group directly with GNU tar (we
already expect that tar variant).

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

Conflicts:
Makefile.org

9 years agocorrect example
Dr. Stephen Henson [Thu, 9 Jul 2015 18:32:36 +0000 (19:32 +0100)]
correct example

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

9 years agoExit on error in ecparam
Peter Waltenberg [Thu, 9 Jul 2015 18:57:30 +0000 (14:57 -0400)]
Exit on error in ecparam

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

9 years agoSort @sstacklst correctly.
Dr. Stephen Henson [Thu, 9 Jul 2015 15:56:45 +0000 (16:56 +0100)]
Sort @sstacklst correctly.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoPrepare for 1.0.2e-dev
Matt Caswell [Thu, 9 Jul 2015 12:18:51 +0000 (13:18 +0100)]
Prepare for 1.0.2e-dev

Reviewed-by: Stephen Henson <steve@openssl.org>
9 years agoPrepare for 1.0.2d release OpenSSL_1_0_2d
Matt Caswell [Thu, 9 Jul 2015 12:03:09 +0000 (13:03 +0100)]
Prepare for 1.0.2d release

Reviewed-by: Stephen Henson <steve@openssl.org>
9 years agoUpdate CHANGES and NEWS for the new release
Matt Caswell [Thu, 2 Jul 2015 14:38:32 +0000 (15:38 +0100)]
Update CHANGES and NEWS for the new release

Reviewed-by: Stephen Henson <steve@openssl.org>
9 years agoAdd documentation for some missing verify options
Matt Caswell [Thu, 25 Jun 2015 11:34:38 +0000 (12:34 +0100)]
Add documentation for some missing verify options

Fills in a couple of verify options that were lacking documentation.

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

Conflicts:
doc/apps/verify.pod

9 years agoReject calls to X509_verify_cert that have not been reinitialised
Matt Caswell [Thu, 25 Jun 2015 08:47:15 +0000 (09:47 +0100)]
Reject calls to X509_verify_cert that have not been reinitialised

The function X509_verify_cert checks the value of |ctx->chain| at the
beginning, and if it is NULL then it initialises it, along with the value
of ctx->untrusted. The normal way to use X509_verify_cert() is to first
call X509_STORE_CTX_init(); then set up various parameters etc; then call
X509_verify_cert(); then check the results; and finally call
X509_STORE_CTX_cleanup(). The initial call to X509_STORE_CTX_init() sets
|ctx->chain| to NULL. The only place in the OpenSSL codebase  where
|ctx->chain| is set to anything other than a non NULL value is in
X509_verify_cert itself. Therefore the only ways that |ctx->chain| could be
non NULL on entry to X509_verify_cert is if one of the following occurs:
1) An application calls X509_verify_cert() twice without re-initialising
in between.
2) An application reaches inside the X509_STORE_CTX structure and changes
the value of |ctx->chain| directly.

With regards to the second of these, we should discount this - it should
not be supported to allow this.

With regards to the first of these, the documentation is not exactly
crystal clear, but the implication is that you must call
X509_STORE_CTX_init() before each call to X509_verify_cert(). If you fail
to do this then, at best, the results would be undefined.

Calling X509_verify_cert() with |ctx->chain| set to a non NULL value is
likely to have unexpected results, and could be dangerous. This commit
changes the behaviour of X509_verify_cert() so that it causes an error if
|ctx->chain| is anything other than NULL (because this indicates that we
have not been initialised properly). It also clarifies the associated
documentation. This is a follow up commit to CVE-2015-1793.

Reviewed-by: Stephen Henson <steve@openssl.org>
9 years agoAdd test for CVE-2015-1793
Matt Caswell [Wed, 1 Jul 2015 23:15:56 +0000 (00:15 +0100)]
Add test for CVE-2015-1793

This adds a test for CVE-2015-1793. This adds a new test file
verify_extra_test.c, which could form the basis for additional
verification tests.

Reviewed-by: Stephen Henson <steve@openssl.org>
9 years agoFix alternate chains certificate forgery issue
Matt Caswell [Wed, 24 Jun 2015 14:55:36 +0000 (15:55 +0100)]
Fix alternate chains certificate forgery issue

During certificate verfification, OpenSSL will attempt to find an
alternative certificate chain if the first attempt to build such a chain
fails. An error in the implementation of this logic can mean that an
attacker could cause certain checks on untrusted certificates to be
bypassed, such as the CA flag, enabling them to use a valid leaf
certificate to act as a CA and "issue" an invalid certificate.

This occurs where at least one cert is added to the first chain from the
trust store, but that chain still ends up being untrusted. In that case
ctx->last_untrusted is decremented in error.

Patch provided by the BoringSSL project.

CVE-2015-1793

Reviewed-by: Stephen Henson <steve@openssl.org>
9 years agoRelax CCM tag check.
Dr. Stephen Henson [Tue, 9 Jun 2015 22:17:06 +0000 (23:17 +0100)]
Relax CCM tag check.

In CCM mode don't require a tag before initialising decrypt: this allows
the tag length to be set without requiring the tag.

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

9 years agodocument -2 return value
Dr. Stephen Henson [Mon, 6 Jul 2015 13:17:49 +0000 (14:17 +0100)]
document -2 return value

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

9 years agoFix PSK handling.
Dr. Stephen Henson [Wed, 1 Jul 2015 22:40:03 +0000 (23:40 +0100)]
Fix PSK handling.

The PSK identity hint should be stored in the SSL_SESSION structure
and not in the parent context (which will overwrite values used
by other SSL structures with the same SSL_CTX).

Use BUF_strndup when copying identity as it may not be null terminated.

Reviewed-by: Tim Hudson <tjh@openssl.org>
9 years agoCheck for errors with SRP
Dr. Stephen Henson [Thu, 25 Jun 2015 14:07:25 +0000 (15:07 +0100)]
Check for errors with SRP

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

9 years agoDon't output bogus errors in PKCS12_parse
Dr. Stephen Henson [Wed, 24 Jun 2015 11:28:50 +0000 (12:28 +0100)]
Don't output bogus errors in PKCS12_parse

PR#3923

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

9 years agoAdd docs for ssl verification parameter functions.
Dr. Stephen Henson [Wed, 17 Jun 2015 14:51:41 +0000 (15:51 +0100)]
Add docs for ssl verification parameter functions.

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

9 years agoGH297: Fix NAME section of SSL_CTX_use_serverinfo.pod
Vitezslav Cizek [Tue, 16 Jun 2015 19:57:59 +0000 (15:57 -0400)]
GH297: Fix NAME section of SSL_CTX_use_serverinfo.pod

Signed-off-by: Rich Salz <rsalz@akamai.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoRT3682: Avoid double-free on OCSP parse error
Rich Salz [Tue, 23 Jun 2015 12:14:24 +0000 (08:14 -0400)]
RT3682: Avoid double-free on OCSP parse error

Found by Kurt Cancemi

(Manual cherry-pick of f8e427154bbc0c33f29fa7aad001b1b655e5995b)
Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoRT3856: Fix memory leaks in test code
Russell Webb [Sat, 13 Jun 2015 14:35:55 +0000 (10:35 -0400)]
RT3856: Fix memory leaks in test code

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

9 years agomake update
Richard Levitte [Tue, 23 Jun 2015 01:03:10 +0000 (03:03 +0200)]
make update

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoRearrange rsaz
Richard Levitte [Mon, 22 Jun 2015 23:55:46 +0000 (01:55 +0200)]
Rearrange rsaz

A small rearrangement so the inclusion of rsaz_exp.h would be
unconditional, but what that header defines becomes conditional.

This solves the weirdness where rsaz_exp.h gets in and out of the
dependency list for bn_exp.c, depending on the present architecture.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoRT3907-fix
Rich Salz [Mon, 22 Jun 2015 23:26:50 +0000 (19:26 -0400)]
RT3907-fix

Typo in local variable name; introduced by previous fix.

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

9 years agoRT3907: avoid "local" in testssl script
Rich Salz [Sat, 13 Jun 2015 21:18:47 +0000 (17:18 -0400)]
RT3907: avoid "local" in testssl script

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

9 years agoRT3917: add cleanup on an error path
Rich Salz [Sun, 21 Jun 2015 19:37:53 +0000 (15:37 -0400)]
RT3917: add cleanup on an error path

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

9 years agoCleanup mttest.c : because we no longer use stdio here, don't include it
Richard Levitte [Sun, 21 Jun 2015 19:35:59 +0000 (21:35 +0200)]
Cleanup mttest.c : because we no longer use stdio here, don't include it

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

9 years agoAdd -ldl to the build of mttest.c
Richard Levitte [Sun, 21 Jun 2015 17:19:59 +0000 (19:19 +0200)]
Add -ldl to the build of mttest.c

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

9 years agoCleanup mttest.c : do not try to output reference counts when threads are done
Richard Levitte [Sun, 21 Jun 2015 17:16:50 +0000 (19:16 +0200)]
Cleanup mttest.c : do not try to output reference counts when threads are done

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

9 years agoCleanup mttest.c : better error reporting when certs are missing
Richard Levitte [Sun, 21 Jun 2015 17:13:57 +0000 (19:13 +0200)]
Cleanup mttest.c : better error reporting when certs are missing

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

9 years agoCleanup mttest.c : make ssl_method a pointer to const
Richard Levitte [Sun, 21 Jun 2015 17:12:33 +0000 (19:12 +0200)]
Cleanup mttest.c : make ssl_method a pointer to const

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

Conflicts:
crypto/threads/mttest.c

9 years agoCleanup mttest.c : more output changes
Richard Levitte [Sun, 21 Jun 2015 17:19:17 +0000 (19:19 +0200)]
Cleanup mttest.c : more output changes

More fprintf()s and printf()s to turn into BIO calls.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoCleanup mttest.c : modernise output
Richard Levitte [Sun, 21 Jun 2015 17:11:43 +0000 (19:11 +0200)]
Cleanup mttest.c : modernise output

Construct bio_err and bio_stdout from file handles instead of FILE
pointers, since the latter might not be implemented (when OPENSSL_NO_STDIO
is defined).
Convert all output to use BIO_printf.
Change lh_foo to lh_SSL_SESSION_foo.

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

Conflicts:
crypto/threads/mttest.c

9 years agoCleanup mttest.c : modernise the threads setup
Richard Levitte [Sun, 21 Jun 2015 17:03:44 +0000 (19:03 +0200)]
Cleanup mttest.c : modernise the threads setup

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

Conflicts:
crypto/threads/mttest.c

9 years agoCleanup mttest.c : remove MS_CALLBACK
Richard Levitte [Sun, 21 Jun 2015 16:51:18 +0000 (18:51 +0200)]
Cleanup mttest.c : remove MS_CALLBACK

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

9 years agoRT1688: Add dependencies for parallel make
Rich Salz [Sun, 21 Jun 2015 19:12:20 +0000 (15:12 -0400)]
RT1688: Add dependencies for parallel make

Backport to 1.0.1 and 1.0.2 to fix RT 3905

Reviewed-by: Richard Levitte <levitte@openssl.org>
9 years agotypo: should be OPENSSL_free
Dr. Stephen Henson [Sat, 20 Jun 2015 15:10:54 +0000 (16:10 +0100)]
typo: should be OPENSSL_free

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

9 years agoMake preprocessor error into real preprocessor error
Richard Levitte [Mon, 15 Jun 2015 07:59:25 +0000 (09:59 +0200)]
Make preprocessor error into real preprocessor error

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

9 years agoRemove one extraneous parenthesis
Richard Levitte [Sat, 13 Jun 2015 11:13:55 +0000 (13:13 +0200)]
Remove one extraneous parenthesis

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

9 years agoPrepare for 1.0.2d-dev
Matt Caswell [Fri, 12 Jun 2015 15:14:35 +0000 (16:14 +0100)]
Prepare for 1.0.2d-dev

Reviewed-by: Richard Levitte <levitte@openssl.org>
9 years agoPrepare for 1.0.2c release OpenSSL_1_0_2c
Matt Caswell [Fri, 12 Jun 2015 15:10:40 +0000 (16:10 +0100)]
Prepare for 1.0.2c release

Reviewed-by: Richard Levitte <levitte@openssl.org>
9 years agoUpdated CHANGES and NEWS entries for new release
Matt Caswell [Fri, 12 Jun 2015 14:56:51 +0000 (15:56 +0100)]
Updated CHANGES and NEWS entries for new release

Reviewed-by: Richard Levitte <levitte@openssl.org>
9 years agoAllow a zero length extension block
Adam Langley [Fri, 12 Jun 2015 07:05:49 +0000 (08:05 +0100)]
Allow a zero length extension block

It is valid for an extension block to be present in a ClientHello, but to
be of zero length.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoFix ABI break with HMAC
Matt Caswell [Fri, 12 Jun 2015 12:08:04 +0000 (13:08 +0100)]
Fix ABI break with HMAC

Recent HMAC changes broke ABI compatibility due to a new field in HMAC_CTX.
This backs that change out, and does it a different way.

Thanks to Timo Teras for the concept.

Conflicts:
crypto/hmac/hmac.c

Reviewed-by: Richard Levitte <levitte@openssl.org>
9 years agoPrepare for 1.0.2c-dev
Matt Caswell [Thu, 11 Jun 2015 13:59:37 +0000 (14:59 +0100)]
Prepare for 1.0.2c-dev

Reviewed-by: Stephen Henson <steve@openssl.org>
9 years agoPrepare for 1.0.2b release OpenSSL_1_0_2b
Matt Caswell [Thu, 11 Jun 2015 13:55:38 +0000 (14:55 +0100)]
Prepare for 1.0.2b release

Reviewed-by: Stephen Henson <steve@openssl.org>
9 years agomake update
Matt Caswell [Thu, 11 Jun 2015 13:55:38 +0000 (14:55 +0100)]
make update

Reviewed-by: Stephen Henson <steve@openssl.org>
9 years agobn/bn_gf2m.c: avoid infinite loop wich malformed ECParamters.
Andy Polyakov [Wed, 10 Jun 2015 22:18:01 +0000 (00:18 +0200)]
bn/bn_gf2m.c: avoid infinite loop wich malformed ECParamters.

CVE-2015-1788

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

9 years agoUpdate CHANGES and NEWS
Matt Caswell [Wed, 10 Jun 2015 10:49:31 +0000 (11:49 +0100)]
Update CHANGES and NEWS

Updates to CHANGES and NEWS to take account of the latest security fixes.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoPKCS#7: Fix NULL dereference with missing EncryptedContent.
Emilia Kasper [Tue, 12 May 2015 17:00:30 +0000 (19:00 +0200)]
PKCS#7: Fix NULL dereference with missing EncryptedContent.

CVE-2015-1790

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoFix length checks in X509_cmp_time to avoid out-of-bounds reads.
Emilia Kasper [Wed, 8 Apr 2015 14:56:43 +0000 (16:56 +0200)]
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>
9 years agoFix infinite loop in CMS
Dr. Stephen Henson [Fri, 5 Jun 2015 11:11:25 +0000 (12:11 +0100)]
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>