oweals/openssl.git
8 years agoClient side CKE processing can double free on error
Matt Caswell [Thu, 28 Apr 2016 14:12:37 +0000 (15:12 +0100)]
Client side CKE processing can double free on error

The tls_client_key_exchange_post_work() frees the pms on error. It also
calls ssl_generate_master_secret() which also free the pms. If an error
occurs after ssl_generate_master_secret() has been called then a double
free can occur.

Reviewed-by: Andy Polyakov <appro@openssl.org>
8 years agoDon't free the BIGNUM passed to BN_mpi2bn
Matt Caswell [Thu, 28 Apr 2016 18:53:08 +0000 (19:53 +0100)]
Don't free the BIGNUM passed to BN_mpi2bn

Commit 91fb42dd fixed a leak but introduced a problem where a parameter
is erroneously freed instead.

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoFix a leak in i2b_PVK
Matt Caswell [Thu, 28 Apr 2016 18:49:17 +0000 (19:49 +0100)]
Fix a leak in i2b_PVK

Commit 8e588e28 fixed a leak but introduced a new one.

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agomake update
Richard Levitte [Fri, 29 Apr 2016 07:09:46 +0000 (09:09 +0200)]
make update

Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoapps/progs.pl: don't make digests disablable by default
Richard Levitte [Fri, 29 Apr 2016 07:08:06 +0000 (09:08 +0200)]
apps/progs.pl: don't make digests disablable by default

Some digest algorithms can't be disabled, don't pretend they can.

Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoBIO_free should call method->destroy before free'ing member fields
FdaSilvaYY [Thu, 28 Apr 2016 18:13:44 +0000 (20:13 +0200)]
BIO_free should call method->destroy before free'ing member fields

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

8 years agoAdd checks on CRYPTO_new_ex_data return value...
FdaSilvaYY [Tue, 8 Mar 2016 19:11:48 +0000 (20:11 +0100)]
Add checks on CRYPTO_new_ex_data return value...
with some adaptation to new multi-threading API.

Once reference, lock, meth and flag fields are setup,
DSA_free/DH_free can be called directly.

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

8 years agoAdd checks on CRYPTO_new_ex_data return value
FdaSilvaYY [Sat, 13 Feb 2016 18:29:34 +0000 (19:29 +0100)]
Add checks on CRYPTO_new_ex_data return value

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

8 years agoFix an error code spelling.
FdaSilvaYY [Mon, 4 Apr 2016 18:42:27 +0000 (20:42 +0200)]
Fix an error code spelling.

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

8 years agovarious spelling fixes
FdaSilvaYY [Thu, 10 Mar 2016 20:34:48 +0000 (21:34 +0100)]
various spelling fixes

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

8 years agoAdd getters for X509_STORE and X509_OBJECT members
Christian Heimes [Tue, 19 Apr 2016 19:11:30 +0000 (21:11 +0200)]
Add getters for X509_STORE and X509_OBJECT members

OpenSSL 1.1.0-pre5 has made some additional structs opaque. Python's ssl
module requires access to some of the struct members. Three new getters
are added:

int X509_OBJECT_get_type(X509_OBJECT *a);
STACK_OF(X509_OBJECT) *X509_STORE_get0_objects(X509_STORE *v);
X509_VERIFY_PARAM *X509_STORE_get0_param(X509_STORE *ctx);

Signed-off-by: Christian Heimes <cheimes@redhat.com>
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agomake update
Viktor Dukhovni [Wed, 27 Apr 2016 18:37:19 +0000 (14:37 -0400)]
make update

Recycling an unused slot.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoImplement X509_STORE_CTX_set_current_cert() accessor
Viktor Dukhovni [Wed, 27 Apr 2016 18:36:48 +0000 (14:36 -0400)]
Implement X509_STORE_CTX_set_current_cert() accessor

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoFix BIO_set_nbio_accept()
Richard Levitte [Thu, 28 Apr 2016 15:39:26 +0000 (17:39 +0200)]
Fix BIO_set_nbio_accept()

