openssl.git
7 years agoFix VMS/openssl_{startup,shutddown}.com.in
Richard Levitte [Mon, 9 May 2016 20:59:02 +0000 (22:59 +0200)]
Fix VMS/openssl_{startup,shutddown}.com.in

They were using the wrong variables.

Reviewed-by: Andy Polyakov <appro@openssl.org>
7 years agoConfigure: adhere to $(CROSS_COMPILE)ranlib.
Andy Polyakov [Mon, 9 May 2016 13:35:55 +0000 (15:35 +0200)]
Configure: adhere to $(CROSS_COMPILE)ranlib.

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoConfigure: make it work with Perl 5.10.
Andy Polyakov [Mon, 9 May 2016 09:44:10 +0000 (11:44 +0200)]
Configure: make it work with Perl 5.10.

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoIRIX fixes.
Andy Polyakov [Wed, 4 May 2016 21:40:47 +0000 (23:40 +0200)]
IRIX fixes.

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 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>
7 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>
7 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>
7 years agoFix: failed to open config file if not specified when using CA commands
Hansruedi Patzen [Sat, 20 Feb 2016 16:27:02 +0000 (17:27 +0100)]
Fix: failed to open config file if not specified when using CA commands

Issue was introduced in
https://github.com/openssl/openssl/commit/a0a82324f965bbcc4faed4e1ee3fcaf81ea52166

This patch fixes an issue which causes the 'openssl ca' commands to
fail if '-config' is not specified even if it says so otherwise.
Problem is that the default config is not loaded and the conf variable
is NULL which causes an exception.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoVMS: support VERBOSE and V in descrip.mms
Richard Levitte [Sun, 8 May 2016 14:57:55 +0000 (16:57 +0200)]
VMS: support VERBOSE and V in descrip.mms

With Unixly Makefiles as well as with nmake, make variables are
transferred to the shell running the commands as envinronment
variables.  This principle doesn't apply with MMS, so we must
explicitely define VERBOSE as commands when it's needed.

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoRecognise VERBOSE and V as well as HARNESS_VERBOSE
Dr. Stephen Henson [Sun, 8 May 2016 12:09:56 +0000 (13:09 +0100)]
Recognise VERBOSE and V as well as HARNESS_VERBOSE

PR#4462

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoMissing credit in CHANGES
Rich Salz [Mon, 9 May 2016 12:56:35 +0000 (08:56 -0400)]
Missing credit in CHANGES

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoFix error in the loop of ECDH
Andrea Grandi [Tue, 3 May 2016 02:24:48 +0000 (03:24 +0100)]
Fix error in the loop of ECDH

The tests was incorrectly repeated multiple times when using the
async_jobs options

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
7 years agoFree any existing SRTP connection profile
Matt Caswell [Thu, 5 May 2016 19:59:03 +0000 (20:59 +0100)]
Free any existing SRTP connection profile

When setting a new SRTP connection profile using
SSL_CTX_set_tlsext_use_srtp() or SSL_set_tlsext_use_srtp() we should
free any existing profile first to avoid a memory leak.

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
7 years agoConfigurations/windows-makefile.tmpl: expand environments early.
Andy Polyakov [Fri, 6 May 2016 10:45:50 +0000 (12:45 +0200)]
Configurations/windows-makefile.tmpl: expand environments early.

If environment variables are not explanded early enough, expanded
strings are passed with single backslash to C compiler, e.g.
C:\Program Files, which effectively results in OpenSSL looking for
engines and certificates in C:Program Files.

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agofix tab-space mixed indentation
FdaSilvaYY [Tue, 3 May 2016 20:40:33 +0000 (22:40 +0200)]
fix tab-space mixed indentation

No code change

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
7 years agofix check
J Mohan Rao Arisankala [Fri, 6 May 2016 01:35:44 +0000 (07:05 +0530)]
fix check

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
7 years agofew missing allocation failure checks and releases on error paths
J Mohan Rao Arisankala [Thu, 5 May 2016 18:13:32 +0000 (23:43 +0530)]
few missing allocation failure checks and releases on error paths

