openssl.git
6 years agoCopy dlls into fuzz directory
Matt Caswell [Wed, 16 Aug 2017 13:33:13 +0000 (14:33 +0100)]
Copy dlls into fuzz directory

This should fix the recent AppVeyor failures.

[extended tests]

Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4171)

(cherry picked from commit 30bb02597df9a79b46bae2ddc9885a35286ed205)

6 years agoAdd the target 'build_all_generated'
Richard Levitte [Fri, 16 Jun 2017 01:46:41 +0000 (03:46 +0200)]
Add the target 'build_all_generated'

This new target is used to build all generated files and only that.
This can be used to prepare everything that requires things like perl
for a system that lacks perl and then move everything to that system
and do the rest of the build there.

Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3695)

(cherry picked from commit 9b03b91b84b64c086081b87bd0a2c7d3612af6c0)

6 years agoRemove code that prints "<SPACES/NULS>" in hexdumps
Bernd Edlinger [Mon, 12 Feb 2018 08:28:33 +0000 (09:28 +0100)]
Remove code that prints "<SPACES/NULS>" in hexdumps
when the data block ends with SPACEs or NULs.

The problem is, you can't see if the data ends
with SPACE or NUL or a combination of both.

This can happen for instance with
openssl rsautl -decrypt -hexdump

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

6 years agoCopy name string in BIO_meth_new
Rich Salz [Sat, 10 Feb 2018 20:07:39 +0000 (15:07 -0500)]
Copy name string in BIO_meth_new

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

6 years agoAvoid leaking peername data via accept BIOs
Viktor Dukhovni [Fri, 9 Feb 2018 23:34:33 +0000 (18:34 -0500)]
Avoid leaking peername data via accept BIOs

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

6 years agoSwap the check in ssl3_write_pending to avoid using
Bernd Edlinger [Fri, 9 Feb 2018 17:09:59 +0000 (18:09 +0100)]
Swap the check in ssl3_write_pending to avoid using
the possibly indeterminate pointer value in wpend_buf.

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

6 years agoDon't calculate the Finished MAC twice
Matt Caswell [Thu, 8 Feb 2018 14:48:51 +0000 (14:48 +0000)]
Don't calculate the Finished MAC twice

In <= TLSv1.2 a Finished message always comes immediately after a CCS
except in the case of NPN where there is an additional message between
the CCS and Finished. Historically we always calculated the Finished MAC
when we processed the CCS. However to deal with NPN we also calculated it
when we receive the Finished message. Really this should only have been
done if we hand negotiated NPN.

This simplifies the code to only calculate the MAC when we receive the
Finished. In 1.1.1 we need to do it this way anyway because there is no
CCS (except in middlebox compat mode) in TLSv1.3.

Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5286)

6 years agoutil/mkdef.pl: Fix incomplete cherry-pick
Richard Levitte [Thu, 8 Feb 2018 11:54:25 +0000 (12:54 +0100)]
util/mkdef.pl: Fix incomplete cherry-pick

The cherry pick that resulted in 65de3f1657d8a3bdb7c48063931a3c619817c921
was incomplete.

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

6 years agoutil/mkdef.pl: use better array in search of 'DEPRECATEDIN_'
Richard Levitte [Thu, 8 Feb 2018 11:31:05 +0000 (12:31 +0100)]
util/mkdef.pl: use better array in search of 'DEPRECATEDIN_'

%disabled_algorithms isn't necessarily initialised with the "algos"
'DEPRECATEDIN_1_1_0' etc.  However, we know that @known_algorithms has
them all, so use that to find them instead.

Fixes #5157
(where this was reported)

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

(cherry picked from commit b53fdad0e4350ba49812c50305686ee5a6239111)

6 years agoutil/mkdef.pl: Trust configdata.pm
Richard Levitte [Wed, 24 Jan 2018 13:17:39 +0000 (14:17 +0100)]
util/mkdef.pl: Trust configdata.pm

This script kept its own database of disablable algorithms, which is a
maintenance problem, as it's not always perfectly in sync with what
Configure does.  However, we do have all the data in configdata.pm,
produced by Configure, so let's use that instead.

Also, make sure to parse the *err.h header files, as they contain
function declarations that might not be present elsewhere.

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

(cherry picked from commit 54f3b7d2f5a313e5c702f75ee030f8a08e6bf6aa)

6 years agoMake all private functions in e_afalg.c static
Richard Levitte [Wed, 7 Feb 2018 18:56:57 +0000 (19:56 +0100)]
Make all private functions in e_afalg.c static

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

6 years agoRemove unused file
Rich Salz [Tue, 6 Feb 2018 20:27:03 +0000 (15:27 -0500)]
Remove unused file

Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5267)
(cherry picked from commit a3a5d1b73db46274e2cdedaad42fda5ce5cfb2da)

6 years agoFix timing leak in BN_from_montgomery_word.
David Benjamin [Wed, 31 Jan 2018 19:47:41 +0000 (14:47 -0500)]
Fix timing leak in BN_from_montgomery_word.

BN_from_montgomery_word doesn't have a constant memory access pattern.
Replace the pointer trick with a constant-time select. There is, of
course, still the bn_correct_top leak pervasive in BIGNUM itself.

See also https://boringssl-review.googlesource.com/22904 from BoringSSL.

Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/5228)

(cherry picked from commit f345b1f39d9b4e4c9ef07e7522e9b2a870c9ca09)

6 years agoDon't leak the exponent bit width in BN_mod_exp_mont_consttime.
David Benjamin [Tue, 23 Jan 2018 18:57:10 +0000 (13:57 -0500)]
Don't leak the exponent bit width in BN_mod_exp_mont_consttime.

The exponent here is one of d, dmp1, or dmq1 for RSA. This value and its
bit length are both secret. The only public upper bound is the bit width
of the corresponding modulus (RSA n, p, and q, respectively).