The code that implements this control would work when enabling nbio,
but the disabling code needed fixing.

Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoDon't leak memory on error path in dane_ctx_enable()
Matt Caswell [Wed, 27 Apr 2016 13:22:20 +0000 (14:22 +0100)]
Don't leak memory on error path in dane_ctx_enable()

The function dane_ctx_enable() allocated some memory that it did not
free in an error path.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoFree an ASN1_OBJECT in an error path
Matt Caswell [Wed, 27 Apr 2016 13:17:33 +0000 (14:17 +0100)]
Free an ASN1_OBJECT in an error path

The r2i_certpol() function allocates an ASN1_OBJECT but can fail to free
it in an error path.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoDon't leak an ASN1_OCTET_STRING on error in rsa_cms_encrypt
Matt Caswell [Wed, 27 Apr 2016 13:13:59 +0000 (14:13 +0100)]
Don't leak an ASN1_OCTET_STRING on error in rsa_cms_encrypt

The rsa_cms_encrypt() function allocates an ASN1_OCTET_STRING but can
then fail to free it in an error condition.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoFree memory on error in PKCS7_dataFinal()
Matt Caswell [Wed, 27 Apr 2016 13:09:35 +0000 (14:09 +0100)]
Free memory on error in PKCS7_dataFinal()

The PKCS7_dataFinal() function allocates a memory buffer but then fails
to free it on an error condition.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoDon't leak memory on error in PKCS12_key_gen_uni
Matt Caswell [Wed, 27 Apr 2016 13:06:40 +0000 (14:06 +0100)]
Don't leak memory on error in PKCS12_key_gen_uni

The PKCS12_key_gen_uni() had one error path which did not free memory
correctly.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoDon't leak memory on error in i2b_PVK
Matt Caswell [Wed, 27 Apr 2016 13:00:37 +0000 (14:00 +0100)]
Don't leak memory on error in i2b_PVK

The i2b_PVK function leaked a number of different memory allocations on
error paths (and even some non-error paths).

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoDon't leak memory on error in b2i_rsa
Matt Caswell [Wed, 27 Apr 2016 12:52:37 +0000 (13:52 +0100)]
Don't leak memory on error in b2i_rsa

The b2i_rsa() function uses a number of temporary local variables which
get leaked on an error path.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoDon't leak resource on error in OCSP_url_svcloc_new
Matt Caswell [Wed, 27 Apr 2016 12:40:52 +0000 (13:40 +0100)]
Don't leak resource on error in OCSP_url_svcloc_new

On error we could leak a ACCESS_DESCRIPTION and an ASN1_IA5STRING. Both
should be freed in the error path.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoCheck that we were actually allocated BIGNUMs in dsa_builtin_paramgen2
Matt Caswell [Wed, 27 Apr 2016 12:32:58 +0000 (13:32 +0100)]
Check that we were actually allocated BIGNUMs in dsa_builtin_paramgen2

Calls to BN_CTX_get() can fail so we should check that they were
successful.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoDon't leak EVP_MD_CTX on error path
Matt Caswell [Wed, 27 Apr 2016 12:22:29 +0000 (13:22 +0100)]
Don't leak EVP_MD_CTX on error path

The cms_SignerInfo_content_sign() function allocated an EVP_MD_CTX but
then failed to free it on an error path.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoDon't leak memory on error in cms_RecipientInfo_pwri_crypt
Matt Caswell [Wed, 27 Apr 2016 12:18:38 +0000 (13:18 +0100)]
Don't leak memory on error in cms_RecipientInfo_pwri_crypt

The cms_RecipientInfo_pwri_crypt() allocated an EVP_CIPHER_CTX but then
failed to free it in some error paths. By allocating it a bit later that
can be avoided.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoDon't leak memory on error in BN_generate_prime_ex
Matt Caswell [Wed, 27 Apr 2016 11:59:19 +0000 (12:59 +0100)]
Don't leak memory on error in BN_generate_prime_ex

In BN_generate_prime_ex() we do some sanity checks first and return
with an error if they fail. We should do that *before* allocating any
resources to avoid a memory leak.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoFree a BIGNUM on error in BN_mpi2bn
Matt Caswell [Wed, 27 Apr 2016 11:55:44 +0000 (12:55 +0100)]
Free a BIGNUM on error in BN_mpi2bn

