oweals/openssl.git
8 years agodescrip.mms.tmpl: Simplify fiddling of logical names record and statem
Richard Levitte [Wed, 9 Nov 2016 23:41:53 +0000 (00:41 +0100)]
descrip.mms.tmpl: Simplify fiddling of logical names record and statem

Instead of enumerating exactly those files in test/ that include
../ssl/ssl_locl.h, assume they all do.

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

8 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>
8 years agoFix the no-tls option
Matt Caswell [Thu, 10 Nov 2016 11:27:07 +0000 (11:27 +0000)]
Fix the no-tls option

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoFix no-cms (CVE-2016-7053)
Richard Levitte [Thu, 10 Nov 2016 00:49:47 +0000 (01:49 +0100)]
Fix no-cms (CVE-2016-7053)

Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agotest/evptests.txt: add negative tests for AEAD ciphers.
Andy Polyakov [Tue, 1 Nov 2016 21:06:42 +0000 (22:06 +0100)]
test/evptests.txt: add negative tests for AEAD ciphers.

This is done by taking one vector, "corrupting" last bit of the
tag value and verifying that decrypt fails.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
8 years agotest: add TLS application data corruption test.
Andy Polyakov [Mon, 31 Oct 2016 20:50:26 +0000 (21:50 +0100)]
test: add TLS application data corruption test.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
8 years agoadd test for CVE-2016-7053
Dr. Stephen Henson [Fri, 14 Oct 2016 11:02:12 +0000 (12:02 +0100)]
add test for CVE-2016-7053

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoDon't set choice selector on parse failure.
Dr. Stephen Henson [Fri, 14 Oct 2016 10:51:43 +0000 (11:51 +0100)]
Don't set choice selector on parse failure.

Don't set choice selector on parse failure: this can pass unexpected
values to the choice callback. Instead free up partial structure
directly.

CVE-2016-7053

Thanks to Tyler Nighswander of ForAllSecure for reporting this issue.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agochacha20/poly1305: make sure to clear the buffer at correct position
Richard Levitte [Fri, 4 Nov 2016 13:21:46 +0000 (14:21 +0100)]
chacha20/poly1305: make sure to clear the buffer at correct position

The offset to the memory to clear was incorrect, causing a heap buffer
overflow.

CVE-2016-7054

Thanks to Robert Święcki for reporting this

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoaes/asm/aesp8-ppc.pl: improve [backward] portability.
Andy Polyakov [Tue, 8 Nov 2016 19:25:09 +0000 (20:25 +0100)]
aes/asm/aesp8-ppc.pl: improve [backward] portability.

Some of stone-age assembler can't cope with r0 in address. It's actually
sensible thing to do, because r0 is shunted to 0 in address arithmetic
and by refusing r0 assembler effectively makes you understand that.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 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>
8 years agotest/bntest.c: regression test for CVE-2016-7055.
Andy Polyakov [Sun, 6 Nov 2016 17:31:14 +0000 (18:31 +0100)]
test/bntest.c: regression test for CVE-2016-7055.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoFix the evp_test Ctrl keyword processing
Richard Levitte [Thu, 10 Nov 2016 09:03:37 +0000 (10:03 +0100)]
Fix the evp_test Ctrl keyword processing

Skip the test if the value after ":" is a disabled algorithm, rather
than failing it

Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoFix no-dso (shlibloadtest)
Richard Levitte [Thu, 10 Nov 2016 01:08:22 +0000 (02:08 +0100)]
Fix no-dso (shlibloadtest)

Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoAddress some supported_versions review comments
Matt Caswell [Wed, 9 Nov 2016 14:43:05 +0000 (14:43 +0000)]
Address some supported_versions review comments

Added some TODOs, refactored a couple of things and added a SSL_IS_TLS13()
macro.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoRemove some redundant trace code
Matt Caswell [Wed, 9 Nov 2016 09:52:37 +0000 (09:52 +0000)]
Remove some redundant trace code

No need to have a supported versions table and a versions table. They
should be the same.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoFix some missing checks for TLS1_3_VERSION_DRAFT
Matt Caswell [Mon, 7 Nov 2016 13:48:07 +0000 (13:48 +0000)]
Fix some missing checks for TLS1_3_VERSION_DRAFT

