openssl.git
15 months agoReject duplicate -addext parameters
Rich Salz [Thu, 5 Jul 2018 23:57:22 +0000 (19:57 -0400)]
Reject duplicate -addext parameters

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

15 months agoAdd missing include file to doc
Rich Salz [Thu, 5 Jul 2018 20:10:55 +0000 (16:10 -0400)]
Add missing include file to doc

Reported by Ingo Schwarze

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/6656)

15 months agoDocument more EVP_MD_CTX functions
Richard Levitte [Wed, 4 Jul 2018 07:26:05 +0000 (09:26 +0200)]
Document more EVP_MD_CTX functions

Fixes #6644

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

15 months ago[crypto/ec] disable SCA mitigations for curves with incomplete parameters
Billy Brumley [Wed, 4 Jul 2018 12:35:18 +0000 (15:35 +0300)]
[crypto/ec] disable SCA mitigations for curves with incomplete parameters

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

15 months agoFix no-tls1_2
Matt Caswell [Tue, 3 Jul 2018 12:36:31 +0000 (13:36 +0100)]
Fix no-tls1_2

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

15 months agoTests for MD5-SHA1 combined digest.
Pauli [Tue, 3 Jul 2018 21:48:45 +0000 (07:48 +1000)]
Tests for MD5-SHA1 combined digest.

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

15 months agoFix some issues found by Denian's lintian tool
Rich Salz [Tue, 3 Jul 2018 16:45:14 +0000 (12:45 -0400)]
Fix some issues found by Denian's lintian tool

Also fix some L<> labels and =item entries found while doing this.

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

15 months agochacha/asm/chacha-x86_64.pl: add dedicated path for 128-byte inputs.
Andy Polyakov [Mon, 2 Jul 2018 11:16:33 +0000 (13:16 +0200)]
chacha/asm/chacha-x86_64.pl: add dedicated path for 128-byte inputs.

The 128-byte vectors are extensively used in chacha20_poly1305_tls_cipher
and dedicated code path is ~30-50% faster on most platforms.

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

15 months agoperlasm/x86_64-xlate.pl: refine symbol recognition in .xdata.
Andy Polyakov [Mon, 2 Jul 2018 11:12:49 +0000 (13:12 +0200)]
perlasm/x86_64-xlate.pl: refine symbol recognition in .xdata.

Hexadecimals were erroneously recognized as symbols in .xdata.

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

15 months agoRemove TLSv1.3 tickets from the client cache as we use them
Matt Caswell [Tue, 26 Jun 2018 17:07:56 +0000 (18:07 +0100)]
Remove TLSv1.3 tickets from the client cache as we use them

Tickets are supposed to be single use so we remove them from the cache on
use.

Fixes #6377

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

15 months agoRestore behaviour from commit 36ff232cf that was incorrectly removed
Matt Caswell [Tue, 26 Jun 2018 17:06:45 +0000 (18:06 +0100)]
Restore behaviour from commit 36ff232cf that was incorrectly removed

In TLSv1.2 and below we should remove an old session from the client
session cache in the event that we receive a new session ticket from the
server.

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

15 months agoCheck for NULL conf in NCONF_get_number
Pauli [Mon, 2 Jul 2018 22:02:37 +0000 (08:02 +1000)]
Check for NULL conf in NCONF_get_number

The problematic case falls back to a NULL conf which returns the result
of getenv(2).  If this returns NULL, everything was good.  If this returns
a string an attempt to convert it to a number is made using the function
pointers from conf.

This fix uses the strtol(3) function instead, we don't have the
configuration settings and this behaves as the default would.

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

15 months agoAdd the ability to configure anti-replay via SSL_CONF
Matt Caswell [Fri, 15 Jun 2018 13:55:06 +0000 (14:55 +0100)]
Add the ability to configure anti-replay via SSL_CONF

This also adds the ability to control this through s_server

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

15 months agoAdd a test for the new early data callback
Matt Caswell [Fri, 8 Jun 2018 09:03:19 +0000 (10:03 +0100)]
Add a test for the new early data callback

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

15 months agoDocument the new early data callback and option
Matt Caswell [Thu, 7 Jun 2018 15:32:19 +0000 (16:32 +0100)]
Document the new early data callback and option

Document SSL_OP_NO_ANTI_REPLAY and SSL_CTX_set_allow_early_data_cb()

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

