openssl.git
7 years agoFix a bug in TLSProxy where zero length messages were not being recorded
Matt Caswell [Tue, 22 Nov 2016 16:16:23 +0000 (16:16 +0000)]
Fix a bug in TLSProxy where zero length messages were not being recorded

Perl changes reviewed by Richard Levitte. Non-perl changes reviewed by Rich
Salz

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoAdd a test to check messsages sent are the ones we expect
Matt Caswell [Tue, 22 Nov 2016 16:16:11 +0000 (16:16 +0000)]
Add a test to check messsages sent are the ones we expect

Repeat for various handshake types

Perl changes reviewed by Richard Levitte. Non-perl changes reviewed by Rich
Salz

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoSupport renegotiation in TLSProxy
Matt Caswell [Tue, 22 Nov 2016 13:43:50 +0000 (13:43 +0000)]
Support renegotiation in TLSProxy

Perl changes reviewed by Richard Levitte. Non-perl changes reviewed by Rich
Salz

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoAdd tests for new extension code
Matt Caswell [Mon, 28 Nov 2016 22:39:23 +0000 (22:39 +0000)]
Add tests for new extension code

Extend test_tls13messages to additionally check the expected extensions
under different options given to s_client/s_server.

Perl changes reviewed by Richard Levitte. Non-perl changes reviewed by Rich
Salz

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoSplit ServerHello extensions
Matt Caswell [Mon, 28 Nov 2016 16:45:52 +0000 (16:45 +0000)]
Split ServerHello extensions

In TLS1.3 some ServerHello extensions remain in the ServerHello, while
others move to the EncryptedExtensions message. This commit performs that
move.

Perl changes reviewed by Richard Levitte. Non-perl changes reviewed by Rich
Salz

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoMove ServerHello extension parsing into the new extension framework
Matt Caswell [Mon, 28 Nov 2016 16:15:51 +0000 (16:15 +0000)]
Move ServerHello extension parsing into the new extension framework

Perl changes reviewed by Richard Levitte. Non-perl changes reviewed by Rich
Salz

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoAvoid repeatedly scanning the list of extensions
Matt Caswell [Mon, 28 Nov 2016 09:31:59 +0000 (09:31 +0000)]
Avoid repeatedly scanning the list of extensions

Because extensions were keyed by type which is sparse, we were continually
scanning the list to find the one we wanted. The way we stored them also
had the side effect that we were running initialisers/finalisers in a
different oder to the parsers. In this commit we change things so that we
instead key on an index value for each extension.

Perl changes reviewed by Richard Levitte. Non-perl changes reviewed by Rich
Salz

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoSimplify ClientHello extension parsing
Matt Caswell [Sat, 26 Nov 2016 11:45:02 +0000 (11:45 +0000)]
Simplify ClientHello extension parsing

Remove some functions that are no longer needed now that we have the new
extension framework.

Perl changes reviewed by Richard Levitte. Non-perl changes reviewed by Rich
Salz

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoMove ALPN processing into an extension finalisation function
Matt Caswell [Sat, 26 Nov 2016 11:22:50 +0000 (11:22 +0000)]
Move ALPN processing into an extension finalisation function

Perl changes reviewed by Richard Levitte. Non-perl changes reviewed by Rich
Salz

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoProvide server side extension init and finalisation functions
Matt Caswell [Fri, 25 Nov 2016 23:19:56 +0000 (23:19 +0000)]
Provide server side extension init and finalisation functions

Perl changes reviewed by Richard Levitte. Non-perl changes reviewed by Rich
Salz

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoAdd an extension initilisation and finalisation capability
Matt Caswell [Fri, 25 Nov 2016 17:52:35 +0000 (17:52 +0000)]
Add an extension initilisation and finalisation capability

Perl changes reviewed by Richard Levitte. Non-perl changes reviewed by Rich
Salz

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoMove client construction of ClientHello extensions into new framework
Matt Caswell [Fri, 25 Nov 2016 16:28:02 +0000 (16:28 +0000)]
Move client construction of ClientHello extensions into new framework

Perl changes reviewed by Richard Levitte. Non-perl changes reviewed by Rich
Salz

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoMove client parsing of ServerHello extensions into new framework
Matt Caswell [Fri, 25 Nov 2016 12:34:29 +0000 (12:34 +0000)]
Move client parsing of ServerHello extensions into new framework

