openssl.git
7 years agoReformat M_check_autoarg to match our coding style
Richard Levitte [Tue, 20 Dec 2016 18:21:00 +0000 (19:21 +0100)]
Reformat M_check_autoarg to match our coding style

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/2121)
(cherry picked from commit 2629440d42e4d64cd0cb849c1b19fa87a4fcb90f)

7 years agoM_check_autoarg: sanity check the key
Richard Levitte [Tue, 20 Dec 2016 11:56:14 +0000 (12:56 +0100)]
M_check_autoarg: sanity check the key

For now, checking that the size is non-zero will suffice.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/2120)
(cherry picked from commit d7c8f142ea5953bf260b70a58739c1c9b0f038eb)

7 years agoFix typo.
Finn Hakansson [Thu, 15 Dec 2016 17:58:19 +0000 (12:58 -0500)]
Fix typo.

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
CLA: trivial
(Merged from https://github.com/openssl/openssl/pull/2086)
(cherry picked from commit 0b742f93ea7882a447f6523ac56a6f847d9f8e92)

(cherry picked from commit f7a2da1d584bed2e05774f92d69fee39ce3edda2)

7 years agozero pad DHE public key in ServerKeyExchange message for interop
russor [Mon, 25 Jul 2016 20:11:28 +0000 (13:11 -0700)]
zero pad DHE public key in ServerKeyExchange message for interop

Some versions of the Microsoft TLS stack have problems when the DHE public key
is encoded with fewer bytes than the DHE prime. (Backported from master)

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

7 years agoFix ssl_cert_dup: change one 'return NULL' to 'goto err'
Richard Levitte [Wed, 14 Dec 2016 13:10:33 +0000 (14:10 +0100)]
Fix ssl_cert_dup: change one 'return NULL' to 'goto err'

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

7 years agoMake 'err' lable in ssl_cert_dup unconditional
Richard Levitte [Wed, 14 Dec 2016 12:51:01 +0000 (13:51 +0100)]
Make 'err' lable in ssl_cert_dup unconditional

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

7 years agoFix a bug in clienthello processing
Benjamin Kaduk [Fri, 22 Jul 2016 14:55:48 +0000 (09:55 -0500)]
Fix a bug in clienthello processing

- Always process ALPN (previously there was an early return in the
  certificate status handling)

1.0.2 did not have the double-alert issue from master, but it seems
cleanest to pull in the structural change to alert handling anyway
and jump to f_err instead of err to send the alert in the caller.

(cherry picked from commit 70c22888c1648fe8652e77107f3c74bf2212de36)

Reviewed-by: Emilia Käsper <emilia@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
7 years agoperlasm/x86_64-xlate.pl: refine sign extension in ea package.
Andy Polyakov [Fri, 9 Dec 2016 14:26:19 +0000 (15:26 +0100)]
perlasm/x86_64-xlate.pl: refine sign extension in ea package.

$1<<32>>32 worked fine with either 32- or 64-bit perl for a good while,
relying on quirk that [pure] 32-bit perl performed it as $1<<0>>0. But
this apparently changed in some version past minimally required 5.10,
and operation result became 0. Yet, it went unnoticed for another while,
because most perl package providers configure their packages with
-Duse64bitint option.

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

7 years agoUI_OpenSSL()'s session opener fails on MacOS X
Richard Levitte [Wed, 7 Dec 2016 19:28:43 +0000 (20:28 +0100)]
UI_OpenSSL()'s session opener fails on MacOS X

If on a non-tty stdin, TTY_get() will fail with errno == ENODEV.
We didn't catch that.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/2039)
(cherry picked from commit c901bccec6f747467e1af31473655c8290e32309)

7 years agoVMS UI_OpenSSL: if the TT device isn't a tty, flag instead of error
Richard Levitte [Fri, 9 Dec 2016 22:41:01 +0000 (23:41 +0100)]
VMS UI_OpenSSL: if the TT device isn't a tty, flag instead of error

On all platforms, if the controlling tty isn't an actual tty, this is
flagged by setting is_a_tty to zero...  except on VMS, where this was
treated as an error.  Change this to behave like the other platforms.

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

7 years agoCheck input length to pkey_rsa_verify()
Dr. Stephen Henson [Thu, 8 Dec 2016 12:16:02 +0000 (12:16 +0000)]
Check input length to pkey_rsa_verify()

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/2065)
(cherry picked from commit 71bbc79b7d3b1195a7a7dd5f547d52ddce32d6f0)

Conflicts:
crypto/rsa/rsa_err.c
include/openssl/rsa.h

7 years agoRemove extra bang
Richard Levitte [Thu, 8 Dec 2016 19:51:21 +0000 (20:51 +0100)]
Remove extra bang

