oweals/openssl.git
8 years agoRevert "make update"
Richard Levitte [Thu, 19 May 2016 04:20:02 +0000 (06:20 +0200)]
Revert "make update"

This reverts commit 7229a91a48d706804f790a392b3ad50bc358cdc4.

Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoRevert "Make it possible to have RFC2254 escapes with ASN1_STRING_print_ex()"
Richard Levitte [Thu, 19 May 2016 04:19:53 +0000 (06:19 +0200)]
Revert "Make it possible to have RFC2254 escapes with ASN1_STRING_print_ex()"

This reverts commit 87728c682995d0575b52a5a19d69405bb764e76e.

Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agorand/randfile.c: remove _XOPEN_SOURCE definition.
Andy Polyakov [Mon, 16 May 2016 14:44:33 +0000 (16:44 +0200)]
rand/randfile.c: remove _XOPEN_SOURCE definition.

Defintions of macros similar to _XOPEN_SOURCE belong in command line
or in worst case prior first #include directive in source. As for
macros is was allegedly controlling. One can argue that we are
probably better off demanding S_IS* macros but there are systems
that just don't comply, hence this compromise solution...

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

8 years agoEnsure verify error is set when X509_verify_cert() fails
Viktor Dukhovni [Tue, 17 May 2016 22:25:40 +0000 (18:25 -0400)]
Ensure verify error is set when X509_verify_cert() fails

Set ctx->error = X509_V_ERR_OUT_OF_MEM when verificaiton cannot
continue due to malloc failure.  Similarly for issuer lookup failures
and caller errors (bad parameters or invalid state).

Also, when X509_verify_cert() returns <= 0 make sure that the
verification status does not remain X509_V_OK, as a last resort set
it it to X509_V_ERR_UNSPECIFIED, just in case some code path returns
an error without setting an appropriate value of ctx->error.

Add new and some missing error codes to X509 error -> SSL alert switch.

Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agoClarify negative return from X509_verify_cert()
Viktor Dukhovni [Tue, 17 May 2016 01:38:03 +0000 (21:38 -0400)]
Clarify negative return from X509_verify_cert()

Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agoCheck that the obtained public key is valid
Matt Caswell [Mon, 25 Apr 2016 15:50:59 +0000 (16:50 +0100)]
Check that the obtained public key is valid

In the X509 app check that the obtained public key is valid before we
attempt to use it.

Issue reported by Yuan Jochen Kang.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
8 years agoFix a double free in tls1_setup_key_block
Matt Caswell [Thu, 5 May 2016 08:35:10 +0000 (09:35 +0100)]
Fix a double free in tls1_setup_key_block

If p2 == NULL then p1 can get freed twice and a crash could occur.

Issue reported by Shi Lei (Qihoo 360 Inc)

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
8 years agoFix SRP client key computation
Cynh [Sun, 1 May 2016 13:59:43 +0000 (15:59 +0200)]
Fix SRP client key computation

Signed-off-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Matt Caswell <matt@openssl.org>
GH: #1017
(cherry picked from commit c9141a43e246d527ec8b5a97b98e93fc31b0f0b8)

8 years agoCleanup openssl.ec
Richard Levitte [Wed, 18 May 2016 20:27:54 +0000 (22:27 +0200)]
Cleanup openssl.ec

HMAC doesn't have any error codes

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoFix util/mkerr.pl
Richard Levitte [Wed, 18 May 2016 17:52:34 +0000 (19:52 +0200)]
Fix util/mkerr.pl

- Adjust mkerr.pl to produce the line length we used for source
  reformating.

- Have mkerr.pl keep track of preprocessor directive indentation

  Among others, do not spuriously throw away a #endif at the end of
  header files.

- Make sure mkerr.pl specifies any header inclusion correctly

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoRun the refreshed scripts
Richard Levitte [Wed, 18 May 2016 17:09:42 +0000 (19:09 +0200)]
Run the refreshed scripts

Some output difference in crypto/conf/conf_def.h, because the earlier
source reformatting needlessly indented the macro values.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoRefresh seldom used C generating scripts to current C standard
Richard Levitte [Wed, 18 May 2016 17:08:41 +0000 (19:08 +0200)]
Refresh seldom used C generating scripts to current C standard

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoAvoid double declaration of COMP_METHOD
Alessandro Ghedini [Tue, 17 May 2016 15:23:46 +0000 (16:23 +0100)]
Avoid double declaration of COMP_METHOD
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1083)