In the BN_mpi2bn() function, a failure of a call to BN_bin2bn() could
result in the leak of a previously allocated BIGNUM value.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoDon't leak memory on failure to create a mem BIO
Matt Caswell [Wed, 27 Apr 2016 11:52:29 +0000 (12:52 +0100)]
Don't leak memory on failure to create a mem BIO

During construction of a mem BIO we allocate some resources. If this
allocation fails we can end up leaking everything we have allocated so
far.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoClose the accept socket on error
Matt Caswell [Wed, 27 Apr 2016 11:46:51 +0000 (12:46 +0100)]
Close the accept socket on error

When setting an accepted socket for non-blocking, if the operation fails
make sure we close the accepted socket.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoMake BIO_sock_error return a proper error code when getsockopt fails
Richard Levitte [Thu, 28 Apr 2016 11:19:38 +0000 (13:19 +0200)]
Make BIO_sock_error return a proper error code when getsockopt fails

BIO_sock_error() returned 1 when getsockopt() fails when it should
return the error code for that failure.

Additionally, the optlen parameter to getsockopt() has to point at
the size of the area that the optval parameter points at rather than
zero.  Some systems may forgive it being zero, but others don't.

Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoReject inappropriate private key encryption ciphers.
Dr. Stephen Henson [Sat, 23 Apr 2016 12:33:05 +0000 (13:33 +0100)]
Reject inappropriate private key encryption ciphers.

The traditional private key encryption algorithm doesn't function
properly if the IV length of the cipher is zero. These ciphers
(e.g. ECB mode) are not suitable for private key encryption
anyway.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
8 years agoFix set0 reuse test
Viktor Dukhovni [Wed, 27 Apr 2016 19:08:33 +0000 (15:08 -0400)]
Fix set0 reuse test

We must test for new object == current object, not !=.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoFuture proof build_chain() in x509_vfy.c
Viktor Dukhovni [Tue, 26 Apr 2016 18:17:57 +0000 (14:17 -0400)]
Future proof build_chain() in x509_vfy.c

Coverity reports a potential NULL deref when "2 0 0" DANE trust-anchors
from DNS are configured via SSL_dane_tlsa_add() and X509_STORE_CTX_init()
is called with a NULL stack of untrusted certificates.

Since ssl_verify_cert_chain() always provideds a non-NULL stack of
untrusted certs, and no other code path enables DANE, the problem
can only happen in applications that use SSL_CTX_set_cert_verify_callback()
to implement their own wrappers around X509_verify_cert() passing
only the leaf certificate to the latter.

Regardless of the "improbability" of the problem, we do need to
ensure that build_chain() handles this case correctly.

Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoDocumentation the changed {RSA,DSA,DH}_set0_* functionality change
Richard Levitte [Tue, 26 Apr 2016 11:40:53 +0000 (13:40 +0200)]
Documentation the changed {RSA,DSA,DH}_set0_* functionality change

Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoRSA, DSA, DH: Allow some given input to be NULL on already initialised keys
Richard Levitte [Mon, 25 Apr 2016 18:28:54 +0000 (20:28 +0200)]
RSA, DSA, DH: Allow some given input to be NULL on already initialised keys

The diverse {RSA,DSA,DH}_set0_* functions are made to allow some
parameters to be NULL IF the corresponding numbers in the given key
structure have already been previously initialised.  Specifically,
this allows the addition of private components to be added to a key
that already has the public half, approximately like this:

    RSA_get0_key(rsa, NULL, &e, NULL);
    RSA_get0_factors(rsa, &p, &q);
    /* calculate new d */
    RSA_set0_key(rsa, NULL, NULL, d);

Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoGH975 Add ex_data functions for X509_STORE
Kazuki Yamaguchi [Tue, 19 Apr 2016 01:22:15 +0000 (10:22 +0900)]
GH975 Add ex_data functions for X509_STORE

Add X509_STORE_{set,get}_ex_data() function and
X509_STORE_get_ex_new_index() macro.