Although BN_num_bits is constant-time (sort of; see bn_correct_top notes
in preceding patch), this does not fix the root problem, which is that
the windows are based on the minimal bit width, not the upper bound. We
could use BN_num_bits(m), but BN_mod_exp_mont_consttime is public API
and may be called with larger exponents. Instead, use all top*BN_BITS2
bits in the BIGNUM. This is still sensitive to the long-standing
bn_correct_top leak, but we need to fix that regardless.

This may cause us to do a handful of extra multiplications for RSA keys
which are just above a whole number of words, but that is not a standard
RSA key size.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5154)

(cherry picked from commit 39eeb64f59ff838f976ad305de7d15747d47a41c)

6 years agoMake BN_num_bits_word constant-time.
David Benjamin [Tue, 23 Jan 2018 18:46:53 +0000 (13:46 -0500)]
Make BN_num_bits_word constant-time.

(This patch was written by Andy Polyakov. I only wrote the commit
message. Mistakes in the analysis are my fault.)

BN_num_bits, by way of BN_num_bits_word, currently leaks the
most-significant word of its argument via branching and memory access
pattern.

BN_num_bits is called on RSA prime factors in various places. These have
public bit lengths, but all bits beyond the high bit are secret. This
fully resolves those cases.

There are a few places where BN_num_bits is called on an input where the
bit length is also secret. This does *not* fully resolve those cases as
we still only look at the top word. Today, that is guaranteed to be
non-zero, but only because of the long-standing bn_correct_top timing
leak. Once that is fixed, a constant-time BN_num_bits on such inputs
must count bits on each word.

Instead, those cases should not call BN_num_bits at all. In particular,
BN_mod_exp_mont_consttime uses the exponent bit width to pick windows,
but it should be using the maximum bit width. The next patch will fix
this.

Thanks to Dinghao Wu, Danfeng Zhang, Shuai Wang, Pei Wang, and Xiao Liu
for reporting this issue.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5154)

(cherry picked from commit 972c87dfc7e765bd28a4964519c362f0d3a58ca4)

6 years agoAdd OPENSSL_VERSION_AT_LEAST
Michael Richardson [Thu, 1 Feb 2018 18:22:48 +0000 (13:22 -0500)]
Add OPENSSL_VERSION_AT_LEAST

added macro to create version number
use the macro to build OPENSSL_VERSION_AT_LEAST(maj,min,fix) so that
customers of libssl (such as ruby-openssl) do not need to be so aware of
openssl version numbers.
includes updates to ssl(7) and OPENSSL_VERSION_NUMBER(3) man page

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5212)
(cherry picked from commit 3c5a61dd0f9d9a9eac098419bcaf47d1c296ca81)

6 years agoRemove "dummy" BIO create and destroy functions
Richard Levitte [Wed, 31 Jan 2018 14:24:24 +0000 (15:24 +0100)]
Remove "dummy" BIO create and destroy functions

They aren't needed if all they do is set bio->init = 1 and zero other
fields that are already zeroed

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

(cherry picked from commit 94f1c9379c3ed4b088718b35d0dd807d619d50c5)

6 years agoBIO: at the end of BIO_new, declare the BIO inited if no create method present
Richard Levitte [Wed, 31 Jan 2018 10:17:32 +0000 (11:17 +0100)]
BIO: at the end of BIO_new, declare the BIO inited if no create method present

Without this, every BIO implementation is forced to have a create
method, just to set bio->init = 1.

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

(cherry picked from commit 7f55808fe723c146428415a470ed42331548007b)

6 years agoUpdate CHANGES with info about SSL_OP_NO_RENGOTIATION
Matt Caswell [Mon, 11 Dec 2017 14:10:43 +0000 (14:10 +0000)]
Update CHANGES with info about SSL_OP_NO_RENGOTIATION