A bang (!) slipped through in the recent UI cleanup

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/2051)
(cherry picked from commit 949320c567811e714216ea987fe24eea1b56da5e)

7 years agoUI code style cleanup
Richard Levitte [Thu, 8 Dec 2016 17:01:04 +0000 (18:01 +0100)]
UI code style cleanup

Mostly condition check changes.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/2047)
(cherry picked from commit 120fb9e43656e1801c75a4fbb7c178ebec9bac18)

7 years agoRevert "Fix heartbeat_test"
Matt Caswell [Mon, 28 Nov 2016 09:41:42 +0000 (09:41 +0000)]
Revert "Fix heartbeat_test"

Commit fa4c37457 got reverted, so this one also needs to be reverted as
a result.

This reverts commit ad69a30323cbc6723c2387d6ce546a51b10c42d0.

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoapps/speed.c: Fix crash when config loading fails
Vitezslav Cizek [Thu, 24 Nov 2016 12:21:41 +0000 (13:21 +0100)]
apps/speed.c: Fix crash when config loading fails

Move rsa_key initialization in front of load_config().
If loading the config fails, rsa_key isn't initialized and may
cause invalid free() in the end: cleanup.
Remove superfluous memset.

Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoINSTALL: clarify 386 and no-sse2 options.
Andy Polyakov [Fri, 25 Nov 2016 16:50:37 +0000 (17:50 +0100)]
INSTALL: clarify 386 and no-sse2 options.

This is 1.0.2-specific reformat of 5ae5dc96610f0a598dac9d2f267b5c0ddd77b2e4.

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agomodes/ctr128.c: fix false carry in counter increment procedure.
Andy Polyakov [Sun, 20 Nov 2016 22:38:12 +0000 (23:38 +0100)]
modes/ctr128.c: fix false carry in counter increment procedure.

GH issue #1916 affects only big-endian platforms. TLS is not affected,
because TLS fragment is never big enough.

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

7 years agoClarify what X509_NAME_online does with the given buffer and size
Richard Levitte [Tue, 22 Nov 2016 10:22:16 +0000 (11:22 +0100)]
Clarify what X509_NAME_online does with the given buffer and size

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1980)
(cherry picked from commit 19cb71ef6e414759d737918bab10be2cc1d8bd99)

(cherry picked from commit 793d9b79033c2fffc8e781dab2fd678661b348cd)

7 years agoMake SSL_read and SSL_write return the old behaviour and document it.
Kurt Roeckx [Tue, 15 Nov 2016 17:58:52 +0000 (18:58 +0100)]
Make SSL_read and SSL_write return the old behaviour and document it.

Backport of beacb0f0c1ae7b0542fe053b95307f515b578eb7, revert of
fa4c374572e94f467900f5820cd1d00af2470a17

Fixes: #1903
Reviewed-by: Matt Caswell <matt@openssl.org>
GH: #1967

7 years agoUse consistent variable names
Beat Bolli [Fri, 18 Nov 2016 08:53:48 +0000 (09:53 +0100)]
Use consistent variable names

In the X509_NAME_get_index_by_NID.pod example, the initialized variable is called
"loc", but the one used in the for loop is called "lastpos". Make the names match.

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

(cherry picked from commit 4b9c2669f31da26bfe56f629973fa014083dc2a0)

7 years agodomd: Preserve Makefile time when it is unchanged
Orgad Shaneh [Mon, 19 Sep 2016 12:12:08 +0000 (15:12 +0300)]
domd: Preserve Makefile time when it is unchanged

also on systems with makedepend that does not report its version, or that
its version does not contain "gcc" or "clang".

Some versions of makedepends just overwrite Makefile. Preserve the
timestamp of the previous Makefile, and copy it back if it is unchanged.

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

7 years agomklink: Do not needlessly overwrite linked files...
Orgad Shaneh [Sun, 31 Jul 2016 06:18:22 +0000 (09:18 +0300)]
mklink: Do not needlessly overwrite linked files...

... on systems with symlinks.

Creating or overwriting a symlink sets the file ctime to the current time.
This causes needless rebuilds because the time of all the headers is
changed, and apparently make considers the link's time rather than the
time of the target.

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

7 years agodomd: Do not needlessly overwrite Makefiles
Orgad Shaneh [Sun, 31 Jul 2016 12:34:57 +0000 (15:34 +0300)]
domd: Do not needlessly overwrite Makefiles

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

7 years agomklink: Do not needlessly overwrite linked files...
Orgad Shaneh [Sun, 31 Jul 2016 06:18:22 +0000 (09:18 +0300)]
mklink: Do not needlessly overwrite linked files...

... on systems without symlinks.