X509_STORE has ex_data and the documentation also mentions them but they
are not actually implemented.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoFix no-gost no-srp no-ec no-dh.
Ben Laurie [Tue, 19 Apr 2016 07:25:58 +0000 (08:25 +0100)]
Fix no-gost no-srp no-ec no-dh.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoFix enable-ssl-trace no-nextprotoneg.
Ben Laurie [Mon, 18 Apr 2016 09:45:02 +0000 (10:45 +0100)]
Fix enable-ssl-trace no-nextprotoneg.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoFix no-engine no-ui.
Ben Laurie [Mon, 18 Apr 2016 09:44:42 +0000 (10:44 +0100)]
Fix no-engine no-ui.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agosplit_send_fragment should always be less than or equal to max_send_fragment
Matt Caswell [Tue, 26 Apr 2016 17:01:24 +0000 (18:01 +0100)]
split_send_fragment should always be less than or equal to max_send_fragment

A bug meant that SSL_CTRL_SET_MAX_SEND_FRAGMENT was not adjusting
split_send_fragment properly.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoFix BIO_CTRL_DUP for an SSL BIO
Matt Caswell [Tue, 26 Apr 2016 16:52:21 +0000 (17:52 +0100)]
Fix BIO_CTRL_DUP for an SSL BIO

The variables in the BIO weren't being duplicated properly.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
8 years agoFix passwd seg fault
Matt Caswell [Tue, 26 Apr 2016 16:00:33 +0000 (17:00 +0100)]
Fix passwd seg fault

Passing the -stdin arg to the passwd command line app *and* supply a
password on the command line causes a seg fault.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoSPARCv9 assembly pack: fine-tune run-time switch.
Andy Polyakov [Mon, 25 Apr 2016 21:17:57 +0000 (23:17 +0200)]
SPARCv9 assembly pack: fine-tune run-time switch.

Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agocamellia/build.info: fix typo
Andy Polyakov [Mon, 25 Apr 2016 21:24:06 +0000 (23:24 +0200)]
camellia/build.info: fix typo

RT#4520

Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agoRemove dead-code infinite loop
Benjamin Kaduk [Mon, 18 Apr 2016 17:50:34 +0000 (12:50 -0500)]
Remove dead-code infinite loop

Commit d32f5d8733df9938727710d4194e92813c421ef1 added a 'goto end;' statement
at the end of the code block for the 'end' label.  Fortunately, it was after a
return statement, so no infinite loop occurred, but it is still dead code.

Remove the extra goto statement as cleanup.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoAdd ex_data functions for X509_STORE
Kazuki Yamaguchi [Tue, 19 Apr 2016 01:22:15 +0000 (10:22 +0900)]
Add ex_data functions for X509_STORE

Add X509_STORE_{set,get}_ex_data() function and
X509_STORE_get_ex_new_index() macro.

X509_STORE has ex_data and the documentation also mentions them but they
are not actually implemented.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoEnsure we check i2d_X509 return val
Matt Caswell [Mon, 25 Apr 2016 15:05:55 +0000 (16:05 +0100)]
Ensure we check i2d_X509 return val

The i2d_X509() function can return a negative value on error. Therefore
we should make sure we check it.

Issue reported by Yuan Jochen Kang.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
8 years ago*.der files are binary.
Dr. Stephen Henson [Tue, 26 Apr 2016 11:57:24 +0000 (12:57 +0100)]
*.der files are binary.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoRemove the never-functional no-sct
Benjamin Kaduk [Wed, 20 Apr 2016 18:51:58 +0000 (13:51 -0500)]
Remove the never-functional no-sct

It was added as part of 2df84dd3299ff25fa078ca7ffbdeaac65b361feb
but has never actually been used for anything; presumably it was
a typo for one of SCTP or CT.

This removes the last '??' entry from INSTALL.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoRemove some OPENSSL_NO_SHA that snuck in
Benjamin Kaduk [Wed, 20 Apr 2016 18:58:25 +0000 (13:58 -0500)]
Remove some OPENSSL_NO_SHA that snuck in