- Missing checks for allocation failure.
- releasing memory in few missing error paths

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
7 years agomemset() doesn't take NULL.
Ben Laurie [Wed, 4 May 2016 10:45:49 +0000 (11:45 +0100)]
memset() doesn't take NULL.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
7 years agoAdd fuzzing!
Ben Laurie [Sat, 26 Mar 2016 17:19:14 +0000 (17:19 +0000)]
Add fuzzing!

Reviewed-by: Emilia Käsper <emilia@openssl.org>
7 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>
7 years agoAdd documentation of PKCS12_newpass()
Jeffrey Walton [Thu, 5 May 2016 13:26:26 +0000 (14:26 +0100)]
Add documentation of PKCS12_newpass()

PR#4478

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Stephen Henson <steve@openssl.org>
7 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>
7 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>
7 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: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoREADME.PERL: clarify "matching" Perl requirement on Windows.
Andy Polyakov [Thu, 5 May 2016 15:07:06 +0000 (17:07 +0200)]
README.PERL: clarify "matching" Perl requirement on Windows.

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agopoly1305/asm/poly1305-x86_64.pl: contain symbols within shared lib.
Andy Polyakov [Wed, 4 May 2016 21:53:06 +0000 (23:53 +0200)]
poly1305/asm/poly1305-x86_64.pl: contain symbols within shared lib.

We don't need it, but external users might find it handy.

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agopoly1305/asm/poly1305-x86_64.pl: make it cross-compile.
Andy Polyakov [Wed, 4 May 2016 21:45:35 +0000 (23:45 +0200)]
poly1305/asm/poly1305-x86_64.pl: make it cross-compile.

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agotestlib/OpenSSL/Test.pm: address 5.10 warnings.
Andy Polyakov [Wed, 4 May 2016 21:42:57 +0000 (23:42 +0200)]
testlib/OpenSSL/Test.pm: address 5.10 warnings.

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agotest/evp_test.c: exercise different combinations of data misalignment.
Andy Polyakov [Sat, 23 Apr 2016 17:14:21 +0000 (19:14 +0200)]
test/evp_test.c: exercise different combinations of data misalignment.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
7 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>
7 years agotypo
Dr. Stephen Henson [Thu, 5 May 2016 21:44:44 +0000 (22:44 +0100)]
typo

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoMove 3DES from HIGH to MEDIUM
Rich Salz [Thu, 5 May 2016 21:08:41 +0000 (17:08 -0400)]
Move 3DES from HIGH to MEDIUM

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
7 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>
7 years agoGH356: Change assert to normal error
Sergio Garcia Murillo [Thu, 5 May 2016 21:27:30 +0000 (17:27 -0400)]
GH356: Change assert to normal error

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoHandle no async jobs in libssl
Matt Caswell [Tue, 3 May 2016 16:55:00 +0000 (17:55 +0100)]
Handle no async jobs in libssl

If the application has limited the size of the async pool using
ASYNC_init_thread() then we could run out of jobs while trying to start a
libssl io operation. However libssl was failing to handle this and treating
it like a fatal error. It should not be fatal...we just need to retry when
there are jobs available again.

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoDocument inversion ladder in curve25519
Emilia Kasper [Fri, 29 Apr 2016 17:19:58 +0000 (19:19 +0200)]
Document inversion ladder in curve25519

This demystifies two for-loops that do nothing. They were used to write
the ladder in a unified way. Now that the ladder is otherwise commented,
remove the dead loops.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoScript changed; update the generated file.
Rich Salz [Thu, 5 May 2016 14:21:46 +0000 (10:21 -0400)]
Script changed; update the generated file.

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
7 years agoImprove heartbeats coding style
Matt Caswell [Thu, 5 May 2016 15:04:22 +0000 (16:04 +0100)]
Improve heartbeats coding style

Based on an orignal commit by GitHub user BertramScharpf. Rebased and
updated to take account of all the updates since this was first raised.

GH PR#62

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoTweak generated warning lines.
Rich Salz [Sun, 1 May 2016 12:47:43 +0000 (08:47 -0400)]
Tweak generated warning lines.

Reviewed-by: Andy Polyakov <appro@openssl.org>
7 years agoremove unused macros in list -disabled
J Mohan Rao Arisankala [Fri, 26 Feb 2016 06:07:08 +0000 (11:37 +0530)]
remove unused macros in list -disabled