8 years agoDocument the esc_2254 command line name option
Richard Levitte [Wed, 18 May 2016 15:39:33 +0000 (17:39 +0200)]
Document the esc_2254 command line name option

RT#1466

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

8 years agomake update
Richard Levitte [Wed, 18 May 2016 15:33:53 +0000 (17:33 +0200)]
make update

RT#1466

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

8 years agoMake it possible to have RFC2254 escapes with ASN1_STRING_print_ex()
Richard Levitte [Wed, 18 May 2016 15:14:19 +0000 (17:14 +0200)]
Make it possible to have RFC2254 escapes with ASN1_STRING_print_ex()

Also adds 'esc_2254' to the possible command line name options

RT#1466

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

8 years agoDon't require any length of password when decrypting
Richard Levitte [Mon, 16 May 2016 15:29:43 +0000 (17:29 +0200)]
Don't require any length of password when decrypting

RT#2534

Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoAdd missing initialiser in e_chil.c
Richard Levitte [Mon, 16 May 2016 15:13:32 +0000 (17:13 +0200)]
Add missing initialiser in e_chil.c

RT#2616

Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoAdd support for RC / WINDRES env variables
Richard Levitte [Mon, 16 May 2016 15:10:16 +0000 (17:10 +0200)]
Add support for RC / WINDRES env variables

RT#2558

Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoRemove repeated condition from if in X509_NAME_oneline
Matt Caswell [Tue, 17 May 2016 10:07:27 +0000 (11:07 +0100)]
Remove repeated condition from if in X509_NAME_oneline

An if checks the value of |type| to see if it is V_ASN1_VISIBLESTRING
twice. We only need to do it once.

GitHub Issue #656

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

8 years agoFix SSL compression symbol exporting
Matt Caswell [Tue, 17 May 2016 08:23:36 +0000 (09:23 +0100)]
Fix SSL compression symbol exporting

Some compression related functions in libssl have dummy versions to be
used when compiled with no-comp. However those dummy functions were not
being exported on Windows so they are unusable when dynamically linked.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoDocumentation: Clarify sizes for UI_add_input_string()
Richard Levitte [Mon, 16 May 2016 13:39:50 +0000 (15:39 +0200)]
Documentation: Clarify sizes for UI_add_input_string()

The given sizes to not include the final NUL character.

RT#2622

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

8 years agoWindows: Add CRYPT32.LIB to the libraries to link your app with
Richard Levitte [Thu, 12 May 2016 20:34:17 +0000 (22:34 +0200)]
Windows: Add CRYPT32.LIB to the libraries to link your app with

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1064)

8 years agoRT3513: req doesn't display attributes using utf8string
isnotnick [Tue, 16 Dec 2014 15:25:59 +0000 (16:25 +0100)]
RT3513: req doesn't display attributes using utf8string

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoUse RPMBUILD macros rather than hard coded paths in openssl.spec
Richard Levitte [Thu, 12 May 2016 15:23:21 +0000 (17:23 +0200)]
Use RPMBUILD macros rather than hard coded paths in openssl.spec

RT#4522

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoRecommend GH over RT, per team vote.
Rich Salz [Wed, 11 May 2016 20:46:44 +0000 (16:46 -0400)]
Recommend GH over RT, per team vote.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(Manual cherry-pick of f2b9c257216a27b568b3d5d703ca5bdd926c5c28)

8 years agoAdding missing BN_CTX_(start/end) in crypto/ec/ec_key.c
Steven Valdez [Tue, 1 Mar 2016 18:20:43 +0000 (13:20 -0500)]
Adding missing BN_CTX_(start/end) in crypto/ec/ec_key.c

RT#4363

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

Conflicts:
crypto/ec/ec_key.c

8 years agoAdd -signcert to CA.pl usage message.
Dr. Stephen Henson [Tue, 10 May 2016 19:30:00 +0000 (20:30 +0100)]
Add -signcert to CA.pl usage message.

RT#4256

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

Conflicts:
apps/CA.pl.in

8 years agoFix i2d_X509_AUX and update docs
Viktor Dukhovni [Mon, 2 May 2016 19:00:21 +0000 (15:00 -0400)]
Fix i2d_X509_AUX and update docs