Commit d064e6ab52ac8e7b80b2a5d11b31bca583b769c7 removed all the
OPENSSL_NO_SHA guards, but commit
a50ad1daaa68c109ea1a14225a7aba8660526101 regenerated some due to the
sha entries in the %md_disabler table in apps/progs.pl.

Update %md_disabler to reflect that sha is not disableable, and
remove OPENSSL_NO_SHA for good.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agocrypto/poly1305/asm: chase overflow bit on x86 and ARM platforms.
Andy Polyakov [Fri, 15 Apr 2016 14:30:29 +0000 (16:30 +0200)]
crypto/poly1305/asm: chase overflow bit on x86 and ARM platforms.

Even though no test could be found to trigger this, paper-n-pencil
estimate suggests that x86 and ARM inner loop lazy reductions can
loose a bit in H4>>*5+H0 step.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
8 years agomake update
Viktor Dukhovni [Mon, 25 Apr 2016 19:13:27 +0000 (15:13 -0400)]
make update

And recycle some disused slots.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoAdded missing X509_STORE_CTX_set_error_depth() accessor
Viktor Dukhovni [Mon, 25 Apr 2016 19:02:02 +0000 (15:02 -0400)]
Added missing X509_STORE_CTX_set_error_depth() accessor

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoDocument the enhancements for DEPEND and INCLUDE and use a better example
Richard Levitte [Thu, 21 Apr 2016 19:08:42 +0000 (21:08 +0200)]
Document the enhancements for DEPEND and INCLUDE and use a better example

Reviewed-by: Emilia Käsper <emilia@openssl.org>
8 years agoBuild system: add include directories and dependencies for generators
Richard Levitte [Thu, 21 Apr 2016 12:30:08 +0000 (14:30 +0200)]
Build system: add include directories and dependencies for generators

In the case of generating a file like this:

    GENERATE[foo.S]=mkfoo.pl arg1 arg2

the 'mkfoo.pl' generator itself might need to include other files,
such as perl modules within our source tree.  We can reuse already
existing syntax for it, like this:

    INCLUDE[mkfoo.pl]=module/path

or:

    DEPEND[mkfoo.pl]=modules/mymodule.pm

This change implements the support for such constructs, and for the
DEPEND statement, for any value that indicates a perl module (.pm
file), it will automatically infer an INCLUDE statement for its
directory, just like it does for C header files, so you won't have do
write this:

    DEPEND[mkfoo.pl]=modules/mymodule.pm
    INCLUDE[mkfoo.pl]=modules

Reviewed-by: Emilia Käsper <emilia@openssl.org>
8 years agoFix NULL deref in apps/pkcs7
Rich Salz [Mon, 25 Apr 2016 12:56:54 +0000 (08:56 -0400)]
Fix NULL deref in apps/pkcs7

Thanks to Brian Carpenter for finding and reporting this.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
8 years agoAPI compat macros for renamed X509_STORE_CTX functions
Viktor Dukhovni [Sat, 23 Apr 2016 04:39:20 +0000 (00:39 -0400)]
API compat macros for renamed X509_STORE_CTX functions

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agos390x assembly pack: cache capability query results.
Andy Polyakov [Fri, 15 Apr 2016 14:39:22 +0000 (16:39 +0200)]
s390x assembly pack: cache capability query results.

IBM argues that in certain scenarios capability query is really
expensive. At the same time it's asserted that query results can
be safely cached, because disabling CPACF is incompatible with
reboot-free operation.

Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agocrypto/sparc_arch.h: reserve more SPARCv9 capability bits.
Andy Polyakov [Sat, 23 Apr 2016 17:10:04 +0000 (19:10 +0200)]
crypto/sparc_arch.h: reserve more SPARCv9 capability bits.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agochacha/asm/chacha-ppc.pl: get misalignment corner case right on big-endian.
Andy Polyakov [Sat, 23 Apr 2016 17:16:56 +0000 (19:16 +0200)]
chacha/asm/chacha-ppc.pl: get misalignment corner case right on big-endian.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoFix EC_KEY_set_private_key() to call key->group->meth->set_private()
Kazuki Yamaguchi [Thu, 21 Apr 2016 08:35:53 +0000 (17:35 +0900)]
Fix EC_KEY_set_private_key() to call key->group->meth->set_private()