15 months agoAdd setters to set the early_data callback
Matt Caswell [Thu, 7 Jun 2018 14:14:36 +0000 (15:14 +0100)]
Add setters to set the early_data callback

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

15 months agoMake the anti-replay feature optional
Matt Caswell [Thu, 7 Jun 2018 08:11:05 +0000 (09:11 +0100)]
Make the anti-replay feature optional

Fixes #6389

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

15 months agoFix a NULL ptr deref in error path in tls_process_cke_dhe()
Matt Caswell [Tue, 26 Jun 2018 14:40:54 +0000 (15:40 +0100)]
Fix a NULL ptr deref in error path in tls_process_cke_dhe()

Fixes #6574

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

15 months agoAddress coverity-reported NULL dereference in SSL_SESSION_print()
Benjamin Kaduk [Sun, 1 Jul 2018 17:49:24 +0000 (12:49 -0500)]
Address coverity-reported NULL dereference in SSL_SESSION_print()

We need to check the provided SSL_SESSION* for NULL before
attempting to derference it to see if it's a TLS 1.3 session.

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

15 months agoRemove development artifacts.
Pauli [Wed, 27 Jun 2018 01:34:54 +0000 (11:34 +1000)]
Remove development artifacts.

The issue was discovered on the x86/64 when attempting to include
libcrypto inside another shared library.  A relocation of type
R_X86_64_PC32 was generated which causes a linker error.

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

15 months agorand/rand_unix.c: address macro redifinition warning.
Andy Polyakov [Fri, 29 Jun 2018 16:46:57 +0000 (18:46 +0200)]
rand/rand_unix.c: address macro redifinition warning.

Occasionally, e.g. when compiling for elderly glibc, you end up passing
-D_GNU_SOURCE on command line, and doing so triggered warning...

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

15 months agomodes/asm/ghash-armv4.pl: address "infixes are deprecated" warnings.
Andy Polyakov [Fri, 29 Jun 2018 15:48:54 +0000 (17:48 +0200)]
modes/asm/ghash-armv4.pl: address "infixes are deprecated" warnings.

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

15 months agoevp/e_chacha20_poly1305.c: improve performance for short TLS records.
Andy Polyakov [Wed, 27 Jun 2018 10:16:52 +0000 (12:16 +0200)]
evp/e_chacha20_poly1305.c: improve performance for short TLS records.

Inputs not longer than 64 bytes are processed ~10% faster, longer
lengths not divisble by 64, e.g. 255, up to ~20%. Unfortunately it's
impossible to measure with apps/speed.c, -aead benchmarks TLS-like
call sequence, but not exact. It took specially crafted code path...

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

15 months agoMore EVP ECC testing: positive and negative
Billy Brumley [Thu, 28 Jun 2018 07:59:08 +0000 (10:59 +0300)]
More EVP ECC testing: positive and negative

1. For every named curve, two "golden" keypair positive tests.
2. Also two "golden" stock ECDH positive tests.
3. For named curves with non-trivial cofactors, additionally two "golden"
   ECC CDH positive tests.
4. For named curves with non-trivial cofactors, additionally two negative
   tests.

There is some overlap with existing EVP tests, especially for the NIST
curves (for example, positive testing ECC CDH KATs for NIST curves).

"Golden" here means all the values are independent from OpenSSL's ECC
code. I used sage to calculate them. What comes from OpenSSL is:

1. The OIDs (parsed by tooling)
2. The curve parameters (parsing ecparam output with tooling)

The values inside the PEMs (private keys, public keys) and shared keys
are from sage. The PEMs themselves are the output of asn1parse, with
input taken from sage.

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

15 months agoCheck return from BN_set_word.
Pauli [Thu, 28 Jun 2018 23:55:23 +0000 (09:55 +1000)]
Check return from BN_set_word.
In ssl/t1_lib.c.

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

15 months agoZero-fill IV by default.
Rich Salz [Thu, 28 Jun 2018 22:13:54 +0000 (18:13 -0400)]
Zero-fill IV by default.

Fixes uninitialized memory read reported by Nick Mathewson

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

15 months agoReturn a fatal error if application data is encountered during shutdown
Matt Caswell [Mon, 25 Jun 2018 13:51:11 +0000 (14:51 +0100)]
Return a fatal error if application data is encountered during shutdown