Overwriting all the headers on each Configure causes full rebuild even if
nothing has changed.

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

7 years agoConfigure: Improve incremental build time
Orgad Shaneh [Sun, 31 Jul 2016 06:13:13 +0000 (09:13 +0300)]
Configure: Improve incremental build time

When Makefile/opensslconf.h is unchanged, don't write it at all.

Currently every time Configure is executed, these files are overwritten.
Makefile leads to regeneration of buildinf.h, and opensslconf.h is itself
a central header.

As a result, Configure triggers full rebuild, even if nothing is changed.

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

7 years agoCheck return value of some BN functions.
Rich Salz [Tue, 15 Nov 2016 23:54:28 +0000 (18:54 -0500)]
Check return value of some BN functions.

Factorise multiple bn_get_top(group->field) calls
Add missing checks on some conditional BN_copy return value
Add missing checks on some BN_copy return value
Add missing checks on a few bn_wexpand return value

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

7 years agoSolution proposal for issue #1647.
Matthias Kraft [Fri, 30 Sep 2016 08:50:17 +0000 (10:50 +0200)]
Solution proposal for issue #1647.

Avoid a memory alignment issue.

Signed-off-by: Matthias Kraft <Matthias.Kraft@softwareag.com>
CLA: trivial
Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1650)

7 years agoUpdate CHANGES and NEWS
Matt Caswell [Thu, 10 Nov 2016 11:49:06 +0000 (11:49 +0000)]
Update CHANGES and NEWS

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agobn/asm/x86_64-mont.pl: fix for CVE-2016-7055 (Low severity).
Andy Polyakov [Sun, 6 Nov 2016 17:33:17 +0000 (18:33 +0100)]
bn/asm/x86_64-mont.pl: fix for CVE-2016-7055 (Low severity).

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

7 years agoMakefile.org: clear APPS environment variable.
Andy Polyakov [Sun, 6 Nov 2016 20:46:11 +0000 (21:46 +0100)]
Makefile.org: clear APPS environment variable.

Build failure was reported in GH#1818 if APPS environment was defined.

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

7 years agoMissed a mention of RT
Rich Salz [Fri, 4 Nov 2016 14:27:47 +0000 (10:27 -0400)]
Missed a mention of RT

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

7 years agoAdd a CHANGES entry for the unrecognised record type change
Matt Caswell [Wed, 2 Nov 2016 22:27:22 +0000 (22:27 +0000)]
Add a CHANGES entry for the unrecognised record type change

Reviewed-by: Tim Hudson <tjh@openssl.org>
7 years agoFail if an unrecognised record type is received
Matt Caswell [Wed, 2 Nov 2016 22:26:17 +0000 (22:26 +0000)]
Fail if an unrecognised record type is received

TLS1.0 and TLS1.1 say you SHOULD ignore unrecognised record types, but
TLS 1.2 says you MUST send an unexpected message alert. We swap to the
TLS 1.2 behaviour for all protocol versions to prevent issues where no
progress is being made and the peer continually sends unrecognised record
types, using up resources processing them.

Issue reported by 郭志攀

Reviewed-by: Tim Hudson <tjh@openssl.org>
7 years agoFix heartbeat_test
Matt Caswell [Wed, 2 Nov 2016 15:36:06 +0000 (15:36 +0000)]
Fix heartbeat_test

The heartbeat_test reaches into the internals of libssl and calls some
internal functions. It then checks the return value to check its what it
expected. However commit fa4c37457 changed the return value of these
internal functions, and now the test is failing.

The solution is to update the test to look for the new return value.

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoSecure our notification email.
Richard Levitte [Tue, 1 Nov 2016 23:09:03 +0000 (00:09 +0100)]
Secure our notification email.

Forks will have to define their own

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1821)
(cherry picked from commit 5e28b1c1e048eef600dc49820934a5e1531186d4)

7 years agoFix grammar-o in CONTRIBUTING
Benjamin Kaduk [Mon, 26 Sep 2016 20:30:42 +0000 (15:30 -0500)]
Fix grammar-o in CONTRIBUTING

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

7 years agoAdd $(EX_LIBS) to the LIBDEPS for libgost.so, just as for all other engines
Richard Levitte [Fri, 28 Oct 2016 21:57:58 +0000 (23:57 +0200)]
Add $(EX_LIBS) to the LIBDEPS for libgost.so, just as for all other engines

Without this, any linker flag the user gave when configuring are ignored.

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

7 years agoImplement length checks as a macro
Matt Caswell [Tue, 25 Oct 2016 10:10:56 +0000 (11:10 +0100)]
Implement length checks as a macro