Fix a bug introduced by 6903e2e7e9a4 (Extended EC_METHOD customisation
support., 2016-02-01). key->meth->set_private() is wrongly called where
it should call key->group->meth->set_private().

PR#4517

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Stephen Henson <steve@openssl.org>
8 years agoadd test for CVE-2016-2109
Dr. Stephen Henson [Fri, 22 Apr 2016 17:44:23 +0000 (18:44 +0100)]
add test for CVE-2016-2109

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoIn d2i_test return error for malloc failure.
Dr. Stephen Henson [Fri, 22 Apr 2016 17:37:42 +0000 (18:37 +0100)]
In d2i_test return error for malloc failure.

Bad ASN.1 data should never be able to trigger a malloc failure so return
an error in d2i_test if a malloc failure occurs.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoHarden ASN.1 BIO handling of large amounts of data.
Dr. Stephen Henson [Mon, 11 Apr 2016 12:57:20 +0000 (13:57 +0100)]
Harden ASN.1 BIO handling of large amounts of data.

If the ASN.1 BIO is presented with a large length field read it in
chunks of increasing size checking for EOF on each read. This prevents
small files allocating excessive amounts of data.

CVE-2016-2109

Thanks to Brian Carpenter for reporting this issue.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
8 years agoWarn when doing an out-of-source build and finding in-source build artifacts
Richard Levitte [Thu, 21 Apr 2016 16:03:16 +0000 (18:03 +0200)]
Warn when doing an out-of-source build and finding in-source build artifacts

The reason to warn is that configuration *may* pick up on
configuration header files that are in the source tree, that might be
for a wildly different configuration than what is expected in the
current out-of-source configuration.

Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agomake update
Viktor Dukhovni [Fri, 22 Apr 2016 00:06:49 +0000 (20:06 -0400)]
make update

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoEnabled DANE only when at least one TLSA RR was added
Viktor Dukhovni [Fri, 22 Apr 2016 00:00:58 +0000 (20:00 -0400)]
Enabled DANE only when at least one TLSA RR was added

It is up to the caller of SSL_dane_tlsa_add() to take appropriate
action when no records are added successfully or adding some records
triggers an internal error (negative return value).

With this change the caller can continue with PKIX if desired when
none of the TLSA records are usable, or take some appropriate action
if DANE is required.

Also fixed the internal ssl_dane_dup() function to properly initialize
the TLSA RR stack in the target SSL handle.  Errors in ssl_dane_dup()
are no longer ignored.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoDon't set peer_tmp until we have finished constructing it
Matt Caswell [Tue, 19 Apr 2016 22:33:35 +0000 (23:33 +0100)]
Don't set peer_tmp until we have finished constructing it

If we fail halfway through constructing the peer_tmp EVP_PKEY but we have
already stored it in s->s3->peer_tmp then if anything tries to use it then
it will likely fail. This was causing s_client to core dump in the
sslskewith0p test. s_client was trying to print out the connection
parameters that it had negotiated so far. Arguably s_client should not do
that if the connection has failed...but given it is existing functionality
it's easier to fix libssl.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
8 years agoExtensions to d2i_test.
Dr. Stephen Henson [Wed, 20 Apr 2016 20:37:57 +0000 (21:37 +0100)]
Extensions to d2i_test.

Using ASN1_ITEM tables in d2i_test: this then uses consistent names and
makes it easier to extend.

Add bio, reencode and compare tests.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
8 years agoFix capi engine for no-dsa
Matt Caswell [Fri, 22 Apr 2016 11:23:07 +0000 (12:23 +0100)]
Fix capi engine for no-dsa

The capi engine was failing to compile on Windows if the no-dsa option
was selected.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoFix no-dsa on Windows/VMS
Matt Caswell [Fri, 22 Apr 2016 11:10:19 +0000 (12:10 +0100)]
Fix no-dsa on Windows/VMS

