oweals/openssl.git
8 years agoSimplify PKCS#12 PBE algorithm.
Dr. Stephen Henson [Sat, 1 Oct 2016 20:19:41 +0000 (21:19 +0100)]
Simplify PKCS#12 PBE algorithm.

Simplify PKCS#12 PBE algorithm by working out Ij + B + 1 directly
instead of using BIGNUMs.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoAdd a warning stipulating how things should be coded in ossl_init_base
Richard Levitte [Mon, 14 Nov 2016 23:58:51 +0000 (00:58 +0100)]
Add a warning stipulating how things should be coded in ossl_init_base

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

8 years agoStop init loops
Richard Levitte [Mon, 14 Nov 2016 22:53:45 +0000 (23:53 +0100)]
Stop init loops

Under certain circumstances, the libcrypto init code would loop,
causing a deadlock.  This would typically happen if something in
ossl_init_base() caused an OpenSSL error, and the error stack routines
would recurse into the init code before the flag that ossl_init_base()
had been run was checked.

This change makes sure ossl_init_base isn't run once more of the base
is initiated.

Thanks to Dmitry Kostjuchenko for the idea.

Fixes Github issue #1899

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

8 years agoConfigurations/10-main.conf: remove obsolete flag from solaris-x86-gcc.
Andy Polyakov [Sat, 12 Nov 2016 15:14:03 +0000 (16:14 +0100)]
Configurations/10-main.conf: remove obsolete flag from solaris-x86-gcc.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoConfigurations/10-main.conf: document GCC for Solaris config constraint.
Andy Polyakov [Sat, 12 Nov 2016 15:01:47 +0000 (16:01 +0100)]
Configurations/10-main.conf: document GCC for Solaris config constraint.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoAllow CA.pl script user to pass extra arguments to openssl command
marko asplund [Fri, 28 Oct 2016 07:01:02 +0000 (10:01 +0300)]
Allow CA.pl script user to pass extra arguments to openssl command

Useful e.g. to fully script CA commands

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

8 years agodsa/dsa_gen: add error message for seed_len < 0
Sebastian Andrzej Siewior [Mon, 3 Oct 2016 15:54:06 +0000 (17:54 +0200)]
dsa/dsa_gen: add error message for seed_len < 0

prio openssl 1.1.0 seed_len < q was accepted and the seed argument was
then ignored. Now DSA_generate_parameters_ex() returns an error in such
a case but no error string.

Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1657)

8 years agoRevert "Fixed deadlock in CRYPTO_THREAD_run_once for Windows"
Matt Caswell [Mon, 14 Nov 2016 11:55:13 +0000 (11:55 +0000)]
Revert "Fixed deadlock in CRYPTO_THREAD_run_once for Windows"

This reverts commit 349d1cfddcfa33d352240582a3803f2eba39d9a0.

The proposed fix is incorrect. It marks the "run_once" code as having
finished before it has. The intended semantics of run_once is that no
threads should proceed until the code has run exactly once. With this
change the "second" thread will think the run_once code has already been
run and will continue, even though it is still in progress. This could
result in a crash or other incorrect behaviour.

Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agoRemove heartbeat support
Richard Levitte [Sun, 13 Nov 2016 21:24:02 +0000 (16:24 -0500)]
Remove heartbeat support

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

8 years agoFixed deadlock in CRYPTO_THREAD_run_once for Windows
DK [Sun, 13 Nov 2016 12:48:15 +0000 (14:48 +0200)]
Fixed deadlock in CRYPTO_THREAD_run_once for Windows

Fixed deadlock in CRYPTO_THREAD_run_once() if call to init() is causing
a recursive call to CRYPTO_THREAD_run_once() again that is causing a hot
deadloop inside do { } while (result == ONCE_ININIT); section.

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

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

8 years agoUpdate s_client and s_server documentation about some missing arguments
EasySec [Sat, 12 Nov 2016 20:08:32 +0000 (21:08 +0100)]
Update s_client and s_server documentation about some missing arguments

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

8 years agoReplace the 'SSL' broken link with SSL_CTX_set_security_level which seems not being...
EasySec [Thu, 10 Nov 2016 23:51:04 +0000 (00:51 +0100)]
Replace the 'SSL' broken link with SSL_CTX_set_security_level which seems not being referenced from elsewhere

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

8 years agoEVP docs: chacha20, chacha20-poly1305
enkore [Sat, 12 Nov 2016 10:38:20 +0000 (11:38 +0100)]
EVP docs: chacha20, chacha20-poly1305

CLA: trivial

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

8 years agoUpdate fuzz corpora
Kurt Roeckx [Sat, 12 Nov 2016 14:37:04 +0000 (15:37 +0100)]
Update fuzz corpora

New minimal fuzz corpora set

Reviewed-by: Andy Polyakov <appro@openssl.org>
GH: #1910

8 years agoCast to an unsigned type before negating
Kurt Roeckx [Fri, 11 Nov 2016 20:41:50 +0000 (21:41 +0100)]
Cast to an unsigned type before negating

llvm's ubsan reported:
runtime error: negation of -9223372036854775808 cannot be represented in
type 'int64_t' (aka 'long'); cast to an unsigned type to negate this
value to itself

Found using libfuzzer

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

8 years agosha/asm/sha512-armv8.pl: add NEON version of SHA256.
Andy Polyakov [Fri, 4 Nov 2016 11:24:14 +0000 (12:24 +0100)]
sha/asm/sha512-armv8.pl: add NEON version of SHA256.