Perl changes reviewed by Richard Levitte. Non-perl changes reviewed by Rich
Salz

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoRename some functions
Matt Caswell [Fri, 25 Nov 2016 10:34:35 +0000 (10:34 +0000)]
Rename some functions

The _clienthello_ in the extensions parsing functions is overly specific.
Better to keep the convention to just _client_

Perl changes reviewed by Richard Levitte. Non-perl changes reviewed by Rich
Salz

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoMove ServerHello extension construction into the new extensions framework
Matt Caswell [Fri, 25 Nov 2016 10:22:02 +0000 (10:22 +0000)]
Move ServerHello extension construction into the new extensions framework

This lays the foundation for a later move to have the extensions built and
placed into the correct message for TLSv1.3 (e.g. ServerHello or
EncryptedExtensions).

Perl changes reviewed by Richard Levitte. Non-perl changes reviewed by Rich
Salz

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoSplit extensions code into core extensions and server extensions code
Matt Caswell [Thu, 24 Nov 2016 22:54:59 +0000 (22:54 +0000)]
Split extensions code into core extensions and server extensions code

Later we will have client extensions code too.

Perl changes reviewed by Richard Levitte. Non-perl changes reviewed by Rich
Salz

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoAdd extensions construction support
Matt Caswell [Thu, 24 Nov 2016 18:25:10 +0000 (18:25 +0000)]
Add extensions construction support

Perl changes reviewed by Richard Levitte. Non-perl changes reviewed by Rich
Salz

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoContinue the extensions refactor
Matt Caswell [Thu, 24 Nov 2016 18:02:12 +0000 (18:02 +0000)]
Continue the extensions refactor

Add support for construction of extensions

Perl changes reviewed by Richard Levitte. Non-perl changes reviewed by Rich
Salz

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoRefactor ClientHello extension parsing
Matt Caswell [Thu, 24 Nov 2016 16:59:48 +0000 (16:59 +0000)]
Refactor ClientHello extension parsing

This builds on the work started in 1ab3836b3 and extends is so that
each extension has its own identified parsing functions, as well as an
allowed context identifying which messages and protocols it is relevant for.
Subsequent commits will do a similar job for the ServerHello extensions.
This will enable us to have common functions for processing extension blocks
no matter which of the multiple messages they are received from. In TLSv1.3
a number of different messages have extension blocks, and some extensions
have moved from one message to another when compared to TLSv1.2.

Perl changes reviewed by Richard Levitte. Non-perl changes reviewed by Rich
Salz

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoVerify that extensions are used in the correct context
Matt Caswell [Thu, 24 Nov 2016 11:14:56 +0000 (11:14 +0000)]
Verify that extensions are used in the correct context

Perl changes reviewed by Richard Levitte. Non-perl changes reviewed by Rich
Salz

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoAdd some missing extensions to SSL_extension_supported()
Matt Caswell [Thu, 24 Nov 2016 11:13:35 +0000 (11:13 +0000)]
Add some missing extensions to SSL_extension_supported()

Perl changes reviewed by Richard Levitte. Non-perl changes reviewed by Rich
Salz

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoMove tls_collect_extensions() into a separate file
Matt Caswell [Wed, 23 Nov 2016 17:38:31 +0000 (17:38 +0000)]
Move tls_collect_extensions() into a separate file

Subsequent commits will pull other extensions code into this file.

Perl changes reviewed by Richard Levitte. Non-perl changes reviewed by Rich
Salz

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoAdd EncryptedExtensions message
Matt Caswell [Wed, 23 Nov 2016 15:20:22 +0000 (15:20 +0000)]
Add EncryptedExtensions message

At this stage the message is just empty. We need to fill it in with
extension data.

Perl changes reviewed by Richard Levitte. Non-perl changes reviewed by Rich
Salz

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoSend and Receive a TLSv1.3 format ServerHello
Matt Caswell [Mon, 7 Nov 2016 13:50:43 +0000 (13:50 +0000)]
Send and Receive a TLSv1.3 format ServerHello

There are some minor differences in the format of a ServerHello in TLSv1.3.

Perl changes reviewed by Richard Levitte. Non-perl changes reviewed by Rich
Salz

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
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)