Replace the various length checks in the extension code with a macro to
simplify the logic.

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoEnsure we have length checks for all extensions
Matt Caswell [Fri, 14 Oct 2016 12:07:00 +0000 (13:07 +0100)]
Ensure we have length checks for all extensions

The previous commit inspired a review of all the length checks for the
extension adding code. This adds more robust checks and adds checks where
some were missing previously. The real solution for this is to use WPACKET
which is currently in master - but that cannot be applied to release
branches.

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoFix length check writing status request extension
Matt Caswell [Fri, 14 Oct 2016 10:49:06 +0000 (11:49 +0100)]
Fix length check writing status request extension

The status request extension did not correctly check its length, meaning
that writing the extension could go 2 bytes beyond the buffer size. In
practice this makes little difference because, due to logic in buffer.c the
buffer is actually over allocated by approximately 5k!

Issue reported by Guido Vranken.

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoFix a double free in ca command line
Matt Caswell [Mon, 10 Oct 2016 15:53:11 +0000 (16:53 +0100)]
Fix a double free in ca command line

Providing a spkac file with no default section causes a double free.

Thanks to Brian Carpenter for reporting this issue.

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
(cherry picked from commit 229bd12487f8576fc088dc4f641950ac33c62033)

7 years agoA zero return from BIO_read/BIO_write() could be retryable
Matt Caswell [Fri, 21 Oct 2016 13:49:33 +0000 (14:49 +0100)]
A zero return from BIO_read/BIO_write() could be retryable

A zero return from BIO_read()/BIO_write() could mean that an IO operation
is retryable. A zero return from SSL_read()/SSL_write() means that the
connection has been closed down (either cleanly or not). Therefore we
should not propagate a zero return value from BIO_read()/BIO_write() back
up the stack to SSL_read()/SSL_write(). This could result in a retryable
failure being treated as fatal.

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoFix typo (reported by Matthias St. Pierre)
Rich Salz [Wed, 26 Oct 2016 15:48:43 +0000 (11:48 -0400)]
Fix typo (reported by Matthias St. Pierre)

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 12a7715e3daed439e46cbed461d2a3d9dfd37c0f)

7 years agoFix leak of secrecy in ecdh_compute_key()
Dr. Matthias St. Pierre [Sat, 15 Oct 2016 22:53:33 +0000 (00:53 +0200)]
Fix leak of secrecy in ecdh_compute_key()

A temporary buffer containing g^xy was not cleared in ecdh_compute_key()
before freeing it, so the shared secret was leaked in memory.

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
7 years agoCorrectly find all critical CRL extensions
Rich Salz [Sat, 22 Oct 2016 07:53:47 +0000 (03:53 -0400)]
Correctly find all critical CRL extensions

Unhandled critical CRL extensions were not detected if they appeared
after the handled ones.  (GitHub issue 1757).  Thanks to John Chuah
for reporting this.

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

7 years agoremove redundant zero assignments
Cristian Stoica [Wed, 17 Aug 2016 11:55:57 +0000 (14:55 +0300)]
remove redundant zero assignments

The structure has already been initialized to zero with memset.
See also commit 64b25758edca688a30f02c260262150f7ad0bc7d (remove 0 assignments)

Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com>
CLA: trivial
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1463)

7 years ago%p takes void*, so make sure to cast arguments to void*
Richard Levitte [Thu, 20 Oct 2016 07:07:06 +0000 (09:07 +0200)]
%p takes void*, so make sure to cast arguments to void*

This avoids failures when configuring with --strict-warnings

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

7 years agoapps: make setup_engine() and release_engine() available always
Richard Levitte [Wed, 19 Oct 2016 17:46:38 +0000 (19:46 +0200)]
apps: make setup_engine() and release_engine() available always

This removes some #ifndef clutter.

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

7 years agoIf an engine comes up explicitely, it must also come down explicitely
Richard Levitte [Wed, 28 Sep 2016 22:40:20 +0000 (00:40 +0200)]
If an engine comes up explicitely, it must also come down explicitely

In apps/apps.c, one can set up an engine with setup_engine().
However, we freed the structural reference immediately, which means
that for engines that don't already have a structural reference
somewhere else (because it has registered at least one cipher or digest
algorithm method, and therefore gets a functional reference through the
ENGINE_set_default() call), we end up returning an invalid reference.

Instead, the function release_engine() is added, and called at the end
of the routines that call setup_engine().

Originally, the ENGINE API wasn't designed for this to happen, an
engine had to register at least one algorithm method, and was
especially expected to register the algorithms corresponding to the
key types that could be stored and hidden in hardware.  However, it
turns out that some engines will not register those algorithms with
the ENGINE_set_{algo}, ENGINE_set_cipher or ENGINE_set_digest
functions, as they only want the methods to be used for keys, not as
general crypto accelerator methods.  That may cause ENGINE_set_default()
to do nothing, and no functional reference is therefore made, leading
to a premature deallocation of the engine and it thereby becoming
unavailable when trying to fetch a key.

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

