Commit graph

16555 commits

Author SHA1 Message Date
Matt Caswell
ee1e3cac2e Avoid overflow in EVP_EncodeUpdate
An overflow can occur in the EVP_EncodeUpdate function which is used for
Base64 encoding of binary data. If an attacker is able to supply very large
amounts of input data then a length check can overflow resulting in a heap
corruption. Due to the very large amounts of data involved this will most
likely result in a crash.

Internally to OpenSSL the EVP_EncodeUpdate function is primarly used by the
PEM_write_bio* family of functions. These are mainly used within the
OpenSSL command line applications, so any application which processes
data from an untrusted source and outputs it as a PEM file should be
considered vulnerable to this issue.

User applications that call these APIs directly with large amounts of
untrusted data may also be vulnerable.

Issue reported by Guido Vranken.

CVE-2016-2105

Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-05-03 11:56:23 +01:00
Dmitry-Me
b7b8e94801 Properly own the duplicated string
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-05-03 12:33:44 +02:00
Dmitry-Me
399de49699 Improve comment
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-05-03 12:30:09 +02:00
Richard Levitte
d227a302a3 Try 'make install' with one of the Travis configurations
Reviewed-by: Matt Caswell <matt@openssl.org>
2016-05-03 12:28:49 +02:00
Matt Caswell
ea96ad5a20 Prevent EBCDIC overread for very long strings
ASN1 Strings that are over 1024 bytes can cause an overread in
applications using the X509_NAME_oneline() function on EBCDIC systems.
This could result in arbitrary stack data being returned in the buffer.

Issue reported by Guido Vranken.

CVE-2016-2176

Reviewed-by: Andy Polyakov <appro@openssl.org>
2016-05-03 10:22:47 +01:00
Matt Caswell
3f3582139f Fix encrypt overflow
An overflow can occur in the EVP_EncryptUpdate function. If an attacker is
able to supply very large amounts of input data after a previous call to
EVP_EncryptUpdate with a partial block then a length check can overflow
resulting in a heap corruption.

Following an analysis of all OpenSSL internal usage of the
EVP_EncryptUpdate function all usage is one of two forms.

The first form is like this:
EVP_EncryptInit()
EVP_EncryptUpdate()

i.e. where the EVP_EncryptUpdate() call is known to be the first called
function after an EVP_EncryptInit(), and therefore that specific call
must be safe.

The second form is where the length passed to EVP_EncryptUpdate() can be
seen from the code to be some small value and therefore there is no
possibility of an overflow.

Since all instances are one of these two forms, I believe that there can
be no overflows in internal code due to this problem.

It should be noted that EVP_DecryptUpdate() can call EVP_EncryptUpdate()
in certain code paths. Also EVP_CipherUpdate() is a synonym for
EVP_EncryptUpdate(). Therefore I have checked all instances of these
calls too, and came to the same conclusion, i.e. there are no instances
in internal usage where an overflow could occur.

This could still represent a security issue for end user code that calls
this function directly.

CVE-2016-2106

Issue reported by Guido Vranken.

Reviewed-by: Tim Hudson <tjh@openssl.org>
2016-05-03 08:57:06 +01:00
Dr. Stephen Henson
05aef4bbdb Fix i2d_X509_AUX: pp can be NULL.
Reported by David Benjamin

Reviewed-by: Emilia Käsper <emilia@openssl.org>
2016-05-02 22:46:39 +01:00
Rich Salz
5a1f853b98 GH875: Document -no_check_time
Date:   Tue Mar 15 15:19:44 2016 +0100

This commit updates the documentation of cms, ocsp, s_client,
s_server, and verify to reflect the new "-no_check_time"
option introduced in commit d35ff2c0ad
on 2015-07-31.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-05-02 17:03:55 -04:00
TJ Saunders
5c4b8c6f61 Remove confusing comment.
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-05-02 16:55:14 -04:00
TJ Saunders
5f18bc5898 Issue #719:
If no serverinfo extension is found in some cases, do not abort the handshake,
but simply omit/skip that extension.

Check for already-registered serverinfo callbacks during serverinfo
registration.

Update SSL_CTX_use_serverinfo() documentation to mention the need to reload the
same serverinfo per certificate, for servers with multiple server certificates.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-05-02 16:55:14 -04:00
Richard Levitte
afce395cba Document the addition of OPENSSL_LOCAL_CONFIG_DIR
Reviewed-by: Stephen Henson <steve@openssl.org>
2016-05-02 20:19:41 +02:00
Richard Levitte
38add2300f Add the possibility for local build file templates
Use the environment variable OPENSSL_LOCAL_CONFIG_DIR to find build
file templates as well.

Reviewed-by: Stephen Henson <steve@openssl.org>
2016-05-02 20:19:41 +02:00
Richard Levitte
b5293d4c8d Add the possibility to have an extra local OpenSSL configs directory
The environment variable OPENSSL_LOCAL_CONFIG_DIR is used to indicate
that there's a local directory with extra configuration files.