7 years agoIn UI_OpenSSL's open(), generate an error on unknown errno
Richard Levitte [Thu, 8 Dec 2016 10:16:37 +0000 (11:16 +0100)]
In UI_OpenSSL's open(), generate an error on unknown errno

TTY_get() sometimes surprises us with new errno values to determine if
we have a controling terminal or not.  This generated error is a
helpful tool to figure out that this was what happened and what the
unknown value is.

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

7 years agoMake sure that password_callback exercises UI
Richard Levitte [Thu, 8 Dec 2016 00:27:31 +0000 (01:27 +0100)]
Make sure that password_callback exercises UI

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

7 years agoAdd a test for the UI API
Richard Levitte [Wed, 7 Dec 2016 21:44:47 +0000 (22:44 +0100)]
Add a test for the UI API

The best way to test the UI interface is currently by using an openssl
command that uses password_callback.  The only one that does this is
'genrsa'.
Since password_callback uses a UI method derived from UI_OpenSSL(), it
ensures that one gets tested well enough as well.

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

7 years agoUI_process() didn't generate errors
Richard Levitte [Wed, 7 Dec 2016 15:36:44 +0000 (16:36 +0100)]
UI_process() didn't generate errors

Since there are many parts of UI_process() that can go wrong, it isn't
very helpful to only return -1 with no further explanation.  With this
change, the error message will at least show which part went wrong.

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

7 years agoAlso set the CXXFLAG to the user supplied flags
Kurt Roeckx [Sat, 3 Dec 2016 15:57:04 +0000 (16:57 +0100)]
Also set the CXXFLAG to the user supplied flags

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

7 years agotravis: Use no-shared for the FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION targets
Kurt Roeckx [Sat, 3 Dec 2016 13:37:16 +0000 (14:37 +0100)]
travis: Use no-shared for the FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION targets

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

7 years agoChange various repeated wr[someindex]/pkt[someindex] references to a pointer
Matt Caswell [Mon, 5 Dec 2016 10:27:04 +0000 (10:27 +0000)]
Change various repeated wr[someindex]/pkt[someindex] references to a pointer

Improves the readability of the code, and reduces the liklihood of errors.
Also made a few minor style changes.

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoVarious style fixes from the TLSv1.3 record changes review
Matt Caswell [Fri, 2 Dec 2016 11:10:16 +0000 (11:10 +0000)]
Various style fixes from the TLSv1.3 record changes review

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoChange various repeated rr[someindex] references to a pointer
Matt Caswell [Fri, 2 Dec 2016 11:09:16 +0000 (11:09 +0000)]
Change various repeated rr[someindex] references to a pointer

Improves the readability of the code, and reduces the liklihood of errors.

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoEnsure compressdata is always initialised
Matt Caswell [Thu, 1 Dec 2016 10:20:59 +0000 (10:20 +0000)]
Ensure compressdata is always initialised

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoAdd a TLS1.3 TODO for the msg callback
Matt Caswell [Mon, 21 Nov 2016 17:11:51 +0000 (17:11 +0000)]
Add a TLS1.3 TODO for the msg callback

At the moment the msg callback only received the record header with the
outer record type in it. We never pass the inner record type - we probably
need to at some point.

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoAdd more TLS1.3 record tests
Matt Caswell [Mon, 21 Nov 2016 16:22:00 +0000 (16:22 +0000)]
Add more TLS1.3 record tests

Add some tests for the new record construction

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoUpdate the record layer to use TLSv1.3 style record construction
Matt Caswell [Fri, 18 Nov 2016 23:44:09 +0000 (23:44 +0000)]
Update the record layer to use TLSv1.3 style record construction

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoConvert TLS Record receipt to use PACKET
Matt Caswell [Fri, 18 Nov 2016 17:06:14 +0000 (17:06 +0000)]
Convert TLS Record receipt to use PACKET

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoConvert TLS record construction to use WPACKET
Matt Caswell [Fri, 18 Nov 2016 16:35:46 +0000 (16:35 +0000)]
Convert TLS record construction to use WPACKET

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoAdd an ability to find out the current write location from a WPACKET
Matt Caswell [Fri, 18 Nov 2016 16:34:01 +0000 (16:34 +0000)]
Add an ability to find out the current write location from a WPACKET

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoRestore last-resort expired untrusted intermediate issuers
Viktor Dukhovni [Fri, 25 Nov 2016 05:38:04 +0000 (00:38 -0500)]
Restore last-resort expired untrusted intermediate issuers