Reviewed-by: Ben Kaduk <kaduk@mit.edu>
(Merged from https://github.com/openssl/openssl/pull/4901)

6 years agoAdd the SSL_OP_NO_RENEGOTIATION option to 1.1.0
Matt Caswell [Wed, 10 May 2017 20:46:14 +0000 (16:46 -0400)]
Add the SSL_OP_NO_RENEGOTIATION option to 1.1.0

This is based on a heavily modified version of commit db0f35dda by Todd
Short from the master branch.

We are adding this because it used to be possible to disable reneg using
the flag SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS in 1.0.2. This is no longer
possible because of the opacity work.

A point to note about this is that if an application built against new
1.1.0 headers (that know about the new option SSL_OP_NO_RENEGOTIATION
option) is run using an older version of 1.1.0 (that doesn't know about
the option) then the option will be accepted but nothing will happen, i.e.
renegotiation will not be prevented. There's probably not much we can do
about that.

Fixes #4739

Reviewed-by: Ben Kaduk <kaduk@mit.edu>
(Merged from https://github.com/openssl/openssl/pull/4901)

6 years agoMake sure we check an incoming reneg ClientHello in DTLS
Matt Caswell [Mon, 29 Jan 2018 14:55:44 +0000 (14:55 +0000)]
Make sure we check an incoming reneg ClientHello in DTLS

In TLS we have a check to make sure an incoming reneg ClientHello is
acceptable. The equivalent check is missing in the DTLS code. This means
that if a client does not signal the ability to handle secure reneg in the
initial handshake, then a subsequent reneg handshake should be rejected by
the server. In the DTLS case the reneg was being allowed if the the 2nd
ClientHello had a renegotiation_info extension. This is incorrect.

While incorrect, this does not represent a security issue because if
the renegotiation_info extension is present in the second ClientHello it
also has to be *correct*. Therefore this will only work if both the client
and server believe they are renegotiating, and both know the previous
Finished result. This is not the case in an insecure rengotiation attack.

I have also tidied up the check in the TLS code and given a better check
for determining whether we are renegotiating or not.

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

6 years agoFix strict-warnings build on FreeBSD
Benjamin Kaduk [Wed, 24 Jan 2018 19:54:46 +0000 (13:54 -0600)]
Fix strict-warnings build on FreeBSD

The cryptodev engine is only available for OpenBSD and FreeBSD,
but for the OS version-specific checks the OpenBSD macro is not
defined on FreeBSD.  When building with -Werror and -Wundef (enabled
by strict-warnings), the FreeBSD build fails:

crypto/engine/eng_cryptodev.c:47:7: error: 'OpenBSD' is not defined,
evaluates to 0
      [-Werror,-Wundef]
\# if (OpenBSD >= 200112) || ((__FreeBSD_version >= 470101 &&
\# __FreeBSD_versi...
      ^

The reverse case would be true on OpenBSD (__FreeBSD_version would
not be defined), but since the boolean will short-circuit and this
code is only executed on OpenBSD and FreeBSD, and the line is
already pretty long, leave that out for now.

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

6 years agoDon't define OPENSSL_NO_ERR for the command line
Richard Levitte [Mon, 29 Jan 2018 09:22:51 +0000 (10:22 +0100)]
Don't define OPENSSL_NO_ERR for the command line

It's already in opensslconf.h, which is included where this is relevant.

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

(cherry picked from commit 711a8b999e7a0733f349e7f330fa3fa013e995fd)

6 years agoRemove $no_sse2, as it's just a 'copy' of $disabled{sse2}
Richard Levitte [Mon, 29 Jan 2018 09:21:46 +0000 (10:21 +0100)]
Remove $no_sse2, as it's just a 'copy' of $disabled{sse2}

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

(cherry picked from commit 0d59958c4999a456531835d0b61ba4eaecceaf86)

6 years agoDon't break testing when runnins as root
Richard Levitte [Mon, 29 Jan 2018 05:14:53 +0000 (06:14 +0100)]
Don't break testing when runnins as root

The rehash test broke the test if run by root.  Instead, just skip the
check that requires non-root to be worth it.

Fixes #4387

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

(cherry picked from commit 98ade24200f127a158b60bc736390c587cdd3dfb)

6 years agoVMS config.com: better handling of arguments
Richard Levitte [Sun, 28 Jan 2018 09:22:03 +0000 (10:22 +0100)]
VMS config.com: better handling of arguments

Most of all, this change preserves casing a bit better

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

(cherry picked from commit d4deecc203bf3a7bcc5f31529692f5b668c0c2bc)

6 years agoFix some style nits in commit eee8a40
Bernd Edlinger [Fri, 26 Jan 2018 18:15:28 +0000 (19:15 +0100)]
Fix some style nits in commit eee8a40

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

(cherry picked from commit df05f155a69b96b174e0e47bc689bf729de684b6)

6 years agoCheck # of arguments for remaining commands.
Rich Salz [Wed, 24 Jan 2018 22:13:45 +0000 (17:13 -0500)]
Check # of arguments for remaining commands.

Backport of https://github.com/openssl/openssl/pull/4201

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/5162)

6 years agoMake the s_server command listen on IPv6 only when requested
Bernd Edlinger [Tue, 23 Jan 2018 16:43:45 +0000 (17:43 +0100)]
Make the s_server command listen on IPv6 only when requested

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

(cherry picked from commit eee8a40aa5e06841eed6fa8eb4f6109238d59aea)

6 years agoFix setting of IPV6_V6ONLY on Windows
Bernd Edlinger [Mon, 22 Jan 2018 18:53:45 +0000 (19:53 +0100)]
Fix setting of IPV6_V6ONLY on Windows

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

6 years agoFix BN doc
Rich Salz [Tue, 23 Jan 2018 14:58:33 +0000 (09:58 -0500)]
Fix BN doc

Backport from https://github.com/openssl/openssl/pull/5141

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/5151)

6 years agoFix signature of min/max proto getter
Christian Heimes [Sun, 21 Jan 2018 09:37:59 +0000 (10:37 +0100)]
Fix signature of min/max proto getter

The getters for min and max proto version wrongly passed NULL instead of
0 as third argument to SSL_ctrl() and SSL_CTX_ctrl(). The third argument
is not used, but the error results in a compiler warning:

warning: passing argument 3 of ‘SSL_CTX_ctrl’ makes integer from pointer without a cast [-Wint-conversion]
int v = SSL_CTX_get_max_proto_version(self->ctx);

See https://github.com/openssl/openssl/pull/4364

Signed-off-by: Christian Heimes <christian@python.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Ben Kaduk <kaduk@mit.edu>
(Merged from https://github.com/openssl/openssl/pull/5128)

(cherry picked from commit 1f82eba718f758757a439e717ea7a5aa8be55f8d)

6 years agoFix SSL_CTX_get_{min,max}_proto_version integer conversion warning
Steffan Karger [Wed, 17 Jan 2018 16:06:41 +0000 (17:06 +0100)]
Fix SSL_CTX_get_{min,max}_proto_version integer conversion warning

When using the SSL_CTX_get_min_min_version macro while compiling with
-Wall, my compiler rightfully complains about this construction:

warning: passing argument 3 of ‘SSL_CTX_ctrl’ makes integer from
pointer without a cast [-Wint-conversion]

These macro's should use 0, instead of NULL, for the third argument,
like most other SSL_CTX_ctrl 'get' wrappers do.

CLA: trivial
Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Ben Kaduk <kaduk@mit.edu>
(Merged from https://github.com/openssl/openssl/pull/5099)

(cherry picked from commit 78d0afaa69c2ec662f6c97b47473c2c6a69d636c)

6 years agoFix error-path memory leak in asn_mime.c
Todd Short [Mon, 22 Jan 2018 19:30:24 +0000 (14:30 -0500)]
Fix error-path memory leak in asn_mime.c

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5142)

(cherry picked from commit a26dd465b21d8def440c16b6bd90227b03e12e02)

6 years agoConfigure: ensure that a DEPEND generates the correct inclusion directory
Richard Levitte [Tue, 23 Jan 2018 18:13:48 +0000 (19:13 +0100)]
Configure: ensure that a DEPEND generates the correct inclusion directory

We incorrectly assumed that explicit dependencies meant that the
source directory would be added for inclusion.  However, if the
dependent file is generated, it's stored in the build directory, and
that should be used for inclusion rather than the source directory.

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

(cherry picked from commit e431bcfabd72163b0ee89674e2face26a349ba9c)

6 years agoConfigure: let INCLUDEs set on binaries "trickle down" to the objects
Richard Levitte [Tue, 23 Jan 2018 18:07:14 +0000 (19:07 +0100)]
Configure: let INCLUDEs set on binaries "trickle down" to the objects

This ensures that only one set of includes is associated with each
object file, reagardless of where it's used.

For example, if apps/build.info has this:

    SOURCE[openssl]=foo.c
    INCLUDE[openssl]=.. ../include

and test/build.info has this:

    SOURCE[footest]=../apps/foo.c
    INCLUDE[footest]=../include

The inclusion directories used for apps/foo.o would differ depending
on which program's dependencies get generated first in the build file.

With this change, all those INCLUDEs get combined into one set of
inclusion directories tied to the object file.

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

(cherry picked from commit 1b5ad51fc9b29d8893d5224f00bb3360f8aca465)

6 years agoHave EVP_PKEY_asn1_find_str() work more like EVP_PKEY_asn1_find()
Richard Levitte [Mon, 22 Jan 2018 18:03:37 +0000 (19:03 +0100)]
Have EVP_PKEY_asn1_find_str() work more like EVP_PKEY_asn1_find()

EVP_PKEY_asn1_find_str() would search through standard asn1 methods
first, then those added by the application, which EVP_PKEY_asn1_find()
worked the other way around.  Also, EVP_PKEY_asn1_find_str() didn't
handle aliases.

This change brings EVP_PKEY_asn1_find_str() closer to EVP_PKEY_asn1_find().

Fixes #5086

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/5137)