Currently if you encounter application data while waiting for a
close_notify from the peer, and you have called SSL_shutdown() then
you will get a -1 return (fatal error) and SSL_ERROR_SYSCALL from
SSL_get_error(). This isn't accurate (it should be SSL_ERROR_SSL) and
isn't persistent (you can call SSL_shutdown() again and it might then work).

We change this into a proper fatal error that is persistent.

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/6340)

15 months agoReturn SSL_ERROR_WANT_READ if SSL_shutdown() encounters handshake data
Matt Caswell [Thu, 21 Jun 2018 12:30:38 +0000 (13:30 +0100)]
Return SSL_ERROR_WANT_READ if SSL_shutdown() encounters handshake data

In the case where we are shutdown for writing and awaiting a close_notify
back from a subsequent SSL_shutdown() call we skip over handshake data
that is received. This should not be treated as an error - instead it
should be signalled with SSL_ERROR_WANT_READ.

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/6340)

15 months agoAdd a bi-directional shutdown test
Matt Caswell [Wed, 23 May 2018 11:11:15 +0000 (12:11 +0100)]
Add a bi-directional shutdown test

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/6340)

15 months agoAuto retry if we ditch records during shutdown
Matt Caswell [Wed, 23 May 2018 11:00:10 +0000 (12:00 +0100)]
Auto retry if we ditch records during shutdown

If we've sent a close_notify and we're waiting for one back we drop
incoming records until we see the close_notify we're looking for. If
SSL_MODE_AUTO_RETRY is on, then we should immediately try and read the
next record.

Fixes #6262

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/6340)

15 months agoModify the DEVRANDOM source so that the files are kept open persistently.
Pauli [Wed, 6 Jun 2018 23:31:44 +0000 (09:31 +1000)]
Modify the DEVRANDOM source so that the files are kept open persistently.
This allows operation inside a chroot environment without having the
random device present.

A new call, RAND_keep_random_devices_open(), has been introduced that can
be used to control file descriptor use by the random seed sources. Some
seed sources maintain open file descriptors by default, which allows
such sources to operate in a chroot(2) jail without the associated device
nodes being available.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/6432)

15 months agoDocument changes to SSL_OP_NO_TICKET for TLSv1.3
Matt Caswell [Fri, 22 Jun 2018 14:05:27 +0000 (15:05 +0100)]
Document changes to SSL_OP_NO_TICKET for TLSv1.3

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

15 months agoUse stateful tickets if we are doing anti-replay
Matt Caswell [Thu, 21 Jun 2018 15:54:55 +0000 (16:54 +0100)]
Use stateful tickets if we are doing anti-replay

During anti-replay we cache the ticket anyway, so there is no point in
using a full stateless ticket.

Fixes #6391

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

15 months agoRespect SSL_OP_NO_TICKET in TLSv1.3
Matt Caswell [Wed, 13 Jun 2018 14:57:39 +0000 (15:57 +0100)]
Respect SSL_OP_NO_TICKET in TLSv1.3

Implement support for stateful TLSv1.3 tickets, and use them if
SSL_OP_NO_TICKET is set.

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

15 months agoRestructure the ticket construction code
Matt Caswell [Wed, 13 Jun 2018 10:59:43 +0000 (11:59 +0100)]
Restructure the ticket construction code

Separate out as a new function the code to write out data which is specific
to a stateless ticket.

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

15 months agoNOTES.UNIX: add "Linking your application" paragraph
Andy Polyakov [Fri, 22 Jun 2018 12:13:59 +0000 (14:13 +0200)]
NOTES.UNIX: add "Linking your application" paragraph

... and mention more runtime search path flags.

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

15 months agoUpdate SSL_SESSION_print for TLSv1.3
Matt Caswell [Mon, 25 Jun 2018 16:52:01 +0000 (17:52 +0100)]
Update SSL_SESSION_print for TLSv1.3

Make SSL_SESSION_print() show a bit more information for TLSv1.3

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

15 months agoOnly dump session data after we have received it
Matt Caswell [Mon, 25 Jun 2018 15:46:57 +0000 (16:46 +0100)]
Only dump session data after we have received it

s_client was dumping session data at the end of the handshake. In TLSv1.3
we don't have session data until receipt of a NewSessionTicket message
which happens post-handshake. Therefore we delay dumping the session data
until that message has arrived if TLSv1.3 has been negotiated.

Fixes #6482

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