There were a few places where we weren't checking to see if we were using
the draft TLS1.3 version or not.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoGive the test with only TLS1.1 and TLS1.0 a better name
Matt Caswell [Mon, 7 Nov 2016 15:36:00 +0000 (15:36 +0000)]
Give the test with only TLS1.1 and TLS1.0 a better name

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoAdd a TODO(TLS1.3) about renegotation
Matt Caswell [Wed, 2 Nov 2016 11:33:20 +0000 (11:33 +0000)]
Add a TODO(TLS1.3) about renegotation

Renegotiation does not exist in TLS1.3, so we need to disable it at some
point.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoAdd some more version tests
Matt Caswell [Wed, 2 Nov 2016 09:09:02 +0000 (09:09 +0000)]
Add some more version tests

Send a TLS1.4 ClientHello with supported_versions and get TLS1.3
Send a TLS1.3 ClientHello without supported_versions and get TLS1.2

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoA style tweak based on feedback received
Matt Caswell [Tue, 1 Nov 2016 00:37:23 +0000 (00:37 +0000)]
A style tweak based on feedback received

Replace a bare ";" with "continue;" for the body of a for loop.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoLook at the supported_versions extension even if the server <TLS1.3
Matt Caswell [Mon, 31 Oct 2016 18:12:33 +0000 (18:12 +0000)]
Look at the supported_versions extension even if the server <TLS1.3

If supported_versions is present it takes precedence.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoEnsure that vent->smeth != NULL before we call vent->smeth()
Matt Caswell [Wed, 2 Nov 2016 11:15:08 +0000 (11:15 +0000)]
Ensure that vent->smeth != NULL before we call vent->smeth()

We can end up with a NULL SSL_METHOD function if a method has been
disabled. If that happens then we shouldn't call vent->smeth().

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoAddress some review feedback comments for supported_versions
Matt Caswell [Mon, 31 Oct 2016 17:05:20 +0000 (17:05 +0000)]
Address some review feedback comments for supported_versions

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoAdd a test for the supported_versions extension
Matt Caswell [Thu, 27 Oct 2016 17:32:19 +0000 (18:32 +0100)]
Add a test for the supported_versions extension

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoUpdate TLS1.3 draft version numbers for latest draft
Matt Caswell [Thu, 27 Oct 2016 15:30:36 +0000 (16:30 +0100)]
Update TLS1.3 draft version numbers for latest draft

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoAdd server side support for supported_versions extension
Matt Caswell [Sat, 22 Oct 2016 23:41:11 +0000 (00:41 +0100)]
Add server side support for supported_versions extension

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoEnsure that the -trace option can interpret the supported_versions extension
Matt Caswell [Fri, 21 Oct 2016 22:41:18 +0000 (23:41 +0100)]
Ensure that the -trace option can interpret the supported_versions extension

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoAdd the ability to send the supported_versions extension
Matt Caswell [Fri, 21 Oct 2016 22:40:52 +0000 (23:40 +0100)]
Add the ability to send the supported_versions extension

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoWhen no SRP identity is found, no error was reported server side
EasySec [Sat, 5 Nov 2016 21:56:13 +0000 (22:56 +0100)]
When no SRP identity is found, no error was reported server side

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

8 years agoAdd main() test methods to reduce test boilerplate.
Emilia Kasper [Mon, 7 Nov 2016 15:53:15 +0000 (16:53 +0100)]
Add main() test methods to reduce test boilerplate.

Simple tests only need to implement register_tests().
Tests that need a custom main() should implement test_main(). This will
be wrapped in a main() that performs common setup/teardown (currently
crypto-mdebug).

Note that for normal development, enable-asan is usually
sufficient for detecting leaks, and more versatile.

enable-crypto-mdebug is stricter as it will also
insist that all static variables be freed. This is useful for debugging
library init/deinit; however, it also means that test_main() must free
everything it allocates.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agodtl_mtu_test doesn't follow BIO_* conventions and make Windows build fail
EasySec [Thu, 3 Nov 2016 14:42:11 +0000 (15:42 +0100)]
dtl_mtu_test doesn't follow BIO_* conventions and make Windows build fail

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoEnsure the key and iv labels are declared as static
Matt Caswell [Tue, 8 Nov 2016 23:22:11 +0000 (23:22 +0000)]
Ensure the key and iv labels are declared as static

