Commit Graph

12406 Commits

Author SHA1 Message Date
Richard Levitte aa01b82c69 If an engine comes up explicitely, it must also come down explicitely
In apps/apps.c, one can set up an engine with setup_engine().
However, we freed the structural reference immediately, which means
that for engines that don't already have a structural reference
somewhere else (because it has registered at least one cipher or digest
algorithm method, and therefore gets a functional reference through the
ENGINE_set_default() call), we end up returning an invalid reference.

Instead, the function release_engine() is added, and called at the end
of the routines that call setup_engine().

Originally, the ENGINE API wasn't designed for this to happen, an
engine had to register at least one algorithm method, and was
especially expected to register the algorithms corresponding to the
key types that could be stored and hidden in hardware.  However, it
turns out that some engines will not register those algorithms with
the ENGINE_set_{algo}, ENGINE_set_cipher or ENGINE_set_digest
functions, as they only want the methods to be used for keys, not as
general crypto accelerator methods.  That may cause ENGINE_set_default()
to do nothing, and no functional reference is therefore made, leading
to a premature deallocation of the engine and it thereby becoming
unavailable when trying to fetch a key.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1644)
2016-10-20 09:04:00 +02:00
Richard Levitte 10e60f26ce Fix no-des
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1748)
2016-10-19 22:54:06 +02:00
Richard Levitte 1c6aab6a52 Make 'openssl prime ""' not segfault
Fixes RT#4699

Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1668)
2016-10-19 12:17:45 +02:00
Patrick Steuer 99c002b305 Fix strict-warnings build
crypto/evp/e_aes.c: Types of inp and out parameters of AES_xts_en/decrypt
functions need to be changed from char to unsigned char to avoid build
error due to -Werror=incompatible-pointer-types.

crypto/aes/asm/aes-s390x.pl: Comments need to reflect the above change.

Signed-off-by: Patrick Steuer <psteuer@mail.de>

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
CLA: trivial
2016-10-18 17:34:52 +01:00
Patrick Steuer b0161f6a89 Fix strict-warnings build
crypto/s390xcap.c: cryptlib.h needs to be included for OPENSSL_cpuid_setup
function prototype is located there to avoid build error due to
-Werror=missing-prototypes.

Signed-off-by: Patrick Steuer <psteuer@mail.de>

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
CLA: trivial
2016-10-18 17:34:52 +01:00
Steven Fackler 78ee64c237 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>
(cherry picked from commit 8bdce8d160)
2016-10-15 23:47:01 +01:00
Matt Caswell 02a02319ea 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>
(cherry picked from commit e5c1361580)
2016-10-15 11:34:23 +01:00
Vitezslav Cizek 6d69dc56de Degrade 3DES to MEDIUM in SSL2
The SWEET32 fix moved 3DES from HIGH to MEDIUM, but omitted SSL2.

CLA: trivial
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1683)
2016-10-14 11:31:18 -04:00
Rich Salz e8e380ce01 RT is put out to pasture
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1702)
(cherry picked from commit 7954dced19)
2016-10-13 09:41:17 -04:00
Kurt Cancemi f1f97699cb Add missing error string for SSL_R_TOO_MANY_WARN_ALERTS
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
2016-10-11 19:22:28 +01:00
Richard Levitte 53a71b7429 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>
(cherry picked from commit 49e476a538)
2016-09-28 22:00:26 +02:00
Rich Salz a269e5f09a Revert "Call ENGINE_init() before trying to use keys from engine"
This reverts commit 4badd2b3c2.
This fails to call ENGINE_finish; an alternate fix is coming.

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
2016-09-28 14:39:32 -04:00
David Woodhouse 4badd2b3c2 Call ENGINE_init() before trying to use keys from engine
Things like 'openssl s_client' only ever worked with keys from an engine
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: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1640)
2016-09-28 14:34:20 +01:00
Matt Caswell 9702bf5fa2 Fix NEWS error
The NEWS file referenced the wrong CVE for 1.0.2

Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-09-26 11:20:11 +01:00
Matt Caswell f6e43fee70 Prepare for 1.0.2k-dev
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-09-26 10:50:48 +01:00
Matt Caswell e216bf9d7c Prepare for 1.0.2j release
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-09-26 10:49:49 +01:00
Matt Caswell ca430ece0d Update CHANGES and NEWS for the new release
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-09-26 10:02:06 +01:00
Matt Caswell 6e629b5be4 Add some sanity checks when checking CRL scores
Note: this was accidentally omitted from OpenSSL 1.0.2 branch.
Without this fix any attempt to use CRLs will crash.