15 months agoOpenSSL_add_ssl_algorithm-is-deprecated() is deprecated, make it so
Richard Levitte [Mon, 25 Jun 2018 15:08:20 +0000 (17:08 +0200)]
OpenSSL_add_ssl_algorithm-is-deprecated() is deprecated, make it so

This function is documented to be deprecated since OpenSSL 1.1.0.  We
need to make it so in openssl/ssl.h as well.

Fixes #6565

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

15 months agostore/loader_file.c: fix char-subscripts warning.
Andy Polyakov [Sun, 24 Jun 2018 14:43:21 +0000 (16:43 +0200)]
store/loader_file.c: fix char-subscripts warning.

This happens on systems that perform is* character classifictions as
array lookup, e.g. NetBSD.

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

15 months agoPA-RISC assembly pack: make it work with GNU assembler for HP-UX.
Andy Polyakov [Sun, 24 Jun 2018 11:29:29 +0000 (13:29 +0200)]
PA-RISC assembly pack: make it work with GNU assembler for HP-UX.

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

15 months agorand/rand_unix.c: mask getentropy ELF detection on HP-UX.
Andy Polyakov [Sun, 24 Jun 2018 11:24:27 +0000 (13:24 +0200)]
rand/rand_unix.c: mask getentropy ELF detection on HP-UX.

Unlike other ELF systems, HP-UX run-time linker fails to detect symbol
availability through weak declaration.

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

15 months agoec/ec_pmeth.c: minor cleanups and readability fixes.
Andy Polyakov [Fri, 22 Jun 2018 13:37:26 +0000 (15:37 +0200)]
ec/ec_pmeth.c: minor cleanups and readability fixes.

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

15 months agoUse ec_group_do_inverse_ord() in SM2
Nicola Tuveri [Thu, 21 Jun 2018 16:15:50 +0000 (19:15 +0300)]
Use ec_group_do_inverse_ord() in SM2

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

15 months agoAdd inter-module private header for EC functions
Nicola Tuveri [Thu, 21 Jun 2018 16:08:50 +0000 (19:08 +0300)]
Add inter-module private header for EC functions

Internal submodules of libcrypto may require non-public functions from
the EC submodule.

In preparation to use `ec_group_do_inverse_ord()` (from #6116) inside
the SM2 submodule to apply a SCA mitigation on the modular inversion,
this commit moves the `ec_group_do_inverse_ord()` prototype declaration
from the EC-local `crypto/ec/ec_lcl.h` header to the
`crypto/include/internal/ec_int.h` inter-module private header.

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

15 months agoDon't change a session once its in the cache
Matt Caswell [Fri, 22 Jun 2018 13:15:33 +0000 (14:15 +0100)]
Don't change a session once its in the cache

Sessions should be immutable once they are in the cache because they could
be shared with other threads. If you change them then this can cause
corruptions and races

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

15 months agoapps/speed.c: add missing checks for RAND_bytes()
捷成吴 [Sun, 24 Jun 2018 07:28:33 +0000 (15:28 +0800)]
apps/speed.c: add missing checks for RAND_bytes()

Function RAND_bytes() may return 0 or -1 on error, simply
goto end label when it fails.

Fixes #6567

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

15 months agoFix a new gcc-9 warning [-Wstringop-truncation]
Bernd Edlinger [Sat, 23 Jun 2018 20:17:19 +0000 (22:17 +0200)]
Fix a new gcc-9 warning [-Wstringop-truncation]

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

15 months agoSupport directories with "." in x509_load_serial()
Ana María Martínez Gómez [Fri, 22 Jun 2018 22:01:17 +0000 (00:01 +0200)]
Support directories with "." in x509_load_serial()

Use `strrchr` to get a pointer to the last occurrence of `.` in the
path string, instead of the first one with `strchr`.  This prevent the
path to be wrongly split if it contains several `.`, and not only the
one for the extension.

Fixes https://github.com/openssl/openssl/issues/6489.

CLA: trivial

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/6566)

15 months agoFix prototype of ASN1_INTEGER_get and ASN1_INTEGER_set
Kurt Roeckx [Sat, 23 Jun 2018 08:24:00 +0000 (10:24 +0200)]
Fix prototype of ASN1_INTEGER_get and ASN1_INTEGER_set

The parameters where switched

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

