openssl.git
3 years agoFix strict-warnings build
Patrick Steuer [Sat, 15 Oct 2016 14:54:52 +0000 (16:54 +0200)]
Fix strict-warnings build

crypto/asn1/a_strex.c: Type of width variable in asn1_valid_host
function  needs to be changed from char to signed char to avoid
build error due to '-Werror=type-limits'.

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

3 years agoAdd SSL_OP_NO_ENCRYPT_THEN_MAC
David Woodhouse [Thu, 13 Oct 2016 23:26:38 +0000 (00:26 +0100)]
Add SSL_OP_NO_ENCRYPT_THEN_MAC

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
3 years agoFix encrypt-then-mac implementation for DTLS
David Woodhouse [Wed, 12 Oct 2016 22:12:04 +0000 (23:12 +0100)]
Fix encrypt-then-mac implementation for DTLS

OpenSSL 1.1.0 will negotiate EtM on DTLS but will then not actually *do* it.

If we use DTLSv1.2 that will hopefully be harmless since we'll tend to use
an AEAD ciphersuite anyway. But if we're using DTLSv1, then we certainly
will end up using CBC, so EtM is relevant — and we fail to interoperate with
anything that implements EtM correctly.

Fixing it in HEAD and 1.1.0c will mean that 1.1.0[ab] are incompatible with
1.1.0c+... for the limited case of non-AEAD ciphers, where they're *already*
incompatible with other implementations due to this bug anyway. That seems
reasonable enough, so let's do it. The only alternative is just to turn it
off for ever... which *still* leaves 1.0.0[ab] failing to communicate with
non-OpenSSL implementations anyway.

Tested against itself as well as against GnuTLS both with and without EtM.

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
3 years agoAdd Postgres support to -starttls
Valentin Vidic [Mon, 15 Feb 2016 14:28:41 +0000 (15:28 +0100)]
Add Postgres support to -starttls

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
3 years agoFix embedded string handling.
Dr. Stephen Henson [Sun, 2 Oct 2016 13:13:40 +0000 (14:13 +0100)]
Fix embedded string handling.

Don't rely on embedded flag to free strings correctly: it wont be
set if there is a malloc failure during initialisation.

Thanks to Guido Vranken for reporting this issue.

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

3 years agofix invalid use of incomplete type X509_STORE_CTX
choury [Mon, 17 Oct 2016 07:30:14 +0000 (15:30 +0800)]
fix invalid use of incomplete type X509_STORE_CTX

CLA: trivial

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
3 years agoAllow older versions in the *.num files
Matt Caswell [Sat, 15 Oct 2016 22:13:29 +0000 (23:13 +0100)]
Allow older versions in the *.num files

In 1.1.0 we only allowed a strictly increasing version number in the *.num
files, i.e. you could never introduce a symbol at the end of the *.num file
with a lower version number than the one preceding it. This made sense for
1.1.0. However in master we may be introducing symbols for backport to
1.1.0. Therefore it is ok in master to have a symbol for version 1.1.0c
coming after a symbol for version 1.1.1.

This commit fixes the check in mkdef.pl to be a bit looser to allow this.

Reviewed-by: Richard Levitte <levitte@openssl.org>
3 years agoFix signatures of EVP_Digest{Sign,Verify}Update
Steven Fackler [Sat, 15 Oct 2016 20:01:25 +0000 (13:01 -0700)]
Fix signatures of EVP_Digest{Sign,Verify}Update

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

CLA: trivial

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
3 years agoEnsure we handle len == 0 in ERR_err_string_n
Matt Caswell [Wed, 12 Oct 2016 15:43:03 +0000 (16:43 +0100)]
Ensure we handle len == 0 in ERR_err_string_n

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

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

Reviewed-by: Richard Levitte <levitte@openssl.org>
3 years agoUse clang++ for C++ for the linux-x86_64-clang target
Matt Caswell [Fri, 14 Oct 2016 16:04:38 +0000 (17:04 +0100)]
Use clang++ for C++ for the linux-x86_64-clang target

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoEngine afalg: properly set operation type also on big endian.
Tomas Mraz [Wed, 12 Oct 2016 12:32:05 +0000 (14:32 +0200)]
Engine afalg: properly set operation type also on big endian.