list -disabled was checking OPENSSL_NO_SSL/OPENSSL_NO_TLS, which are
not used to disable SSL/TLS respectively.
Building with these macros wrongly show as SSL/TLS disabled, hence
removing this code.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
7 years agoFix spelling
FdaSilvaYY [Tue, 3 May 2016 17:34:03 +0000 (19:34 +0200)]
Fix spelling

Signed-off-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Matt Caswell <matt@openssl.org>
GH: #1021

7 years agosupport embed in ASN.1 print
Dr. Stephen Henson [Wed, 4 May 2016 13:50:14 +0000 (14:50 +0100)]
support embed in ASN.1 print

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoComplete the list of names in doc/ssl/SSL_CTX_load_verify_locations.pod
Richard Levitte [Wed, 4 May 2016 17:26:59 +0000 (19:26 +0200)]
Complete the list of names in doc/ssl/SSL_CTX_load_verify_locations.pod

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 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>
7 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)

7 years agoDEFINE_STACK_OF(ASN1_UTF8STRING) moved from ts_lcl.h to asn1.h
Marek Klein [Tue, 3 May 2016 08:48:47 +0000 (08:48 +0000)]
DEFINE_STACK_OF(ASN1_UTF8STRING) moved from ts_lcl.h to asn1.h

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1020)

7 years agoHandle malloc failures in BIO_accept
Matt Caswell [Wed, 4 May 2016 09:38:02 +0000 (10:38 +0100)]
Handle malloc failures in BIO_accept

The old BIO_accept() function can encounter errors during malloc. We need
to ensure we properly clean up if that occurs.

GH Issue #817

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoreject zero block length in PKCS12 keygen
Dr. Stephen Henson [Wed, 4 May 2016 12:13:24 +0000 (13:13 +0100)]
reject zero block length in PKCS12 keygen

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoFix Blake block length
Dr. Stephen Henson [Wed, 4 May 2016 12:11:30 +0000 (13:11 +0100)]
Fix Blake block length

PR#4514

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 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>
7 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>
7 years agoGH932: Add more help messages to some apps options.
FdaSilvaYY [Sun, 20 Mar 2016 20:14:10 +0000 (21:14 +0100)]
GH932: Add more help messages to some apps options.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoFix the no-tls option
Matt Caswell [Wed, 4 May 2016 09:13:15 +0000 (10:13 +0100)]
Fix the no-tls option

The TLSProxy based tests don't work when TLS is disabled so we shouldn't
run them.

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoRemove stale errors from early connection attempts in a client
Matt Caswell [Wed, 4 May 2016 08:12:27 +0000 (09:12 +0100)]
Remove stale errors from early connection attempts in a client

The init_client() function in the apps sets up the client connection. It
may try multiple addresses until it finds one that works. We should clear
the error queue if we eventually get a successful connection because
otherwise we get stale errors hanging around. This can cause problems in
subsequent calls to SSL_get_error(), i.e. non-fatal NBIO events appear as
fatal.

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoAllow spaces in filenames when using perl's glob
Richard Levitte [Tue, 3 May 2016 21:58:38 +0000 (23:58 +0200)]
Allow spaces in filenames when using perl's glob

Reviewed-by: Matt Caswell <matt@openssl.org>
7 years agoAlpha assembly pack: make it work on Linux.
Andy Polyakov [Tue, 3 May 2016 11:17:30 +0000 (13:17 +0200)]
Alpha assembly pack: make it work on Linux.

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoMIPS assembly pack: fix MIPS64 assembler warnings.
Andy Polyakov [Tue, 3 May 2016 09:37:56 +0000 (11:37 +0200)]
MIPS assembly pack: fix MIPS64 assembler warnings.

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoConfigurations/unix-Makefile.tmpl: don't count on -E -P.
Andy Polyakov [Mon, 2 May 2016 21:38:11 +0000 (23:38 +0200)]
Configurations/unix-Makefile.tmpl: don't count on -E -P.