(cherry picked from commit 3bf0c3fe31d5339524dae671064cc5fe9e4bda38)

6 years agoRevert "EVP_PKEY_asn1_add0(): Check that this method isn't already registered"
Richard Levitte [Mon, 22 Jan 2018 17:24:55 +0000 (18:24 +0100)]
Revert "EVP_PKEY_asn1_add0(): Check that this method isn't already registered"

This reverts commit d85722d31ac9ff0dc54c06cdc8d125acf56ca27a.

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/5137)

(cherry picked from commit 7203c94e98c9fa76b0859c25b723b2bde4a9059b)

6 years agoDon't add $(EX_LIBS) to libssl.pc's Libs.private
Richard Levitte [Mon, 22 Jan 2018 15:53:23 +0000 (16:53 +0100)]
Don't add $(EX_LIBS) to libssl.pc's Libs.private

Since libssl requires libcrypto and libcrypto.pc already has
Libs.private set exactly the same, there's no reason to repeat it in
libssl.pc.

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/5135)

6 years agoAdd anything specifying a threads library to ex_libs
Richard Levitte [Mon, 22 Jan 2018 15:50:54 +0000 (16:50 +0100)]
Add anything specifying a threads library to ex_libs

Even -pthread gets treated that way.  The reason to do this is so it
ends up in 'Libs.private' in libcrypto.pc.

Fixes #3884

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/5135)

6 years agoDon't attempt to use X25519 for ECDSA in speed
Matt Caswell [Wed, 17 Jan 2018 10:33:18 +0000 (10:33 +0000)]
Don't attempt to use X25519 for ECDSA in speed

Fixes #5090

Reviewed-by: Ben Kaduk <kaduk@mit.edu>
(Merged from https://github.com/openssl/openssl/pull/5097)

(cherry picked from commit da1a1b5ac417c4e38f7717082d69cb5f0ceda6b9)

6 years agoDon't crash on a missing Subject in index.txt
Matt Caswell [Fri, 19 Jan 2018 14:48:45 +0000 (14:48 +0000)]
Don't crash on a missing Subject in index.txt

An index.txt entry which has an empty Subject name field will cause ca
to crash. Therefore check it when we load it to make sure its not empty.

Fixes #5109

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

(cherry picked from commit 1e05c6d07ff963107286d028f6778d2ccc863a9a)

6 years agoDon't allow an empty Subject when creating a Certificate
Matt Caswell [Fri, 19 Jan 2018 14:34:56 +0000 (14:34 +0000)]
Don't allow an empty Subject when creating a Certificate

Misconfiguration (e.g. an empty policy section in the config file) can
lead to an empty Subject. Since certificates should have unique Subjects
this should not be allowed.

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

(cherry picked from commit e505f1e86874acfd98826d64c53bf2ddfd9c1399)

6 years agoAdd a configure option to opt-out secure memory
Bernd Edlinger [Fri, 19 Jan 2018 13:00:14 +0000 (14:00 +0100)]
Add a configure option to opt-out secure memory

./config -DOPENSSL_NO_SECURE_MEMORY

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

(cherry picked from commit 154d8c132fbe22a248f95e95ef21f1840451da62)

6 years agoUpdate the license end year
Richard Levitte [Sat, 20 Jan 2018 09:02:23 +0000 (10:02 +0100)]
Update the license end year

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

(cherry picked from commit 7c24f9d21cddd2bb30167153b05168fee7e3cf0b)

6 years agoEnable TLSProxy tests on Windows
Richard Levitte [Wed, 17 Jan 2018 10:30:37 +0000 (11:30 +0100)]
Enable TLSProxy tests on Windows

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/5096)

6 years agoSet OPENSSL_ENGINES for Windows
Bernd Edlinger [Fri, 19 Jan 2018 07:24:29 +0000 (08:24 +0100)]
Set OPENSSL_ENGINES for Windows

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

(cherry picked from commit 7a6ce9039cb6690aae3cca01f18daab16b8e30d7)

6 years agoCreate one permanent proxy socket per TLSProxy::Proxy instance
Richard Levitte [Wed, 17 Jan 2018 10:22:47 +0000 (11:22 +0100)]
Create one permanent proxy socket per TLSProxy::Proxy instance

On Windows, we sometimes see a behavior with SO_REUSEADDR where there
remains lingering listening sockets on the same address and port as a
newly created one.

To avoid this scenario, we don't create a new proxy port for each new
client run.  Instead, we create one proxy socket when the proxy object
is created, and close it when destroying that object.

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/5095)