Fixes a travis failure

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoAdd a test for the TLS1.3 secret generation
Matt Caswell [Mon, 7 Nov 2016 10:18:41 +0000 (10:18 +0000)]
Add a test for the TLS1.3 secret generation

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoAdd support for TLS1.3 secret generation
Matt Caswell [Tue, 8 Nov 2016 10:34:28 +0000 (10:34 +0000)]
Add support for TLS1.3 secret generation

Nothing is using this yet, it just adds the underlying functions necesary
for generating the TLS1.3 secrets.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoAdd support for initialising WPACKETs from a static buffer
Matt Caswell [Tue, 8 Nov 2016 10:33:35 +0000 (10:33 +0000)]
Add support for initialising WPACKETs from a static buffer

Normally WPACKETs will use a BUF_MEM which can grow as required. Sometimes
though that may be overkill for what is needed - a static buffer may be
sufficient. This adds that capability.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoAdd some documentation for the new HKDF modes
Matt Caswell [Tue, 8 Nov 2016 10:25:21 +0000 (10:25 +0000)]
Add some documentation for the new HKDF modes

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoFollowing the changes to HKDF to accept a mode, add some tests for this
Matt Caswell [Tue, 8 Nov 2016 11:48:33 +0000 (11:48 +0000)]
Following the changes to HKDF to accept a mode, add some tests for this

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoUpdate HKDF to support separte Extract and Expand steps
Matt Caswell [Mon, 7 Nov 2016 10:16:57 +0000 (10:16 +0000)]
Update HKDF to support separte Extract and Expand steps

At the moment you can only do an HKDF Extract and Expand in one go. For
TLS1.3 we need to be able to do an Extract first, and the subsequently do
a number of Expand steps on the same PRK.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoSimplify and clean X509_VERIFY_PARAM new/free code.
FdaSilvaYY [Thu, 15 Sep 2016 19:42:53 +0000 (21:42 +0200)]
Simplify and clean X509_VERIFY_PARAM new/free code.

Split x509_verify_param_zero code to the right place

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoMake some CLIENTHELLO_MSG function arguments const
Matt Caswell [Tue, 8 Nov 2016 13:43:12 +0000 (13:43 +0000)]
Make some CLIENTHELLO_MSG function arguments const

There were a few places where they could be declared const so this commit
does that.

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoUpdate a comment
Matt Caswell [Mon, 7 Nov 2016 15:15:06 +0000 (15:15 +0000)]
Update a comment

The name and type of the argument to ssl_check_for_safari() has changed.

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoSwap back to using SSL3_RANDOM_SIZE instead of sizeof(clienthello.random)
Matt Caswell [Mon, 7 Nov 2016 15:13:04 +0000 (15:13 +0000)]
Swap back to using SSL3_RANDOM_SIZE instead of sizeof(clienthello.random)

The size if fixed by the protocol and won't change even if
sizeof(clienthello.random) does.

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoMove setting the session_id_len until after we filled the session_id
Matt Caswell [Mon, 7 Nov 2016 15:09:19 +0000 (15:09 +0000)]
Move setting the session_id_len until after we filled the session_id

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoLoad the sessionid directly in SSLv2 compat ClientHello
Matt Caswell [Mon, 7 Nov 2016 15:07:56 +0000 (15:07 +0000)]
Load the sessionid directly in SSLv2 compat ClientHello

Don't use a sub-packet, just load it.

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoRename clienthello.version to clienthello.legacy_version
Matt Caswell [Mon, 7 Nov 2016 14:59:12 +0000 (14:59 +0000)]
Rename clienthello.version to clienthello.legacy_version

For consistency with the TLSv1.3 spec.

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoFix some minor style issues
Matt Caswell [Wed, 2 Nov 2016 14:14:23 +0000 (14:14 +0000)]
Fix some minor style issues

Add a blank line, take one away - due to feedback received during review.

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoAdd some function documentation and update some existing comments
Matt Caswell [Mon, 31 Oct 2016 16:36:30 +0000 (16:36 +0000)]
Add some function documentation and update some existing comments

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoFix make update following extensions refactor
Matt Caswell [Mon, 31 Oct 2016 14:52:22 +0000 (14:52 +0000)]
Fix make update following extensions refactor

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoImprove some comment documentation following the extensions refactor
Matt Caswell [Mon, 31 Oct 2016 13:20:03 +0000 (13:20 +0000)]
Improve some comment documentation following the extensions refactor

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoFix various style issues in the extension parsing refactor
Matt Caswell [Mon, 31 Oct 2016 13:11:17 +0000 (13:11 +0000)]
Fix various style issues in the extension parsing refactor