Copy the whole ALG_OP_TYPE to CMSG_DATA.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
3 years agoFix style issue
FdaSilvaYY [Fri, 14 Oct 2016 16:25:14 +0000 (18:25 +0200)]
Fix style issue

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

3 years agoConstify command options
FdaSilvaYY [Sun, 13 Mar 2016 13:07:50 +0000 (14:07 +0100)]
Constify command options

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

3 years agoFix C++ support: set $target{cxx} correctly
Richard Levitte [Fri, 14 Oct 2016 15:44:25 +0000 (17:44 +0200)]
Fix C++ support: set $target{cxx} correctly

Reviewed-by: Matt Caswell <matt@openssl.org>
3 years agoFix typo
Xiaoyin Liu [Mon, 26 Sep 2016 01:28:02 +0000 (21:28 -0400)]
Fix typo

I think the second "VC-WIN32" should be "VC-WIN64".
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
CLA: trivial

3 years agoConfigure: remove superfluous 0x
Vitezslav Cizek [Thu, 13 Oct 2016 09:44:08 +0000 (11:44 +0200)]
Configure: remove superfluous 0x

The number is taken from the OPENSSL_VERSION_NUMBER which is already
in the hex form.

CLA: trivial

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

3 years agoAdd memory leak detection to d2i_test
Dr. Stephen Henson [Thu, 13 Oct 2016 15:10:21 +0000 (16:10 +0100)]
Add memory leak detection to d2i_test

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

3 years agoFix copy-paste test labels
FdaSilvaYY [Tue, 11 Oct 2016 21:52:09 +0000 (23:52 +0200)]
Fix copy-paste test labels

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
3 years agoRemove automatic RPATH - Add a CHANGES entry
Richard Levitte [Wed, 12 Oct 2016 15:57:10 +0000 (17:57 +0200)]
Remove automatic RPATH - Add a CHANGES entry

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoRemove automatic RPATH - adapt shlib_wrap.sh
Richard Levitte [Wed, 12 Oct 2016 22:08:55 +0000 (00:08 +0200)]
Remove automatic RPATH - adapt shlib_wrap.sh

Looking for something starting with '-Wl,-rpath,' isn't good enough,
as someone might give something like '-Wl,--enable-new-dtags,-rpath,/PATH'.
Looking for ',-rpath,' should be safe enough.

We could remove the preloading stuff entirely, but just in case the
user has chosen to given RPATH setting arguments at configuration,
we'd better make sure testing will still work.  Fair warning, there
are some configuration options that do not work with preloaded OpenSSL
libraries, such as the sanity checking ones.

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoRemove automatic RPATH - add user rpath support
Richard Levitte [Wed, 12 Oct 2016 15:05:35 +0000 (17:05 +0200)]
Remove automatic RPATH - add user rpath support

Make Configure recognise -rpath and -R to support user added rpaths
for OSF1 and Solaris.  For convenience, add a variable LIBRPATH in the
Unix Makefile, which the users can use as follows:

    ./config [options] -Wl,-rpath,\$(LIBRPATH)

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoRemove automatic RPATH
Richard Levitte [Wed, 12 Oct 2016 15:18:11 +0000 (17:18 +0200)]
Remove automatic RPATH

Before OpenSSL 1.1.0, binaries were installed in a non-standard
location by default, and runpath directories were therefore added in
those binaries, to make sure the executables would be able to find the
shared libraries they were linked with.

With OpenSSL 1.1.0 and on, binaries are installed in standard
directories by default, and the addition of runpath directories is
therefore not needed any more.

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoRT is put out to pasture
Rich Salz [Wed, 12 Oct 2016 19:49:06 +0000 (15:49 -0400)]
RT is put out to pasture

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

3 years agoAdd C++ settings in the Linux config targets
Richard Levitte [Wed, 12 Oct 2016 13:33:13 +0000 (15:33 +0200)]
Add C++ settings in the Linux config targets

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoAdd support for C++ in Configurations/unix-Makefile.tmpl
Richard Levitte [Wed, 12 Oct 2016 13:30:43 +0000 (15:30 +0200)]
Add support for C++ in Configurations/unix-Makefile.tmpl