(cherry picked from commit c7454e1af74b1b99f3f47f782a6ac484c4c55b7f)

6 years agoOnly implement secure malloc if _POSIX_VERSION allows
Richard Levitte [Thu, 18 Jan 2018 13:05:33 +0000 (14:05 +0100)]
Only implement secure malloc if _POSIX_VERSION allows

Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5060)

(cherry picked from commit e44c7d02ddac975ec6abff7901e77a0c37f9949d)

6 years agoThe Cygwin gcc doesn't define _WIN32, don't pretend it does
Richard Levitte [Mon, 15 Jan 2018 18:05:01 +0000 (19:05 +0100)]
The Cygwin gcc doesn't define _WIN32, don't pretend it does

Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5060)

(cherry picked from commit 4d3c278c1a4f940e098edac6de3d370b94d1bb8b)

6 years agoSimplify Cygwin checks, part 1
Richard Levitte [Mon, 15 Jan 2018 18:04:17 +0000 (19:04 +0100)]
Simplify Cygwin checks, part 1

Because OPENSSL_SYS_CYGWIN will keep OPENSSL_SYS_UNIX defined, there's
no point having checks of this form:

    #if (defined(OPENSSL_SYS_UNIX) || defined(OPENSSL_SYS_CYGWIN))

Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5060)

(cherry picked from commit 6ce66ce073b19af46fd94f4eefdb7c4772d7dd6f)

6 years agoCygwin is POSIX, don't say it isn't
Richard Levitte [Thu, 11 Jan 2018 21:01:44 +0000 (22:01 +0100)]
Cygwin is POSIX, don't say it isn't

More to the point, Cygwin is a POSIX API.  In our library, the use of
a POSIX API is marked by defining the macro OPENSSL_SYS_UNIX.
Therefore, that macro shouldn't be undefined when building for Cygwin.

Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5060)

(cherry picked from commit 33cebb9c0dd6115bc357b5097f7db82b64b10919)

6 years agoTLSProxy::Proxy: Don't use ReuseAddr on Windows
Richard Levitte [Thu, 18 Jan 2018 09:54:48 +0000 (10:54 +0100)]
TLSProxy::Proxy: Don't use ReuseAddr on Windows

On Windows, we sometimes see a behavior with SO_REUSEADDR where there
remains lingering listening sockets on the same address and port as a
newly created one.

An easy solution is not to use ReuseAddr on Windows.

Thanks Bernd Edlinger for the suggestion.

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/5103)

(cherry picked from commit e02d5886636095c26a8bff1bf8344bd0bba7ccff)

6 years agoTLSProxy::Proxy: don't waste time redirecting STDOUT and STDERR
Richard Levitte [Wed, 17 Jan 2018 20:27:33 +0000 (21:27 +0100)]
TLSProxy::Proxy: don't waste time redirecting STDOUT and STDERR

On Windows, it seems that doing so in a forked (pseudo-)process
sometimes affects the parent, and thereby hides all the results that
are supposed to be seen by the running test framework (the "ok" and
"not ok" lines).

It turns out that our redirection isn't necessary, as the test
framework seems to swallow it all in non-verbose mode anyway.
It's possible that we did need this at some point, but the framework
has undergone some refinement since then...

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

(cherry picked from commit 825038d8c36075488922617e48fc4782afe871d1)

6 years agoTLSProxy::Proxy: If we don't support IPv6, force IPv4
Richard Levitte [Tue, 16 Jan 2018 18:50:10 +0000 (19:50 +0100)]
TLSProxy::Proxy:  If we don't support IPv6, force IPv4

We use the first we can of the following IO::Socket modules to create
sockets:

- IO::Socket::INET6
- IO::Socket::IP
- IO::Socket::INET

The last of them doesn't support IPv6, so if that's the one available,
we must force the s_client and s_server processes to use IPv4.

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/5092)

(cherry picked from commit c44bab084ed139b5e5c3f6b318bf1bf65e04cfa5)

6 years agoExtend timeout for TLSProxy
Matt Caswell [Tue, 16 Jan 2018 15:04:51 +0000 (15:04 +0000)]
Extend timeout for TLSProxy

I received this error from a TLSProxy test:

Failed to start up server (localhost,4443): Transport endpoint is not
connected

So, extend the timeout before we give up trying to connect to the server.

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

(cherry picked from commit 82992a4130e668c14ff66fca26170629b23c4556)

6 years agoRevert BN_copy() flag copy semantics change
Matt Caswell [Mon, 15 Jan 2018 11:23:07 +0000 (11:23 +0000)]
Revert BN_copy() flag copy semantics change

Commit 9f9442918a changed the semantics of BN_copy() to additionally
copy the BN_FLG_CONSTTIME flag if it is set. This turns out to be
ill advised as it has unintended consequences. For example calling
BN_mod_inverse_no_branch() can sometimes return a result with the flag
set and sometimes not as a result. This can lead to later failures if we
go down code branches that do not support constant time, but check for
the presence of the flag.

The original commit was made due to an issue in BN_MOD_CTX_set(). The
original PR fixed the problem in that function, but it was changed in
review to fix it in BN_copy() instead. The solution seems to be to revert
the BN_copy() change and go back to the originally proposed way.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/5080)

(cherry picked from commit 7d461736f7bd3af3c2f266f8541034ecf6f41ed9)

6 years agoFix intermittent Windows and Cygwin failures in s_server
Richard Levitte [Mon, 15 Jan 2018 09:40:24 +0000 (10:40 +0100)]
Fix intermittent Windows and Cygwin failures in s_server

The same kind of failure that has already been observed on the
s_client can sometimes also be observed on s_server, so we need to add
the same kind of 50ms delay as was previously added on s_client.

Ref: git commit cb2e10f257a464c6b475b321dd9e4769df84dbf6:

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/5079)

(cherry picked from commit d17bdfc26d87097c2c80854fd521b6ecebdf5ebb)

6 years agoFix intermittent Cygwin failures in s_client
Richard Levitte [Sun, 14 Jan 2018 16:15:32 +0000 (17:15 +0100)]
Fix intermittent Cygwin failures in s_client