Based on review feedback received.

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoUse an explicit name for the struct for definition of RAW_EXTENSION
Matt Caswell [Mon, 31 Oct 2016 12:50:05 +0000 (12:50 +0000)]
Use an explicit name for the struct for definition of RAW_EXTENSION

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoFix a memory leak in the ClientHello extension parsing
Matt Caswell [Mon, 31 Oct 2016 12:48:37 +0000 (12:48 +0000)]
Fix a memory leak in the ClientHello extension parsing

We should be freeing up the raw extension data after we've finished with it.

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoHandle compression methods correctly with SSLv2 compat ClientHello
Matt Caswell [Mon, 31 Oct 2016 12:47:20 +0000 (12:47 +0000)]
Handle compression methods correctly with SSLv2 compat ClientHello

In the case of an SSLv2 compat ClientHello we weren't setting up the
compression methods correctly, which could lead to uninit reads or crashes.

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoRefactor ClientHello processing so that extensions get parsed earlier
Matt Caswell [Sat, 22 Oct 2016 16:24:37 +0000 (17:24 +0100)]
Refactor ClientHello processing so that extensions get parsed earlier

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoMove algorithm specific ppccap code from crypto/ppccap.c
Richard Levitte [Tue, 8 Nov 2016 22:55:51 +0000 (23:55 +0100)]
Move algorithm specific ppccap code from crypto/ppccap.c

Having that code in one central object file turned out to cause
trouble when building test/modes_internal_test.

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

8 years agoUnix Makefile: Make sure to use $(PERL) when running ./Configure
Richard Levitte [Tue, 8 Nov 2016 23:14:56 +0000 (00:14 +0100)]
Unix Makefile: Make sure to use $(PERL) when running ./Configure

For consistency, it's better to use the perl that was specified to
Configure last time it was called.

Use case:

perl v5.8.8 was first along $PATH, perl v5.22.2 was available and
specified as: PERL=/opt/local/bin/perl ./config.  When make wanted to
reconfigure and called './Configure reconf', configuration broke down,
complaining about a perl that's too old.

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

8 years agoMissing BN_RECP_CTX field init.
FdaSilvaYY [Tue, 8 Nov 2016 18:22:09 +0000 (19:22 +0100)]
Missing BN_RECP_CTX field init.

BN_RECP_CTX_new direclty use bn_init to avoid twice memset calls

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

8 years agoZero stack variable with DSA nonce
Rich Salz [Tue, 8 Nov 2016 20:56:04 +0000 (15:56 -0500)]
Zero stack variable with DSA nonce

Thanks to Falko Strenzke for bringing this to our attention.

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

8 years agoFix zlib BIO_METHOD for latest BIO_METHOD structure changes
Matt Caswell [Tue, 8 Nov 2016 13:52:30 +0000 (13:52 +0000)]
Fix zlib BIO_METHOD for latest BIO_METHOD structure changes

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoINSTALL: small typo
Richard Levitte [Tue, 8 Nov 2016 09:17:20 +0000 (10:17 +0100)]
INSTALL: small typo

libssl, not libddl.

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

8 years agoAllow null in X509_CRL_METHOD_free
FdaSilvaYY [Tue, 27 Sep 2016 21:36:37 +0000 (23:36 +0200)]
Allow null in  X509_CRL_METHOD_free

and fix documentation.

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

8 years agoImprove PRF documentation
Andrea Grandi [Thu, 3 Nov 2016 04:42:07 +0000 (04:42 +0000)]
Improve PRF documentation

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Rich Salz <rsalz@openssl.org>
GH: #1834

8 years agoImprove RSA test coverage.
David Benjamin [Mon, 7 Nov 2016 00:12:47 +0000 (19:12 -0500)]
Improve RSA test coverage.

MD5/SHA1 and MDC-2 have special-case logic beyond the generic DigestInfo
wrapping. Test that each of these works, including hash and length
mismatches (both input and signature). Also add VerifyRecover tests. It
appears 5824cc298174d462c827cd090675e30fc03f0caf added support for
VerifyRecover, but forgot to add the test data.

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Rich Salz <rsalz@openssl.org>
GH: #1474

8 years agoMake RSA_sign.pod less confusing.
David Benjamin [Sat, 20 Aug 2016 19:48:56 +0000 (15:48 -0400)]
Make RSA_sign.pod less confusing.