15 months agoReplace accidentally used C99 macro __func__ with __FILE__/__LINE__
Bernd Edlinger [Fri, 22 Jun 2018 07:41:29 +0000 (09:41 +0200)]
Replace accidentally used C99 macro __func__ with __FILE__/__LINE__

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

15 months agofix pyca/cryptography test suite failure
Paul Kehrer [Wed, 20 Jun 2018 15:56:57 +0000 (10:56 -0500)]
fix pyca/cryptography test suite failure

[extended tests]

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/6540)

15 months agoOpenSSL-II style for emacs: don't indent because of extern block
Richard Levitte [Fri, 22 Jun 2018 07:33:29 +0000 (09:33 +0200)]
OpenSSL-II style for emacs: don't indent because of extern block

We don't want an indentation step inside a 'extern "C" {' .. '}'
block.  Apparently, cc-mode has a c-offsets-alist keyword to allow
exactly this.

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

15 months agoecdsa_ossl: address coverity nit
Benjamin Kaduk [Mon, 18 Jun 2018 01:00:02 +0000 (20:00 -0500)]
ecdsa_ossl: address coverity nit

BN_CTX_end() does not handle NULL input, so we must manually check
before calling from the cleanup handler.

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

15 months agoFix negative test result in sm2 test
Bernd Edlinger [Thu, 21 Jun 2018 06:07:48 +0000 (08:07 +0200)]
Fix negative test result in sm2 test

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

16 months agosha/asm/sha{256|512}-armv4.pl: harmonize thumb2 support with the rest.
Andy Polyakov [Thu, 21 Jun 2018 11:52:04 +0000 (13:52 +0200)]
sha/asm/sha{256|512}-armv4.pl: harmonize thumb2 support with the rest.

Reviewed-by: Richard Levitte <levitte@openssl.org>
16 months agoAdd a high level note about the various SCA mitigations
Matt Caswell [Thu, 21 Jun 2018 09:37:54 +0000 (10:37 +0100)]
Add a high level note about the various SCA mitigations

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

16 months agoRemove __cplusplus preamble from internal headers
Nicola Tuveri [Thu, 21 Jun 2018 20:24:34 +0000 (23:24 +0300)]
Remove __cplusplus preamble from internal headers

These headers are internal and never exposed to a cpp compiler, hence no
need for the preamble.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
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/6554)

16 months agoConfigure,util/shlib_wrap.sh: harmonize -Wl and -rpath handling.
Andy Polyakov [Mon, 18 Jun 2018 17:08:50 +0000 (19:08 +0200)]
Configure,util/shlib_wrap.sh: harmonize -Wl and -rpath handling.

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

16 months agoCHANGES: mention AIX shared library support overhaul.
Andy Polyakov [Tue, 19 Jun 2018 16:25:19 +0000 (18:25 +0200)]
CHANGES: mention AIX shared library support overhaul.

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

16 months agorecipes/90-test_shlibload.t: disable tests on AIX till further notice.
Andy Polyakov [Fri, 15 Jun 2018 13:41:07 +0000 (15:41 +0200)]
recipes/90-test_shlibload.t: disable tests on AIX till further notice.

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

16 months agoConfigurations/10-main.conf: always pass -bsrv4 to AIX linker.
Andy Polyakov [Fri, 15 Jun 2018 13:24:14 +0000 (15:24 +0200)]
Configurations/10-main.conf: always pass -bsrv4 to AIX linker.

This makes AIX build procedure behave more like e.g. Solaris. Most
notably this makes it possible to pass -Wl,-R,'$(LIBRPATH)' at config
time to embed installation destination as library search path into
openssl binary. This doesn't imply that other applications have to be
linked with -bsvr4, they are free to choose whatever appropriate for
given circumstances.

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

16 months agoConfigurations/unix-Makefile.tmpl: switch to "natural" AIX shared libraries.
Andy Polyakov [Thu, 14 Jun 2018 09:45:15 +0000 (11:45 +0200)]
Configurations/unix-Makefile.tmpl: switch to "natural" AIX shared libraries.

AIX treats its shared libraries in unique manner, by placing multiple
shared objects of different versions and bitnesses, into .a file.
So far we have been naively linking with version-less libcrypto|ssl.so,
which poses long-term maintenance problems. One could choose to link
straight with libcrypto.so.X.Y [or libcrypto.X.Y.so], but it would be
inconsistent with the way AIX [or Unix] does things.

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