Some non-Gnu compilers interpret -E -P combination differently.
some prioritize -E over -P, others -P over -E (in which case .i
file is generated and sometimes truncated because of redirection).

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoTru64 fixes.
Andy Polyakov [Mon, 2 May 2016 08:33:42 +0000 (10:33 +0200)]
Tru64 fixes.

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoDrop duplicate ctx->verify_cb assignment
Viktor Dukhovni [Fri, 29 Apr 2016 20:36:32 +0000 (16:36 -0400)]
Drop duplicate  ctx->verify_cb assignment

The right variant is ~18 lines below.

Reviewed-by: Matt Caswell <matt@openssl.org>
7 years agoUpdate Diffie-Hellman parameters to IANA standards
Christian Bundy [Wed, 2 Mar 2016 04:48:12 +0000 (23:48 -0500)]
Update Diffie-Hellman parameters to IANA standards

This replaces the old SKIP primes with the most current Diffie-Hellman
MODP groups defined by RFC 7296 and RFC 3526.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from GitHub https://github.com/openssl/openssl/pull/775)

7 years agoUpdate CHANGES and NEWS for the new release
Matt Caswell [Tue, 3 May 2016 08:49:13 +0000 (09:49 +0100)]
Update CHANGES and NEWS for the new release

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 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

7 years agoAdd ASN.1 INTEGER tests.
Dr. Stephen Henson [Tue, 26 Apr 2016 11:12:40 +0000 (12:12 +0100)]
Add ASN.1 INTEGER tests.

Add tests for ASN.1 INTEGER: invalid tag, valid 0, 1, -1 and 0, -1 with
illegal padding.

Also add ASN1_ANY tests for 0, 1 and -1.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
7 years agoadd ASN1_INTEGER type to d2i_test
Dr. Stephen Henson [Tue, 26 Apr 2016 11:04:42 +0000 (12:04 +0100)]
add ASN1_INTEGER type to d2i_test

Reviewed-by: Emilia Käsper <emilia@openssl.org>
7 years agoAdd test for CVE-2016-2018
Dr. Stephen Henson [Sat, 23 Apr 2016 12:52:43 +0000 (13:52 +0100)]
Add test for CVE-2016-2018

Reviewed-by: Emilia Käsper <emilia@openssl.org>
7 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>
7 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>
7 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>
7 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>
7 years agoProperly own the duplicated string
Dmitry-Me [Wed, 9 Mar 2016 12:25:07 +0000 (15:25 +0300)]
Properly own the duplicated string

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoImprove comment
Dmitry-Me [Mon, 14 Mar 2016 11:39:32 +0000 (14:39 +0300)]
Improve comment

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoTry 'make install' with one of the Travis configurations
Richard Levitte [Tue, 29 Mar 2016 15:50:53 +0000 (17:50 +0200)]
Try 'make install' with one of the Travis configurations

Reviewed-by: Matt Caswell <matt@openssl.org>
7 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>
7 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>
7 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>
7 years agoGH875: Document -no_check_time
Rich Salz [Mon, 2 May 2016 21:03:55 +0000 (17:03 -0400)]
GH875: Document -no_check_time
Date:   Tue Mar 15 15:19:44 2016 +0100

This commit updates the documentation of cms, ocsp, s_client,
s_server, and verify to reflect the new "-no_check_time"
option introduced in commit d35ff2c0ade0a12e84aaa2e9841b4983a2f3cf45
on 2015-07-31.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoRemove confusing comment.
TJ Saunders [Fri, 29 Apr 2016 14:41:50 +0000 (07:41 -0700)]
Remove confusing comment.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
7 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: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoDocument the addition of OPENSSL_LOCAL_CONFIG_DIR
Richard Levitte [Mon, 2 May 2016 18:00:12 +0000 (20:00 +0200)]
Document the addition of OPENSSL_LOCAL_CONFIG_DIR

Reviewed-by: Stephen Henson <steve@openssl.org>
7 years agoAdd the possibility for local build file templates
Richard Levitte [Mon, 2 May 2016 15:05:48 +0000 (17:05 +0200)]
Add the possibility for local build file templates

Use the environment variable OPENSSL_LOCAL_CONFIG_DIR to find build
file templates as well.

Reviewed-by: Stephen Henson <steve@openssl.org>
7 years agoAdd the possibility to have an extra local OpenSSL configs directory
Richard Levitte [Mon, 2 May 2016 14:50:51 +0000 (16:50 +0200)]
Add the possibility to have an extra local OpenSSL configs directory