When *pp is NULL, don't write garbage, return an unexpected pointer
or leak memory on error.

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
8 years agoGH837: Avoid double-free in OCSP parse.
Rich Salz [Tue, 10 May 2016 17:41:06 +0000 (13:41 -0400)]
GH837: Avoid double-free in OCSP parse.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
8 years agoTypo.
Dr. Stephen Henson [Tue, 10 May 2016 15:39:52 +0000 (16:39 +0100)]
Typo.

RT#4538

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

8 years agoAdd NULL check in i2d_PrivateKey()
Richard Levitte [Mon, 9 May 2016 19:52:11 +0000 (21:52 +0200)]
Add NULL check in i2d_PrivateKey()

Originally submitted by Kurt Cancemi <kurt@x64architecture.com>

Closes RT#4533

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

8 years agoDon't send signature algorithms when client_version is below TLS 1.2.
David Benjamin [Sun, 6 Mar 2016 00:49:20 +0000 (19:49 -0500)]
Don't send signature algorithms when client_version is below TLS 1.2.

Per RFC 5246,

    Note: this extension is not meaningful for TLS versions prior to 1.2.
    Clients MUST NOT offer it if they are offering prior versions.
    However, even if clients do offer it, the rules specified in [TLSEXT]
    require servers to ignore extensions they do not understand.

Although second sentence would suggest that there would be no interop
problems in always offering the extension, WebRTC has reported issues
with Bouncy Castle on < TLS 1.2 ClientHellos that still include
signature_algorithms. See also
https://bugs.chromium.org/p/webrtc/issues/detail?id=4223

RT#4390

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Stephen Henson <steve@openssl.org>
(cherry picked from commit f7aa318552c4ef62d902c480b59bd7c4513c0009)

Conflicts:
ssl/ssl_locl.h

8 years agoFix BIO_eof() for BIO pairs
Matt Caswell [Mon, 9 May 2016 14:04:11 +0000 (15:04 +0100)]
Fix BIO_eof() for BIO pairs

BIO_eof() was always returning true when using a BIO pair. It should only
be true if the peer BIO is empty and has been shutdown.

RT#1215

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

8 years agoOnly call FIPS_update, FIPS_final in FIPS mode.
Dr. Stephen Henson [Sun, 8 May 2016 23:06:02 +0000 (00:06 +0100)]
Only call FIPS_update, FIPS_final in FIPS mode.

RT#3826

Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agoConstify PKCS12_newpass()
Dr. Stephen Henson [Fri, 6 May 2016 02:46:09 +0000 (03:46 +0100)]
Constify PKCS12_newpass()

PR#4449

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 049f5bbce3eebdf4ec2030042eb2ae64bb67aedb)
Conflicts:
doc/crypto/PKCS12_newpass.pod

8 years agoTidy up PKCS12_newpass() fix memory leaks.
Dr. Stephen Henson [Thu, 5 May 2016 14:37:23 +0000 (15:37 +0100)]
Tidy up PKCS12_newpass() fix memory leaks.

PR#4466

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

Conflicts:
crypto/pkcs12/p12_npas.c

8 years agoOnly set CMS parameter when encrypting
Dr. Stephen Henson [Fri, 6 May 2016 18:27:49 +0000 (19:27 +0100)]
Only set CMS parameter when encrypting

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

8 years agoUse default ASN.1 for SEED.
Dr. Stephen Henson [Thu, 5 May 2016 21:17:05 +0000 (22:17 +0100)]
Use default ASN.1 for SEED.

The default ASN.1 handling can be used for SEED. This also makes
CMS work with SEED.

PR#4504

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

8 years agoAlways try to set ASN.1 parameters for CMS.
Dr. Stephen Henson [Mon, 21 Mar 2016 15:48:51 +0000 (15:48 +0000)]
Always try to set ASN.1 parameters for CMS.

Try to set the ASN.1 parameters for CMS encryption even if the IV
length is zero as the underlying cipher should still set the type.

This will correctly result in errors if an attempt is made to use
an unsupported cipher type.

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

Conflicts:
crypto/cms/cms_enc.c

