oweals/openssl.git
6 years agoUnify timer code
Pauli [Mon, 5 Feb 2018 21:17:31 +0000 (07:17 +1000)]
Unify timer code

Remove the timer and TSC additional input code and instead provide a single
routine that attempts to use the "best" timer/counter available on the
system.  It attempts to use TSC, then various OS dependent resources and
finally several tries to obtain the date.  If any of these timer/counters
is successful, the rest are skipped.

No randomness is credited for this.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/5231)

6 years agoMake OPENSSL_rdtsc universally available.
Pauli [Mon, 5 Feb 2018 21:16:26 +0000 (07:16 +1000)]
Make OPENSSL_rdtsc universally available.

If such a timer/counter register is not available, the return value is always
zero.  This matches the assembly implementations' behaviour.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/5231)

6 years agoMake the OPENSSL_CPUID_OBJ define internal.
Pauli [Mon, 5 Feb 2018 21:15:53 +0000 (07:15 +1000)]
Make the OPENSSL_CPUID_OBJ define internal.
Patch by @levitte.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/5231)

6 years agoCode cleanup: remove benchmark code from internal tests
Richard Levitte [Tue, 6 Feb 2018 19:01:19 +0000 (20:01 +0100)]
Code cleanup: remove benchmark code from internal tests

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

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)

6 years agocrypto/evp/e_aes.c: add comments to s390x aes gcm implementation
Patrick Steuer [Sat, 3 Feb 2018 16:46:34 +0000 (17:46 +0100)]
crypto/evp/e_aes.c: add comments to s390x aes gcm implementation

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/5230)

6 years agos390x assembly pack: add KMAC code path for aes-ccm
Patrick Steuer [Thu, 18 Jan 2018 09:14:30 +0000 (10:14 +0100)]
s390x assembly pack: add KMAC code path for aes-ccm

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/5230)

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)

6 years agoUse RAND_DRBG_bytes() for RAND_bytes() and RAND_priv_bytes()
Dr. Matthias St. Pierre [Sat, 3 Feb 2018 21:33:19 +0000 (22:33 +0100)]
Use RAND_DRBG_bytes() for RAND_bytes() and RAND_priv_bytes()

The functions RAND_bytes() and RAND_priv_bytes() are now both based
on a common implementation using RAND_DRBG_bytes() (if the default
OpenSSL rand method is active). This not only simplifies the code
but also has the advantage that additional input from a high precision
timer is added on every generate call if the timer is available.

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

6 years agoFix size limitation of RAND_DRBG_bytes()
Dr. Matthias St. Pierre [Sat, 3 Feb 2018 21:32:47 +0000 (22:32 +0100)]
Fix size limitation of RAND_DRBG_bytes()

When comparing the implementations of drbg_bytes() and RAND_DRBG_bytes(),
it was noticed that the former split the buffer into chunks when calling
RAND_DRBG_generate() to circumvent the size limitation of the buffer
to outlen <= drb->max_request. This loop was missing in RAND_DRBG_bytes(),
so it was adopted from drbg_bytes().

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

6 years agodrbg_bytes: remove check for DRBG_UNINITIALIZED state
Dr. Matthias St. Pierre [Sat, 3 Feb 2018 20:13:19 +0000 (21:13 +0100)]
drbg_bytes: remove check for DRBG_UNINITIALIZED state

This check not only prevented the automatic reinstantiation of the
DRBG, which is implemented in RAND_DRBG_generate(), but also prevented
an error message from being generated in the case of failure.

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

6 years agoAdd MiddleboxCompat option to SSL_CONF_cmd man page
Matt Caswell [Fri, 2 Feb 2018 10:17:06 +0000 (10:17 +0000)]
Add MiddleboxCompat option to SSL_CONF_cmd man page

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

6 years agoMake sure that exporting keying material is allowed
Tatsuhiro Tsujikawa [Sun, 21 Jan 2018 02:30:36 +0000 (11:30 +0900)]
Make sure that exporting keying material is allowed

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

6 years agoRemove generation of exporter master secret on client application traffic
Tatsuhiro Tsujikawa [Thu, 18 Jan 2018 06:39:45 +0000 (15:39 +0900)]
Remove generation of exporter master secret on client application traffic

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

6 years agoGenerate exporter_master_secret after server Finished
Tatsuhiro Tsujikawa [Sat, 16 Dec 2017 07:46:18 +0000 (16:46 +0900)]
Generate exporter_master_secret after server Finished

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

6 years agoHave configdata.pm also display the contents of %target
Richard Levitte [Fri, 2 Feb 2018 09:33:41 +0000 (10:33 +0100)]
Have configdata.pm also display the contents of %target

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