The environment variable OPENSSL_LOCAL_CONFIG_DIR is used to indicate
that there's a local directory with extra configuration files.

Reviewed-by: Stephen Henson <steve@openssl.org>
7 years agoRemove personal configs from version control
Richard Levitte [Mon, 2 May 2016 14:02:04 +0000 (16:02 +0200)]
Remove personal configs from version control

As per a team decision back in 2014.

Reviewed-by: Stephen Henson <steve@openssl.org>
7 years agoSecure memory fixes
Todd Short [Mon, 11 Apr 2016 20:03:42 +0000 (16:03 -0400)]
Secure memory fixes

Fix some of the variables to be (s)size_t, so that more than 1GB of
secure memory can be allocated. The arena has to be a power of 2, and
2GB fails because it ends up being a negative 32-bit signed number.

The |too_late| flag is not strictly necessary; it is easy to figure
out if something is secure memory by looking at the arena. As before,
secure memory allocations will not fail, but now they can be freed
correctly. Once initialized, secure memory can still be used, even if
allocations occured before initialization.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agossl/record/rec_layer_s3.c: fix typo from previous commit.
Andy Polyakov [Mon, 2 May 2016 13:20:41 +0000 (15:20 +0200)]
ssl/record/rec_layer_s3.c: fix typo from previous commit.

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoHandle multi-line "written by/for" comments.
Rich Salz [Sun, 1 May 2016 13:23:38 +0000 (09:23 -0400)]
Handle multi-line "written by/for" comments.

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoAndroid build fixes.
Andy Polyakov [Sun, 1 May 2016 11:35:31 +0000 (13:35 +0200)]
Android build fixes.

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoRemove obsolete defined(__INTEL__) condition.
Andy Polyakov [Sun, 1 May 2016 12:14:34 +0000 (14:14 +0200)]
Remove obsolete defined(__INTEL__) condition.

This macro was defined by no-longer-supported __MWERKS__ compiler.

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agochacha/asm/chacha-x86.pl: make it compile on legacy systems.
Andy Polyakov [Sun, 1 May 2016 12:09:15 +0000 (14:09 +0200)]
chacha/asm/chacha-x86.pl: make it compile on legacy systems.

Usage of $ymm variable is a bit misleading here, it doesn't refer
to %ymm register bank, but rather to VEX instruction encoding,
which AMD XOP code path depends on.

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoFix spelling in pod files
FdaSilvaYY [Sun, 1 May 2016 17:52:58 +0000 (19:52 +0200)]
Fix spelling in pod files

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agomake update
Richard Levitte [Sun, 1 May 2016 13:10:15 +0000 (15:10 +0200)]
make update

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoAdd the adjusted perl scripts to the set of "update" scripts
Richard Levitte [Sun, 1 May 2016 13:09:20 +0000 (15:09 +0200)]
Add the adjusted perl scripts to the set of "update" scripts

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoAdjust a last few generators to new license boilerplate and C code style
Richard Levitte [Sun, 1 May 2016 13:08:34 +0000 (15:08 +0200)]
Adjust a last few generators to new license boilerplate and C code style

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoSkip blank lines if old copyright comment was removed, and only then
Richard Levitte [Sun, 1 May 2016 12:01:50 +0000 (14:01 +0200)]
Skip blank lines if old copyright comment was removed, and only then

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoFix some X509_STORE macros
Matt Caswell [Fri, 29 Apr 2016 16:44:46 +0000 (17:44 +0100)]
Fix some X509_STORE macros

Some X509_STORE macros do not work since the type was made opaque.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
7 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>
7 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>
7 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>
7 years agoRemove BIO_dummy, it's old cruft
Richard Levitte [Fri, 29 Apr 2016 16:59:20 +0000 (18:59 +0200)]
Remove BIO_dummy, it's old cruft

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoChange 'struct bio_st' in all public header where applicable
Richard Levitte [Fri, 29 Apr 2016 16:57:58 +0000 (18:57 +0200)]
Change 'struct bio_st' in all public header where applicable

Reviewed-by: Rich Salz <rsalz@openssl.org>