8 years agoCheck return of PEM_write_* functions and report possible errors
Richard Levitte [Wed, 4 May 2016 12:44:10 +0000 (14:44 +0200)]
Check return of PEM_write_* functions and report possible errors

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1025)
(cherry picked from commit c73aa309049c4f04ec81f0f1cf552eab8456a16e)

8 years agoFix name length limit check.
Dr. Stephen Henson [Wed, 4 May 2016 15:09:06 +0000 (16:09 +0100)]
Fix name length limit check.

The name length limit check in x509_name_ex_d2i() includes
the containing structure as well as the actual X509_NAME. This will
cause large CRLs to be rejected.

Fix by limiting the length passed to ASN1_item_ex_d2i() which will
then return an error if the passed X509_NAME exceeds the length.

RT#4531

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

8 years agoFix double free in d2i_PrivateKey().
Dr. Stephen Henson [Tue, 3 May 2016 14:05:31 +0000 (15:05 +0100)]
Fix double free in d2i_PrivateKey().

RT#4527

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

8 years agoadd documentation
Dr. Stephen Henson [Tue, 3 May 2016 14:21:41 +0000 (15:21 +0100)]
add documentation

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

8 years agoPrepare for 1.0.2i-dev
Matt Caswell [Tue, 3 May 2016 13:47:32 +0000 (14:47 +0100)]
Prepare for 1.0.2i-dev

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoPrepare for 1.0.2h release OpenSSL_1_0_2h
Matt Caswell [Tue, 3 May 2016 13:46:41 +0000 (14:46 +0100)]
Prepare for 1.0.2h release

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agomake update
Matt Caswell [Tue, 3 May 2016 13:46:41 +0000 (14:46 +0100)]
make update

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoUpdate CHANGES and NEWS for the new release
Matt Caswell [Tue, 3 May 2016 08:37:23 +0000 (09:37 +0100)]
Update CHANGES and NEWS for the new release

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoFix ASN1_INTEGER handling.
Dr. Stephen Henson [Fri, 15 Apr 2016 01:37:09 +0000 (02:37 +0100)]
Fix ASN1_INTEGER handling.

Only treat an ASN1_ANY type as an integer if it has the V_ASN1_INTEGER
tag: V_ASN1_NEG_INTEGER is an internal only value which is never used
for on the wire encoding.

Thanks to David Benjamin <davidben@google.com> for reporting this bug.

This was found using libFuzzer.

RT#4364 (part)CVE-2016-2108.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
8 years agoCheck that we have enough padding characters.
Kurt Roeckx [Sat, 16 Apr 2016 21:08:56 +0000 (23:08 +0200)]
Check that we have enough padding characters.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
CVE-2016-2107

MR: #2572

8 years agoRemove some documentation for functions not in 1.0.x
Matt Caswell [Tue, 3 May 2016 11:45:45 +0000 (12:45 +0100)]
Remove some documentation for functions not in 1.0.x

A few functions in the recently added EVP_EncodeInit docs don't apply to
the 1.0.x branches.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoAdd documentation for EVP_EncodeInit() and similar functions
Matt Caswell [Mon, 25 Apr 2016 10:54:30 +0000 (11:54 +0100)]
Add documentation for EVP_EncodeInit() and similar functions

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoEnsure EVP_EncodeUpdate handles an output length that is too long
Matt Caswell [Mon, 25 Apr 2016 08:06:29 +0000 (09:06 +0100)]
Ensure EVP_EncodeUpdate handles an output length that is too long

With the EVP_EncodeUpdate function it is the caller's responsibility to
determine how big the output buffer should be. The function writes the
amount actually used to |*outl|. However this could go negative with a
sufficiently large value for |inl|. We add a check for this error
condition.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoAvoid overflow in EVP_EncodeUpdate
Matt Caswell [Fri, 4 Mar 2016 10:17:17 +0000 (10:17 +0000)]
Avoid overflow in EVP_EncodeUpdate

An overflow can occur in the EVP_EncodeUpdate function which is used for
Base64 encoding of binary data. If an attacker is able to supply very large
amounts of input data then a length check can overflow resulting in a heap
corruption. Due to the very large amounts of data involved this will most
likely result in a crash.

Internally to OpenSSL the EVP_EncodeUpdate function is primarly used by the
PEM_write_bio* family of functions. These are mainly used within the
OpenSSL command line applications, so any application which processes
data from an untrusted source and outputs it as a PEM file should be
considered vulnerable to this issue.