This was identified for Windows almost two years ago for VC and
msys/mingw.  It seems that Cygwin suffers from the same issue, and
since Cygwin doesn't define OPENSSL_SYS_WINDOWS, we need to make a
special case to have a 50ms pause before closing the TLS connection.

Ref: git commit cb2e10f257a464c6b475b321dd9e4769df84dbf6

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/5074)

(cherry picked from commit 27da42d85212f80fc0db02b1cedf1d49fbfb8c43)

6 years agoUse constant value 1 instead of SHUT_WR in do_server
Bernd Edlinger [Sun, 14 Jan 2018 17:17:59 +0000 (18:17 +0100)]
Use constant value 1 instead of SHUT_WR in do_server

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

(cherry picked from commit 803141f6100ca8d756928328a262e1dc52daef2d)

6 years agoExplicitly shut the socket down in s_client
Bernd Edlinger [Sat, 13 Jan 2018 17:41:08 +0000 (18:41 +0100)]
Explicitly shut the socket down in s_client

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

(cherry picked from commit 26ec943e020c0db6a25e6d155ba318270eff0fd7)

6 years agoCatch SIGPIPE in TLSProxy::Proxy::clientstart
Bernd Edlinger [Sat, 13 Jan 2018 09:24:45 +0000 (10:24 +0100)]
Catch SIGPIPE in TLSProxy::Proxy::clientstart

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

(cherry picked from commit 438e57a43f096d37bf316869b98780e24596a5e8)

6 years agoMake data argument const in SSL_dane_tlsa_add
Patrick Schlangen [Wed, 10 Jan 2018 17:06:35 +0000 (12:06 -0500)]
Make data argument const in SSL_dane_tlsa_add

The data argument of SSL_dane_tlsa_add is used read-only, so it
should be const.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5056)

(cherry picked from commit a41a6120cdcb7e883481bc1bed55e7157c9255c4)

6 years agoTolerate DTLS alerts with an incorrect version number
Matt Caswell [Fri, 5 Jan 2018 10:12:29 +0000 (10:12 +0000)]
Tolerate DTLS alerts with an incorrect version number

In the case of a protocol version alert being sent by a peer the record
version number may not be what we are expecting. In DTLS records with an
unexpected version number are silently discarded. This probably isn't
appropriate for alerts, so we tolerate a mismatch in the minor version
number.

This resolves an issue reported on openssl-users where an OpenSSL server
chose DTLS1.0 but the client was DTLS1.2 only and sent a protocol_version
alert with a 1.2 record number. This was silently ignored by the server.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5018)

(cherry picked from commit 08455bc9b0e69ed5f25c16fc30cc2db57cdca842)

6 years agoConfigure: try to make sure every config target name is unique
Richard Levitte [Tue, 9 Jan 2018 18:51:19 +0000 (19:51 +0100)]
Configure: try to make sure every config target name is unique

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

(cherry picked from commit 225f980d22dfe66aa3945c21609042c32284e61c)

6 years agoUpdate copyright years on all files merged since Jan 1st 2018
Richard Levitte [Tue, 9 Jan 2018 04:54:08 +0000 (05:54 +0100)]
Update copyright years on all files merged since Jan 1st 2018

Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5039)

6 years agoVarious small build improvements on mkdef.pl, progs.pl
David von Oheimb [Mon, 8 Jan 2018 13:13:51 +0000 (14:13 +0100)]
Various small build improvements on mkdef.pl, progs.pl

Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4994)

(cherry picked from commit ab307dc645502d025c2760160062d5032da56bf7)

6 years agoDocument OPENSSL_ENGINES environment variable
Patrick Steuer [Mon, 8 Jan 2018 18:42:32 +0000 (13:42 -0500)]
Document OPENSSL_ENGINES environment variable

In apps/engine.pod and crypto/ENGINE_add.pod

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

(cherry picked from commit c81c38cb2786dd308256c55ce8d5337e6a3f14ce)

6 years agoFix spelling: adroideabi -> androideabi
pass86 [Sun, 7 Jan 2018 13:57:25 +0000 (21:57 +0800)]
Fix spelling: adroideabi -> androideabi

CLA: trivial

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Ben Kaduk <kaduk@mit.edu>
(Merged from https://github.com/openssl/openssl/pull/5029)

(cherry picked from commit bebef673607b9701bc21a0f7b7dbf92434af2588)

6 years agoClean up uClinux targets
Richard Levitte [Mon, 8 Jan 2018 11:40:06 +0000 (12:40 +0100)]
Clean up uClinux targets

The uClinux targets included some attributes that would result in
circular references of CFLAGS and LDCLAGS.

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

(cherry picked from commit f720194cbc174806fe1ce9c349edd249d8076c02)

6 years agoCHANGES: Document the removal of OS390-Unix
Richard Levitte [Sun, 7 Jan 2018 21:36:12 +0000 (22:36 +0100)]
CHANGES: Document the removal of OS390-Unix

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

(cherry picked from commit 4b9e91b02bee0dd114260513cb6a3f28261124b7)

6 years agoAdd fingerprint text, remove MD5
Rich Salz [Sun, 7 Jan 2018 03:32:59 +0000 (22:32 -0500)]
Add fingerprint text, remove MD5

Reviewed-by: Ben Kaduk <kaduk@mit.edu>
(Merged from https://github.com/openssl/openssl/pull/4906)
(Cherry-picked from commit 9422d45de2b70cabec5f6e6a5c812e0647e6d3ab)

6 years agoCorrected 'cms' exit status when key or certificate cannot be opened
Konstantin Shemyak [Thu, 28 Dec 2017 21:12:59 +0000 (23:12 +0200)]
Corrected 'cms' exit status when key or certificate cannot be opened

A backport of #4997.
Fixes #4996.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/5021)

6 years agoStop using unimplemented cipher classes.
Bernd Edlinger [Fri, 5 Jan 2018 17:50:09 +0000 (18:50 +0100)]
Stop using unimplemented cipher classes.
Add comments to no longer usable ciphers.

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

(cherry picked from commit 643d91fea409b0f010ce990f8f0fac234ae058bc)

6 years agoAdd x509(1) reference
Viktor Dukhovni [Wed, 13 Dec 2017 15:57:51 +0000 (10:57 -0500)]
Add x509(1) reference

Reviewed-by: Rich Salz <rsalz@openssl.org>
6 years agoRemove old config that used non-exist util script
Rich Salz [Thu, 4 Jan 2018 18:02:37 +0000 (13:02 -0500)]
Remove old config that used non-exist util script

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

(cherry picked from commit b44a65512a4a0a299f8f817b63df472e74a0007a)

6 years agoec/ecp_nistp*.c: sanitize for undefined/implmentation-specific behaviour.
Andy Polyakov [Sat, 23 Dec 2017 14:15:30 +0000 (15:15 +0100)]
ec/ecp_nistp*.c: sanitize for undefined/implmentation-specific behaviour.

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/4974)

(cherry picked from commit 8af7e94d7b720224547efa7e3364857f7f666dd4)

6 years agoAdd comments to NULL func ptrs in bio_method_st
Daniel Bevenius [Sun, 17 Dec 2017 21:04:48 +0000 (07:04 +1000)]
Add comments to NULL func ptrs in bio_method_st

This commit adds comments to bio_method_st definitions where the
function pointers are defined as NULL. Most of the structs have comments
but some where missing and not all consitent.

CLA: trivial

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4881)