7 years agoFix no-des
Richard Levitte [Wed, 19 Oct 2016 20:54:06 +0000 (22:54 +0200)]
Fix no-des

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

7 years agoMake 'openssl prime ""' not segfault
Richard Levitte [Thu, 6 Oct 2016 07:31:34 +0000 (09:31 +0200)]
Make 'openssl prime ""' not segfault

Fixes RT#4699

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

7 years agoFix strict-warnings build
Patrick Steuer [Mon, 17 Oct 2016 08:30:33 +0000 (10:30 +0200)]
Fix strict-warnings build

crypto/evp/e_aes.c: Types of inp and out parameters of AES_xts_en/decrypt
functions need to be changed from char to unsigned char to avoid build
error due to -Werror=incompatible-pointer-types.

crypto/aes/asm/aes-s390x.pl: Comments need to reflect the above change.

Signed-off-by: Patrick Steuer <psteuer@mail.de>
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
CLA: trivial

7 years agoFix strict-warnings build
Patrick Steuer [Mon, 17 Oct 2016 08:24:49 +0000 (10:24 +0200)]
Fix strict-warnings build

crypto/s390xcap.c: cryptlib.h needs to be included for OPENSSL_cpuid_setup
function prototype is located there to avoid build error due to
-Werror=missing-prototypes.

Signed-off-by: Patrick Steuer <psteuer@mail.de>
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
CLA: trivial

7 years agoFix signatures of EVP_Digest{Sign,Verify}Update
Steven Fackler [Sat, 15 Oct 2016 20:01:25 +0000 (13:01 -0700)]
Fix signatures of EVP_Digest{Sign,Verify}Update

These are implemented as macros delegating to `EVP_DigestUpdate`, which
takes a `size_t` as its third argument, not an `unsigned int`.

CLA: trivial

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 8bdce8d160e29b4e1b80fec31f618d85d8c2b7a8)

7 years agoEnsure we handle len == 0 in ERR_err_string_n
Matt Caswell [Wed, 12 Oct 2016 15:43:03 +0000 (16:43 +0100)]
Ensure we handle len == 0 in ERR_err_string_n

If len == 0 in a call to ERR_error_string_n() then we can read beyond the
end of the buffer. Really applications should not be calling this function
with len == 0, but we shouldn't be letting it through either!

Thanks to Agostino Sarubbo for reporting this issue. Agostino's blog on
this issue is available here:
https://blogs.gentoo.org/ago/2016/10/14/openssl-libcrypto-stack-based-buffer-overflow-in-err_error_string_n-err-c/

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit e5c1361580d8de79682958b04a5f0d262e680f8b)

7 years agoDegrade 3DES to MEDIUM in SSL2
Vitezslav Cizek [Mon, 10 Oct 2016 14:41:57 +0000 (16:41 +0200)]
Degrade 3DES to MEDIUM in SSL2

The SWEET32 fix moved 3DES from HIGH to MEDIUM, but omitted SSL2.

CLA: trivial
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1683)

7 years agoRT is put out to pasture
Rich Salz [Wed, 12 Oct 2016 19:49:06 +0000 (15:49 -0400)]
RT is put out to pasture

Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1702)
(cherry picked from commit 7954dced19a7e59e7055eab95a981fa943c7d100)

7 years agoAdd missing error string for SSL_R_TOO_MANY_WARN_ALERTS
Kurt Cancemi [Thu, 22 Sep 2016 22:05:37 +0000 (18:05 -0400)]
Add missing error string for SSL_R_TOO_MANY_WARN_ALERTS

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
7 years agoapps/apps.c: initialize and de-initialize engine around key loading
Richard Levitte [Wed, 28 Sep 2016 19:28:00 +0000 (21:28 +0200)]
apps/apps.c: initialize and de-initialize engine around key loading

Before loading a key from an engine, it may need to be initialized.
When done loading the key, we must de-initialize the engine.
(if the engine is already initialized somehow, only the reference
counter will be incremented then decremented)

Reviewed-by: Stephen Henson <steve@openssl.org>
(cherry picked from commit 49e476a5382602d0bad1139d6f1f66ddbc7959d6)

7 years agoRevert "Call ENGINE_init() before trying to use keys from engine"
Rich Salz [Wed, 28 Sep 2016 18:39:32 +0000 (14:39 -0400)]
Revert "Call ENGINE_init() before trying to use keys from engine"