CVE-2016-7052

Thanks to Bruce Stephens and Thomas Jakobi for reporting this issue.

Reviewed-by: Stephen Henson <steve@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-26 09:19:50 +01:00
Dirk Feytons f15a7e39a1 Fix build with no-nextprotoneg
Add a missing ifdef. Same change is already present in master.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1100)
2016-09-22 16:17:45 +02:00
Rich Salz 581215a519 Fix typo introduced by a03f81f4
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-09-22 08:57:09 -04:00
Matt Caswell 9d264d11a9 Prepare for 1.0.2j-dev
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-09-22 11:25:49 +01:00
Matt Caswell 32c130160f Prepare for 1.0.2i release
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-09-22 11:24:53 +01:00
Matt Caswell 35aede1cd7 Updates CHANGES and NEWS for new release
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-09-22 09:22:05 +01:00
Dmitry Belyavsky 92c8d6ae0d Avoid KCI attack for GOST
Russian GOST ciphersuites are vulnerable to the KCI attack because they use
long-term keys to establish the connection when ssl client authorization is
on. This change brings the GOST implementation into line with the latest
specs in order to avoid the attack. It should not break backwards
compatibility.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
2016-09-22 09:22:05 +01:00
Matt Caswell 38f59bd1f1 Fix a mem leak in NPN handling
If a server sent multiple NPN extensions in a single ClientHello then a
mem leak can occur. This will only happen where the client has requested
NPN in the first place. It does not occur during renegotiation. Therefore
the maximum that could be leaked in a single connection with a malicious
server is 64k (the maximum size of the ServerHello extensions section). As
this is client side, only occurs if NPN has been requested and does not
occur during renegotiation this is unlikely to be exploitable.

Issue reported by Shi Lei.

Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-22 09:22:05 +01:00
Matt Caswell ea39b16b71 Fix OCSP Status Request extension unbounded memory growth
A malicious client can send an excessively large OCSP Status Request
extension. If that client continually requests renegotiation,
sending a large OCSP Status Request extension each time, then there will
be unbounded memory growth on the server. This will eventually lead to a
Denial Of Service attack through memory exhaustion. Servers with a
default configuration are vulnerable even if they do not support OCSP.
Builds using the "no-ocsp" build time option are not affected.

I have also checked other extensions to see if they suffer from a similar
problem but I could not find any other issues.

CVE-2016-6304

Issue reported by Shi Lei.

Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-22 09:22:05 +01:00
Richard Levitte 90d6f35162 mk1mf.pl: check for no-tls1 here as well
Reviewed-by: Matt Caswell <matt@openssl.org>
2016-09-22 09:16:08 +01:00
Matt Caswell 22646a075e Don't allow too many consecutive warning alerts
Certain warning alerts are ignored if they are received. This can mean that
no progress will be made if one peer continually sends those warning alerts.
Implement a count so that we abort the connection if we receive too many.

Issue reported by Shi Lei.

Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-21 20:14:16 +01:00
Dr. Stephen Henson 006a788c84 Make message buffer slightly larger than message.
Grow TLS/DTLS 16 bytes more than strictly necessary as a precaution against
OOB reads. In most cases this will have no effect because the message buffer
will be large enough already.

Reviewed-by: Matt Caswell <matt@openssl.org>
2016-09-21 19:56:05 +01:00
Dr. Stephen Henson bc9563f83d Use SSL3_HM_HEADER_LENGTH instead of 4.
Reviewed-by: Matt Caswell <matt@openssl.org>
2016-09-21 19:56:05 +01:00
Dr. Stephen Henson 709ec8b384 Remove unnecessary check.
The overflow check will never be triggered because the
the n2l3 result is always less than 2^24.

Reviewed-by: Matt Caswell <matt@openssl.org>
2016-09-21 19:56:05 +01:00
Rich Salz 62841a2350 Dcoument -alpn flag
Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 776e15f939)
2016-09-21 11:24:59 -04:00
Rich Salz ceb7342dab GH1555: Don't bump size on realloc failure
Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 6fcace45bd)
2016-09-21 10:42:10 -04:00
Richard Levitte 9583e4166d apps/apps.c: include sys/socket.h to declare recv()
Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit a19228b7f4)
2016-09-21 16:21:08 +02:00
Dr. Stephen Henson ff553f8371 Fix small OOB reads.
In ssl3_get_client_certificate, ssl3_get_server_certificate and
ssl3_get_certificate_request check we have enough room
before reading a length.