16 months agoConfigure: allow some file extensions to be overridden by target config.
Andy Polyakov [Thu, 14 Jun 2018 20:07:48 +0000 (22:07 +0200)]
Configure: allow some file extensions to be overridden by target config.

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

16 months agoenable-ec_nistp_64_gcc_128: Fix function prototype warning [-Wstrict-prototypes]
Nicola Tuveri [Thu, 21 Jun 2018 21:59:58 +0000 (00:59 +0300)]
enable-ec_nistp_64_gcc_128: Fix function prototype warning [-Wstrict-prototypes]

Fix prototype warnings triggered by -Wstrict-prototypes when configuring
with `enable-ec_nistp_64_gcc_128`

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

16 months agotestutil/driver.c: Fix function prototype warning [-Wstrict-prototypes]
Dr. Matthias St. Pierre [Thu, 21 Jun 2018 21:32:38 +0000 (23:32 +0200)]
testutil/driver.c: Fix function prototype warning [-Wstrict-prototypes]

(introduced by commit 91860165820d, which added -Wstrict-prototypes)

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/6555)

16 months agoFixed range of random produced in BN_is_prime_fasttest_ex() to be 1 < rand < w-1...
Shane Lontis [Thu, 21 Jun 2018 03:37:52 +0000 (13:37 +1000)]
Fixed range of random produced in BN_is_prime_fasttest_ex() to be 1 < rand < w-1. It was using 1<= rand < w (which is wrong by 1 on both ends)

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

16 months agoadd documentation for OCSP_basic_verify()
David von Oheimb [Sat, 10 Feb 2018 14:45:11 +0000 (15:45 +0100)]
add documentation for OCSP_basic_verify()

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

16 months ago[fixup] Add CHANGES entry
Nicola Tuveri [Tue, 19 Jun 2018 13:55:29 +0000 (16:55 +0300)]
[fixup] Add CHANGES entry

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

16 months ago[crypto/ec] default to FLT or error
Billy Brumley [Tue, 8 May 2018 11:00:30 +0000 (14:00 +0300)]
[crypto/ec] default to FLT or error

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

16 months ago[crypto/ec] remove blinding to support even orders
Billy Brumley [Sat, 5 May 2018 08:03:02 +0000 (11:03 +0300)]
[crypto/ec] remove blinding to support even orders

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

16 months agomake EC_GROUP_do_inverse_ord more robust
Billy Brumley [Fri, 27 Apr 2018 14:45:51 +0000 (17:45 +0300)]
make EC_GROUP_do_inverse_ord more robust

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

16 months agoAdd -Wstrict-prototypes option to --strict-warnings
Bernd Edlinger [Wed, 20 Jun 2018 19:41:05 +0000 (21:41 +0200)]
Add -Wstrict-prototypes option to --strict-warnings

[extended tests]

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

16 months agoapps/ca: fix useless get before delete.
FdaSilvaYY [Tue, 8 May 2018 07:47:26 +0000 (09:47 +0200)]
apps/ca: fix useless get before delete.

Small simplification by skipping effectively redundant step and
not resuming search from point past deletion.

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

16 months agoConfigurations/10-main.conf: IRIX configs unification.
Andy Polyakov [Wed, 20 Jun 2018 12:14:11 +0000 (14:14 +0200)]
Configurations/10-main.conf: IRIX configs unification.

Add irix-common template that covers even irix-shared from shared-info.pl.

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

16 months agoRemove some inline assembler and non-standard constructs.
Andy Polyakov [Mon, 18 Jun 2018 10:50:53 +0000 (12:50 +0200)]
Remove some inline assembler and non-standard constructs.

The goal is to minimize maintenance burden by eliminating somewhat
obscure platform-specific tweaks that are not viewed as critical for
contemporary applications. This affects Camellia and digest
implementations that rely on md32_common.h, MD4, MD5, SHA1, SHA256.
SHA256 is the only one that can be viewed as critical, but given
the assembly coverage, the omission is considered appropriate.

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

16 months ago[crypto/ec] don't assume points are of order group->order
Billy Brumley [Wed, 20 Jun 2018 07:56:37 +0000 (10:56 +0300)]
[crypto/ec] don't assume points are of order group->order

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

16 months agoDon't use OPENSSL_strdup() for copying alpn_selected
Matt Caswell [Mon, 18 Jun 2018 10:30:21 +0000 (11:30 +0100)]
Don't use OPENSSL_strdup() for copying alpn_selected