User applications that call these APIs directly with large amounts of
untrusted data may also be vulnerable.

Issue reported by Guido Vranken.

CVE-2016-2105

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoPrevent EBCDIC overread for very long strings
Matt Caswell [Thu, 28 Apr 2016 09:46:55 +0000 (10:46 +0100)]
Prevent EBCDIC overread for very long strings

ASN1 Strings that are over 1024 bytes can cause an overread in
applications using the X509_NAME_oneline() function on EBCDIC systems.
This could result in arbitrary stack data being returned in the buffer.

Issue reported by Guido Vranken.

CVE-2016-2176

Reviewed-by: Andy Polyakov <appro@openssl.org>
8 years agoFix encrypt overflow
Matt Caswell [Thu, 3 Mar 2016 23:36:23 +0000 (23:36 +0000)]
Fix encrypt overflow

An overflow can occur in the EVP_EncryptUpdate function. If an attacker is
able to supply very large amounts of input data after a previous call to
EVP_EncryptUpdate with a partial block then a length check can overflow
resulting in a heap corruption.

Following an analysis of all OpenSSL internal usage of the
EVP_EncryptUpdate function all usage is one of two forms.

The first form is like this:
EVP_EncryptInit()
EVP_EncryptUpdate()

i.e. where the EVP_EncryptUpdate() call is known to be the first called
function after an EVP_EncryptInit(), and therefore that specific call
must be safe.

The second form is where the length passed to EVP_EncryptUpdate() can be
seen from the code to be some small value and therefore there is no
possibility of an overflow.

Since all instances are one of these two forms, I believe that there can
be no overflows in internal code due to this problem.

It should be noted that EVP_DecryptUpdate() can call EVP_EncryptUpdate()
in certain code paths. Also EVP_CipherUpdate() is a synonym for
EVP_EncryptUpdate(). Therefore I have checked all instances of these
calls too, and came to the same conclusion, i.e. there are no instances
in internal usage where an overflow could occur.

This could still represent a security issue for end user code that calls
this function directly.

CVE-2016-2106

Issue reported by Guido Vranken.

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

8 years agoFix i2d_X509_AUX: pp can be NULL.
Dr. Stephen Henson [Mon, 2 May 2016 16:33:50 +0000 (17:33 +0100)]
Fix i2d_X509_AUX: pp can be NULL.

Reported by David Benjamin

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

8 years agoRemove confusing comment.
TJ Saunders [Fri, 29 Apr 2016 14:40:28 +0000 (07:40 -0700)]
Remove confusing comment.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoIssue #719:
TJ Saunders [Wed, 23 Mar 2016 18:55:53 +0000 (11:55 -0700)]
Issue #719:

If no serverinfo extension is found in some cases, do not abort the handshake,
but simply omit/skip that extension.

Check for already-registered serverinfo callbacks during serverinfo
registration.

Update SSL_CTX_use_serverinfo() documentation to mention the need to reload the
same serverinfo per certificate, for servers with multiple server certificates.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoDon't free ret->data if malloc fails.
Dr. Stephen Henson [Wed, 27 Apr 2016 19:27:41 +0000 (20:27 +0100)]
Don't free ret->data if malloc fails.

Issue reported by Guido Vranken.

Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoAdd checks to X509_NAME_oneline()
Dr. Stephen Henson [Thu, 28 Apr 2016 18:45:44 +0000 (19:45 +0100)]
Add checks to X509_NAME_oneline()

Sanity check field lengths and sums to avoid potential overflows and reject
excessively large X509_NAME structures.

Issue reported by Guido Vranken.

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

Conflicts:
crypto/x509/x509_err.c
crypto/x509/x509_obj.c

8 years agoSanity check buffer length.
Dr. Stephen Henson [Thu, 28 Apr 2016 12:09:27 +0000 (13:09 +0100)]
Sanity check buffer length.

Reject zero length buffers passed to X509_NAME_onelne().

Issue reported by Guido Vranken.

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

8 years agoAdd size limit to X509_NAME structure.
Dr. Stephen Henson [Thu, 28 Apr 2016 11:55:29 +0000 (12:55 +0100)]
Add size limit to X509_NAME structure.

This adds an explicit limit to the size of an X509_NAME structure. Some
part of OpenSSL (e.g. TLS) already effectively limit the size due to
restrictions on certificate size.

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