Note that it relies on a trick from Configure, where file names for
object files made from C++ source get '.cc' replaced with '_cc.o' to
recognise them.  This is needed so the correct compiler is used when
linking binaries.

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoAdd support for C++ in Configure
Richard Levitte [Wed, 12 Oct 2016 13:30:08 +0000 (15:30 +0200)]
Add support for C++ in Configure

A note: this will form object file names by changing '.cc' to
'_cc.o'.  This will permit other configuration code to recognise these
object files were built for C++ rather than C.

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoFix X509_NAME decode for malloc failures.
Dr. Stephen Henson [Sun, 2 Oct 2016 14:21:29 +0000 (15:21 +0100)]
Fix X509_NAME decode for malloc failures.

The original X509_NAME decode free code was buggy: this
could result in double free or leaks if a malloc failure
occurred.

Simplify and fix the logic.

Thanks to Guido Vranken for reporting this issue.

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

3 years agodoc/crypto/OPENSSL_ia32cap.pod: update assembler requirements.
Andy Polyakov [Sun, 9 Oct 2016 20:06:12 +0000 (22:06 +0200)]
doc/crypto/OPENSSL_ia32cap.pod: update assembler requirements.

Reviewed-by: Richard Levitte <levitte@openssl.org>
3 years ago.travis.yml: minor optimizations:
Andy Polyakov [Mon, 10 Oct 2016 10:22:10 +0000 (12:22 +0200)]
.travis.yml: minor optimizations:

- make 'pip install --user cpp-coveralls' conditional;
- limit no-stdio to single build per operating environment;
- omit enable-asan duplicate;

Reviewed-by: Richard Levitte <levitte@openssl.org>
3 years ago.travis.yml: install wine on demand.
Andy Polyakov [Sun, 9 Oct 2016 21:28:03 +0000 (23:28 +0200)]
.travis.yml: install wine on demand.

Reviewed-by: Richard Levitte <levitte@openssl.org>
3 years agoFix up bn_prime.pl formatting.
David Benjamin [Mon, 10 Oct 2016 21:33:51 +0000 (17:33 -0400)]
Fix up bn_prime.pl formatting.

Align at 5 characters, not 4. There are 5-digit numbers in the output.
Also avoid emitting an extra blank line and trailing whitespace.

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
3 years agoRemove trailing whitespace from some files.
David Benjamin [Mon, 10 Oct 2016 16:01:24 +0000 (12:01 -0400)]
Remove trailing whitespace from some files.

The prevailing style seems to not have trailing whitespace, but a few
lines do. This is mostly in the perlasm files, but a few C files got
them after the reformat. This is the result of:

  find . -name '*.pl' | xargs sed -E -i '' -e 's/( |'$'\t'')*$//'
  find . -name '*.c' | xargs sed -E -i '' -e 's/( |'$'\t'')*$//'
  find . -name '*.h' | xargs sed -E -i '' -e 's/( |'$'\t'')*$//'

Then bn_prime.h was excluded since this is a generated file.

Note mkerr.pl has some changes in a heredoc for some help output, but
other lines there lack trailing whitespace too.

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
3 years agoAdd some missing types to indent.pro
FdaSilvaYY [Sat, 8 Oct 2016 12:25:20 +0000 (14:25 +0200)]
Add some missing types to indent.pro

Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
3 years agoUpdate fuzz corpora
Kurt Roeckx [Sun, 9 Oct 2016 13:39:15 +0000 (15:39 +0200)]
Update fuzz corpora

New minimal fuzz corpora for asn1, asn1parse, bndiv, crl and x509

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

3 years agoFix linebreaks in the tls_construct_client_certificate function
Matt Caswell [Mon, 3 Oct 2016 14:37:47 +0000 (15:37 +0100)]
Fix linebreaks in the tls_construct_client_certificate function

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoAdd a typedef for the construction function
Matt Caswell [Mon, 3 Oct 2016 14:35:17 +0000 (15:35 +0100)]
Add a typedef for the construction function

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoMove setting of the handshake header up one more level
Matt Caswell [Fri, 30 Sep 2016 10:17:57 +0000 (11:17 +0100)]
Move setting of the handshake header up one more level