Reviewed-by: Matt Caswell <matt@openssl.org>
7 years agoRun a some tests with -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
Kurt Roeckx [Fri, 2 Dec 2016 18:49:34 +0000 (19:49 +0100)]
Run a some tests with -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION

The fuzzers use -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION, and actually
get different results based on that. We should have at least some
targets that actually fully use the fuzz corpora.

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

7 years agoMake the fuzzers more reproducible
Kurt Roeckx [Fri, 2 Dec 2016 18:34:54 +0000 (19:34 +0100)]
Make the fuzzers more reproducible

We want to be in the same global state each time we come in
FuzzerTestOneInput(). There are various reasons why we might not be that
include:
- Initialization that happens on first use. This is mostly the
  RUN_ONCE() things, or loading of error strings.
- Results that get cached. For instance a stack that is sorted, RSA
  blinding that has been set up, ...

So I try to trigger as much as possible in FuzzerInitialize(), and for
things I didn't find out how to trigger this it needs to happen in
FuzzerTestOneInput().

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

7 years agoMove libfuzzer sanitizer options to README
Kurt Roeckx [Fri, 2 Dec 2016 18:26:31 +0000 (19:26 +0100)]
Move libfuzzer sanitizer options to README

This is something you might want to change depending on the version to
use, there is no point in us fixing this to something.

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

7 years agoCMS fuzzer: also use id2
Kurt Roeckx [Sat, 19 Nov 2016 16:50:33 +0000 (17:50 +0100)]
CMS fuzzer: also use id2

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

7 years agoMake the random number generator predictable when fuzzing.
Kurt Roeckx [Sat, 19 Nov 2016 16:20:34 +0000 (17:20 +0100)]
Make the random number generator predictable when fuzzing.

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

7 years agoUse 8bit-counters when using libfuzzer
Kurt Roeckx [Sat, 19 Nov 2016 16:15:43 +0000 (17:15 +0100)]
Use 8bit-counters when using libfuzzer

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

7 years agobndiv fuzzer: move new and free calls to the init and cleanup function.
Kurt Roeckx [Sat, 19 Nov 2016 20:00:21 +0000 (21:00 +0100)]
bndiv fuzzer: move new and free calls to the init and cleanup function.

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

7 years agobignum fuzzer: move new and free calls to the init and cleanup function.
Kurt Roeckx [Sat, 19 Nov 2016 18:26:19 +0000 (19:26 +0100)]
bignum fuzzer: move new and free calls to the init and cleanup function.

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

7 years agoasn1parse: create the out bio during init, free it during cleanup
Kurt Roeckx [Sat, 19 Nov 2016 16:24:39 +0000 (17:24 +0100)]
asn1parse: create the out bio during init, free it during cleanup

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

7 years agoAdd a FuzzerClean() function
Kurt Roeckx [Sat, 19 Nov 2016 16:13:10 +0000 (17:13 +0100)]
Add a FuzzerClean() function

This allows to free everything we allocated, so we can detect memory
leaks.

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

7 years agoFuzzerInitialize always exists
Kurt Roeckx [Sat, 19 Nov 2016 16:12:11 +0000 (17:12 +0100)]
FuzzerInitialize always exists

There was a time it could be NULL, but that was changed to always have it.

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

7 years agoFix formatting of fuzzers
Kurt Roeckx [Sat, 19 Nov 2016 16:10:35 +0000 (17:10 +0100)]
Fix formatting of fuzzers

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

7 years agoFix a typo in bio_read_intern
Matt Caswell [Thu, 1 Dec 2016 13:24:09 +0000 (13:24 +0000)]
Fix a typo in bio_read_intern

Reviewed-by: Stephen Henson <steve@openssl.org>
7 years agoMake refdata in tls13encryptest static
Matt Caswell [Wed, 30 Nov 2016 10:57:10 +0000 (10:57 +0000)]
Make refdata in tls13encryptest static

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoConvert tls13encryptiontest so that we pass around a pointer not an index
Matt Caswell [Wed, 30 Nov 2016 10:53:57 +0000 (10:53 +0000)]
Convert tls13encryptiontest so that we pass around a pointer not an index