Thanks to Shi Lei (Gear Team, Qihoo 360 Inc.) for reporting these bugs.

CVE-2016-6306

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
2016-09-21 14:10:59 +01:00
Matt Caswell d0cbaa2f3a Fix a missing NULL check in dsa_builtin_paramgen
We should check the last BN_CTX_get() call to ensure that it isn't NULL
before we try and use any of the allocated BIGNUMs.

Issue reported by Shi Lei.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 1ff7425d61)
2016-09-21 13:35:11 +01:00
Richard Levitte a5e55f6297 RT4669: dgst can only sign/verify one file
Check arg count and print an error message.

Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-20 21:56:04 +02:00
Marcus Meissner 6180c0ff0c initialize the RSA struct to 0.
This helps with program code linked against static builds accessing a uninitialized ->engine pointer.

CLA: none; trivial

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1540)
2016-09-19 22:06:35 -04:00
Dr. Stephen Henson 32cc4c2627 update default dependencies
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-09-16 00:10:00 +01:00
Matt Caswell 502fcc67cc Revert "Abort on unrecognised warning alerts"
This reverts commit 15d8174932.

There were some unexpected side effects to this commit, e.g. in SSLv3 a
warning alert gets sent "no_certificate" if a client does not send a
Certificate during Client Auth. With the above commit this causes the
connection to abort, which is incorrect. There may be some other edge cases
like this so we need to have a rethink on this.

Reviewed-by: Tim Hudson <tjh@openssl.org>
2016-09-15 22:53:27 +01:00
Richard Levitte 15c088e4cf Finally, make sure vms_term_sock.c is built
Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-15 23:23:06 +02:00
Richard Levitte d6d04b64f5 Refactor to avoid unnecessary preprocessor logic
Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-15 23:23:06 +02:00
Richard Levitte b50826727e Reformat to fit OpenSSL source code standards
Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-15 23:23:06 +02:00
Richard Levitte a2d2120033 Remove entirely unnecessary pointer size guards
Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-15 23:23:06 +02:00
Richard Levitte 4585254547 Add copyright and license on apps/vms_term_sock.[ch]
Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-15 23:23:06 +02:00
Richard Levitte 1015609ac0 VSI submission: redirect terminal input through socket
This is needed, because on VMS, select() can only be used on sockets.  being
able to use select() on all kinds of file descriptors is unique to Unix.

So, the solution for VMS is to create a layer that translates input from
standard input to socket communication.

Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-15 23:23:06 +02:00
Dr. Stephen Henson d692475989 Fix memory leak on realloc error.
Backport leak fix from master branch.

Thanks to Shi Lei (Gear Team, Qihoo 360 Inc.) for reporting this bug.

Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-15 12:49:00 +01:00
Dr. Stephen Henson ea060e026d Fix memory leak on error.
Thanks to Shi Lei (Gear Team, Qihoo 360 Inc.) for reporting this bug.

Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-15 12:49:00 +01:00
Richard Levitte b05f231cd9 VMS: only use _realloc32 with /POINTER_SIZE=32
This fixes the following error when building with no particular pointer size
is specified (implied 32 bit):

    static void *(*realloc_func) (void *, size_t) = realloc;
    ................................................^
    %CC-E-UNDECLARED, In the initializer for realloc_func, "_realloc32" is not declared.
    at line number 93 in file DEV:[OPENSSL102.crypto]mem.c;1

Reviewed-by: Andy Polyakov <appro@openssl.org>
2016-09-15 10:33:42 +02:00
Matt Caswell 68f11e82d9 Add some sanity checks around usage of t_fromb64()
The internal SRP function t_fromb64() converts from base64 to binary. It
does not validate that the size of the destination is sufficiently large -
that is up to the callers. In some places there was such a check, but not
in others.

Add an argument to t_fromb64() to provide the size of the destination
buffer and validate that we don't write too much data. Also add some sanity
checks to the callers where appropriate.

With thanks to Shi Lei for reporting this issue.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 73f0df8331)
2016-09-14 10:17:46 +01:00