We now set the handshake header, and close the packet directly in the
write_state_machine. This is now possible because it is common for all
messages.

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoRemove the special case processing for finished construction
Matt Caswell [Fri, 30 Sep 2016 09:50:57 +0000 (10:50 +0100)]
Remove the special case processing for finished construction

tls_construct_finished() used to have different arguments to all of the
other construction functions. It doesn't anymore, so there is no neeed to
treat it as a special case.

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoHarmonise setting the header and closing construction
Matt Caswell [Fri, 30 Sep 2016 09:38:32 +0000 (10:38 +0100)]
Harmonise setting the header and closing construction

Ensure all message types work the same way including CCS so that the state
machine doesn't need to know about special cases. Put all the special logic
into ssl_set_handshake_header() and ssl_close_construct_packet().

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoDon't set the handshake header in every message
Matt Caswell [Thu, 29 Sep 2016 23:27:40 +0000 (00:27 +0100)]
Don't set the handshake header in every message

Move setting the handshake header up a level into the state machine code
in order to reduce boilerplate.

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoMove init of the WPACKET into write_state_machine()
Matt Caswell [Thu, 29 Sep 2016 22:28:29 +0000 (23:28 +0100)]
Move init of the WPACKET into write_state_machine()

Instead of initialising, finishing and cleaning up the WPACKET in every
message construction function, we should do it once in
write_state_machine().

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoRemove untrue comment.
Ben Laurie [Sat, 1 Oct 2016 11:41:36 +0000 (12:41 +0100)]
Remove untrue comment.

Reviewed-by: Richard Levitte <levitte@openssl.org>
3 years agoMake dependencies if Makefile is new.
Ben Laurie [Sat, 1 Oct 2016 11:40:58 +0000 (12:40 +0100)]
Make dependencies if Makefile is new.

Reviewed-by: Richard Levitte <levitte@openssl.org>
3 years agoRename ssl_set_handshake_header2()
Matt Caswell [Thu, 29 Sep 2016 21:40:15 +0000 (22:40 +0100)]
Rename ssl_set_handshake_header2()

ssl_set_handshake_header2() was only ever a temporary name while we had
to have ssl_set_handshake_header() for code that hadn't been converted to
WPACKET yet. No code remains that needed that so we can rename it.

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoRemove ssl_set_handshake_header()
Matt Caswell [Thu, 29 Sep 2016 21:32:36 +0000 (22:32 +0100)]
Remove ssl_set_handshake_header()

Remove the old ssl_set_handshake_header() implementations. Later we will
rename ssl_set_handshake_header2() to ssl_set_handshake_header().

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoRemove the tls12_get_sigandhash_old() function
Matt Caswell [Thu, 29 Sep 2016 17:08:34 +0000 (18:08 +0100)]
Remove the tls12_get_sigandhash_old() function

This is no longer needed now that all messages use WPACKET

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agofix memory leak
Dr. Stephen Henson [Sun, 2 Oct 2016 14:59:26 +0000 (15:59 +0100)]
fix memory leak

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoDon't use DES when disabled.
Ben Laurie [Sun, 2 Oct 2016 10:19:29 +0000 (11:19 +0100)]
Don't use DES when disabled.

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agofix memory leak
Dr. Stephen Henson [Sat, 1 Oct 2016 14:16:59 +0000 (15:16 +0100)]
fix memory leak

Reviewed-by: Tim Hudson <tjh@openssl.org>
3 years agoAdd SRP test vectors from RFC5054
Dr. Stephen Henson [Thu, 29 Sep 2016 22:22:46 +0000 (23:22 +0100)]
Add SRP test vectors from RFC5054

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoSRP code tidy.
Dr. Stephen Henson [Thu, 29 Sep 2016 18:24:26 +0000 (19:24 +0100)]
SRP code tidy.

Tidy up srp_Calc_k and SRP_Calc_u by making them a special case of
srp_Calc_xy which performs SHA1(PAD(x) | PAD(y)).

This addresses an OCAP Audit issue.

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoConvert NewSessionTicket construction to WPACKET
Matt Caswell [Thu, 29 Sep 2016 17:00:37 +0000 (18:00 +0100)]
Convert NewSessionTicket construction to WPACKET

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoFix an error in packet_locl.h
Matt Caswell [Thu, 29 Sep 2016 17:00:01 +0000 (18:00 +0100)]
Fix an error in packet_locl.h