The no-dsa option was failing on Windows because some symbols were not
correctly flagged in libcrypto.num. Problem found due to the new symbol
consistency test.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoFix the indentation of OPENSSL_NO_STDIO in pem.h
Matt Caswell [Fri, 22 Apr 2016 11:09:49 +0000 (12:09 +0100)]
Fix the indentation of OPENSSL_NO_STDIO in pem.h

Some pre-processor macros were incorrectly indented

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoFix no-cmac on Windows/VMS
Matt Caswell [Fri, 22 Apr 2016 10:47:57 +0000 (11:47 +0100)]
Fix no-cmac on Windows/VMS

no-cmac was failing on Windows/VMS due to libcrypto.num not marking the
CMAC functions properly. Found due to the new symbol consistency test.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoUnified copyright for test recipes
Rich Salz [Fri, 22 Apr 2016 11:21:51 +0000 (07:21 -0400)]
Unified copyright for test recipes

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoAdd a best effort test to check shared library consistency
Richard Levitte [Fri, 22 Apr 2016 08:20:59 +0000 (10:20 +0200)]
Add a best effort test to check shared library consistency

Our main development platforms are of the Unix family, which doesn't
have the same strictness regarding a shared library being consistent
with the contents of the ld script (.map file, on Linux and Solaris)
as Windows is with the contents of the .def file or VMS is with the
linker symb_vector option.

To eliminate surprises, we therefore need to make sure to check that
the contents of the .map file is matched with the shared library, at
least to check that the shared library isn't missing any symbols that
should be present.

This test isn't absolutely perfect, as it will only check the symbols
that would be present on Linux / Solaris and will therefore miss those
that would only appear on Windows or VMS.  On the other hand, those
platform specific are few and far apart in time, so it's not likely
they will pose a problem.

Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoFix CRYPTO_clear_realloc() bug.
Dr. Stephen Henson [Thu, 21 Apr 2016 14:30:17 +0000 (15:30 +0100)]
Fix CRYPTO_clear_realloc() bug.

If allocation in CRYPTO_clear_realloc() fails don't free up the original
buffer: this is consistent with the behaviour of realloc(3) and is expected
in other places in OpenSSL.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
8 years agoUpdate the Configurations READMEs
Richard Levitte [Thu, 21 Apr 2016 19:36:48 +0000 (21:36 +0200)]
Update the Configurations READMEs

Reviewed-by: Tim Hudson <tjh@openssl.org>
8 years agoFix no-ocsp on Windows (and probably VMS)
Matt Caswell [Wed, 20 Apr 2016 15:38:29 +0000 (16:38 +0100)]
Fix no-ocsp on Windows (and probably VMS)

The ocsp.h file did not have appropriate guards causing link failures on
Windows.

GH Issue 900

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoRemove some unneccessary assignments to argc
Matt Caswell [Thu, 21 Apr 2016 09:01:19 +0000 (10:01 +0100)]
Remove some unneccessary assignments to argc

openssl.c and ts.c assign the value of opt_num_rest() to argc, but then
only use the value once.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoRemove some unused argc assignments
Matt Caswell [Sat, 16 Apr 2016 11:18:19 +0000 (12:18 +0100)]
Remove some unused argc assignments

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoFix a missing return value check in v3_addr
Matt Caswell [Fri, 15 Apr 2016 13:45:12 +0000 (14:45 +0100)]
Fix a missing return value check in v3_addr

All other instances of extract_min_max are checked for an error return,
except this one.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoAdd missing return value check in pkcs8 app
Matt Caswell [Fri, 15 Apr 2016 13:42:48 +0000 (14:42 +0100)]
Add missing return value check in pkcs8 app

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoAdd missing return value checks
Matt Caswell [Fri, 15 Apr 2016 13:31:03 +0000 (14:31 +0100)]
Add missing return value checks

Also correct the return value from the the "prime" application

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoFix missing break in option parsing
Matt Caswell [Fri, 15 Apr 2016 13:11:09 +0000 (14:11 +0100)]
Fix missing break in option parsing

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoRemove some dead code
Matt Caswell [Fri, 15 Apr 2016 13:01:41 +0000 (14:01 +0100)]
Remove some dead code

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoFix some code maintenance issues
Matt Caswell [Fri, 15 Apr 2016 12:56:44 +0000 (13:56 +0100)]
Fix some code maintenance issues

