Matt Caswell [Mon, 12 Feb 2018 17:22:17 +0000 (17:22 +0000)]
Make sure we check the return value of extract_min_max()
Commit
42d7d7dd6 turned this function from returning void to
returning an int error code. This instance of calling it was
missed.
Found by Coverity.
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5338)
Matt Caswell [Mon, 12 Feb 2018 16:58:33 +0000 (16:58 +0000)]
Fix a memory leak in an error path
Found by Coverity.
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/5336)
Richard Levitte [Tue, 13 Feb 2018 19:04:35 +0000 (20:04 +0100)]
Build files: parametrize cpp
Instead of having the knowledge of the exact flags to run the C
preprocessor only and have it output on standard output in the deeper
recesses of the build file template, make it a config parameter, or
rely on build CPP in value ('$(CC) -E' on Unix).
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/5356)
Richard Levitte [Wed, 14 Feb 2018 09:34:12 +0000 (10:34 +0100)]
VMS: simplify config targets
All VMS config targets were literally copies of each other, only
differing in what argument the parameter seeking function vms_info()
received (the pointer size).
This could be hugely simplified by letting vms_info() detect what
pointer size was desired from the desired config target name instead.
Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5364)
Viktor Dukhovni [Wed, 14 Feb 2018 03:43:15 +0000 (22:43 -0500)]
Avoid fragile aliasing of SHA224/384 update/final
This is purported to save a few cycles, but makes the code less
obvious and more brittle, and in fact breaks on platforms where for
ABI continuity reasons there is a SHA2 implementation in libc, and
so EVP needs to call those to avoid conflicts.
A sufficiently good optimizer could simply generate the same entry
points for:
foo(...) { ... }
and
bar(...) { return foo(...); }
but, even without that, the different is negligible, with the
"winner" varying from run to run (openssl speed -evp sha384):
Old:
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes 16384 bytes
sha384 28864.28k 117362.62k 266469.21k 483258.03k 635144.87k 649123.16k
New:
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes 16384 bytes
sha384 30055.18k 120725.98k 272057.26k 482847.40k 634585.09k 650308.27k
Reviewed-by: Rich Salz <rsalz@openssl.org>
Kurt Roeckx [Fri, 9 Feb 2018 23:30:29 +0000 (00:30 +0100)]
Use both getrandom() and /dev/urandom by default on Linux.
getrandom() is now used on Linux by default when using Linux >= 3.17
and glibc >= 2.25
Reviewed-by: Rich Salz <rsalz@openssl.org>
GH: #5314
Richard Levitte [Tue, 13 Feb 2018 18:10:22 +0000 (19:10 +0100)]
VMS: for testutil, make sure to use BIO_f_linebuffer
Without that, output comes one character per line. It's the same
issue as has been observed before, this happens when using write()
on a record oriented stream (possibly unbuffered too).
This also uncovered a bug in BIO_f_linebuffer, where this would cause
an error:
BIO_write(bio, "1\n", 1);
I.e. there's a \n just after the part of the string that we currently
ask to get written.
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5352)
Richard Levitte [Tue, 13 Feb 2018 18:46:10 +0000 (19:46 +0100)]
Configure: if a file is generated, never assume it's in the source dir
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5355)
Patrick Steuer [Wed, 7 Feb 2018 17:49:29 +0000 (18:49 +0100)]
s390x assembly pack: implement OPENSSL_rdtsc as STCKF
.. if avalable. STCK has an artificial delay to ensure uniqueness
which can result in a performance penalty if used heavily
concurrently.
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/5284)
Rich Salz [Tue, 13 Feb 2018 18:09:02 +0000 (13:09 -0500)]
Generate copyright year properly
Output copyright year depends on any input file(s) and the script.
This is not perfect, but better than what we had.
Also run 'make update'
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5350)
Dr. Matthias St. Pierre [Mon, 12 Feb 2018 01:37:27 +0000 (02:37 +0100)]
OPENSSL_cleanup: cleanup secure memory
If the global DRBGs are allocated on the secure heap, then calling
CRYPTO_secure_malloc_done() inside main() will have no effect, unless
OPENSSL_cleanup() has been called explicitely before that, because
otherwise the DRBGs will still be allocated. So it is better to cleanup
the secure heap automatically at the end of OPENSSL_cleanup().
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5294)
Dr. Matthias St. Pierre [Thu, 8 Feb 2018 22:04:16 +0000 (23:04 +0100)]
DRBG: make the derivation function the default for ctr_drbg
The NIST standard presents two alternative ways for seeding the
CTR DRBG, depending on whether a derivation function is used or not.
In Section 10.2.1 of NIST SP800-90Ar1 the following is assessed:
The use of the derivation function is optional if either an
approved RBG or an entropy source provides full entropy output
when entropy input is requested by the DRBG mechanism.
Otherwise, the derivation function shall be used.
Since the OpenSSL DRBG supports being reseeded from low entropy random
sources (using RAND_POOL), the use of a derivation function is mandatory.
For that reason we change the default and replace the opt-in flag
RAND_DRBG_FLAG_CTR_USE_DF with an opt-out flag RAND_DRBG_FLAG_CTR_NO_DF.
This change simplifies the RAND_DRBG_new() calls.
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5294)
Dr. Matthias St. Pierre [Thu, 8 Feb 2018 21:46:23 +0000 (22:46 +0100)]
DRBG: unify initialization and cleanup code
The functions drbg_setup() and drbg_cleanup() used to duplicate a lot of
code from RAND_DRBG_new() and RAND_DRBG_free(). This duplication has been
removed, which simplifies drbg_setup() and makes drbg_cleanup() obsolete.
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5294)
Dr. Matthias St. Pierre [Thu, 8 Feb 2018 15:40:32 +0000 (16:40 +0100)]
DRBG: add locking api
This commit adds three new accessors to the internal DRBG lock
int RAND_DRBG_lock(RAND_DRBG *drbg)
int RAND_DRBG_unlock(RAND_DRBG *drbg)
int RAND_DRBG_enable_locking(RAND_DRBG *drbg)
The three shared DRBGs are intended to be used concurrently, so they
have locking enabled by default. It is the callers responsibility to
guard access to the shared DRBGs by calls to RAND_DRBG_lock() and
RAND_DRBG_unlock().
All other DRBG instances don't have locking enabled by default, because
they are intendended to be used by a single thread. If it is desired,
locking can be enabled by using RAND_DRBG_enable_locking().
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5294)
Matt Caswell [Tue, 13 Feb 2018 13:49:49 +0000 (13:49 +0000)]
Prepare for 1.1.1-pre2-dev
Reviewed-by: Richard Levitte <levitte@openssl.org>
Matt Caswell [Tue, 13 Feb 2018 13:48:07 +0000 (13:48 +0000)]
Prepare for 1.1.1-pre1 release
Reviewed-by: Richard Levitte <levitte@openssl.org>
Matt Caswell [Tue, 13 Feb 2018 12:51:29 +0000 (12:51 +0000)]
Update copyright year
Reviewed-by: Richard Levitte <levitte@openssl.org>
Matt Caswell [Tue, 13 Feb 2018 10:17:18 +0000 (10:17 +0000)]
OpenSSL 1.1.1 is now in pre release
Reviewed-by: Richard Levitte <levitte@openssl.org>
Matt Caswell [Tue, 13 Feb 2018 10:09:34 +0000 (10:09 +0000)]
Update last release letter for CHANGES and NEWS
Reviewed-by: Richard Levitte <levitte@openssl.org>
Dr. Matthias St. Pierre [Tue, 13 Feb 2018 01:04:50 +0000 (02:04 +0100)]
Fix whitespace issues in CHANGES and NEWS
Removed mixed tabs (converted tabs to eight spaces)
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5344)
Dr. Matthias St. Pierre [Tue, 13 Feb 2018 01:02:22 +0000 (02:02 +0100)]
Document new random generator in NEWS and CHANGES
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5344)
Matt Caswell [Mon, 12 Feb 2018 15:16:01 +0000 (15:16 +0000)]
Update NEWS file for new release
Updated the NEWS file with the most significant items from CHANGES
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5333)
Matt Caswell [Mon, 12 Feb 2018 09:39:28 +0000 (09:39 +0000)]
Some minor tweaks following TLSv1.3 becoming default
Fix a typo in INSTALL and update the link in CHANGES
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5329)
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/5328)
Andy Polyakov [Sun, 11 Feb 2018 11:29:47 +0000 (12:29 +0100)]
sha/asm/sha512-armv8.pl: add hardware-assisted SHA512 subroutine.
Reviewed-by: Rich Salz <rsalz@openssl.org>
Andy Polyakov [Sun, 11 Feb 2018 11:29:06 +0000 (12:29 +0100)]
crypto/armcap.c: detect hardware-assisted SHA512 support.
Reviewed-by: Rich Salz <rsalz@openssl.org>
Matt Caswell [Fri, 9 Feb 2018 18:03:08 +0000 (18:03 +0000)]
The function ssl_get_min_max_version() can fail
We should always check the return code.
This fixes a coverity issue.
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5308)
Matt Caswell [Fri, 9 Feb 2018 16:39:27 +0000 (16:39 +0000)]
Don't overestimate the ticket age
On the client we calculate the age of the ticket in seconds but the server
may work in ms. Due to rounding errors we could overestimate the age by up
to 1s. It is better to underestimate it. Otherwise, if the RTT is very
short, when the server calculates the age reported by the client it could
be bigger than the age calculated on the server - which should never happen.
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5306)
Daniël van Eeden [Sun, 11 Feb 2018 15:55:38 +0000 (10:55 -0500)]
Fix include in manpage of X509_check_host
Fixes Issue #5255
CLA: trivial
Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5256)
Rich Salz [Sat, 10 Feb 2018 18:36:47 +0000 (13:36 -0500)]
Copy name string in BIO_meth_new
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5318)
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>
Bernd Edlinger [Fri, 9 Feb 2018 16:19:50 +0000 (17:19 +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/5305)
Matt Caswell [Fri, 9 Feb 2018 10:19:14 +0000 (10:19 +0000)]
Fixes for no-tls1_2 and no-tls1_2-method
The no-tls1_2 option does not work properly in conjunction with TLSv1.3
being enabled (which is now the default). This commit fixes the issues.
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5301)
Nick Mathewson [Fri, 9 Feb 2018 14:03:07 +0000 (09:03 -0500)]
Run "make update"
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5150)
Nick Mathewson [Tue, 23 Jan 2018 15:49:53 +0000 (10:49 -0500)]
In err_all.c, include the *err.h headers.
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5150)
Nick Mathewson [Tue, 23 Jan 2018 15:48:35 +0000 (10:48 -0500)]
Improve #include structure of pem{,2}.h
- pem2.h is empty, so pem.h doesn't need to include it.
- pem2.h once declared ERR_load_PEM_strings(), so it should now
include pemerr.h
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5150)
Nick Mathewson [Tue, 23 Jan 2018 14:46:13 +0000 (09:46 -0500)]
Remove redundant declarations of ERR_load_*_strings()
In commit
52df25cf2e656146cb3b206d8220124f0417d03f, the
ERR_load_FOO_strings() functions were moved from their original
location in foo.h into new headers called fooerr.h. But they were
never removed from their original locations. This duplication
causes redundant-declaration warnings on programs that use OpenSSL's
headers with such warnings enabled.
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5150)
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.
Coincidentally, this commit also fixes the fact that no-nextprotoneg does
not currently work in master.
Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5285)
Richard Levitte [Thu, 8 Feb 2018 22:26:22 +0000 (23:26 +0100)]
Configuration: move the handling of zlib_include to config files
It was a bit absurd to have this being specially handled in the build
file templates, especially that we have the 'includes' attribute.
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5296)
Richard Levitte [Fri, 9 Feb 2018 12:45:58 +0000 (13:45 +0100)]
Turn off printf format checking for BIO_printf et al on Mac OS/X
Mac OS/X has a type for %j that doesn't agree with how we define it,
which gives incorrect warnings. The easiest way out of that situation
is simply to turn off that check on Mac OS/X.
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5302)
FdaSilvaYY [Thu, 8 Feb 2018 23:47:30 +0000 (18:47 -0500)]
Small simplification in mkerr.pl
As suggested in https://github.com/openssl/openssl/pull/5275
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5288)
Richard Levitte [Fri, 9 Feb 2018 08:55:36 +0000 (09:55 +0100)]
VMS: take care of includes
Configurations/descrip.mms.tmpl didn't treat the includes config
attribute very well. In fact, it didn't treat it at all!
Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5295)
Pauli [Thu, 8 Feb 2018 01:04:30 +0000 (11:04 +1000)]
Fix glibc version detection.
Simplify Posix timer detection.
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5279)
Richard Levitte [Fri, 9 Feb 2018 08:03:05 +0000 (09:03 +0100)]
Fix check of cpuid_asm_src config attribute
The contents of that attribute is C file names, not object file names.
This went undetected because quite a lot of systems have assembler
implementations anyway, so setting OPENSSL_CPUID_OBJ was correct for
them.
Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5291)
Richard Levitte [Fri, 9 Feb 2018 08:12:47 +0000 (09:12 +0100)]
Revert ".travis.yml: remove osx from build matrix."
Recent changes seem to have gotten OS X back on track, so we should be
able to run our tests there again.
This reverts commit
e12e903e9ac675d08f9dd0db1f0c1a2049232c21.
Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5292)
Dr. Matthias St. Pierre [Fri, 9 Feb 2018 07:52:56 +0000 (08:52 +0100)]
CRYPTO_THREAD_run_once.pod: fix typo and punktuation
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5293)
Matt Caswell [Thu, 8 Feb 2018 15:45:35 +0000 (15:45 +0000)]
Fix no-chacha and no-poly1305
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5287)
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)
Richard Levitte [Wed, 7 Feb 2018 21:40:32 +0000 (22:40 +0100)]
With nmake, invoking $(MAKE) needs /$(MAKEFLAGS)
The slash should be there according to Microsoft documentation,
see https://msdn.microsoft.com/en-us/library/7cafx990.aspx
Fixes #5277
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5278)
Matt Caswell [Wed, 7 Feb 2018 14:53:31 +0000 (14:53 +0000)]
Don't run tls13encryptiontest on a shared Windows build
tls13encryptiontest is an "internal" test. As with all the other internal
tests it should not be run on a shared native Windows build.
[extended tests]
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5266)
Matt Caswell [Wed, 7 Feb 2018 14:20:31 +0000 (14:20 +0000)]
Fix some undefined behaviour in ossltest engine
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5266)
Matt Caswell [Wed, 7 Feb 2018 10:55:02 +0000 (10:55 +0000)]
Fix clienthellotest with TLSv1.3
If TLSv1.3 is enabled and combined with other options that extend the
size of the ClientHello, then the clienthello test can sometimes fail
because the ClientHello has grown too large. Part of the purpose of the
test is to check that the padding extension works properly. This requires
the ClientHello size to be kept within certain bounds.
By restricting the number of ciphersuites sent we can reduce the size of
the ClientHello.
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5266)
Matt Caswell [Tue, 6 Feb 2018 17:27:25 +0000 (17:27 +0000)]
Enable TLSv1.3 by default
[extended tests]
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5266)
Richard Levitte [Wed, 7 Feb 2018 21:18:44 +0000 (22:18 +0100)]
Revert "Modify test/afalgtest to fail if the afalg engine couldn't be loaded"
It turns out that even if you successfully build the engine, it might
not load properly, so we cannot make the test program fail for it.
See the message in commit
25b9d11c002e5c71840c2a6733c5009d78f2c9db
This reverts commit
227a1e3f45bf06fdb00f2bdfb922f6f0d1f1d1de.
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5276)
Richard Levitte [Wed, 7 Feb 2018 18:40:19 +0000 (19:40 +0100)]
make update ERROR_REBUILD=-rebuild
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5275)
Richard Levitte [Wed, 7 Feb 2018 18:23:39 +0000 (19:23 +0100)]
mkerr.pl: When writing internal FOOerr.h, pay attention to disablable modules
If a module is disablable (i.e. can be configured with 'no-FOO'), the
resulting header file needs to be guarded with a check of the
corresponding OPENSSL_NO_FOO. While this seem fairly innocuous, it
has an impact on the information in util/*.num, generated by mkdef.pl.
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5275)
Richard Levitte [Wed, 7 Feb 2018 13:05:20 +0000 (14:05 +0100)]
Make all private functions in e_afalg.c static
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5270)
Richard Levitte [Wed, 7 Feb 2018 13:02:49 +0000 (14:02 +0100)]
test/recipes/30-test_afalg.t: set OPENSSL_ENGINES correctly
The afalg engine was moved down from engines/afalg/ to engines/, but
the test wasn't changed accordingly. This was undetected because the
test program didn't fail when it couldn't load the engine.
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5270)
Richard Levitte [Wed, 7 Feb 2018 13:01:13 +0000 (14:01 +0100)]
Modify test/afalgtest to fail if the afalg engine couldn't be loaded
If you know that there's no afalg engine, don't run this test.
test/recipes/30-test_afalg.t checks this correctly.
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5270)
Pauli [Wed, 7 Feb 2018 01:46:15 +0000 (11:46 +1000)]
Fix glibc specific conditional for Mac OS/X
MacOS seems to define __GLIBC__ but not __GLIBC_PREREQ.
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5269)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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>
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>
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)