6 years agoDocument SSL_OP_ENABLE_MIDDLEBOX_COMPAT
Matt Caswell [Thu, 1 Feb 2018 17:40:17 +0000 (17:40 +0000)]
Document SSL_OP_ENABLE_MIDDLEBOX_COMPAT

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

6 years agoFix of prefix bio filter (bf_prefix.c): rely on the given length
Richard Levitte [Thu, 1 Feb 2018 20:28:59 +0000 (21:28 +0100)]
Fix of prefix bio filter (bf_prefix.c): rely on the given length

The assumption that the received buffer has to be NUL-terminated was
faulty.

Fault found in #5224

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

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)

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)

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)

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)

6 years agoShorten output by a line
Rich Salz [Thu, 1 Feb 2018 18:18:32 +0000 (13:18 -0500)]
Shorten output by a line

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

6 years agoVMS: MMS wants a space before the target / dependecies separator
Richard Levitte [Thu, 1 Feb 2018 09:35:59 +0000 (10:35 +0100)]
VMS: MMS wants a space before the target / dependecies separator

So as not to be mixed up with a device specification...

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

6 years agoFix some minor code nits
Todd Short [Wed, 31 Jan 2018 21:36:27 +0000 (16:36 -0500)]
Fix some minor code nits

Reviewed-by: Ben Kaduk <kaduk@mit.edu>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4964)

6 years agoFix doc nits
Todd Short [Wed, 31 Jan 2018 21:34:20 +0000 (16:34 -0500)]
Fix doc nits

Reviewed-by: Ben Kaduk <kaduk@mit.edu>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4964)

6 years agoFree pha_dgst in SSL_clear()
Todd Short [Wed, 31 Jan 2018 21:20:52 +0000 (16:20 -0500)]
Free pha_dgst in SSL_clear()

Reviewed-by: Ben Kaduk <kaduk@mit.edu>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4964)

6 years agoAdd TLSv1.3 post-handshake authentication (PHA)
Todd Short [Mon, 18 Dec 2017 21:52:28 +0000 (16:52 -0500)]
Add TLSv1.3 post-handshake authentication (PHA)

Add SSL_verify_client_post_handshake() for servers to initiate PHA

Add SSL_force_post_handshake_auth() for clients that don't have certificates
initially configured, but use a certificate callback.

Update SSL_CTX_set_verify()/SSL_set_verify() mode:

* Add SSL_VERIFY_POST_HANDSHAKE to postpone client authentication until after
the initial handshake.

* Update SSL_VERIFY_CLIENT_ONCE now only sends out one CertRequest regardless
of when the certificate authentication takes place; either initial handshake,
re-negotiation, or post-handshake authentication.

Add 'RequestPostHandshake' and 'RequirePostHandshake' SSL_CONF options that
add the SSL_VERIFY_POST_HANDSHAKE to the 'Request' and 'Require' options

Add support to s_client:
* Enabled automatically when cert is configured
* Can be forced enabled via -force_pha

Add support to s_server:
* Use 'c' to invoke PHA in s_server
* Remove some dead code

Update documentation

Update unit tests:
* Illegal use of PHA extension
* TLSv1.3 certificate tests

DTLS and TLS behave ever-so-slightly differently. So, when DTLS1.3 is
implemented, it's PHA support state machine may need to be different.
Add a TODO and a #error

Update handshake context to deal with PHA.

The handshake context for TLSv1.3 post-handshake auth is up through the
ClientFinish message, plus the CertificateRequest message. Subsequent
Certificate, CertificateVerify, and Finish messages are based on this
handshake context (not the Certificate message per se, but it's included
after the hash). KeyUpdate, NewSessionTicket, and prior Certificate
Request messages are not included in post-handshake authentication.

After the ClientFinished message is processed, save off the digest state
for future post-handshake authentication. When post-handshake auth occurs,
copy over the saved handshake context into the "main" handshake digest.
This effectively discards the any KeyUpdate or NewSessionTicket messages
and any prior post-handshake authentication.

This, of course, assumes that the ID-22 did not mean to include any
previous post-handshake authentication into the new handshake transcript.
This is implied by section 4.4.1 that lists messages only up to the
first ClientFinished.

Reviewed-by: Ben Kaduk <kaduk@mit.edu>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4964)

6 years agoRemove bad comments
Todd Short [Fri, 19 Jan 2018 15:43:19 +0000 (10:43 -0500)]
Remove bad comments

Reviewed-by: Ben Kaduk <kaduk@mit.edu>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4964)