PKCS #1 v2.0 is the name of a document which specifies an algorithm
RSASSA-PKCS1-v1_5, often referred to as "PKCS #1 v1.5" after an earlier
document which specified it. This gets further confusing because the
document PKCS #1 v2.1 specifies two signature algorithms,
RSASSA-PKCS1-v1_5 and RSASSA-PSS. RSA_sign implements RSASSA-PKCS1-v1_5.

Refer to the document using the RFC number which is easier to find
anyway, and refer to the algorithm by its name.

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Rich Salz <rsalz@openssl.org>
GH: #1474

8 years agoImplement RSASSA-PKCS1-v1_5 as specified.
David Benjamin [Sat, 20 Aug 2016 17:35:17 +0000 (13:35 -0400)]
Implement RSASSA-PKCS1-v1_5 as specified.

RFC 3447, section 8.2.2, steps 3 and 4 states that verifiers must encode
the DigestInfo struct and then compare the result against the public key
operation result. This implies that one and only one encoding is legal.

OpenSSL instead parses with crypto/asn1, then checks that the encoding
round-trips, and allows some variations for the parameter. Sufficient
laxness in this area can allow signature forgeries, as described in
https://www.imperialviolet.org/2014/09/26/pkcs1.html

Although there aren't known attacks against OpenSSL's current scheme,
this change makes OpenSSL implement the algorithm as specified. This
avoids the uncertainty and, more importantly, helps grow a healthy
ecosystem. Laxness beyond the spec, particularly in implementations
which enjoy wide use, risks harm to the ecosystem for all. A signature
producer which only tests against OpenSSL may not notice bugs and
accidentally become widely deployed. Thus implementations have a
responsibility to honor the specification as tightly as is practical.

In some cases, the damage is permanent and the spec deviation and
security risk becomes a tax all implementors must forever pay, but not
here. Both BoringSSL and Go successfully implemented and deployed
RSASSA-PKCS1-v1_5 as specified since their respective beginnings, so
this change should be compatible enough to pin down in future OpenSSL
releases.

See also https://tools.ietf.org/html/draft-thomson-postel-was-wrong-00

As a bonus, by not having to deal with sign/verify differences, this
version is also somewhat clearer. It also more consistently enforces
digest lengths in the verify_recover codepath. The NID_md5_sha1 codepath
wasn't quite doing this right.

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Rich Salz <rsalz@openssl.org>
GH: #1474

8 years agoPartial revert of "Fix client verify mode to check SSL_VERIFY_PEER"
Matt Caswell [Thu, 27 Oct 2016 09:46:25 +0000 (10:46 +0100)]
Partial revert of "Fix client verify mode to check SSL_VERIFY_PEER"

This partially reverts commit c636c1c47. It also tweaks the documentation
and comments in this area. On the client side the documented interface for
SSL_CTX_set_verify()/SSL_set_verify() is that setting the flag
SSL_VERIFY_PEER causes verfication of the server certificate to take place.
Previously what was implemented was that if *any* flag was set then
verification would take place. The above commit improved the semantics to
be as per the documented interface.

However, we have had a report of at least one application where an
application was incorrectly using the interface and used *only*
SSL_VERIFY_FAIL_IF_NO_PEER_CERT on the client side. In OpenSSL prior to
the above commit this still caused verification of the server certificate
to take place. After this commit the application silently failed to verify
the server certificate.

Ideally SSL_CTX_set_verify()/SSL_set_verify() could be modified to indicate
if invalid flags were being used. However these are void functions!

The simplest short term solution is to revert to the previous behaviour
which at least means we "fail closed" rather than "fail open".

Thanks to Cory Benfield for reporting this issue.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoSimplify tests part 2
Emilia Kasper [Fri, 4 Nov 2016 15:06:12 +0000 (16:06 +0100)]
Simplify tests part 2

1) Remove some unnecessary fixtures
2) Add EXECUTE_TEST_NO_TEARDOWN shorthand when a fixture exists but has
no teardown.
3) Fix return values in ct_test.c (introduced by an earlier refactoring,
oops)

Note that for parameterized tests, the index (test vector) usually holds all the
customization, and there should be no need for a separate test
fixture. The CTS test is an exception: it demonstrates how to combine
customization with parameterization.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoAdd a test for the wrong version number in a record
Matt Caswell [Mon, 7 Nov 2016 14:26:41 +0000 (14:26 +0000)]
Add a test for the wrong version number in a record