A convenience macro was using the wrong underlying function.

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoConvert CertStatus message construction to WPACKET
Matt Caswell [Thu, 29 Sep 2016 15:40:13 +0000 (16:40 +0100)]
Convert CertStatus message construction to WPACKET

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoFix mis-named macro in packet_locl.h
Matt Caswell [Thu, 29 Sep 2016 15:39:32 +0000 (16:39 +0100)]
Fix mis-named macro in packet_locl.h

A couple of the WPACKET_sub_memcpy* macros were mis-named.

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoConvert SeverDone construction to WPACKET
Matt Caswell [Thu, 29 Sep 2016 14:14:33 +0000 (15:14 +0100)]
Convert SeverDone construction to WPACKET

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agomake update
Dr. Stephen Henson [Wed, 28 Sep 2016 15:59:54 +0000 (16:59 +0100)]
make update

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoPrint <ABSENT> if a STACK is NULL.
Dr. Stephen Henson [Wed, 28 Sep 2016 14:18:58 +0000 (15:18 +0100)]
Print <ABSENT> if a STACK is NULL.

If a STACK (corresponding to SEQUENCE OF or SET OF) is NULL then the
field is absent as opposed to empty (present but has zero elements).

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoadd item list support to d2i_test
Dr. Stephen Henson [Tue, 27 Sep 2016 23:24:58 +0000 (00:24 +0100)]
add item list support to d2i_test

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoASN1_ITEM should use type name not structure name.
Dr. Stephen Henson [Tue, 27 Sep 2016 21:39:12 +0000 (22:39 +0100)]
ASN1_ITEM should use type name not structure name.

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoAdd -item option to asn1parse
Dr. Stephen Henson [Tue, 27 Sep 2016 21:25:08 +0000 (22:25 +0100)]
Add -item option to asn1parse

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoAdd ASN1_ITEM lookup and enumerate functions.
Dr. Stephen Henson [Tue, 27 Sep 2016 20:15:57 +0000 (21:15 +0100)]
Add ASN1_ITEM lookup and enumerate functions.

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoFix missing NULL checks in NewSessionTicket construction
Matt Caswell [Thu, 29 Sep 2016 14:38:44 +0000 (15:38 +0100)]
Fix missing NULL checks in NewSessionTicket construction

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoFix an mis-matched function code so that "make update" doesn't fail
Matt Caswell [Thu, 29 Sep 2016 14:32:35 +0000 (15:32 +0100)]
Fix an mis-matched function code so that "make update" doesn't fail

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoAdd an example of usage to the WPACKET_reserve_bytes() documentation
Matt Caswell [Thu, 29 Sep 2016 13:45:49 +0000 (14:45 +0100)]
Add an example of usage to the WPACKET_reserve_bytes() documentation

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoAddress style feedback comments
Matt Caswell [Thu, 29 Sep 2016 13:39:47 +0000 (14:39 +0100)]
Address style feedback comments

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoFix a bug in CKE construction for PSK
Matt Caswell [Thu, 29 Sep 2016 11:04:08 +0000 (12:04 +0100)]
Fix a bug in CKE construction for PSK

In plain PSK we don't need to do anymore construction after the preamble.
We weren't detecting this case and treating it as an unknown cipher.

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoConvert ServerKeyExchange construction to WPACKET
Matt Caswell [Thu, 29 Sep 2016 10:46:08 +0000 (11:46 +0100)]
Convert ServerKeyExchange construction to WPACKET

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoAdd the WPACKET_reserve_bytes() function
Matt Caswell [Thu, 29 Sep 2016 10:43:37 +0000 (11:43 +0100)]
Add the WPACKET_reserve_bytes() function

WPACKET_allocate_bytes() requires you to know the size of the data you
are allocating for, before you create it. Sometimes this isn't the case,
for example we know the maximum size that a signature will be before we
create it, but not the actual size. WPACKET_reserve_bytes() enables us to
reserve bytes in the WPACKET, but not count them as written yet. We then
subsequently need to acall WPACKET_allocate_bytes to actually count them as
written.

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoRemove tls12_copy_sigalgs_old()
Matt Caswell [Thu, 29 Sep 2016 13:26:36 +0000 (14:26 +0100)]
Remove tls12_copy_sigalgs_old()