6 years agoFix some instances of the wrong alert type being sent
Matt Caswell [Wed, 31 Jan 2018 09:53:51 +0000 (09:53 +0000)]
Fix some instances of the wrong alert type being sent

In a few places we sent an internal_error alert instead of a decode_error.

Fixes #5213
Fixes #5214

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

6 years agoocsp.c doesn't free the whole output chain, maybe causing a memory leak
Richard Levitte [Wed, 31 Jan 2018 21:08:12 +0000 (22:08 +0100)]
ocsp.c doesn't free the whole output chain, maybe causing a memory leak

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

6 years agoMake sure that apps/openssl prefixes its output with '# ' during tests
Richard Levitte [Sun, 28 Jan 2018 08:49:46 +0000 (09:49 +0100)]
Make sure that apps/openssl prefixes its output with '# ' during tests

The reason to do this is that some output might start with an 'ok',
which TAP catches and takes for TAP output.  The TAP compatible way is
to make all output it shouldn't catch look like comments.

We do this by setting the environment variable HARNESS_OSSL_PREFIX
during tests.  When that is set, apps/openssl uses BIO_f_linebuffer
and sets its prefix to the content of that environment variable.

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

6 years agoAdd an apps internal BIO filter for prefixing output lines
Richard Levitte [Tue, 30 Jan 2018 21:03:27 +0000 (22:03 +0100)]
Add an apps internal BIO filter for prefixing output lines

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

6 years agoAdd missing \n in some testutil output
Richard Levitte [Wed, 31 Jan 2018 20:49:27 +0000 (21:49 +0100)]
Add missing \n in some testutil output

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

6 years agoMake test/uitest depend on the private apps support library
Richard Levitte [Wed, 31 Jan 2018 13:18:54 +0000 (14:18 +0100)]
Make test/uitest depend on the private apps support library

This avoids having to enumerate specific modules in apps, or to have
to include them in libtestutil.a.

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

6 years agoApps: divide the modules in direct command modules, support library and init
Richard Levitte [Wed, 31 Jan 2018 13:15:52 +0000 (14:15 +0100)]
Apps: divide the modules in direct command modules, support library and init

Most modules are direct implementations of openssl application
sub-commands, but some constitute a support library, which can be used
by more than one program (and is, incidently, by test/uitest).

For practical purposes, we place the support library modules in a
private, static library.

Finally, there are some modules that don't have direct references in
the rest of the apps code, but are still crucial.  See them as some
kind of extra crt0 or similar for your platform.

Inspiration from David von Oheimb

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

6 years agoapps: Don't include progs.h in apps.h
Richard Levitte [Wed, 31 Jan 2018 10:13:10 +0000 (11:13 +0100)]
apps: Don't include progs.h in apps.h

Everything in apps includes apps.h, because that one declares apps
internal library routines.  However, progs.h doesn't declare library
routines, but rather the main commands and their options, and there's
no reason why the library modules should include it.

So, remove the inclusion of progs.h from apps.h and add that inclusion
in all command source files.

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

6 years agotest/asn1_time_test.c: fix pre-C90 warning.
Andy Polyakov [Tue, 23 Jan 2018 19:33:36 +0000 (20:33 +0100)]
test/asn1_time_test.c: fix pre-C90 warning.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
6 years agopoly1305/poly1305_ieee754.c: add support for MIPS.
Andy Polyakov [Mon, 29 Jan 2018 22:44:33 +0000 (23:44 +0100)]
poly1305/poly1305_ieee754.c: add support for MIPS.

Reviewed-by: Rich Salz <rsalz@openssl.org>
6 years agoRestore clearing of init_lock after free
Benjamin Kaduk [Fri, 26 Jan 2018 15:32:40 +0000 (09:32 -0600)]
Restore clearing of init_lock after free

The behavior of resetting the init_lock value to NULL after
freeing it during OPENSSL_cleanup() was added as part of the
global lock commits that were just reverted, but there is desire
to retain this behavior for clarity.

It is unclear that the library would actually remain usable in
any form after OPENSSL_cleanup(), since the required re-initialization
occurs under a CRYPTO_ONCE check that cannot be reset at cleanup time.
That said, a NULL dereference is probably more friendly behavior
in these treacherous waters than using freed memory would be.

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/5089)

6 years agoRevert the crypto "global lock" implementation
Benjamin Kaduk [Tue, 16 Jan 2018 15:49:54 +0000 (09:49 -0600)]
Revert the crypto "global lock" implementation

Conceptually, this is a squashed version of:

    Revert "Address feedback"

    This reverts commit 75551e07bd2339dfea06ef1d31d69929e13a4495.