Prior to TLS1.3 we check that the received record version number is correct.
In TLS1.3 we need to ignore the record version number. This adds a test to
make sure we do it correctly.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoIgnore the record version in TLS1.3
Matt Caswell [Mon, 7 Nov 2016 13:49:18 +0000 (13:49 +0000)]
Ignore the record version in TLS1.3

The record layer version field must be ignored in TLSv1.3, so we remove the
check when using that version.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agotest_sslcbcpadding only makes sense <TLS1.3
Matt Caswell [Mon, 7 Nov 2016 14:44:38 +0000 (14:44 +0000)]
test_sslcbcpadding only makes sense <TLS1.3

We may get failures if we run it in TLS1.3, and it makes no sense anyway
so force TLS1.2

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoCorrect the Id for the TLS1.3 ciphersuite
Matt Caswell [Mon, 7 Nov 2016 13:44:56 +0000 (13:44 +0000)]
Correct the Id for the TLS1.3 ciphersuite

We have one TLS1.3 ciphersuite, but there is a typo in the id that should
be corrected.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoAlways ensure that init_msg is initialised for a CCS
Matt Caswell [Thu, 3 Nov 2016 13:21:28 +0000 (13:21 +0000)]
Always ensure that init_msg is initialised for a CCS

We read it later in grow_init_buf(). If CCS is the first thing received in
a flight, then it will use the init_msg from the last flight we received. If
the init_buf has been grown in the meantime then it will point to some
arbitrary other memory location. This is likely to result in grow_init_buf()
attempting to grow to some excessively large amount which is likely to
fail. In practice this should never happen because the only time we receive
a CCS as the first thing in a flight is in an abbreviated handshake. None
of the preceding messages from the server flight would be large enough to
trigger this.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoWindows: use default ZLIB1 unless --with-zlib-lib is set
Richard Levitte [Mon, 24 Oct 2016 13:11:29 +0000 (15:11 +0200)]
Windows: use default ZLIB1 unless --with-zlib-lib is set

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

8 years agoFix the LIBZ macro on VC config targets
Richard Levitte [Mon, 24 Oct 2016 13:03:57 +0000 (15:03 +0200)]
Fix the LIBZ macro on VC config targets

If zlib-dynamic was given but not --with-zlib-lib, LIBZ was defined to
the empty string.  Instead, give it the default "ZLIB1".

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

8 years agoVMS: pretend to use -znodelete
Richard Levitte [Sun, 6 Nov 2016 17:35:01 +0000 (18:35 +0100)]
VMS: pretend to use -znodelete

VMS only unloads shared libraries at process rundown, so tell the
OpenSSL code so by pretending we linked with -znodelete.

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

8 years agoconstant time test: include our internal/numbers.h rather than limits.h
Richard Levitte [Sat, 5 Nov 2016 10:38:29 +0000 (11:38 +0100)]
constant time test: include our internal/numbers.h rather than limits.h

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

8 years agoVMS build file template: assign 'arch' to local symbol table
Richard Levitte [Fri, 4 Nov 2016 18:11:11 +0000 (19:11 +0100)]
VMS build file template: assign 'arch' to local symbol table

Since the local symbol table is looked up before the global symbol
table, 'arch' assigned in the local symbol table of the DCL where MMS
is called would be seen before the 'arch' defined in descrip.mms.
Assigning it to the local symbol table in descrip.mms removes that
issue.

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

8 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)

8 years agoCorrect internal tests sources
Richard Levitte [Fri, 4 Nov 2016 14:26:57 +0000 (15:26 +0100)]
Correct internal tests sources

The sources for internal tests were sometimes badly formed, assuming
perl variables such as $target{cpuid_asm_src} contains only one file
name.  This change correctly massages all file names in such a
variable.

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

8 years agoVMS: update the list of files that need some extra treatment
Richard Levitte [Fri, 4 Nov 2016 13:08:55 +0000 (14:08 +0100)]
VMS: update the list of files that need some extra treatment

This is related to a lack in path merging involding includes of includes

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

8 years agoVMS: correct the logic around linking executables
Richard Levitte [Fri, 4 Nov 2016 13:08:25 +0000 (14:08 +0100)]
VMS: correct the logic around linking executables

The logic around avoiding MULDEF warnings was flawed.  Simplifying it
makes it better.

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