An alpn_selected value containing NUL bytes in it will result in
ext.alpn_selected_len having a larger value than the number of bytes
allocated in ext.alpn_selected.

Issue found by OSS-fuzz.

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

16 months agoUse DEPRECATEDIN_1_2_0 macro for DSA_sign_setup declaration
Nicola Tuveri [Tue, 12 Jun 2018 14:42:31 +0000 (17:42 +0300)]
Use DEPRECATEDIN_1_2_0 macro for DSA_sign_setup declaration

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

16 months agoAdd blinding to a DSA signature
Matt Caswell [Tue, 19 Jun 2018 14:07:02 +0000 (15:07 +0100)]
Add blinding to a DSA signature

This extends the recently added ECDSA signature blinding to blind DSA too.

This is based on side channel attacks demonstrated by Keegan Ryan (NCC
Group) for ECDSA which are likely to be able to be applied to DSA.

Normally, as in ECDSA, during signing the signer calculates:

s:= k^-1 * (m + r * priv_key) mod order

In ECDSA, the addition operation above provides a sufficient signal for a
flush+reload attack to derive the private key given sufficient signature
operations.

As a mitigation (based on a suggestion from Keegan) we add blinding to
the operation so that:

s := k^-1 * blind^-1 (blind * m + blind * r * priv_key) mod order

Since this attack is a localhost side channel only no CVE is assigned.

This commit also tweaks the previous ECDSA blinding so that blinding is
only removed at the last possible step.

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

16 months agoDocument no-sm2
Matt Caswell [Tue, 19 Jun 2018 20:41:49 +0000 (21:41 +0100)]
Document no-sm2

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

16 months agoopenssl ca: open the output file as late as possible
Richard Levitte [Thu, 21 Jun 2018 04:24:33 +0000 (06:24 +0200)]
openssl ca: open the output file as late as possible

Fixes #6544

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

16 months agoFix spelling errors in documentation.
Pauli [Thu, 21 Jun 2018 03:39:23 +0000 (13:39 +1000)]
Fix spelling errors in documentation.
Also fix some clumsy wording.

[skip_ci]

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

16 months agoNOTES.UNIX: expand the description of RPATHs
Richard Levitte [Tue, 19 Jun 2018 11:03:55 +0000 (13:03 +0200)]
NOTES.UNIX: expand the description of RPATHs

Hopefully, this will make it more clear that it isn't only ELF
specific, even though there is a part that is (or even more
restrictively GNU ld.so specific).

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

16 months agoPrepare for 1.1.1-pre9-dev
Matt Caswell [Wed, 20 Jun 2018 14:49:35 +0000 (15:49 +0100)]
Prepare for 1.1.1-pre9-dev

Reviewed-by: Richard Levitte <levitte@openssl.org>
16 months agoPrepare for 1.1.1-pre8 release OpenSSL_1_1_1-pre8
Matt Caswell [Wed, 20 Jun 2018 14:48:08 +0000 (15:48 +0100)]
Prepare for 1.1.1-pre8 release

Reviewed-by: Richard Levitte <levitte@openssl.org>
16 months agoUpdate copyright year
Matt Caswell [Wed, 20 Jun 2018 14:25:43 +0000 (15:25 +0100)]
Update copyright year

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

16 months agoupdate pyca/cryptography submodule
Paul Kehrer [Tue, 19 Jun 2018 17:49:19 +0000 (12:49 -0500)]
update pyca/cryptography submodule

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

16 months agoFix no-sm2
Matt Caswell [Tue, 19 Jun 2018 20:36:42 +0000 (21:36 +0100)]
Fix no-sm2

Fixes #6525

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

16 months agoFix test sm2 test failure with ec blinding
Bernd Edlinger [Tue, 19 Jun 2018 18:08:59 +0000 (20:08 +0200)]
Fix test sm2 test failure with ec blinding

[extended tests]

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

16 months agoFix enable-ssl3 enable-ssl3-method
Matt Caswell [Mon, 18 Jun 2018 11:06:52 +0000 (12:06 +0100)]
Fix enable-ssl3 enable-ssl3-method

Commit 4aa5a5669 accidentally missed off the catch all case of ignoring all
warning alerts that are otherwise unhandled. This breaks the SSLv3 tests
which send a "no certificate" warning alert.