8 years agoReject inappropriate private key encryption ciphers.
Dr. Stephen Henson [Sat, 23 Apr 2016 12:33:05 +0000 (13:33 +0100)]
Reject inappropriate private key encryption ciphers.

The traditional private key encryption algorithm doesn't function
properly if the IV length of the cipher is zero. These ciphers
(e.g. ECB mode) are not suitable for private key encryption
anyway.

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

8 years agoEnsure we check i2d_X509 return val
Matt Caswell [Mon, 25 Apr 2016 15:05:55 +0000 (16:05 +0100)]
Ensure we check i2d_X509 return val

The i2d_X509() function can return a negative value on error. Therefore
we should make sure we check it.

Issue reported by Yuan Jochen Kang.

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

8 years agoFix a signed/unsigned warning
Matt Caswell [Mon, 25 Apr 2016 16:45:11 +0000 (17:45 +0100)]
Fix a signed/unsigned warning

This causes a compilation failure when using --strict-warnings in 1.0.2
and 1.0.1

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
8 years agoFix NULL deref in apps/pkcs7
Rich Salz [Mon, 25 Apr 2016 12:56:54 +0000 (08:56 -0400)]
Fix NULL deref in apps/pkcs7

Thanks to Brian Carpenter for finding and reporting this.

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

8 years agos390x assembly pack: cache capability query results.
Andy Polyakov [Fri, 15 Apr 2016 14:39:22 +0000 (16:39 +0200)]
s390x assembly pack: cache capability query results.

IBM argues that in certain scenarios capability query is really
expensive. At the same time it's asserted that query results can
be safely cached, because disabling CPACF is incompatible with
reboot-free operation.

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

8 years agoFix buffer overrun in ASN1_parse().
Viktor Dukhovni [Wed, 20 Apr 2016 02:23:24 +0000 (22:23 -0400)]
Fix buffer overrun in ASN1_parse().

Backport of commits:

        79c7f74d6cefd5d32fa20e69195ad3de834ce065
bdcd660e33710079b495cf5cc6a1aaa5d2dcd317

from master.

Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoHarden ASN.1 BIO handling of large amounts of data.
Dr. Stephen Henson [Mon, 11 Apr 2016 12:57:20 +0000 (13:57 +0100)]
Harden ASN.1 BIO handling of large amounts of data.

If the ASN.1 BIO is presented with a large length field read it in
chunks of increasing size checking for EOF on each read. This prevents
small files allocating excessive amounts of data.

CVE-2016-2109

Thanks to Brian Carpenter for reporting this issue.

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

8 years agoPPC assembly pack: remove branch hints.
Andy Polyakov [Thu, 31 Mar 2016 16:47:17 +0000 (18:47 +0200)]
PPC assembly pack: remove branch hints.

As it turns out branch hints grew as kind of a misconception. In
addition their interpretation by GNU assembler is affected by
assembler flags and can end up with opposite meaning on different
processors. As we have to loose quite a lot on misinterprerations,
especially on newer processors, we just omit them altogether.

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

8 years agoFix memory leak on invalid CertificateRequest.
David Benjamin [Mon, 14 Mar 2016 19:03:07 +0000 (15:03 -0400)]
Fix memory leak on invalid CertificateRequest.

Free up parsed X509_NAME structure if the CertificateRequest message
contains excess data.

The security impact is considered insignificant. This is a client side
only leak and a large number of connections to malicious servers would
be needed to have a significant impact.

This was found by libFuzzer.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
Reviewed-by: Stephen Henson <steve@openssl.org>
8 years agoFix ALPN
Todd Short [Sat, 5 Mar 2016 13:47:55 +0000 (08:47 -0500)]
Fix ALPN

* Perform ALPN after the SNI callback; the SSL_CTX may change due to
  that processing
* Add flags to indicate that we actually sent ALPN, to properly error
  out if unexpectedly received.
* document ALPN functions
* unit tests

Backport of commit 817cd0d52f0462039d1fe60462150be7f59d2002

Reviewed-by: Emilia Käsper <emilia@openssl.org>
Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
8 years agoFix FIPS SSLv2 test
Dr. Stephen Henson [Sat, 26 Mar 2016 15:00:53 +0000 (15:00 +0000)]
Fix FIPS SSLv2 test

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
8 years agoFix the no-comp option for Windows
Matt Caswell [Thu, 17 Mar 2016 12:55:02 +0000 (12:55 +0000)]
Fix the no-comp option for Windows