8 years agoDon't create fixtures for simple tests
Emilia Kasper [Thu, 3 Nov 2016 16:15:41 +0000 (17:15 +0100)]
Don't create fixtures for simple tests

The test fixtures are (meant to be) useful for sharing common
setup. Don't bother when we don't have any setup/teardown.

This only addresses simple tests. Parameterized tests (ADD_ALL_TESTS)
will be made more user-friendly in a follow-up.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agotestutil: always print errors on failure
Emilia Kasper [Thu, 3 Nov 2016 13:27:05 +0000 (14:27 +0100)]
testutil: always print errors on failure

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoTravis: add a strict build
Richard Levitte [Thu, 3 Nov 2016 15:46:14 +0000 (16:46 +0100)]
Travis: add a strict build

Clang on Linux seems to catch things that we might miss otherwise.
Also, throw in 'no-deprecated' to make sure we test that as well.

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

8 years agoFix a missed size_t variable declaration
Matt Caswell [Fri, 4 Nov 2016 10:26:57 +0000 (10:26 +0000)]
Fix a missed size_t variable declaration

pqueue_size() now returns a size_t, but the variable that gets returned
was still declared as an int.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoFix some style issues from libssl size_tify review
Matt Caswell [Fri, 4 Nov 2016 10:25:03 +0000 (10:25 +0000)]
Fix some style issues from libssl size_tify review

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoTweak the SSL_read()/SSL_write() text based on feedback received.
Matt Caswell [Wed, 26 Oct 2016 19:59:49 +0000 (20:59 +0100)]
Tweak the SSL_read()/SSL_write() text based on feedback received.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoRename all "read" variables with "readbytes"
Matt Caswell [Wed, 26 Oct 2016 09:43:34 +0000 (10:43 +0100)]
Rename all "read" variables with "readbytes"

Travis is reporting one file at a time shadowed variable warnings where
"read" has been used. This attempts to go through all of libssl and replace
"read" with "readbytes" to fix all the problems in one go.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoClarify the return values for SSL_read_ex()/SSL_write_ex()
Matt Caswell [Tue, 25 Oct 2016 22:46:27 +0000 (23:46 +0100)]
Clarify the return values for SSL_read_ex()/SSL_write_ex()

Give more detail on what constitutes success/failure.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoFix a shadowed variable declaration warning picked up by Travis
Matt Caswell [Tue, 25 Oct 2016 22:27:16 +0000 (23:27 +0100)]
Fix a shadowed variable declaration warning picked up by Travis

Rename "read" to "readbytes"

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoDocument the HMAC_size() function
Matt Caswell [Tue, 25 Oct 2016 16:10:44 +0000 (17:10 +0100)]
Document the HMAC_size() function

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoTest the size_t constant time functions
Matt Caswell [Tue, 25 Oct 2016 14:29:35 +0000 (15:29 +0100)]
Test the size_t constant time functions

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoEnsure SSL_DEBUG works following size_t changes
Matt Caswell [Tue, 25 Oct 2016 14:29:17 +0000 (15:29 +0100)]
Ensure SSL_DEBUG works following size_t changes

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoClarify the return values for the peek functions
Matt Caswell [Tue, 25 Oct 2016 14:27:55 +0000 (15:27 +0100)]
Clarify the return values for the peek functions

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoUpdates various man pages based on review feedback received.
Matt Caswell [Fri, 21 Oct 2016 15:16:20 +0000 (16:16 +0100)]
Updates various man pages based on review feedback received.

Improvements to style, grammar etc.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoFix style issues in HMAC_size()
Matt Caswell [Fri, 21 Oct 2016 14:41:04 +0000 (15:41 +0100)]
Fix style issues in HMAC_size()

Based on review feedback.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoFix some bogus warnings about uninitialised variables
Matt Caswell [Thu, 20 Oct 2016 22:49:41 +0000 (23:49 +0100)]
Fix some bogus warnings about uninitialised variables

Travis was failing in some builds due to a bogus complaint
about uninit variables.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoFix some clashing symbol numbers due to merge conflict
Matt Caswell [Thu, 20 Oct 2016 16:27:59 +0000 (17:27 +0100)]
Fix some clashing symbol numbers due to merge conflict

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoDocument the newly added SSL functions
Matt Caswell [Thu, 20 Oct 2016 14:04:21 +0000 (15:04 +0100)]
Document the newly added SSL functions

Also document SSL_peek() which was missing from the docs.

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