Reviewed-by: Stephen Henson <steve@openssl.org>
2016-05-02 20:19:41 +02:00
Richard Levitte
85e2fe8113 Remove personal configs from version control
As per a team decision back in 2014.

Reviewed-by: Stephen Henson <steve@openssl.org>
2016-05-02 20:19:41 +02:00
Todd Short
e8408681b3 Secure memory fixes
Fix some of the variables to be (s)size_t, so that more than 1GB of
secure memory can be allocated. The arena has to be a power of 2, and
2GB fails because it ends up being a negative 32-bit signed number.

The |too_late| flag is not strictly necessary; it is easy to figure
out if something is secure memory by looking at the arena. As before,
secure memory allocations will not fail, but now they can be freed
correctly. Once initialized, secure memory can still be used, even if
allocations occured before initialization.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-05-02 12:58:03 -04:00
Andy Polyakov
fbaf30d087 ssl/record/rec_layer_s3.c: fix typo from previous commit.
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-05-02 15:23:22 +02:00
Rich Salz
d244dd559d Handle multi-line "written by/for" comments.
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-05-02 08:27:39 -04:00
Andy Polyakov
cba792a1e9 Android build fixes.
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-05-02 12:49:57 +02:00
Andy Polyakov
b1a07c3854 Remove obsolete defined(__INTEL__) condition.
This macro was defined by no-longer-supported __MWERKS__ compiler.

Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-05-02 12:35:01 +02:00
Andy Polyakov
8e9f1bb99e chacha/asm/chacha-x86.pl: make it compile on legacy systems.
Usage of $ymm variable is a bit misleading here, it doesn't refer
to %ymm register bank, but rather to VEX instruction encoding,
which AMD XOP code path depends on.

Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-05-02 12:34:42 +02:00
FdaSilvaYY
24c2cd3967 Fix spelling in pod files
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-05-01 19:14:57 -04:00
Richard Levitte
e0f96357e4 make update
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-05-01 15:10:15 +02:00
Richard Levitte
b7650c6797 Add the adjusted perl scripts to the set of "update" scripts
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-05-01 15:09:20 +02:00
Richard Levitte
e18cf66aaf Adjust a last few generators to new license boilerplate and C code style
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-05-01 15:08:34 +02:00
Richard Levitte
e428f59514 Skip blank lines if old copyright comment was removed, and only then
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-05-01 14:16:32 +02:00
Matt Caswell
7cafbb4bd3 Fix some X509_STORE macros
Some X509_STORE macros do not work since the type was made opaque.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
2016-04-29 23:13:58 +01:00
Dr. Stephen Henson
77076dc944 Add checks to X509_NAME_oneline()
Sanity check field lengths and sums to avoid potential overflows and reject
excessively large X509_NAME structures.

Issue reported by Guido Vranken.

Reviewed-by: Matt Caswell <matt@openssl.org>
2016-04-29 19:42:21 +01:00
Dr. Stephen Henson
b33d1141b6 Sanity check buffer length.
Reject zero length buffers passed to X509_NAME_onelne().

Issue reported by Guido Vranken.

Reviewed-by: Matt Caswell <matt@openssl.org>
2016-04-29 19:42:21 +01:00
Dr. Stephen Henson
295f3a2491 Add size limit to X509_NAME structure.
This adds an explicit limit to the size of an X509_NAME structure. Some
part of OpenSSL (e.g. TLS) already effectively limit the size due to
restrictions on certificate size.

Reviewed-by: Matt Caswell <matt@openssl.org>
2016-04-29 19:42:21 +01:00
Richard Levitte
3cd3f0024b Remove BIO_dummy, it's old cruft
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-04-29 18:59:20 +02:00
Richard Levitte
83f2695c31 Change 'struct bio_st' in all public header where applicable
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-04-29 18:57:58 +02:00
Rich Salz
be4ba1b06c Add asn1_mac
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-04-29 12:50:01 -04:00
Matt Caswell
b8c51459aa Remove some dead code from EC_GROUP_check()
EC_GROUP_check() was obtaining a temporary BIGNUM from the BN_CTX, but
then not using it.

Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-04-29 16:47:41 +01:00
Matt Caswell
9d7ec8090e Don't use an uninitialised variable in srp application
The srp application created an uninitialised DB_ATTR object and then
passed it to the load_index function which attempted to read it. A
DB_ATTR object only contains a single field called "unique_subject".
AFAICT this attribute is unused in the SRP case, and therefore it would be
better to pass a NULL DB_ATTR to load_index (which handles that case
gracefully).

Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-04-29 16:47:41 +01:00
Matt Caswell
40a8643a37 Avoid a NULL ptr deref if group is not set
We should only copy parameters and keys if the group is set. Otherwise
they don't really make any sense. Previously we copied the private key
regardless of whether the group was set...but if it wasn't a NULL ptr
deref could occur. It's unclear whether we could ever get into that
situation, but since we were already checking it for the public key we
should be consistent.

Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-04-29 16:47:41 +01:00
Matt Caswell
7001571330 Check for a NULL return value from a call to X509_STORE_CTX_new()
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-04-29 16:47:41 +01:00
Matt Caswell
138388fe33 Check for failed malloc in BIO_ADDR_new
BIO_ADDR_new() calls OPENSSL_zalloc() which can fail - but the return
value is not checked.

Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-04-29 16:47:41 +01:00
Matt Caswell
ed3eb5e0cc The x509_name_canon function doesn't check for an error return
i2d_name_canon can return a negative number on error. We should check it
before continuing.

Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-04-29 16:47:41 +01:00
Paul Kehrer
3b7a71b2f0 Make header signature of CRYPTO_mem_leaks BIO instead of struct bio_st
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1012)
2016-04-29 16:42:44 +01:00
David Benjamin
87a8405b66 Avoid overflow issues in X509_cmp.
The length is a long, so returning the difference does not quite work.