and

    Revert "Add CRYPTO_thread_glock_new"

    This reverts commit ed6b2c7938ec6f07b15745d4183afc276e74c6dd.

But there were some intervening commits that made neither revert apply
cleanly, so instead do it all as one shot.

The crypto global locks were an attempt to cope with the awkward
POSIX semantics for pthread_atfork(); its documentation (the "RATIONALE"
section) indicates that the expected usage is to have the prefork handler
lock all "global" locks, and the parent and child handlers release those
locks, to ensure that forking happens with a consistent (lock) state.
However, the set of functions available in the child process is limited
to async-signal-safe functions, and pthread_mutex_unlock() is not on
the list of async-signal-safe functions!  The only synchronization
primitives that are async-signal-safe are the semaphore primitives,
which are not really appropriate for general-purpose usage.

However, the state consistency problem that the global locks were
attempting to solve is not actually a serious problem, particularly for
OpenSSL.  That is, we can consider four cases of forking application
that might use OpenSSL:

(1) Single-threaded, does not call into OpenSSL in the child (e.g.,
the child calls exec() immediately)

For this class of process, no locking is needed at all, since there is
only ever a single thread of execution and the only reentrancy is due to
signal handlers (which are themselves limited to async-signal-safe
operation and should not be doing much work at all).

(2) Single-threaded, calls into OpenSSL after fork()

The application must ensure that it does not fork() with an unexpected
lock held (that is, one that would get unlocked in the parent but
accidentally remain locked in the child and cause deadlock).  Since
OpenSSL does not expose any of its internal locks to the application
and the application is single-threaded, the OpenSSL internal locks
will be unlocked for the fork(), and the state will be consistent.
(OpenSSL will need to reseed its PRNG in the child, but that is
an orthogonal issue.)  If the application makes use of locks from
libcrypto, proper handling for those locks is the responsibility of
the application, as for any other locking primitive that is available
for application programming.

(3) Multi-threaded, does not call into OpenSSL after fork()

As for (1), the OpenSSL state is only relevant in the parent, so
no particular fork()-related handling is needed.  The internal locks
are relevant, but there is no interaction with the child to consider.

(4) Multi-threaded, calls into OpenSSL after fork()

This is the case where the pthread_atfork() hooks to ensure that all
global locks are in a known state across fork() would come into play,
per the above discussion.  However, these "calls into OpenSSL after
fork()" are still subject to the restriction to async-signal-safe
functions.  Since OpenSSL uses all sorts of locking and libc functions
that are not on the list of safe functions (e.g., malloc()), this
case is not currently usable and is unlikely to ever be usable,
independently of the locking situation.  So, there is no need to
go through contortions to attempt to support this case in the one small
area of locking interaction with fork().

In light of the above analysis (thanks @davidben and @achernya), go
back to the simpler implementation that does not need to distinguish
"library-global" locks or to have complicated atfork handling for locks.

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/5089)

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)

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)

6 years agocrypto/rand/rand_lib.c: fix undefined reference to `clock_gettime'
Dr. Matthias St. Pierre [Tue, 30 Jan 2018 22:53:57 +0000 (23:53 +0100)]
crypto/rand/rand_lib.c: fix undefined reference to `clock_gettime'