no-comp on Windows was not actually suppressing compilation of the code,
although it was suppressing its use.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoAdd a check for a failed malloc
Matt Caswell [Tue, 15 Mar 2016 11:51:48 +0000 (11:51 +0000)]
Add a check for a failed malloc

Ensure we check for a NULL return from OPENSSL_malloc

Issue reported by Guido Vranken.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoEnsure that memory allocated for the ticket is freed
Matt Caswell [Tue, 15 Mar 2016 11:38:56 +0000 (11:38 +0000)]
Ensure that memory allocated for the ticket is freed

If a call to EVP_DecryptUpdate fails then a memory leak could occur.
Ensure that the memory is freed appropriately.

Issue reported by Guido Vranken.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoFix a potential double free in EVP_DigestInit_ex
Matt Caswell [Mon, 14 Mar 2016 17:06:19 +0000 (17:06 +0000)]
Fix a potential double free in EVP_DigestInit_ex

There is a potential double free in EVP_DigestInit_ex. This is believed
to be reached only as a result of programmer error - but we should fix it
anyway.

Issue reported by Guido Vranken.

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

8 years agoAdd no-ssl2-method
Kurt Roeckx [Wed, 9 Mar 2016 17:10:52 +0000 (18:10 +0100)]
Add no-ssl2-method

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
MR: #2341

8 years agoTouch the correct variables for the system; shlib_wrap.sh on Solaris
Richard Levitte [Wed, 9 Mar 2016 10:36:32 +0000 (11:36 +0100)]
Touch the correct variables for the system; shlib_wrap.sh on Solaris

If there is cause to think LD_LIBRARY_PATH_32 and LD_PRELOAD_32 are
appropriate variables to touch, do so.  Otherwise, touch the usual
LD_LIBRARY_PATH and LD_PRELOAD.  This covers for older installations
that don't have a mix of 32-bit and 64-bit libs.

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

8 years agoRecognise 32-bit Solaris in util/shlib_wrap.sh
Richard Levitte [Sun, 6 Mar 2016 21:36:57 +0000 (22:36 +0100)]
Recognise 32-bit Solaris in util/shlib_wrap.sh

Submitted by Erik Forsberg <erik@efca.com>

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

8 years agoexpose SSLv2 method prototypes
Viktor Dukhovni [Tue, 8 Mar 2016 20:33:02 +0000 (15:33 -0500)]
expose SSLv2 method prototypes

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
8 years agoRetain SSLv2 methods as functions that return NULL
Viktor Dukhovni [Mon, 7 Mar 2016 21:10:38 +0000 (21:10 +0000)]
Retain SSLv2 methods as functions that return NULL

This improves ABI compatibility when symbol resolution is not lazy.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoRemove LOW from the default
Kurt Roeckx [Sun, 10 Jan 2016 12:23:43 +0000 (13:23 +0100)]
Remove LOW from the default

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
8 years agoDon't shift serial number into sign bit
Dr. Stephen Henson [Fri, 4 Mar 2016 18:04:46 +0000 (18:04 +0000)]
Don't shift serial number into sign bit

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agobn/asm/x86[_64]-mont*.pl: complement alloca with page-walking.
Andy Polyakov [Fri, 4 Mar 2016 10:39:11 +0000 (11:39 +0100)]
bn/asm/x86[_64]-mont*.pl: complement alloca with page-walking.

Some OSes, *cough*-dows, insist on stack being "wired" to
physical memory in strictly sequential manner, i.e. if stack
allocation spans two pages, then reference to farmost one can
be punishable by SEGV. But page walking can do good even on
other OSes, because it guarantees that villain thread hits
the guard page before it can make damage to innocent one...

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

8 years agoperlasm/x86_64-xlate.pl: handle binary constants early.
Andy Polyakov [Fri, 4 Mar 2016 10:32:26 +0000 (11:32 +0100)]
perlasm/x86_64-xlate.pl: handle binary constants early.

Not all assemblers of "gas" flavour handle binary constants, e.g.
seasoned MacOS Xcode doesn't, so give them a hand.

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