Various instances of variables being written to, but then never read.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoBIO socket connect failure was not handled correctly.
Davide Galassi [Mon, 18 Apr 2016 13:48:27 +0000 (15:48 +0200)]
BIO socket connect failure was not handled correctly.
The state was always set to BIO_CONN_S_OK.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoFix missing IDEA renames (windows build)
Michel [Wed, 20 Apr 2016 18:38:35 +0000 (14:38 -0400)]
Fix missing IDEA renames (windows build)

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoCopyright consolidation script
Rich Salz [Wed, 20 Apr 2016 02:25:27 +0000 (22:25 -0400)]
Copyright consolidation script

With Richard Levitte.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoTravis: _srcdist, not _srcdir
Richard Levitte [Wed, 20 Apr 2016 16:39:01 +0000 (18:39 +0200)]
Travis: _srcdist, not _srcdir

Reviewed-by: Matt Caswell <matt@openssl.org>
8 years agoFix no-ui on Windows
Matt Caswell [Wed, 20 Apr 2016 12:48:57 +0000 (13:48 +0100)]
Fix no-ui on Windows

Ensure public functions have appropriate guards in header files.

GH Issue 899

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoCopyright consolidation; .pm and Configure
Rich Salz [Wed, 20 Apr 2016 14:20:59 +0000 (10:20 -0400)]
Copyright consolidation; .pm and Configure

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoUpdate copyright; generated files.
Rich Salz [Wed, 20 Apr 2016 14:26:11 +0000 (10:26 -0400)]
Update copyright; generated files.

Reviewed-by: Richard Levitte <levitte@openssl.org>
8 years agoRemove --classic build entirely
Richard Levitte [Sat, 2 Apr 2016 16:36:52 +0000 (18:36 +0200)]
Remove --classic build entirely

The Unix build was the last to retain the classic build scheme.  The
new unified scheme has matured enough, even though some details may
need polishing.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoFix no-sock on Windows
Matt Caswell [Wed, 20 Apr 2016 11:56:37 +0000 (12:56 +0100)]
Fix no-sock on Windows

Link errors were occurring on Windows because the header files were not
correctly guarding some functions with OPENSSL_NO_SOCK

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoInclude winsock2.h even if compiling no-sock
Matt Caswell [Wed, 20 Apr 2016 11:43:27 +0000 (12:43 +0100)]
Include winsock2.h even if compiling no-sock

We need the struct timeval definition from winsock2.h even if we're not
going to call any socket functions.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoDon't use select on Windows
Matt Caswell [Wed, 20 Apr 2016 11:56:54 +0000 (12:56 +0100)]
Don't use select on Windows

Windows "select" only works for sockets so don't use it to wait for async.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoCascade no-dgram from no-sock in Configure not e_os.h
Matt Caswell [Wed, 20 Apr 2016 10:24:49 +0000 (11:24 +0100)]
Cascade no-dgram from no-sock in Configure not e_os.h

e_os.h was defining OPENSSL_NO_DGRAM if OPENSSL_NO_SOCK was defined.
This causes link problems on Windows because the generated .def files
still contain the DGRAM symbols even though they have not been compiled.

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoFix no-dgram on Windows
Matt Caswell [Wed, 20 Apr 2016 08:47:29 +0000 (09:47 +0100)]
Fix no-dgram on Windows

Link errors were occurring on Windows because the header files were not
correctly guarding some functions with OPENSSL_NO_DGRAM

Reviewed-by: Rich Salz <rsalz@openssl.org>
8 years agoCopyright consolidation: perl files
Rich Salz [Wed, 20 Apr 2016 02:10:43 +0000 (22:10 -0400)]
Copyright consolidation: perl files

Add copyright to most .pl files
This does NOT cover any .pl file that has other copyright in it.
Most of those are Andy's but some are public domain.
Fix typo's in some existing files.

Reviewed-by: Richard Levitte <levitte@openssl.org>