This reverts commit 4badd2b3c29c2c6c551c737c07a429a53d9d1a0d.
This fails to call ENGINE_finish; an alternate fix is coming.

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
7 years agoCall ENGINE_init() before trying to use keys from engine
David Woodhouse [Wed, 28 Sep 2016 13:31:22 +0000 (14:31 +0100)]
Call ENGINE_init() before trying to use keys from engine

Things like 'openssl s_client' only ever worked with keys from an engine
which provided a default generic method for some key type — because it
called ENGINE_set_default() and that ended up being an implicit
initialisation and functional refcount.

But an engine which doesn't provide generic methods doesn't get
initialised, and then when you try to use it you get an error:

cannot load client certificate private key file from engine
140688147056384:error:26096075:engine routines:ENGINE_load_private_key:not initialised:crypto/engine/eng_pkey.c:66:
unable to load client certificate private key file

cf. https://github.com/OpenSC/libp11/issues/107 (in which we discover
that engine_pkcs11 *used* to provide generic methods that OpenSSL would
try to use for ephemeral DH keys when negotiating ECDHE cipher suites in
TLS, and that didn't work out very well.)

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

7 years agoFix NEWS error
Matt Caswell [Mon, 26 Sep 2016 10:20:11 +0000 (11:20 +0100)]
Fix NEWS error

The NEWS file referenced the wrong CVE for 1.0.2

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoPrepare for 1.0.2k-dev
Matt Caswell [Mon, 26 Sep 2016 09:50:48 +0000 (10:50 +0100)]
Prepare for 1.0.2k-dev

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoPrepare for 1.0.2j release OpenSSL_1_0_2j
Matt Caswell [Mon, 26 Sep 2016 09:49:49 +0000 (10:49 +0100)]
Prepare for 1.0.2j release

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoUpdate CHANGES and NEWS for the new release
Matt Caswell [Mon, 26 Sep 2016 08:51:30 +0000 (09:51 +0100)]
Update CHANGES and NEWS for the new release

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoAdd some sanity checks when checking CRL scores
Matt Caswell [Mon, 22 Aug 2016 23:01:57 +0000 (00:01 +0100)]
Add some sanity checks when checking CRL scores

Note: this was accidentally omitted from OpenSSL 1.0.2 branch.
Without this fix any attempt to use CRLs will crash.

CVE-2016-7052

Thanks to Bruce Stephens and Thomas Jakobi for reporting this issue.

Reviewed-by: Stephen Henson <steve@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoFix build with no-nextprotoneg
Dirk Feytons [Thu, 22 Sep 2016 14:17:45 +0000 (16:17 +0200)]
Fix build with no-nextprotoneg

Add a missing ifdef. Same change is already present in master.

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

7 years agoFix typo introduced by a03f81f4
Rich Salz [Thu, 22 Sep 2016 12:47:45 +0000 (08:47 -0400)]
Fix typo introduced by a03f81f4

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoPrepare for 1.0.2j-dev
Matt Caswell [Thu, 22 Sep 2016 10:25:49 +0000 (11:25 +0100)]
Prepare for 1.0.2j-dev

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoPrepare for 1.0.2i release OpenSSL_1_0_2i
Matt Caswell [Thu, 22 Sep 2016 10:24:53 +0000 (11:24 +0100)]
Prepare for 1.0.2i release

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoUpdates CHANGES and NEWS for new release
Matt Caswell [Wed, 21 Sep 2016 20:59:49 +0000 (21:59 +0100)]
Updates CHANGES and NEWS for new release

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoAvoid KCI attack for GOST
Dmitry Belyavsky [Mon, 19 Sep 2016 15:05:53 +0000 (16:05 +0100)]
Avoid KCI attack for GOST

Russian GOST ciphersuites are vulnerable to the KCI attack because they use
long-term keys to establish the connection when ssl client authorization is
on. This change brings the GOST implementation into line with the latest
specs in order to avoid the attack. It should not break backwards
compatibility.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
7 years agoFix a mem leak in NPN handling
Matt Caswell [Fri, 9 Sep 2016 09:53:39 +0000 (10:53 +0100)]
Fix a mem leak in NPN handling

If a server sent multiple NPN extensions in a single ClientHello then a
mem leak can occur. This will only happen where the client has requested
NPN in the first place. It does not occur during renegotiation. Therefore
the maximum that could be leaked in a single connection with a malicious
server is 64k (the maximum size of the ServerHello extensions section). As
this is client side, only occurs if NPN has been requested and does not
occur during renegotiation this is unlikely to be exploitable.

Issue reported by Shi Lei.

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoFix OCSP Status Request extension unbounded memory growth
Matt Caswell [Fri, 9 Sep 2016 09:08:45 +0000 (10:08 +0100)]
Fix OCSP Status Request extension unbounded memory growth