This was a temporary function needed during the conversion to WPACKET. All
callers have now been converted to the new way of doing this so this
function is no longer required.

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoConvert CertificateRequest construction to WPACKET
Matt Caswell [Thu, 29 Sep 2016 13:25:52 +0000 (14:25 +0100)]
Convert CertificateRequest construction to WPACKET

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoAddress style feedback comments
Matt Caswell [Thu, 29 Sep 2016 09:06:11 +0000 (10:06 +0100)]
Address style feedback comments

Merge declarations of same type together.

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoFix a bug in the construction of the ClienHello SRTP extension
Matt Caswell [Wed, 28 Sep 2016 12:33:41 +0000 (13:33 +0100)]
Fix a bug in the construction of the ClienHello SRTP extension

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoFix heartbeat compilation error
Matt Caswell [Wed, 28 Sep 2016 11:03:30 +0000 (12:03 +0100)]
Fix heartbeat compilation error

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoDelete some unneeded code
Matt Caswell [Wed, 28 Sep 2016 10:15:36 +0000 (11:15 +0100)]
Delete some unneeded code

Some functions were being called from both code that used WPACKETs and code
that did not. Now that more code has been converted to use WPACKETs some of
that duplication can be removed.

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoConvert ServerHello construction to WPACKET
Matt Caswell [Wed, 28 Sep 2016 10:13:48 +0000 (11:13 +0100)]
Convert ServerHello construction to WPACKET

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoFix an Uninit read in DTLS
Matt Caswell [Wed, 28 Sep 2016 13:12:26 +0000 (14:12 +0100)]
Fix an Uninit read in DTLS

If we have a handshake fragment waiting then dtls1_read_bytes() was not
correctly setting the value of recvd_type, leading to an uninit read.

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoFix no-dtls
Matt Caswell [Wed, 28 Sep 2016 08:35:05 +0000 (09:35 +0100)]
Fix no-dtls

The new large message test in sslapitest needs OPENSSL_NO_DTLS guards

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

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

Reviewed-by: Stephen Henson <steve@openssl.org>
3 years agoRevert "Call ENGINE_init() before trying to use keys from engine"
Rich Salz [Wed, 28 Sep 2016 18:40:25 +0000 (14:40 -0400)]
Revert "Call ENGINE_init() before trying to use keys from engine"

This reverts commit 0a72002993b8619fd0642d19af3364bafbd9a06c.
This fails to call ENGINE_finish; an alternate fix is forthcoming.

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

When I said before that s_client "used to work in 1.0.2" that was only
partly true. It worked for engines which provided a default generic
method for some key type, because it called ENGINE_set_default() and
that ended up being an implicit initialisation and functional refcount.

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

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

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

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

3 years agoRestore '-keyform engine' support for s_client
David Woodhouse [Wed, 28 Sep 2016 12:07:52 +0000 (13:07 +0100)]
Restore '-keyform engine' support for s_client

This used to work in 1.0.2 but disappeared when the argument parsing was
revamped.

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

3 years agoAdd DTLS renegotiation tests
Matt Caswell [Tue, 27 Sep 2016 11:24:47 +0000 (12:24 +0100)]
Add DTLS renegotiation tests

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoExtend the renegotiation tests
Matt Caswell [Tue, 27 Sep 2016 10:50:43 +0000 (11:50 +0100)]
Extend the renegotiation tests

Add the ability to test both server initiated and client initiated reneg.

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoUpdate README.ssltest.md
Matt Caswell [Tue, 27 Sep 2016 09:18:00 +0000 (10:18 +0100)]
Update README.ssltest.md

Add update for testing renegotiation. Also change info on CTLOG_FILE
environment variable - which always seems to be required.

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoAdd support for testing renegotiation
Matt Caswell [Mon, 26 Sep 2016 16:25:43 +0000 (17:25 +0100)]
Add support for testing renegotiation

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoFix a bug in Renegotiation extension construction
Matt Caswell [Mon, 26 Sep 2016 14:31:20 +0000 (15:31 +0100)]
Fix a bug in Renegotiation extension construction