(cherry picked from commit b4ff66223b53ad9d2f5b4efd75bf8d52cc59c8dd)

6 years agoFix invalid function type casts.
Bernd Edlinger [Sun, 8 Oct 2017 21:21:22 +0000 (23:21 +0200)]
Fix invalid function type casts.
Rename bio_info_cb to BIO_info_cb.

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

6 years agoFix a gcc fallthru warning
Bernd Edlinger [Fri, 15 Dec 2017 22:54:44 +0000 (23:54 +0100)]
Fix a gcc fallthru warning

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

6 years agoRemove test-runs dir
Bernd Edlinger [Fri, 15 Dec 2017 23:30:45 +0000 (00:30 +0100)]
Remove test-runs dir

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

6 years agoDocument the X509_V_FLAG_PARTIAL_CHAIN flag
Viktor Dukhovni [Mon, 11 Dec 2017 23:37:58 +0000 (18:37 -0500)]
Document the X509_V_FLAG_PARTIAL_CHAIN flag

Also improved documentation of TRUSTED_FIRST

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
6 years agoFix more OCSP_resp_get0_signer() nits
Ben Kaduk [Tue, 12 Dec 2017 17:41:26 +0000 (11:41 -0600)]
Fix more OCSP_resp_get0_signer() nits

Fix a typo for "retrieve" and some indentation.

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(cherry picked from commit eb48052ec96a7551391b5955f03f5ef70b3528f6)

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

6 years agoWrap more of ocspapitest.c in OPENSSL_NO_OCSP
Benjamin Kaduk [Thu, 7 Dec 2017 22:37:54 +0000 (16:37 -0600)]
Wrap more of ocspapitest.c in OPENSSL_NO_OCSP

make_dummy_resp() uses OCSP types, and get_cert_and_key() is unused
once make_dummy_resp() is compiled out, so neither can be included
in the build when OCSP is disabled and strict warnings are active.

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