We also split the long string literals into 3 to avoid problems where we
go over the 509 character limit.

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoFix some style issues in the TLSv1.3 nonce construction code
Matt Caswell [Tue, 29 Nov 2016 23:27:27 +0000 (23:27 +0000)]
Fix some style issues in the TLSv1.3 nonce construction code

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoFix a double free in tls13encryptiontest
Matt Caswell [Tue, 22 Nov 2016 10:12:55 +0000 (10:12 +0000)]
Fix a double free in tls13encryptiontest

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoFix a travis compilation error
Matt Caswell [Mon, 21 Nov 2016 17:26:22 +0000 (17:26 +0000)]
Fix a travis compilation error

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoAdd a test for TLSv1.3 encryption using the new nonce construction
Matt Caswell [Thu, 17 Nov 2016 22:58:46 +0000 (22:58 +0000)]
Add a test for TLSv1.3 encryption using the new nonce construction

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoUse the TLSv1.3 nonce construction
Matt Caswell [Thu, 17 Nov 2016 18:00:17 +0000 (18:00 +0000)]
Use the TLSv1.3 nonce construction

This updates the record layer to use the TLSv1.3 style nonce construciton.
It also updates TLSProxy and ossltest to be able to recognise the new
layout.

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoFix mac-then-encrypt test with enable-tls1_3
Matt Caswell [Tue, 29 Nov 2016 09:49:04 +0000 (09:49 +0000)]
Fix mac-then-encrypt test with enable-tls1_3

Commit b3618f44 added a test for mac-then-encrypt. However the test fails
when running with "enable-tls1_3". The problem is that the test creates a
connection, which ends up being TLSv1.3. However it also restricts the
ciphers to a single mac-then-encrypt ciphersuite that is not TLSv1.3
compatible so the connection aborts and the test fails. Mac-then-encrypt
is not relevant to TLSv1.3, so the test should disable that protocol
version.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
7 years agoEnsure we are in accept state in DTLSv1_listen
Matt Caswell [Wed, 23 Nov 2016 23:03:13 +0000 (23:03 +0000)]
Ensure we are in accept state in DTLSv1_listen

Calling SSL_set_accept_state() after DTLSv1_listen() clears the state, so
SSL_accept() no longer works. In 1.0.2 calling DTLSv1_listen() would set
the accept state automatically. We should still do that.

Fixes #1989

Reviewed-by: Andy Polyakov <appro@openssl.org>
7 years agoMake bntest be (mostly) file-based.
Rich Salz [Mon, 28 Nov 2016 17:26:05 +0000 (12:26 -0500)]
Make bntest be (mostly) file-based.

Test suite used from boring, written by David Benjamin.
Test driver converted from C++ to C.
Added a Perl program to check the testsuite file.
Extensive review feedback incorporated (thanks folks).

Reviewed-by: Emilia Käsper <emilia@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoTest mac-then-encrypt
Emilia Kasper [Fri, 25 Nov 2016 16:05:30 +0000 (17:05 +0100)]
Test mac-then-encrypt

Verify that the encrypt-then-mac negotiation is handled
correctly. Additionally, when compiled with no-asm, this test ensures
coverage for the constant-time MAC copying code in
ssl3_cbc_copy_mac. The proxy-based CBC padding test covers that as
well but it's nevertheless better to have an explicit handshake test
for mac-then-encrypt.

Reviewed-by: Andy Polyakov <appro@openssl.org>
7 years agoadd CMS SHA1 signing test
Dr. Stephen Henson [Tue, 22 Nov 2016 22:07:16 +0000 (22:07 +0000)]
add CMS SHA1 signing test

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoFix ctrl operation for SHA1/MD5SHA1.
Dr. Stephen Henson [Tue, 22 Nov 2016 21:59:21 +0000 (21:59 +0000)]
Fix ctrl operation for SHA1/MD5SHA1.

This makes S/MIME and CMS signing in MIME format for SHA1 work again.

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoINSTALL: clarify 386 and no-sse2 options.
Andy Polyakov [Sun, 20 Nov 2016 20:52:41 +0000 (21:52 +0100)]
INSTALL: clarify 386 and no-sse2 options.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@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>
7 years agotest/evptests.txt: add regression test for false carry in ctr128.c.
Andy Polyakov [Sun, 20 Nov 2016 22:32:24 +0000 (23:32 +0100)]
test/evptests.txt: add regression test for false carry in ctr128.c.

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>
7 years agobn/asm/ppc-mont.pl: signal no-op in 32-bit bit build.
Andy Polyakov [Mon, 21 Nov 2016 14:15:52 +0000 (15:15 +0100)]
bn/asm/ppc-mont.pl: signal no-op in 32-bit bit build.