This provides up to 30% better performance on some of recent processors.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agosha/keccak1600.c: add some optimized implementations.
Andy Polyakov [Wed, 2 Nov 2016 19:13:53 +0000 (20:13 +0100)]
sha/keccak1600.c: add some optimized implementations.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agochacha/asm/chacha-x86.pl: improve [backward] portability.
Andy Polyakov [Tue, 8 Nov 2016 10:11:58 +0000 (11:11 +0100)]
chacha/asm/chacha-x86.pl: improve [backward] portability.

In order to minimize dependency on assembler version a number of
post-SSE2 instructions are encoded manually. But in order to simplify
the procedure only register operands are considered. Non-register
operands are passed down to assembler. Module in question uses pshufb
with memory operands, and old [GNU] assembler can't handle it.
Fortunately in this case it's possible skip just the problematic
segment without skipping SSSE3 support altogether.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoPPC assembler pack: add some PPC970/G5 performance data.
Andy Polyakov [Tue, 8 Nov 2016 20:48:34 +0000 (21:48 +0100)]
PPC assembler pack: add some PPC970/G5 performance data.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoFix typo in util/process_docs.pl
Richard Levitte [Fri, 11 Nov 2016 09:02:58 +0000 (10:02 +0100)]
Fix typo in util/process_docs.pl

The links weren't properly terminated with a "

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

8 years agoFix referenses in section 7 manuals
Richard Levitte [Fri, 11 Nov 2016 08:33:55 +0000 (09:33 +0100)]
Fix referenses in section 7 manuals

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

8 years agoFix referenses in section 1 manuals
Richard Levitte [Fri, 11 Nov 2016 08:33:47 +0000 (09:33 +0100)]
Fix referenses in section 1 manuals

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

8 years agoFix referenses in section 3 manuals
Richard Levitte [Fri, 11 Nov 2016 08:33:09 +0000 (09:33 +0100)]
Fix referenses in section 3 manuals

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

8 years agoAdd util/check-doc-links.pl, to be used to check referenses in manuals
Richard Levitte [Fri, 11 Nov 2016 08:19:52 +0000 (09:19 +0100)]
Add util/check-doc-links.pl, to be used to check referenses in manuals

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

8 years agoFix the effect of no-dso in crypto/init.c
Richard Levitte [Fri, 11 Nov 2016 09:23:26 +0000 (10:23 +0100)]
Fix the effect of no-dso in crypto/init.c

When configured no-dso, there are no DSO_{whatever} macros defined.
Therefore, before checking those, you have to check if OPENSSL_NO_DSO
is defined.

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

8 years agoSmall fixups of util/process_docs.pl
Richard Levitte [Thu, 10 Nov 2016 21:03:28 +0000 (22:03 +0100)]
Small fixups of util/process_docs.pl

- the pod path hadn't been changed with the directory layout change
- apparently, pod2html doesn't add ".html" at the end of links, making
  them useless, so we need to fix that

With thanks for the report to Michel <michel.sales@free.fr>

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

8 years agoFix test_sslcorrupt when using TLSv1.3
Matt Caswell [Thu, 10 Nov 2016 15:35:42 +0000 (15:35 +0000)]
Fix test_sslcorrupt when using TLSv1.3

The test loops through all the ciphers, attempting to test each one in turn.
However version negotiation happens before cipher selection, so with TLSv1.3
switched on if we use a non-TLSv1.3 compatible cipher suite we get "no
share cipher".

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoRevert "Move algorithm specific ppccap code from crypto/ppccap.c"
Richard Levitte [Thu, 10 Nov 2016 15:21:54 +0000 (16:21 +0100)]
Revert "Move algorithm specific ppccap code from crypto/ppccap.c"

Now that we can link specifically with static libraries, the immediate
need to split ppccap.c (and eventually other *cap.c files) is no more.

This reverts commit e3fb4d3d52e188b83ccb8506aa2f16cb686f4d6c.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoRename the Elliptic Curves extension to supported_groups
Matt Caswell [Wed, 9 Nov 2016 14:51:06 +0000 (14:51 +0000)]
Rename the Elliptic Curves extension to supported_groups

This is a skin deep change, which simply renames most places where we talk
about curves in a TLS context to groups. This is because TLS1.3 has renamed
the extension, and it can now include DH groups too. We still only support
curves, but this rename should pave the way for a future extension for DH
groups.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoLink internal tests with static OpenSSL libraries when needed
Richard Levitte [Wed, 9 Nov 2016 19:09:03 +0000 (20:09 +0100)]
Link internal tests with static OpenSSL libraries when needed

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

8 years agoDocument how to force linking with static libraries
Richard Levitte [Thu, 10 Nov 2016 00:00:17 +0000 (01:00 +0100)]
Document how to force linking with static libraries

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

8 years agoBuilding: make it possible to force linking with static OpenSSL libs
Richard Levitte [Wed, 9 Nov 2016 19:01:51 +0000 (20:01 +0100)]
Building: make it possible to force linking with static OpenSSL libs

Very simply, support having the .a extension to denote depending on
static libraries.  Note that this is not supported on native Windows
when building shared libraries, as there is not static library then,
just an import library with the same name.

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

8 years agoFix no-ct in test/ct_test.c
Richard Levitte [Thu, 10 Nov 2016 00:33:54 +0000 (01:33 +0100)]
Fix no-ct in test/ct_test.c

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

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