Fixes #6496

[extended tests]

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

16 months agoImprove the output of `make doc-nits`
Dr. Matthias St. Pierre [Mon, 18 Jun 2018 20:09:20 +0000 (22:09 +0200)]
Improve the output of `make doc-nits`

- Print positive feedback in the case when 'make doc-nits' finds no errors.
- Other than before, keep the 'doc-nits' output file only in case of errors
  and remove it if it is empty.
- Declare 'doc-nits' as a phony make target to facilitate rerunning
  'make doc-nits' without having to remove the output file first.

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

16 months agoFix & update documentation about RAND_priv_bytes()
Nicola Tuveri [Mon, 18 Jun 2018 16:13:36 +0000 (19:13 +0300)]
Fix & update documentation about RAND_priv_bytes()

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Ben Kaduk <kaduk@mit.edu>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/6514)

16 months agoImplement coordinate blinding for EC_POINT
Sohaib ul Hassan [Sat, 16 Jun 2018 14:07:40 +0000 (17:07 +0300)]
Implement coordinate blinding for EC_POINT

This commit implements coordinate blinding, i.e., it randomizes the
representative of an elliptic curve point in its equivalence class, for
prime curves implemented through EC_GFp_simple_method,
EC_GFp_mont_method, and EC_GFp_nist_method.

This commit is derived from the patch
https://marc.info/?l=openssl-dev&m=131194808413635 by Billy Brumley.

Coordinate blinding is a generally useful side-channel countermeasure
and is (mostly) free. The function itself takes a few field
multiplicationss, but is usually only necessary at the beginning of a
scalar multiplication (as implemented in the patch). When used this way,
it makes the values that variables take (i.e., field elements in an
algorithm state) unpredictable.

For instance, this mitigates chosen EC point side-channel attacks for
settings such as ECDH and EC private key decryption, for the
aforementioned curves.

For EC_METHODs using different coordinate representations this commit
does nothing, but the corresponding coordinate blinding function can be
easily added in the future to extend these changes to such curves.

Co-authored-by: Nicola Tuveri <nic.tuv@gmail.com>
Co-authored-by: Billy Brumley <bbrumley@gmail.com>
Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/6501)

16 months agoMove SM2 algos to SM2 specific PKEY method
Jack Lloyd [Mon, 18 Jun 2018 19:51:56 +0000 (15:51 -0400)]
Move SM2 algos to SM2 specific PKEY method

Use EVP_PKEY_set_alias_type to access

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

16 months agoAdd EVP_PKEY_set_alias_type
Jack Lloyd [Mon, 18 Jun 2018 19:49:15 +0000 (15:49 -0400)]
Add EVP_PKEY_set_alias_type

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

16 months agoConvert our own check of OPENSSL_NO_DEPRECATED
Richard Levitte [Tue, 12 Jun 2018 16:31:57 +0000 (18:31 +0200)]
Convert our own check of OPENSSL_NO_DEPRECATED

... to the check OPENSSL_API_COMPAT < 0x10100000L, to correspond with
how it's declared.

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

16 months agoConfigure option 'no-deprecated' means '-DOPENSSL_API_COMPAT=0x10100000L'
Richard Levitte [Tue, 12 Jun 2018 16:26:37 +0000 (18:26 +0200)]
Configure option 'no-deprecated' means '-DOPENSSL_API_COMPAT=0x10100000L'

(that is, until 1.2.0 comes along)

Since we allow future deprecation (and that shouldn't be affected
by 'no-deprecated'), we need to distinguish what to have deprecated
on the value of OPENSSL_API_COMPAT, not the existence of
OPENSSL_NO_DEPRECATED.

Note that the macro OPENSSL_NO_DEPRECATED still exists, in case
someone still uses it.

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

16 months agoec/asm/ecp_nistz256-avx2.pl: harmonize clang version detection.
Andy Polyakov [Sat, 16 Jun 2018 14:25:40 +0000 (16:25 +0200)]
ec/asm/ecp_nistz256-avx2.pl: harmonize clang version detection.

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

16 months ago{chacha|poly1305}/asm/*-x64.pl: harmonize clang version detection.
Andy Polyakov [Sat, 16 Jun 2018 14:24:55 +0000 (16:24 +0200)]
{chacha|poly1305}/asm/*-x64.pl: harmonize clang version detection.

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