A malicious client can send an excessively large OCSP Status Request
extension. If that client continually requests renegotiation,
sending a large OCSP Status Request extension each time, then there will
be unbounded memory growth on the server. This will eventually lead to a
Denial Of Service attack through memory exhaustion. Servers with a
default configuration are vulnerable even if they do not support OCSP.
Builds using the "no-ocsp" build time option are not affected.

I have also checked other extensions to see if they suffer from a similar
problem but I could not find any other issues.

CVE-2016-6304

Issue reported by Shi Lei.

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agomk1mf.pl: check for no-tls1 here as well
Richard Levitte [Thu, 22 Sep 2016 08:01:38 +0000 (10:01 +0200)]
mk1mf.pl: check for no-tls1 here as well

Reviewed-by: Matt Caswell <matt@openssl.org>
7 years agoDon't allow too many consecutive warning alerts
Matt Caswell [Wed, 21 Sep 2016 13:48:16 +0000 (14:48 +0100)]
Don't allow too many consecutive warning alerts

Certain warning alerts are ignored if they are received. This can mean that
no progress will be made if one peer continually sends those warning alerts.
Implement a count so that we abort the connection if we receive too many.

Issue reported by Shi Lei.

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoMake message buffer slightly larger than message.
Dr. Stephen Henson [Wed, 21 Sep 2016 12:26:01 +0000 (13:26 +0100)]
Make message buffer slightly larger than message.

Grow TLS/DTLS 16 bytes more than strictly necessary as a precaution against
OOB reads. In most cases this will have no effect because the message buffer
will be large enough already.

Reviewed-by: Matt Caswell <matt@openssl.org>
7 years agoUse SSL3_HM_HEADER_LENGTH instead of 4.
Dr. Stephen Henson [Wed, 21 Sep 2016 11:54:13 +0000 (12:54 +0100)]
Use SSL3_HM_HEADER_LENGTH instead of 4.

Reviewed-by: Matt Caswell <matt@openssl.org>
7 years agoRemove unnecessary check.
Dr. Stephen Henson [Wed, 21 Sep 2016 11:57:01 +0000 (12:57 +0100)]
Remove unnecessary check.

The overflow check will never be triggered because the
the n2l3 result is always less than 2^24.

Reviewed-by: Matt Caswell <matt@openssl.org>
7 years agoDcoument -alpn flag
Rich Salz [Wed, 21 Sep 2016 14:59:15 +0000 (10:59 -0400)]
Dcoument -alpn flag

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 776e15f9393a9e3083bec60a8da376ce2fe1e97e)

7 years agoGH1555: Don't bump size on realloc failure
Rich Salz [Fri, 9 Sep 2016 14:52:59 +0000 (10:52 -0400)]
GH1555: Don't bump size on realloc failure

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 6fcace45bda108ad4d3f95261494dd479720d92c)

7 years agoapps/apps.c: include sys/socket.h to declare recv()
Richard Levitte [Tue, 20 Sep 2016 16:43:24 +0000 (18:43 +0200)]
apps/apps.c: include sys/socket.h to declare recv()

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit a19228b7f4fc6fcb49713455b3caedbc24fb0b01)

7 years agoFix small OOB reads.
Dr. Stephen Henson [Sat, 17 Sep 2016 11:36:58 +0000 (12:36 +0100)]
Fix small OOB reads.

In ssl3_get_client_certificate, ssl3_get_server_certificate and
ssl3_get_certificate_request check we have enough room
before reading a length.

Thanks to Shi Lei (Gear Team, Qihoo 360 Inc.) for reporting these bugs.

CVE-2016-6306

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
7 years agoFix a missing NULL check in dsa_builtin_paramgen
Matt Caswell [Wed, 14 Sep 2016 12:27:59 +0000 (13:27 +0100)]
Fix a missing NULL check in dsa_builtin_paramgen

We should check the last BN_CTX_get() call to ensure that it isn't NULL
before we try and use any of the allocated BIGNUMs.

Issue reported by Shi Lei.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 1ff7425d6130380bb00d3e64739633a4b21b11a3)

7 years agoRT4669: dgst can only sign/verify one file
Richard Levitte [Tue, 20 Sep 2016 19:41:58 +0000 (21:41 +0200)]
RT4669: dgst can only sign/verify one file

Check arg count and print an error message.

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoinitialize the RSA struct to 0.
Marcus Meissner [Tue, 6 Sep 2016 09:01:21 +0000 (11:01 +0200)]
initialize the RSA struct to 0.

This helps with program code linked against static builds accessing a uninitialized ->engine pointer.

CLA: none; trivial

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