8 years agoSanity check PVK file fields.
Dr. Stephen Henson [Thu, 3 Mar 2016 23:37:36 +0000 (23:37 +0000)]
Sanity check PVK file fields.

PVK files with abnormally large length or salt fields can cause an
integer overflow which can result in an OOB read and heap corruption.
However this is an rarely used format and private key files do not
normally come from untrusted sources the security implications not
significant.

Fix by limiting PVK length field to 100K and salt to 10K: these should be
more than enough to cover any files encountered in practice.

Issue reported by Guido Vranken.

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

8 years agoRT4358: Extra ] in doc/ocsp.pod
Eric S. Raymond [Mon, 29 Feb 2016 19:54:47 +0000 (14:54 -0500)]
RT4358: Extra ] in doc/ocsp.pod

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoPrepare for 1.0.2h-dev
Matt Caswell [Tue, 1 Mar 2016 13:37:56 +0000 (13:37 +0000)]
Prepare for 1.0.2h-dev

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoPrepare for 1.0.2g release OpenSSL_1_0_2g
Matt Caswell [Tue, 1 Mar 2016 13:36:54 +0000 (13:36 +0000)]
Prepare for 1.0.2g release

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agomake update
Matt Caswell [Tue, 1 Mar 2016 13:36:54 +0000 (13:36 +0000)]
make update

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoEnsure mk1mf.pl is aware of no-weak-ssl-ciphers option
Matt Caswell [Tue, 1 Mar 2016 12:08:33 +0000 (12:08 +0000)]
Ensure mk1mf.pl is aware of no-weak-ssl-ciphers option

Update mk1mf.pl to properly handle no-weak-ssl-ciphers

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoUpdate CHANGES and NEWS for new release
Matt Caswell [Tue, 1 Mar 2016 11:00:48 +0000 (11:00 +0000)]
Update CHANGES and NEWS for new release

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agobn/asm/x86_64-mont5.pl: unify gather procedure in hardly used path
Andy Polyakov [Tue, 26 Jan 2016 15:50:10 +0000 (16:50 +0100)]
bn/asm/x86_64-mont5.pl: unify gather procedure in hardly used path
and reorganize/harmonize post-conditions.

Additional hardening following on from CVE-2016-0702

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

8 years agocrypto/bn/x86_64-mont5.pl: constant-time gather procedure.
Andy Polyakov [Mon, 25 Jan 2016 22:41:01 +0000 (23:41 +0100)]
crypto/bn/x86_64-mont5.pl: constant-time gather procedure.

At the same time remove miniscule bias in final subtraction.
Performance penalty varies from platform to platform, and even with
key length. For rsa2048 sign it was observed to be 4% for Sandy
Bridge and 7% on Broadwell.

CVE-2016-0702

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

8 years agobn/asm/rsaz-avx2.pl: constant-time gather procedure.
Andy Polyakov [Mon, 25 Jan 2016 22:25:40 +0000 (23:25 +0100)]
bn/asm/rsaz-avx2.pl: constant-time gather procedure.

Performance penalty is 2%.

CVE-2016-0702

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

8 years agobn/asm/rsax-x86_64.pl: constant-time gather procedure.
Andy Polyakov [Mon, 25 Jan 2016 22:06:45 +0000 (23:06 +0100)]
bn/asm/rsax-x86_64.pl: constant-time gather procedure.

Performance penalty is 2% on Linux and 5% on Windows.

CVE-2016-0702

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

8 years agobn/bn_exp.c: constant-time MOD_EXP_CTIME_COPY_FROM_PREBUF.
Andy Polyakov [Mon, 25 Jan 2016 19:38:38 +0000 (20:38 +0100)]
bn/bn_exp.c: constant-time MOD_EXP_CTIME_COPY_FROM_PREBUF.

Performance penalty varies from platform to platform, and even
key length. For rsa2048 sign it was observed to reach almost 10%.

CVE-2016-0702

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

Resolved conflicts:
crypto/bn/bn_exp.c

8 years agoDisable EXPORT and LOW SSLv3+ ciphers by default
Viktor Dukhovni [Fri, 19 Feb 2016 18:05:11 +0000 (13:05 -0500)]
Disable EXPORT and LOW SSLv3+ ciphers by default

Reviewed-by: Emilia Käsper <emilia@openssl.org>