The bug was introduced in 80d27cdb84985c697f8fabb7649abf1f54714d13,
one too many instructions was removed. It went unnoticed, because
new subroutine introduced in previous commit is called in real-life
RSA/DSA/DH cases, while original code is called only in rare tests.
The bug was caught in test_fuzz.

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agocoveralls: Use gcov-5 since we build it using gcc-5
Kurt Roeckx [Thu, 24 Nov 2016 17:51:23 +0000 (18:51 +0100)]
coveralls: Use gcov-5 since we build it using gcc-5

Reviewed-by: Emilia Käsper <emilia@openssl.org>
GH: #2003

7 years agoFix a bogus uninit var warning
Matt Caswell [Thu, 24 Nov 2016 09:22:49 +0000 (09:22 +0000)]
Fix a bogus uninit var warning

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoFix a warning about an uninit var
Matt Caswell [Thu, 24 Nov 2016 09:19:04 +0000 (09:19 +0000)]
Fix a warning about an uninit var

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoRun BoringSSL tests on Travis
Emilia Kasper [Wed, 9 Nov 2016 16:25:35 +0000 (17:25 +0100)]
Run BoringSSL tests on Travis

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoFix a missing function prototype in AFALG engine
Matt Caswell [Wed, 23 Nov 2016 22:55:13 +0000 (22:55 +0000)]
Fix a missing function prototype in AFALG engine

Reviewed-by: Richard Levitte <levitte@openssl.org>
7 years agoFix missing NULL checks in key_share processing
Matt Caswell [Wed, 23 Nov 2016 22:12:56 +0000 (22:12 +0000)]
Fix missing NULL checks in key_share processing

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoFix missing NULL checks in CKE processing
Matt Caswell [Wed, 23 Nov 2016 22:12:40 +0000 (22:12 +0000)]
Fix missing NULL checks in CKE processing

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoUse ClientHello.legacy_version for the RSA pre-master no matter what
Matt Caswell [Wed, 23 Nov 2016 13:56:15 +0000 (13:56 +0000)]
Use ClientHello.legacy_version for the RSA pre-master no matter what

Don't use what is in supported_versions for the RSA pre-master

Reviewed-by: Emilia Käsper <emilia@openssl.org>
7 years agoFix some defines in ossl_shim
Matt Caswell [Wed, 23 Nov 2016 13:55:35 +0000 (13:55 +0000)]
Fix some defines in ossl_shim

ossl_shim had some TLS1.3 defines that are now in ssl.h so need to be
removed.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
7 years agoFix a double ;; causing a travis failure
Matt Caswell [Wed, 23 Nov 2016 16:09:30 +0000 (16:09 +0000)]
Fix a double ;; causing a travis failure

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoFix an uninit variable usage
Matt Caswell [Wed, 23 Nov 2016 16:06:46 +0000 (16:06 +0000)]
Fix an uninit variable usage

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoUpdate tls13secretstest to use the new simpler test framework
Matt Caswell [Thu, 17 Nov 2016 11:12:20 +0000 (11:12 +0000)]
Update tls13secretstest to use the new simpler test framework

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoFix some style issues with TLSv1.3 state machine PR
Matt Caswell [Wed, 23 Nov 2016 15:38:32 +0000 (15:38 +0000)]
Fix some style issues with TLSv1.3 state machine PR

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoFix some style issues identified during review
Matt Caswell [Mon, 21 Nov 2016 12:10:35 +0000 (12:10 +0000)]
Fix some style issues identified during review

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoFix SSL_IS_TLS13(s)
Matt Caswell [Mon, 21 Nov 2016 13:24:50 +0000 (13:24 +0000)]
Fix SSL_IS_TLS13(s)

The SSL_IS_TLS13() macro wasn't quite right. It would come back with true
in the case where we haven't yet negotiated TLSv1.3, but it could be
negotiated.

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoExtend test_tls13messages
Matt Caswell [Tue, 15 Nov 2016 14:53:37 +0000 (14:53 +0000)]
Extend test_tls13messages

