Commit graph

7946 commits

Author SHA1 Message Date
Richard Levitte
1f644005ac make update
Reviewed-by: Matt Caswell <matt@openssl.org>
2016-04-29 09:09:46 +02:00
FdaSilvaYY
a14a740dbe 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)
2016-04-28 22:16:52 +02:00
FdaSilvaYY
2bbf0baa95 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)
2016-04-28 14:37:41 -04:00
FdaSilvaYY
25a807bcb9 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)
2016-04-28 14:37:41 -04:00
FdaSilvaYY
8483a003bf 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)
2016-04-28 14:22:26 -04:00
Christian Heimes
f0c58c3212 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>
2016-04-28 20:02:27 +02:00
Viktor Dukhovni
c965487373 Implement X509_STORE_CTX_set_current_cert() accessor
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-04-28 13:50:13 -04:00
Richard Levitte
68423b1461 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>
2016-04-28 18:00:25 +02:00
Matt Caswell
34b9acbd3f 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>
2016-04-28 13:13:09 +01:00
Matt Caswell
5e8129f278 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>
2016-04-28 13:13:09 +01:00
Matt Caswell
d54ac5c4bf 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>
2016-04-28 13:13:09 +01:00
Matt Caswell
460c5e1d2f 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>
2016-04-28 13:13:09 +01:00
Matt Caswell
8e588e2812 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>
2016-04-28 13:13:09 +01:00
Matt Caswell
204cf9406e 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>
2016-04-28 13:13:09 +01:00
Matt Caswell
a4e584a610 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>
2016-04-28 13:13:09 +01:00
Matt Caswell
f08e803450 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>
2016-04-28 13:13:09 +01:00
Matt Caswell
2280358146 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>
2016-04-28 13:13:09 +01:00
Matt Caswell
29f4c357f0 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>
2016-04-28 13:13:09 +01:00
Matt Caswell
d71eb667c4 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>
2016-04-28 13:13:09 +01:00
Matt Caswell
91fb42ddbe 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>
2016-04-28 13:13:09 +01:00
Matt Caswell
b0b6ba2d11 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>
2016-04-28 13:13:09 +01:00
Matt Caswell
df0f275922 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>
2016-04-28 13:13:09 +01:00
Richard Levitte
2bd8c85395 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>
2016-04-28 14:04:03 +02:00
Dr. Stephen Henson
d78df5dfd6 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>
2016-04-28 00:04:48 +01:00
Viktor Dukhovni
4a397f5168 Fix set0 reuse test
We must test for new object == current object, not !=.

Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-04-27 16:16:34 -04:00
Viktor Dukhovni
69664d6af0 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>
2016-04-27 14:42:38 -04:00
Richard Levitte
1da12e34ed 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>
2016-04-27 15:07:53 +02:00
Kazuki Yamaguchi
3aec886ed4 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>
2016-04-27 08:23:53 -04:00
Andy Polyakov
33ea23dc5c SPARCv9 assembly pack: fine-tune run-time switch.
Reviewed-by: Tim Hudson <tjh@openssl.org>
2016-04-26 21:35:05 +02:00
Andy Polyakov
7936a86b9f camellia/build.info: fix typo
RT#4520

Reviewed-by: Tim Hudson <tjh@openssl.org>
2016-04-26 21:30:55 +02:00
Benjamin Kaduk
9547982e8c Remove dead-code infinite loop
Commit d32f5d8733 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>
2016-04-26 14:17:41 -04:00
Matt Caswell
446ba8de9a 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>
2016-04-26 14:29:54 +01:00
Andy Polyakov
dc3c5067cd 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>
2016-04-25 22:56:09 +02:00
Viktor Dukhovni
51227177b1 Added missing X509_STORE_CTX_set_error_depth() accessor
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-04-25 15:26:04 -04:00
Andy Polyakov
670ad0fbf6 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>
2016-04-25 11:53:45 +02:00
Andy Polyakov
299ccadcdb crypto/sparc_arch.h: reserve more SPARCv9 capability bits.
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-04-25 11:50:54 +02:00
Andy Polyakov
a82a9f71ad chacha/asm/chacha-ppc.pl: get misalignment corner case right on big-endian.
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-04-25 11:48:44 +02:00
Kazuki Yamaguchi
acde647fb0 Fix EC_KEY_set_private_key() to call key->group->meth->set_private()
Fix a bug introduced by 6903e2e7e9 (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>
2016-04-23 04:24:27 +01:00
Dr. Stephen Henson
c62981390d 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>
2016-04-23 00:26:43 +01:00
Dr. Stephen Henson
2ac7753c10 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>
2016-04-21 23:56:44 +01:00
Matt Caswell
dfefe7ec1e 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>
2016-04-21 10:51:57 +01:00
Matt Caswell
d278284e74 Fix some code maintenance issues
Various instances of variables being written to, but then never read.

Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-04-21 10:51:57 +01:00
Davide Galassi
a043d0b91d 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>
2016-04-20 21:26:01 +02:00
Michel
098a23828f Fix missing IDEA renames (windows build)
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-04-20 14:48:54 -04:00
Rich Salz
3fb2cf1ad1 Update copyright; generated files.
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-04-20 10:33:15 -04:00
Richard Levitte
45c6e23c97 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>
2016-04-20 16:04:56 +02:00
Rich Salz
e0a651945c 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>
2016-04-20 09:45:40 -04:00
Andy Polyakov
6944565bd5 evp/aes_aes.c: engage Fujitsu SPARC64 X AES support.
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-04-20 09:57:43 +02:00
Andy Polyakov
4400f6c61e sparcv9cap.c: add Fujitsu SPARC64 X AES capability detection.
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-04-20 09:57:37 +02:00
Andy Polyakov
fb65020b37 Add AES assembly module for Fujitsu SPARC64 X/X+.
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-04-20 09:57:20 +02:00