Some older glibc versions require the `-lrt` linker option for
resolving the reference to `clock_gettime'. Since it is not desired
to add new library dependencies in version 1.1.1, the call to
clock_gettime() is replaced by a call to gettimeofday() for the
moment. It will be added back in version 1.2.

Signed-off-by: Dr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/5199)

6 years agoConfigure: Fix configdata.pm shorthand for --dump, should be -d
Peter Meerwald-Stadler [Wed, 31 Jan 2018 00:16:51 +0000 (10:16 +1000)]
Configure: Fix configdata.pm shorthand for --dump, should be -d
INSTALL: Mention 'aria' algorithm for no-<alg>

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Ben Kaduk <kaduk@mit.edu>
(Merged from https://github.com/openssl/openssl/pull/5215)

6 years agoFix small typo (parenthesis missing)
Richard Levitte [Tue, 30 Jan 2018 18:13:11 +0000 (19:13 +0100)]
Fix small typo (parenthesis missing)

Fixes #5207 (another PR)

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

6 years agoConfigure: when checking user input, check both %user and %useradd
Richard Levitte [Tue, 30 Jan 2018 16:21:12 +0000 (17:21 +0100)]
Configure: when checking user input, check both %user and %useradd

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

6 years agoConfigure: add configure command line C flags after the configured C flags
Richard Levitte [Tue, 30 Jan 2018 16:16:13 +0000 (17:16 +0100)]
Configure: add configure command line C flags after the configured C flags

Fixes #5203

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

6 years agoMove decisions about whether to accept reneg into the state machine
Matt Caswell [Mon, 29 Jan 2018 14:19:52 +0000 (14:19 +0000)]
Move decisions about whether to accept reneg into the state machine

If a server receives an unexpected ClientHello then we may or may not
accept it. Make sure all such decisions are made in the state machine
and not in the record layer. This also removes a disparity between the
TLS and the DTLS code. The TLS code was making this decision in the
record layer, while the DTLS code was making it later.

Finally it also solves a problem where a warning alert was being sent
during tls_setup_handshake() and the function was returning a failure
return code. This is problematic because it can be called from a
transition function - which we only allow fatal errors to occur in.

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

6 years agoAdd a 'reconfigure' make target
Richard Levitte [Mon, 29 Jan 2018 22:17:43 +0000 (23:17 +0100)]
Add a 'reconfigure' make target

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

6 years agoRestore perl variables for ENGINESDIR and OPENSSLDIR
Richard Levitte [Mon, 29 Jan 2018 21:49:50 +0000 (22:49 +0100)]
Restore perl variables for ENGINESDIR and OPENSSLDIR

For proper escaping, we need the direct perl variable values, not a
make variable reference.

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

6 years agoFix typo in Windows makefile template: quotify, not quotiry
Richard Levitte [Mon, 29 Jan 2018 20:54:52 +0000 (21:54 +0100)]
Fix typo in Windows makefile template: quotify, not quotiry

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

6 years agoTo make it less surprising and confusing, leave a message on configdata.pm
Richard Levitte [Mon, 29 Jan 2018 17:33:32 +0000 (18:33 +0100)]
To make it less surprising and confusing, leave a message on configdata.pm

This message will ONLY be visible in OpenSSL 1.1.1, it will not show
in 1.1.1a or any other release or update.

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

6 years agoMake Travis and Appveyor display the configuration data dump
Richard Levitte [Mon, 29 Jan 2018 17:22:33 +0000 (18:22 +0100)]
Make Travis and Appveyor display the configuration data dump

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

6 years agoDocument the use of configdata.pm as a script
Richard Levitte [Mon, 29 Jan 2018 17:19:36 +0000 (18:19 +0100)]
Document the use of configdata.pm as a script

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

6 years agoMove the display of disabled features to configdata.pm as well.
Richard Levitte [Mon, 29 Jan 2018 16:33:58 +0000 (17:33 +0100)]
Move the display of disabled features to configdata.pm as well.

The additional possibility is:

perl configdata.pm --options            Display the features, both
                                        enabled and disabled, and
                                        display defined macro and
                                        skipped directories where
                                        applicable.

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

6 years agoHave the build files use the executable configdata.pm
Richard Levitte [Mon, 29 Jan 2018 07:20:26 +0000 (08:20 +0100)]
Have the build files use the executable configdata.pm

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

6 years agoMake configdata.pm runnable and move all display of information there
Richard Levitte [Mon, 29 Jan 2018 05:19:17 +0000 (06:19 +0100)]
Make configdata.pm runnable and move all display of information there

The "make variable" information displayed by Configure was selective
and incomplete, and possibly undesirable (too verbose).

Instead, we make configdata.pm and have the user run it to get the
information they desire, and also make it possible to have it perform
a reconfiguration.

Possibilities so far:

perl configdata.pm --dump               Displays everything (i.e. the
                                        combined output from
                                        --command-line, --environment,
                                        --make-variables and
                                        --build-parameters.
perl configdata.pm --command-line       Displays the config command
                                        line.
perl configdata.pm --envirnoment        Displays the recorded
                                        environment variables.
perl configdata.pm --make-variables     Displays the configured "make
                                        variables".
perl configdata.pm --build-parameters   Displays the build file and
                                        the template files to create
                                        it.
perl configdata.pm --reconfigure        Re-runs the configuration with
                                        the recorded environment
                                        variables.

--verbose can be used to have --reconfigure be a bit more verbose.

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

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)

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)

6 years agoFix recent typo. -DL_ENDIAN / -DB_ENDIAN, not -DL_DEBIAN / -DB_DEBIAN
Richard Levitte [Mon, 29 Jan 2018 11:42:35 +0000 (12:42 +0100)]
Fix recent typo.  -DL_ENDIAN / -DB_ENDIAN, not -DL_DEBIAN / -DB_DEBIAN

Thank you Beat Bolli for notifying us

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

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)

6 years agoAdd RAND_DRBG_bytes
Kurt Roeckx [Fri, 17 Nov 2017 14:00:35 +0000 (15:00 +0100)]
Add RAND_DRBG_bytes

Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/4752)

6 years agoCreate troubleshooting subsection in INSTALL file
nickthetait [Sun, 28 Jan 2018 19:15:23 +0000 (20:15 +0100)]
Create troubleshooting subsection in INSTALL file

Fixes: #5130

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/5178)

6 years agoGet rid of a warning about unused results
Richard Levitte [Sat, 27 Jan 2018 14:00:16 +0000 (15:00 +0100)]
Get rid of a warning about unused results

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

6 years agoTreat C++ flags more like C flags, and only if C++ compiler specified
Richard Levitte [Sat, 27 Jan 2018 13:56:06 +0000 (14:56 +0100)]
Treat C++ flags more like C flags, and only if C++ compiler specified

C++ flags got the same config target value as C flags, but then
nothing else happened while C flags get all kinds of stuff added to
them (especially when --strict-warnings is used).

Now, C++ flags get the exact same treatment as C flags.  However, this
only happens when a C++ compiler is specified, to avoid confusing
messages about added C++ flags.

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

6 years agoFix WinCE config target
Richard Levitte [Sun, 28 Jan 2018 12:26:01 +0000 (13:26 +0100)]
Fix WinCE config target

vc_wince_info()->{defines} was left around, when it should be
vc_wince_info()->{cppflags}

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

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)

6 years agoUpdate copyright year in mkerr.pl
Steve Linsell [Sun, 28 Jan 2018 11:01:04 +0000 (12:01 +0100)]
Update copyright year in mkerr.pl

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/5166)

6 years agoAdd a note on Configure variable processing in NEWS and CHANGES
Richard Levitte [Sat, 27 Jan 2018 15:53:07 +0000 (16:53 +0100)]
Add a note on Configure variable processing in NEWS and CHANGES

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

6 years agoMake sure all our config targets inherit a BASE template
Richard Levitte [Sat, 27 Jan 2018 12:06:39 +0000 (13:06 +0100)]
Make sure all our config targets inherit a BASE template

There were a small number that inherited no BASE, the now inherit
BASE_unix.

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

6 years agoWe need Unixly defaults for config targets that don't inherit a BASE
Richard Levitte [Sat, 27 Jan 2018 12:01:44 +0000 (13:01 +0100)]
We need Unixly defaults for config targets that don't inherit a BASE

Ideally, each config target should inherit a base to get their
platform specific defaults.  Unfortunately, that is currently not the
case, so we duplicate the Unixly defaults from the BASE_unix template
into the DEFAULT template.

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

6 years agoStop having Unix defaults in Configure (partial)
Richard Levitte [Sat, 27 Jan 2018 11:13:35 +0000 (12:13 +0100)]
Stop having Unix defaults in Configure (partial)

Default values belong in the DEFAULT config target template, in
Configurations/00-base-templates.conf.

This isn't a complete move, but takes care of the most blatant
examples.

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

6 years agoProcessing GNU-style "make variables" - implementation
Richard Levitte [Fri, 26 Jan 2018 18:56:44 +0000 (19:56 +0100)]
Processing GNU-style "make variables" - implementation

Support the following "make variables":

AR              (GNU compatible)
ARFLAGS         (GNU Compatible)
AS              (GNU Compatible)
ASFLAGS         (GNU Compatible)
CC              (GNU Compatible)
CFLAGS          (GNU Compatible)
CXX             (GNU Compatible)
CXXFLAGS        (GNU Compatible)
CPP             (GNU Compatible)
CPPFLAGS        (GNU Compatible)
CPPDEFINES      List of CPP macro definitions.  Alternative for -D
CPPINCLUDES     List of CPP inclusion directories.  Alternative for -I
HASHBANGPERL    Perl invocation to be inserted after '#!' in public
                perl scripts.
LDFLAGS         (GNU Compatible)
LDLIBS          (GNU Compatible)
RANLIB          Program to generate library archive index
RC              Program to manipulate Windows resources
RCFLAGS         Flags for $(RC)
RM              (GNU Compatible)

Setting one of these overrides the corresponding data from our config
targets.  However, flags given directly on the configuration command
line are additional, and are therefore added to the flags coming from
one of the variables above or the config target.

Fixes #2420

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

6 years agoProcessing GNU-style "make variables" - separate CPP flags from C flags
Richard Levitte [Tue, 23 Jan 2018 12:54:55 +0000 (13:54 +0100)]
Processing GNU-style "make variables" - separate CPP flags from C flags

C preprocessor flags get separated from C flags, which has the
advantage that we don't get loads of macro definitions and inclusion
directory specs when linking shared libraries, DSOs and programs.

This is a step to add support for "make variables" when configuring.

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

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)

6 years agoCatch some more old sigalg names in comments
Benjamin Kaduk [Fri, 26 Jan 2018 15:23:57 +0000 (09:23 -0600)]
Catch some more old sigalg names in comments

Make the sigalg name in comments reflect one that actually exists
in the draft standard.

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

6 years agoFix ssl-trace with TLS 1.3 draft-23 PSS sigalgs
Benjamin Kaduk [Fri, 26 Jan 2018 15:21:08 +0000 (09:21 -0600)]
Fix ssl-trace with TLS 1.3 draft-23 PSS sigalgs

The latest TLS 1.3 draft split the RSA-PSS signature schemes into
two versions that indicate the OID of the RSA key being used.
This forced us to rename the preprocessor defines for the sigalg
values, and the ssl-trace code was not adopted to match, since
it was not enabled int the default build.

Belatedly update the ssl_sigalg_tbl in the trace code to match.

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

6 years agoFix uninitialized read in sigalg parsing code
Benjamin Kaduk [Fri, 26 Jan 2018 01:30:54 +0000 (19:30 -0600)]
Fix uninitialized read in sigalg parsing code

The check for a duplicate value was reading one entry past
where it was supposed to, getting an uninitialized value.

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

6 years agoAdd TLSProxy tests for signature_algorithms_cert
Benjamin Kaduk [Wed, 24 Jan 2018 20:45:08 +0000 (14:45 -0600)]
Add TLSProxy tests for signature_algorithms_cert

We don't need to send this extension in normal operation since
we are our own X.509 library, but add some test cases that force
the extension to be sent and exercise our code to process the extension.

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

6 years agoAdd support for the TLS 1.3 signature_algorithms_cert extension
Benjamin Kaduk [Thu, 11 Jan 2018 17:47:12 +0000 (11:47 -0600)]
Add support for the TLS 1.3 signature_algorithms_cert extension

The new extension is like signature_algorithms, but only for the
signature *on* the certificate we will present to the peer (the
old signature_algorithms extension is still used for signatures that
we *generate*, i.e., those over TLS data structures).

We do not need to generate this extension, since we are the same
implementation as our X.509 stack and can handle the same types
of signatures, but we need to be prepared to receive it, and use the received
information when selecting what certificate to present.

There is a lot of interplay between signature_algorithms_cert and
signature_algorithms, since both affect what certificate we can
use, and thus the resulting signature algorithm used for TLS messages.
So, apply signature_algorithms_cert (if present) as a filter on what
certificates we can consider when choosing a certificate+sigalg
pair.

As part of this addition, we also remove the fallback code that let
keys of type EVP_PKEY_RSA be used to generate RSA-PSS signatures -- the
new rsa_pss_pss_* and rsa_pss_rsae_* signature schemes have pulled
the key type into what is covered by the signature algorithm, so
we should not apply this sort of compatibility workaround.

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

6 years agoUpdate documentation for SSL_set1_sigalgs()
Benjamin Kaduk [Thu, 18 Jan 2018 05:21:19 +0000 (23:21 -0600)]
Update documentation for SSL_set1_sigalgs()

These functions can now take both "sig+hash" strings and
algorithm-specific identifiers like "rsa_pss_pss_sha256" that
indicate a particular entry from the TLS signature algorithm
registry.

Also clarify that only the "_list" form allows for the new-style names
(the non-"list" interfaces take sig and hasn NIDs, which cannot
access all of the new-style schemes).

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

6 years agoPropagate TLS 1.3 sigalgs through tls1_set_sigalgs()
Benjamin Kaduk [Wed, 17 Jan 2018 17:55:29 +0000 (11:55 -0600)]
Propagate TLS 1.3 sigalgs through tls1_set_sigalgs()

Our historical SSL{,_CTX}_set_sigalgs() APIs take an array of
NID pairs (hash and signature), and our parser for manually
specifying unified sigalgs (that do not necessarily correspond
to an actual signature+hash pair) was transiting via (the implementation
of) this historical API.  The TLS 1.3 draft-23 has introduced
signature schemes that have identical signature type and hash type,
differing only in the (RSA) public key OID, which prevents
the rsa_pss_pss_* schemes from being properly identified and
sent on the wire.

To fix the issue, parse sigalg strings directly into SIGALG_LOOKUP
objects, and pass around an array of uint16 wire protocol values
instead of NID pairs.  The old interface is retained for API
compatibility but will become less and less useful with time.

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

6 years agoAdd TLS 1.3 draft-23 PSS signature algorithms
Benjamin Kaduk [Thu, 11 Jan 2018 19:39:30 +0000 (13:39 -0600)]
Add TLS 1.3 draft-23 PSS signature algorithms

We now have a split in the signature algorithms codepoint space for
whether the certificate's key is for rsaEncryption or a PSS-specific
key, which should let us get rid of some special-casing that we
previously needed to try to coax rsaEncryption keys into performing PSS.
(This will be done in a subsequent commit.)

Send the new PSS-with-PSS-specific key first in our list, so that
we prefer the new technology to the old one.

We need to update the expected certificate type in one test,
since the "RSA-PSS+SHA256" form now corresponds to a public key
of type rsaEncryption, so we should expect the server certificate
type to be just "RSA".  If we want to get a server certificate
type of "RSA-PSS", we need to use a new signature algorithm
that cannot be represented as signature+hash, so add a test for that
as well.

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

6 years agoRenumber TLSEXT_TYPE_key_share for draft-23
Benjamin Kaduk [Thu, 11 Jan 2018 16:55:05 +0000 (10:55 -0600)]
Renumber TLSEXT_TYPE_key_share for draft-23

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

6 years agoBump TLS1_3_VERSION_DRAFT for draft-23
Benjamin Kaduk [Thu, 11 Jan 2018 16:49:33 +0000 (10:49 -0600)]
Bump TLS1_3_VERSION_DRAFT for draft-23

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

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)

6 years agoFix setting of IPV6_V6ONLY on Windows
Bernd Edlinger [Thu, 25 Jan 2018 14:16:18 +0000 (15:16 +0100)]
Fix setting of IPV6_V6ONLY on Windows

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

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)

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)

6 years agoAdded "B" tag to all variables.
David Cooper [Wed, 24 Jan 2018 17:27:19 +0000 (12:27 -0500)]
Added "B" tag to all variables.

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

6 years agoAdd documentation for the OCSP_basic_sign() and OCSP_basic_sign_ctx() functions.
David Cooper [Wed, 24 Jan 2018 16:47:23 +0000 (11:47 -0500)]
Add documentation for the OCSP_basic_sign() and OCSP_basic_sign_ctx() functions.

Correct error return value in OCSP_basic_sign().

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

6 years agoMake editorial changes suggested by Matt Caswell and fixed Travis failures.
David Cooper [Tue, 23 Jan 2018 19:22:17 +0000 (14:22 -0500)]
Make editorial changes suggested by Matt Caswell and fixed Travis failures.

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

6 years agoMake editorial changes suggested by Rich Salz and add the -rsigopt option to the...
David Cooper [Tue, 12 Dec 2017 21:01:22 +0000 (16:01 -0500)]
Make editorial changes suggested by Rich Salz and add the -rsigopt option to the man page for the ocsp command.

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

6 years agoAdd -rsigopt option to ocsp command
David Cooper [Fri, 18 Aug 2017 13:27:19 +0000 (09:27 -0400)]
Add -rsigopt option to ocsp command

Add a -rsigopt option to the ocsp command that allows signature parameters to be provided for the signing of OCSP responses. The parameters that may be provided to -rsigopt are the same as may be provided to -sigopt in the ca, req, and x509 commands.

This PR also defines a OCSP_basic_sign_ctx() function, which functions in the same way as OCSP_basic_sign(), except that it accepts a EVP_MD_CTX rather than a key and digest. The OCSP_basic_sign_ctx() function is used to implement the -rsigopt option in the ocsp command.

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

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)

6 years agoUpdates following review of SSL_stateless() code
Matt Caswell [Tue, 23 Jan 2018 12:23:23 +0000 (12:23 +0000)]
Updates following review of SSL_stateless() code

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

6 years agoAdd a timestamp to the cookie
Matt Caswell [Wed, 17 Jan 2018 14:29:22 +0000 (14:29 +0000)]
Add a timestamp to the cookie

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

6 years agoAdd the ability for s_server to operate statelessly
Matt Caswell [Fri, 29 Dec 2017 17:37:04 +0000 (17:37 +0000)]
Add the ability for s_server to operate statelessly

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

6 years agoDon't send unexpected_message if we receive CCS while stateless
Matt Caswell [Fri, 29 Dec 2017 17:36:28 +0000 (17:36 +0000)]
Don't send unexpected_message if we receive CCS while stateless

Probably this is the CCS between the first and second ClientHellos. It
should be ignored.

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