The conversion to WPACKET broke the construction of the renegotiation
extension.

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoConvert HelloRequest construction to WPACKET
Matt Caswell [Mon, 26 Sep 2016 13:59:08 +0000 (14:59 +0100)]
Convert HelloRequest construction to WPACKET

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoAdd missing parameter.
David Benjamin [Thu, 25 Aug 2016 05:55:48 +0000 (01:55 -0400)]
Add missing parameter.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
3 years agoSwitch back to assuming TLS 1.2.
David Benjamin [Thu, 18 Aug 2016 04:43:05 +0000 (00:43 -0400)]
Switch back to assuming TLS 1.2.

The TLSProxy::Record->new call hard-codes a version, like
70-test_sslrecords.t.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
3 years agoAddress review comments.
David Benjamin [Thu, 18 Aug 2016 04:38:43 +0000 (00:38 -0400)]
Address review comments.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
3 years agoDon't test quite so many of them.
David Benjamin [Wed, 10 Aug 2016 14:45:49 +0000 (10:45 -0400)]
Don't test quite so many of them.

Avoid making the CI blow up.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
3 years agoTest CBC mode padding.
David Benjamin [Wed, 10 Aug 2016 04:45:51 +0000 (00:45 -0400)]
Test CBC mode padding.

This is a regression test for
https://github.com/openssl/openssl/pull/1431. It tests a
maximally-padded record with each possible invalid offset.

This required fixing a bug in Message.pm where the client sending a
fatal alert followed by close_notify was still treated as success.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
3 years agoFix some mem leaks in sslapitest
Matt Caswell [Mon, 26 Sep 2016 11:04:23 +0000 (12:04 +0100)]
Fix some mem leaks in sslapitest

A mem leak could occur on an error path. Also the mempacket BIO_METHOD
needs to be cleaned up, because of the newly added DTLS test.

Also fixed a double semi-colon in ssltestlib.c

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoAdd a basic test for BN_bn2dec.
David Benjamin [Thu, 25 Aug 2016 21:45:20 +0000 (17:45 -0400)]
Add a basic test for BN_bn2dec.

This would have caught 099e2968ed3c7d256cda048995626664082b1b30. This is
a port of the test added in
https://boringssl.googlesource.com/boringssl/+/7c040756178e14a4d181b6d93abb3827c93189c4

Reviewed-by: Emilia Käsper <emilia@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1496)

3 years agoFix HelloVerifyRequest construction
Matt Caswell [Fri, 23 Sep 2016 13:40:16 +0000 (14:40 +0100)]
Fix HelloVerifyRequest construction

commit c536b6be1a introduced a bug that causes a reachable assert. This fixes
it.

Reviewed-by: Rich Salz <rsalz@openssl.org>
3 years agoUpdates CHANGES and NEWS for new release
Matt Caswell [Mon, 26 Sep 2016 08:43:45 +0000 (09:43 +0100)]
Updates CHANGES and NEWS for new release

Reviewed-by: Richard Levitte <levitte@openssl.org>
3 years agoAdd to fuzz corpora for CVE-2016-6309
Robert Swiecki [Sun, 25 Sep 2016 15:35:56 +0000 (16:35 +0100)]
Add to fuzz corpora for CVE-2016-6309

Reviewed-by: Emilia Käsper <emilia@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
3 years agoFix Use After Free for large message sizes
Matt Caswell [Fri, 23 Sep 2016 15:58:11 +0000 (16:58 +0100)]
Fix Use After Free for large message sizes

The buffer to receive messages is initialised to 16k. If a message is
received that is larger than that then the buffer is "realloc'd". This can
cause the location of the underlying buffer to change. Anything that is
referring to the old location will be referring to free'd data. In the
recent commit c1ef7c97 (master) and 4b390b6c (1.1.0) the point in the code
where the message buffer is grown was changed. However s->init_msg was not
updated to point at the new location.

CVE-2016-6309

Reviewed-by: Emilia Käsper <emilia@openssl.org>
3 years agoFix a WPACKET bug
Matt Caswell [Fri, 23 Sep 2016 15:41:50 +0000 (16:41 +0100)]
Fix a WPACKET bug

If we request more bytes to be allocated than double what we have already
written, then we grow the buffer by the wrong amount.

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