Add various different handshake types that are possible.

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoAdd an s_server capability to read an OCSP Response from a file
Matt Caswell [Tue, 15 Nov 2016 14:22:29 +0000 (14:22 +0000)]
Add an s_server capability to read an OCSP Response from a file

Current s_server can only get an OCSP Response from an OCSP responder. This
provides the capability to instead get the OCSP Response from a DER encoded
file.

This should make testing of OCSP easier.

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoAdd a test for the TLSv1.3 state machine
Matt Caswell [Tue, 15 Nov 2016 13:26:12 +0000 (13:26 +0000)]
Add a test for the TLSv1.3 state machine

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoFix some TLSProxy warnings
Matt Caswell [Tue, 15 Nov 2016 11:09:25 +0000 (11:09 +0000)]
Fix some TLSProxy warnings

After the client processes the server's initial flight in TLS1.3 it may
respond with either an encrypted, or an unencrypted alert. We needed to
teach TLSProxy about this so that it didn't issue spurious warnings.

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoEnsure unexpected messages are handled consistently
Matt Caswell [Tue, 15 Nov 2016 10:30:34 +0000 (10:30 +0000)]
Ensure unexpected messages are handled consistently

In one case we weren't always sending an unexpected message alert if we
don't get what we expect.

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoEnsure the end of first server flight processing is done
Matt Caswell [Tue, 15 Nov 2016 10:13:09 +0000 (10:13 +0000)]
Ensure the end of first server flight processing is done

There is a set of miscellaneous processing for OCSP, CT etc at the end of
the ServerDone processing. In TLS1.3 we don't have a ServerDone, so this
needs to move elsewhere.

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoFix the tests following the state machine changes for TLSv1.3
Matt Caswell [Fri, 11 Nov 2016 16:22:19 +0000 (16:22 +0000)]
Fix the tests following the state machine changes for TLSv1.3

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoCreate the Finished message payload
Matt Caswell [Fri, 11 Nov 2016 00:20:19 +0000 (00:20 +0000)]
Create the Finished message payload

The previous commit had a dummy payload for the Finished data. This commit
fills it in with a real value.

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoUpdate state machine to be closer to TLS1.3
Matt Caswell [Wed, 9 Nov 2016 14:06:12 +0000 (14:06 +0000)]
Update state machine to be closer to TLS1.3

This is a major overhaul of the TLSv1.3 state machine. Currently it still
looks like TLSv1.2. This commit changes things around so that it starts
to look a bit less like TLSv1.2 and bit more like TLSv1.3.

After this commit we have:

ClientHello
+ key_share          ---->
                           ServerHello
                           +key_share
                           {CertificateRequest*}
                           {Certificate*}
                           {CertificateStatus*}
                     <---- {Finished}
{Certificate*}
{CertificateVerify*}
{Finished}           ---->
[ApplicationData]    <---> [Application Data]

Key differences between this intermediate position and the final TLSv1.3
position are:
- No EncryptedExtensions message yet
- No server side CertificateVerify message yet
- CertificateStatus still exists as a separate message
- A number of the messages are still in the TLSv1.2 format
- Still running on the TLSv1.2 record layer

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoImplement tls13_change_cipher_state()
Matt Caswell [Tue, 8 Nov 2016 23:20:31 +0000 (23:20 +0000)]
Implement tls13_change_cipher_state()

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoRemove old style NewSessionTicket from TLSv1.3
Matt Caswell [Tue, 8 Nov 2016 16:10:21 +0000 (16:10 +0000)]
Remove old style NewSessionTicket from TLSv1.3

TLSv1.3 has a NewSessionTicket message, but it is *completely* different to
the TLSv1.2 one and may as well have been called something else. This commit
removes the old style NewSessionTicket from TLSv1.3. We will have to add the
new style one back in later.

Reviewed-by: Rich Salz <rsalz@openssl.org>
7 years agoFix EXTMS error introduced by commit 94ed2c6
Matt Caswell [Tue, 22 Nov 2016 09:31:12 +0000 (09:31 +0000)]
Fix EXTMS error introduced by commit 94ed2c6

Commit 94ed2c6 dropped a ! operator by mistake, which causes extended
master secret connections to fail. This puts in back.

Reviewed-by: Richard Levitte <levitte@openssl.org>
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)