Thanks to Torbjörn Granlund for noticing.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-04-29 17:01:09 +02:00
Matt Caswell
a1f41284d7 Misc tweaks for EBCDIC based on feedback received
Reviewed-by: Andy Polyakov <appro@openssl.org>
2016-04-29 15:04:15 +01:00
Matt Caswell
a1f82f0639 Fix EBCDIC problem in conf_def.h
The non-ascii version of this set of macros ensures that the "a" variable
is inside the expected range. This logic wasn't quite right for the
EBCDIC version.

Reviewed-by: Andy Polyakov <appro@openssl.org>
2016-04-29 15:04:15 +01:00
Matt Caswell
97a982e2ee Fix the tests to work with EBCDIC
Most of the tests already pass with EBCIDC but a few were trying to
write into read only memory.

Reviewed-by: Andy Polyakov <appro@openssl.org>
2016-04-29 15:04:15 +01:00
Matt Caswell
4cd5c3f4ee Fix a build error with strict-warnings and CHARSET_EBCDIC
Reviewed-by: Andy Polyakov <appro@openssl.org>
2016-04-29 15:04:15 +01:00
Matt Caswell
e31066f7e9 Add the ability to test EBCDIC builds
This adds the define CHARSET_EBCDIC_TEST which enables testing of EBCDIC
code on an ASCII system.

Reviewed-by: Andy Polyakov <appro@openssl.org>
2016-04-29 15:04:15 +01:00
Matt Caswell
5fd1478df3 Fix building with -DCHARSET_EBCDIC
Building with -DCHARSET_EBCDIC and using --strict-warnings resulted in
lots of miscellaneous errors. This fixes it.

Reviewed-by: Andy Polyakov <appro@openssl.org>
2016-04-29 15:04:15 +01:00
Richard Levitte
e590afdcf4 VMS: only explicitely translate names in library C files.
When compiling all other C files, rely on the compiler to
automatically pick up the name translation information from the header
files __DECC_INCLUDE_{PRO,EPI}LOGUE.H.

Reviewed-by: Andy Polyakov <appro@openssl.org>
2016-04-29 15:20:48 +02:00
Richard Levitte
1bfe73d500 VMS: It seems DEC C doesn't handle certain header files quite right
With DEC C on VMS, you can use __DECC_INCLUDE_PROLOGUE.H and
__DECC_INCLUDE_EPILOGUE.H to include some DEC C specific features or
pragmas without having to touch the other header files.

It seems, however, that the current version of the compiler requires
the file names to be upcased, or it doesn't handle them quite right.

Reviewed-by: Andy Polyakov <appro@openssl.org>
2016-04-29 15:19:33 +02:00
Kirill Marinushkin
842dc98705 Add aliases for des-ede-ecb and des-ede3-ecb ciphers.
Currently we can get all block ciphers with
	EVP_get_cipherbyname("<alg_name>-<block-mode-name>")
for example, by names "aes-128-ecb" or "des-ede-cbc".
I found a problem with des-ede-ecb and des-ede3-ecb ciphers as
they can be accessed only with names:
	EVP_get_cipherbyname("des-ede")
	EVP_get_cipherbyname("des-ede3")
It breaks the general concept.

In this patch I add aliases which allow to use names:
	EVP_get_cipherbyname("des-ede-ecb")
	EVP_get_cipherbyname("des-ede3-ecb")
in addition to the currently used names.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-04-29 09:17:09 -04:00
Kirill Marinushkin
e6f2bb6604 Fixed scripts order for generate_crypto_objects target
Script obj_dat.pl depends on file obj_mac.h generated by script objects.pl

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-04-29 09:17:09 -04:00