(Merged from https://github.com/openssl/openssl/pull/4723)

6 years agoFix coverity-reported errors in ocspapitest
Benjamin Kaduk [Thu, 7 Dec 2017 20:14:47 +0000 (14:14 -0600)]
Fix coverity-reported errors in ocspapitest

Avoid memory leaks in error paths, and correctly apply
parentheses to function calls in a long if-chain.

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

(Merged from https://github.com/openssl/openssl/pull/4723)

6 years agoFix typo that cause find-doc-nits failure
Rich Salz [Mon, 13 Nov 2017 00:32:52 +0000 (19:32 -0500)]
Fix typo that cause find-doc-nits failure

Reviewed-by: Ben Kaduk <kaduk@mit.edu>
(cherry picked from commit b741fcd2ddc4e94faee75a47c241fa136854c81f)

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

6 years agomake update
Ben Kaduk [Sun, 12 Nov 2017 02:04:42 +0000 (20:04 -0600)]
make update

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

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

6 years agoAdd OCSP API test executable
Benjamin Kaduk [Thu, 19 Oct 2017 19:44:10 +0000 (14:44 -0500)]
Add OCSP API test executable

Some of the OCSP APIs (such as the recently added OCSP_resp_get0_signer)
do not really merit inclusion in the ocsp(1) utility, but we should still
have unit tests for them.

For now, only test OCSP_resp_get0_signer(), but it should be easy to
add more tests in the future.

Provide an X509 cert and private key in the test's data directory
to use for signing responses, since constructing those on the fly
is more effort than is needed.

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

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

6 years agoAdd an API to get the signer of an OCSP response
Benjamin Kaduk [Wed, 18 Oct 2017 20:29:18 +0000 (15:29 -0500)]
Add an API to get the signer of an OCSP response

Add a new function OCSP_resp_get0_signer() that looks in the
certs bundled with the response as well as in additional certificates
provided as a function argument, returning the certificate that signed
the given response (if present).

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

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

6 years agocrypto/bio/bss_dgram.c: annotate fallthrough (-Wimplicit-fallthrough)
Patrick Steuer [Tue, 12 Dec 2017 13:49:21 +0000 (14:49 +0100)]
crypto/bio/bss_dgram.c: annotate fallthrough (-Wimplicit-fallthrough)

Signed-off-by: Patrick Steuer <patrick.steuer@de.ibm.com>
Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4916)

(cherry picked from commit 147167548bb692dc1b772cf4ee1d0917e45b1aff)

6 years agoFix leak in ERR_get_state() when OPENSSL_init_crypto() isn't called yet
Richard Levitte [Tue, 12 Dec 2017 01:05:38 +0000 (02:05 +0100)]
Fix leak in ERR_get_state() when OPENSSL_init_crypto() isn't called yet

If OPENSSL_init_crypto() hasn't been called yet when ERR_get_state()
is called, it need to be called early, so the base initialization is
done.  On some platforms (those who support DSO functionality and
don't define OPENSSL_USE_NODELETE), that includes a call of
ERR_set_mark(), which calls this function again.
Furthermore, we know that ossl_init_thread_start(), which is called
later in ERR_get_state(), calls OPENSSL_init_crypto(0, NULL), except
that's too late.
Here's what happens without an early call of OPENSSL_init_crypto():

    => ERR_get_state():
         => CRYPTO_THREAD_get_local():
         <= NULL;
         # no state is found, so it gets allocated.
         => ossl_init_thread_start():
              => OPENSSL_init_crypto():
                   # Here, base_inited is set to 1
                   # before ERR_set_mark() call
                   => ERR_set_mark():
                        => ERR_get_state():
                             => CRYPTO_THREAD_get_local():
                             <= NULL;
                             # no state is found, so it gets allocated!!!!!
                             => ossl_init_thread_start():
                                  => OPENSSL_init_crypto():
                                       # base_inited is 1,
                                       # so no more init to be done
                                  <= 1
                             <=
                             => CRYPTO_thread_set_local():
                             <=
                        <=
                   <=
              <= 1
         <=
         => CRYPTO_thread_set_local()      # previous value removed!
    <=

Result: double allocation, and we have a leak.

By calling the base OPENSSL_init_crypto() early, we get this instead:

    => ERR_get_state():
         => OPENSSL_init_crypto():
              # Here, base_inited is set to 1
              # before ERR_set_mark() call
              => ERR_set_mark():
                   => ERR_get_state():
                        => OPENSSL_init_crypto():
                             # base_inited is 1,
                             # so no more init to be done
                        <= 1
                        => CRYPTO_THREAD_get_local():
                        <= NULL;
                        # no state is found, so it gets allocated
                        # let's assume we got 0xDEADBEEF
                        => ossl_init_thread_start():
                             => OPENSSL_init_crypto():
                                  # base_inited is 1,
                                  # so no more init to be done
                             <= 1
                        <= 1
                        => CRYPTO_thread_set_local():
                        <=
                   <=
              <=
         <= 1
         => CRYPTO_THREAD_get_local():
         <= 0xDEADBEEF
    <= 0xDEADBEEF

Result: no leak.

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

(cherry picked from commit aef84bb4efbddfd95d042f3f5f1d362ed7d4faeb)

6 years agoFix typo in comment
Benjamin Kaduk [Mon, 11 Dec 2017 14:48:46 +0000 (08:48 -0600)]
Fix typo in comment

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

6 years agoFix a switch statement fallthrough
Matt Caswell [Sun, 10 Dec 2017 09:55:08 +0000 (09:55 +0000)]
Fix a switch statement fallthrough

SSL_trace() has a case which was inadvertently falling through.

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

6 years agoUseless conf != NULL test
FdaSilvaYY [Sat, 9 Dec 2017 14:49:13 +0000 (15:49 +0100)]
Useless conf != NULL test

check is already made 10 line above.
clean commented code

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

(cherry picked from commit df364297495e1d7409f1fcb0f4432c8671019cd8)

6 years agoMake BIO_METHOD struct definitions consistent
Daniel Bevenius [Fri, 8 Dec 2017 07:20:10 +0000 (08:20 +0100)]
Make BIO_METHOD struct definitions consistent

I noticed that some of the BIO_METHOD structs are placing the name on
the same line as the type and some don't. This commit places the name
on a separate line for consistency (which looks like what the majority
do)

CLA: trivial

Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4878)

(cherry picked from commit 27ab91951c96364351f1ea0652dbf14622440345)

6 years agoStandardize syntax of sizeof(foo)
Rich Salz [Fri, 8 Dec 2017 20:17:12 +0000 (15:17 -0500)]
Standardize syntax of sizeof(foo)

Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4876)

6 years agoCorrect minor typo in ssl_locl.h comment
Daniel Bevenius [Fri, 8 Dec 2017 13:13:30 +0000 (14:13 +0100)]
Correct minor typo in ssl_locl.h comment

CLA: trivial

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

(cherry picked from commit 6aff543b9bf14bdac7f5385a9e56b8785b30f6d8)

6 years agoFix an incoherent test.
FdaSilvaYY [Fri, 8 Dec 2017 15:25:38 +0000 (10:25 -0500)]
Fix an incoherent test.

Pointer 'o' is set inside a local buffer, so it can't be NULL.
Also fix coding style and add comments

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4754)
(cherry picked from commit cef115ff0ca4255d3decc1dda87c5418a961fd2c)

6 years agoIn apps_startup(), call OPENSSL_init_ssl() rather than OPENSSL_init_crypto()
Richard Levitte [Sat, 25 Nov 2017 11:08:47 +0000 (12:08 +0100)]
In apps_startup(), call OPENSSL_init_ssl() rather than OPENSSL_init_crypto()

Otherwise, any command that relies on ssl modules may fail, because
SSL_add_ssl_module() will be called after the config file has already
been loaded.

Fixes #4788

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

(cherry picked from commit 0488c0bbbe87eee3a800797b91350c653e9f1711)

6 years agoIn OPENSSL_init_ssl(), run the base ssl init before OPENSSL_init_crypto()
Richard Levitte [Sat, 25 Nov 2017 11:02:58 +0000 (12:02 +0100)]
In OPENSSL_init_ssl(), run the base ssl init before OPENSSL_init_crypto()

IF OPENSSL_init_ssl() is called with the option flag
OPENSSL_INIT_LOAD_CONFIG, any SSL config will be handled wrongly
(i.e. there will be an attempt to load libssl_conf.so or whatever
corresponds to that on non-Unix platforms).  Therefore, at least
SSL_add_ssl_module() MUST be called before OPENSSL_init_crypto() is
called.  The base ssl init does that, plus adds all kinds of ciphers
and digests, which is harmless.

Fixes #4788

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

(cherry picked from commit 0a90a6831e02e00d9043ada635421cfd3da5ffe2)