7 years agoupdate default dependencies
Dr. Stephen Henson [Thu, 15 Sep 2016 22:49:41 +0000 (23:49 +0100)]
update default dependencies

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoRevert "Abort on unrecognised warning alerts"
Matt Caswell [Thu, 15 Sep 2016 19:53:09 +0000 (20:53 +0100)]
Revert "Abort on unrecognised warning alerts"

This reverts commit 15d81749322c3498027105f8ee44e8c25479d475.

There were some unexpected side effects to this commit, e.g. in SSLv3 a
warning alert gets sent "no_certificate" if a client does not send a
Certificate during Client Auth. With the above commit this causes the
connection to abort, which is incorrect. There may be some other edge cases
like this so we need to have a rethink on this.

Reviewed-by: Tim Hudson <tjh@openssl.org>
7 years agoFinally, make sure vms_term_sock.c is built
Richard Levitte [Wed, 14 Sep 2016 21:37:53 +0000 (23:37 +0200)]
Finally, make sure vms_term_sock.c is built

Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoRefactor to avoid unnecessary preprocessor logic
Richard Levitte [Thu, 15 Sep 2016 07:45:57 +0000 (09:45 +0200)]
Refactor to avoid unnecessary preprocessor logic

Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoReformat to fit OpenSSL source code standards
Richard Levitte [Wed, 14 Sep 2016 18:54:30 +0000 (20:54 +0200)]
Reformat to fit OpenSSL source code standards

Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoRemove entirely unnecessary pointer size guards
Richard Levitte [Wed, 14 Sep 2016 18:53:06 +0000 (20:53 +0200)]
Remove entirely unnecessary pointer size guards

Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoAdd copyright and license on apps/vms_term_sock.[ch]
Richard Levitte [Wed, 14 Sep 2016 18:52:03 +0000 (20:52 +0200)]
Add copyright and license on apps/vms_term_sock.[ch]

Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoVSI submission: redirect terminal input through socket
Richard Levitte [Wed, 3 Aug 2016 19:16:43 +0000 (21:16 +0200)]
VSI submission: redirect terminal input through socket

This is needed, because on VMS, select() can only be used on sockets.  being
able to use select() on all kinds of file descriptors is unique to Unix.

So, the solution for VMS is to create a layer that translates input from
standard input to socket communication.

Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoFix memory leak on realloc error.
Dr. Stephen Henson [Wed, 14 Sep 2016 22:42:55 +0000 (23:42 +0100)]
Fix memory leak on realloc error.

Backport leak fix from master branch.

Thanks to Shi Lei (Gear Team, Qihoo 360 Inc.) for reporting this bug.

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoFix memory leak on error.
Dr. Stephen Henson [Wed, 14 Sep 2016 22:54:12 +0000 (23:54 +0100)]
Fix memory leak on error.

Thanks to Shi Lei (Gear Team, Qihoo 360 Inc.) for reporting this bug.

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoVMS: only use _realloc32 with /POINTER_SIZE=32
Richard Levitte [Tue, 6 Sep 2016 15:39:35 +0000 (17:39 +0200)]
VMS: only use _realloc32 with /POINTER_SIZE=32

This fixes the following error when building with no particular pointer size
is specified (implied 32 bit):

    static void *(*realloc_func) (void *, size_t) = realloc;
    ................................................^
    %CC-E-UNDECLARED, In the initializer for realloc_func, "_realloc32" is not declared.
    at line number 93 in file DEV:[OPENSSL102.crypto]mem.c;1

Reviewed-by: Andy Polyakov <appro@openssl.org>
7 years agoAdd some sanity checks around usage of t_fromb64()
Matt Caswell [Thu, 8 Sep 2016 13:32:27 +0000 (14:32 +0100)]
Add some sanity checks around usage of t_fromb64()

The internal SRP function t_fromb64() converts from base64 to binary. It
does not validate that the size of the destination is sufficiently large -
that is up to the callers. In some places there was such a check, but not
in others.

Add an argument to t_fromb64() to provide the size of the destination
buffer and validate that we don't write too much data. Also add some sanity
checks to the callers where appropriate.

With thanks to Shi Lei for reporting this issue.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 73f0df8331910d6726d45ecaab12bd93cc48b4e2)

7 years agoAbort on unrecognised warning alerts
Matt Caswell [Mon, 12 Sep 2016 10:04:51 +0000 (11:04 +0100)]
Abort on unrecognised warning alerts

A peer continually sending unrecognised warning alerts could mean that we
make no progress on a connection. We should abort rather than continuing if
we receive an unrecognised warning alert.

Thanks to Shi Lei for reporting this issue.

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoAdd enginesdir to libcrypto.pc pkg-config file
Richard Levitte [Mon, 12 Sep 2016 14:29:39 +0000 (16:29 +0200)]
Add enginesdir to libcrypto.pc pkg-config file

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