oweals/openssl.git
9 years agoMake BSD make happy with subdirectories.
Ben Laurie [Sat, 1 Aug 2015 14:55:19 +0000 (15:55 +0100)]
Make BSD make happy with subdirectories.

Reviewed-by: Richard Levitte
9 years agoGH336: Return an exit code if report fails
Dirk Wetter [Fri, 31 Jul 2015 17:02:51 +0000 (13:02 -0400)]
GH336: Return an exit code if report fails

Reviewed-by: Richard Levitte <levitte@openssl.org>
9 years agoOnly define PAGE_SIZE if not already defined.
Ben Laurie [Fri, 31 Jul 2015 08:49:20 +0000 (09:49 +0100)]
Only define PAGE_SIZE if not already defined.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoRemove erroneous server_random filling
Matt Caswell [Thu, 25 Jun 2015 13:12:25 +0000 (14:12 +0100)]
Remove erroneous server_random filling

Commit e481f9b90b164 removed OPENSSL_NO_TLSEXT from the code.

Previously if OPENSSL_NO_TLSEXT *was not* defined then the server random was
filled during getting of the ClientHello. If it *was* defined then the
server random would be filled in ssl3_send_server_hello(). Unfortunately in
commit e481f9b90b164 the OPENSSL_NO_TLSEXT guards were removed but *both*
server random fillings were left in. This could cause problems for session
ticket callbacks.

Reviewed-by: Stephen Henson <steve@openssl.org>
9 years agoClear BN-mont values when free'ing it.
Loganaden Velvindron [Fri, 31 Jul 2015 17:20:16 +0000 (13:20 -0400)]
Clear BN-mont values when free'ing it.

From a CloudFlare patch.

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
9 years agoVarious doc fixes from GH pull requests
Rich Salz [Fri, 31 Jul 2015 15:52:57 +0000 (11:52 -0400)]
Various doc fixes from GH pull requests

Thanks folks:
        348 Benjamin Kaduk
        317 Christian Brueffer
        254 Erik Tews
        253 Erik Tews
        219 Carl Mehner
        155 (ghost)
        95 mancha
        51 DominikNeubauer

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
9 years agoRT3742: Add xmpp_server to s_client.
Kai Engert [Wed, 29 Jul 2015 21:41:00 +0000 (17:41 -0400)]
RT3742: Add xmpp_server to s_client.

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoRT3963: Allow OCSP stapling with -rev and -www
Adam Eijdenberg [Thu, 30 Jul 2015 01:34:35 +0000 (21:34 -0400)]
RT3963: Allow OCSP stapling with -rev and -www

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoRT3962: Check accept_count only if not unlimited
Adam Eijdenberg [Thu, 30 Jul 2015 01:38:22 +0000 (21:38 -0400)]
RT3962: Check accept_count only if not unlimited

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoRT3961: Fix switch/case errors in flag parsing
Adam Eijdenberg [Thu, 30 Jul 2015 01:42:14 +0000 (21:42 -0400)]
RT3961: Fix switch/case errors in flag parsing

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoRT3959: Fix misleading comment
Nicholas Cooper [Thu, 30 Jul 2015 01:44:59 +0000 (21:44 -0400)]
RT3959: Fix misleading comment

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agocleanse psk_identity on error
Dr. Stephen Henson [Tue, 28 Jul 2015 15:13:29 +0000 (16:13 +0100)]
cleanse psk_identity on error

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoFree and cleanse pms on error
Dr. Stephen Henson [Tue, 28 Jul 2015 15:04:53 +0000 (16:04 +0100)]
Free and cleanse pms on error

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoDon't request certificates for any PSK ciphersuite
Dr. Stephen Henson [Sat, 11 Jul 2015 00:17:36 +0000 (01:17 +0100)]
Don't request certificates for any PSK ciphersuite

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoCAMELLIA PSK ciphersuites from RFC6367
Dr. Stephen Henson [Tue, 30 Jun 2015 18:14:58 +0000 (19:14 +0100)]
CAMELLIA PSK ciphersuites from RFC6367

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoAdd PSK ciphersuites to docs
Dr. Stephen Henson [Mon, 29 Jun 2015 13:20:01 +0000 (14:20 +0100)]
Add PSK ciphersuites to docs

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoUpdate CHANGES
Dr. Stephen Henson [Mon, 29 Jun 2015 11:17:21 +0000 (12:17 +0100)]
Update CHANGES

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoAdd RFC4785 ciphersuites
Dr. Stephen Henson [Sun, 28 Jun 2015 23:44:39 +0000 (00:44 +0100)]
Add RFC4785 ciphersuites

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoAdd RFC4279, RFC5487 and RFC5489 ciphersuites.
Dr. Stephen Henson [Sun, 28 Jun 2015 16:05:47 +0000 (17:05 +0100)]
Add RFC4279, RFC5487 and RFC5489 ciphersuites.

Note: some of the RFC4279 ciphersuites were originally part of PR#2464.

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoInitial new PSK ciphersuite defines
Dr. Stephen Henson [Sun, 28 Jun 2015 15:55:00 +0000 (16:55 +0100)]
Initial new PSK ciphersuite defines

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoAdd full PSK trace support
Dr. Stephen Henson [Sun, 28 Jun 2015 15:50:53 +0000 (16:50 +0100)]
Add full PSK trace support

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoPSK premaster secret derivation.
Dr. Stephen Henson [Sun, 28 Jun 2015 15:58:00 +0000 (16:58 +0100)]
PSK premaster secret derivation.

Move PSK premaster secret algorithm to ssl_generate_master secret so
existing key exchange code can be used and modified slightly to add
the PSK wrapping structure.

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoExtended PSK server support.
Dr. Stephen Henson [Sun, 28 Jun 2015 16:23:13 +0000 (17:23 +0100)]
Extended PSK server support.

Add support for RSAPSK, DHEPSK and ECDHEPSK server side.

Update various checks to ensure certificate and server key exchange messages
are only sent when required.

Update message handling. PSK server key exchange parsing now include an
identity hint prefix for all PSK server key exchange messages. PSK
client key exchange message expects PSK identity and requests key for
all PSK key exchange ciphersuites.

Update flags for RSA, DH and ECDH so they are also used in PSK.

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoExtended PSK client support.
Dr. Stephen Henson [Sun, 28 Jun 2015 16:15:10 +0000 (17:15 +0100)]
Extended PSK client support.

Add support for RSAPSK, DHEPSK and ECDHEPSK client side.

Update various checks to ensure certificate and server key exchange messages
are only expected when required.

Update message handling. PSK server key exchange parsing now expects an
identity hint prefix for all PSK server key exchange messages. PSK
client key exchange message requests PSK identity and key for all PSK
key exchange ciphersuites and includes identity in message.

Update flags for RSA, DH and ECDH so they are also used in PSK.

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoPSK PRF correction.
Dr. Stephen Henson [Sun, 28 Jun 2015 22:18:59 +0000 (23:18 +0100)]
PSK PRF correction.

For SHA384 PRF PSK ciphersuites we have to switch to default PRF for
TLS < 1.2

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoMake auto DH work with DHEPSK
Dr. Stephen Henson [Sun, 28 Jun 2015 16:01:52 +0000 (17:01 +0100)]
Make auto DH work with DHEPSK

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoCheck for kECDH with extensions.
Dr. Stephen Henson [Tue, 30 Jun 2015 15:39:41 +0000 (16:39 +0100)]
Check for kECDH with extensions.

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoEnable PSK if corresponding mask set.
Dr. Stephen Henson [Sun, 28 Jun 2015 16:02:56 +0000 (17:02 +0100)]
Enable PSK if corresponding mask set.

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoDisable all PSK if no callback.
Dr. Stephen Henson [Sun, 28 Jun 2015 16:01:07 +0000 (17:01 +0100)]
Disable all PSK if no callback.

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoDisable unsupported PSK algorithms
Dr. Stephen Henson [Sun, 28 Jun 2015 16:09:54 +0000 (17:09 +0100)]
Disable unsupported PSK algorithms

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agonew PSK text constants
Dr. Stephen Henson [Sun, 28 Jun 2015 16:07:41 +0000 (17:07 +0100)]
new PSK text constants

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoNew PSK aliases.
Dr. Stephen Henson [Sun, 28 Jun 2015 16:10:27 +0000 (17:10 +0100)]
New PSK aliases.

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoNew PSK keyex text constants
Dr. Stephen Henson [Sun, 28 Jun 2015 15:54:06 +0000 (16:54 +0100)]
New PSK keyex text constants

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agofields for PSK key, new constants
Dr. Stephen Henson [Sun, 28 Jun 2015 15:52:40 +0000 (16:52 +0100)]
fields for PSK key, new constants

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoFix write failure handling in DTLS1.2
Matt Caswell [Wed, 29 Jul 2015 22:20:56 +0000 (23:20 +0100)]
Fix write failure handling in DTLS1.2

The DTLS code is supposed to drop packets if we try to write them out but
the underlying BIO write buffers are full. ssl3_write_pending() contains
an incorrect test for DTLS that controls this. The test only checks for
DTLS1 so DTLS1.2 does not correctly clear the internal OpenSSL buffer which
can later cause an assert to be hit. This commit changes the test to cover
all DTLS versions.

RT#3967

Reviewed-by: Tim Hudson <tjh@openssl.org>
9 years agoRT3774: double-free in DSA
Martin Vejnar [Wed, 29 Jul 2015 21:28:19 +0000 (17:28 -0400)]
RT3774: double-free in DSA

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoRT3639: Add -no_comp description to online help
Rich Salz [Wed, 29 Jul 2015 20:55:08 +0000 (16:55 -0400)]
RT3639: Add -no_comp description to online help

Reviewed-by: Tim Hudson <tjh@openssl.org>
9 years agoTweak README about rt and bug reporting.
Rich Salz [Tue, 28 Jul 2015 16:41:36 +0000 (12:41 -0400)]
Tweak README about rt and bug reporting.

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoDocument signature algorithm setting functions.
Dr. Stephen Henson [Thu, 23 Jul 2015 12:30:32 +0000 (13:30 +0100)]
Document signature algorithm setting functions.

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoAdd some OCSP documentation.
Dr. Stephen Henson [Sat, 21 Jun 2014 19:13:37 +0000 (20:13 +0100)]
Add some OCSP documentation.

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoAllow any order for signature algorithm string.
Dr. Stephen Henson [Thu, 23 Jul 2015 13:57:42 +0000 (14:57 +0100)]
Allow any order for signature algorithm string.

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoAdd test for SSL_set_session_ticket_ext
Matt Caswell [Mon, 27 Jul 2015 11:04:47 +0000 (12:04 +0100)]
Add test for SSL_set_session_ticket_ext

The function SSL_set_session_ticket_ext sets the ticket data to be sent in
the ClientHello. This is useful for EAP-FAST. This commit adds a test to
ensure that when this function is called the expected ticket data actually
appears in the ClientHello.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
9 years agoRemove support for SSL3_FLAGS_DELAY_CLIENT_FINISHED
Matt Caswell [Mon, 20 Jul 2015 23:02:39 +0000 (00:02 +0100)]
Remove support for SSL3_FLAGS_DELAY_CLIENT_FINISHED

This flag was not set anywhere within the codebase (only read). It could
only be set by an app reaching directly into s->s3->flags and setting it
directly. However that method became impossible when libssl was opaquified.

Even in 1.0.2/1.0.1 if an app set the flag directly it is only relevant to
ssl3_connect(), which calls SSL_clear() during initialisation that clears
any flag settings. Therefore it could take effect if the app set the flag
after the handshake has started but before it completed. It seems quite
unlikely that any apps really do this (especially as it is completely
undocumented).

The purpose of the flag is suppress flushing of the write bio on the client
side at the end of the handshake after the client has written the Finished
message whilst resuming a session. This enables the client to send
application data as part of the same flight as the Finished message.

This flag also controls the setting of a second flag SSL3_FLAGS_POP_BUFFER.
There is an interesting comment in the code about this second flag in the
implementation of ssl3_write:

/* This is an experimental flag that sends the
 * last handshake message in the same packet as the first
 * use data - used to see if it helps the TCP protocol during
 * session-id reuse */

It seems the experiment did not work because as far as I can tell nothing
is using this code. The above comment has been in the code since SSLeay.

This commit removes support for SSL3_FLAGS_DELAY_CLIENT_FINISHED, as well
as the associated SSL3_FLAGS_POP_BUFFER.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agorsaz_exp.h: align license with the rest of the contribution
Emilia Kasper [Thu, 23 Jul 2015 11:20:21 +0000 (13:20 +0200)]
rsaz_exp.h: align license with the rest of the contribution

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoDocument shared sigalgs functions.
Dr. Stephen Henson [Wed, 22 Jul 2015 15:11:55 +0000 (16:11 +0100)]
Document shared sigalgs functions.

Reviewed-by: Tim Hudson <tjh@openssl.org>
9 years agoSome cleanups for crypto/bn
Rich Salz [Wed, 22 Jul 2015 10:44:50 +0000 (06:44 -0400)]
Some cleanups for crypto/bn

Create bn_free_d utility routine and use it.
Fix RT3950
Also a missing cleanse, from Loganaden Velvindron (loganaden@gmail.com),
who noticed it in a Cloudflare patch.

Reviewed-by: Richard Levitte <levitte@openssl.org>
9 years agofree names before context
Dr. Stephen Henson [Tue, 21 Jul 2015 13:27:10 +0000 (14:27 +0100)]
free names before context

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
9 years agotypo
Dr. Stephen Henson [Tue, 21 Jul 2015 13:16:09 +0000 (14:16 +0100)]
typo

Reviewed-by: Kurt Roeckx <kurt@openssl.org>
9 years agoUpdate demo.
Dr. Stephen Henson [Tue, 14 Jul 2015 13:19:38 +0000 (14:19 +0100)]
Update demo.

Use new SSL_CONF options in demo. Add intermediate and root CAs and
update all to use SHA256.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
9 years agoSSL_CONF additions.
Dr. Stephen Henson [Tue, 14 Jul 2015 13:18:37 +0000 (14:18 +0100)]
SSL_CONF additions.

Add support for loading verify and chain stores in SSL_CONF.

Commands to set verify mode and client CA names.

Add documentation.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
9 years agoRewrite crypto/ex_data
Rich Salz [Fri, 24 Apr 2015 20:33:34 +0000 (16:33 -0400)]
Rewrite crypto/ex_data

Removed ability to set ex_data impl at runtime.  This removed these
three functions:
    const CRYPTO_EX_DATA_IMPL *CRYPTO_get_ex_data_implementation(void);
    int CRYPTO_set_ex_data_implementation(const CRYPTO_EX_DATA_IMPL *i);
    int CRYPTO_ex_data_new_class(void);
It is no longer possible to change the ex_data implementation at
runtime.  (Luckily those functions were never documented :)

Also removed the ability to add new exdata "classes."  We don't believe
this received much (if any) use, since you can't add it to OpenSSL objects,
and there are probably better (native) methods for developers to add
their own extensible data, if they really need that.

Replaced the internal hash table (of per-"class" stacks) with a simple
indexed array.  Reserved an index for "app" application.

Each API used to take the lock twice; now it only locks once.

Use local stack storage for function pointers, rather than malloc,
if possible (i.e., number of ex_data items is under a dozen).

Make CRYPTO_EX_DATA_FUNCS opaque/internal.

Also fixes RT3710; index zero is reserved.

Reviewed-by: Richard Levitte <levitte@openssl.org>
9 years agoUse uint32_t consistently for flags.
Dr. Stephen Henson [Tue, 14 Jul 2015 22:19:11 +0000 (23:19 +0100)]
Use uint32_t consistently for flags.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoRemove obsolete key formats.
Rich Salz [Thu, 2 Jul 2015 12:49:54 +0000 (08:49 -0400)]
Remove obsolete key formats.

Remove support for RSA_NET and Netscape key format (-keyform n).

Also removed documentation of SGC.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
9 years agoFix author credit for e5c0bc6
mancha [Wed, 15 Jul 2015 08:54:28 +0000 (04:54 -0400)]
Fix author credit for e5c0bc6

Reviewed-by: Richard Levitte <levitte@openssl.org>
9 years agoRevert "Missing perldoc markup around < literal"
Rich Salz [Wed, 15 Jul 2015 08:52:51 +0000 (04:52 -0400)]
Revert "Missing perldoc markup around < literal"

This reverts commit e5c0bc6cc49a23b50a272801c4bd53639c25fca4.
Reviewed-by: Richard Levitte <levitte@openssl.org>
9 years agoGH322: Fix typo in generated comment.
Ernie Hershey [Wed, 15 Jul 2015 03:08:44 +0000 (23:08 -0400)]
GH322: Fix typo in generated comment.

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
9 years agoMaintain backwards-compatible SSLv23_method macros
Viktor Dukhovni [Wed, 15 Jul 2015 01:26:31 +0000 (21:26 -0400)]
Maintain backwards-compatible SSLv23_method macros

Reviewed-by: Tim Hudson <tjh@openssl.org>
9 years agoCan't use -trusted with -CA{path,file}
Rich Salz [Thu, 9 Jul 2015 18:54:13 +0000 (14:54 -0400)]
Can't use -trusted with -CA{path,file}

Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
9 years agoMissing perldoc markup around < literal
GitHub User [Thu, 9 Jul 2015 19:02:29 +0000 (15:02 -0400)]
Missing perldoc markup around < literal

Reviewed-by: Richard Levitte <levitte@openssl.org>
9 years agoConversion to UTF-8 where needed
Richard Levitte [Mon, 13 Jul 2015 14:53:37 +0000 (16:53 +0200)]
Conversion to UTF-8 where needed

This leaves behind files with names ending with '.iso-8859-1'.  These
should be safe to remove.  If something went wrong when re-encoding,
there will be some files with names ending with '.utf8' left behind.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoSmall script to re-encode files that need it to UTF-8
Richard Levitte [Mon, 13 Jul 2015 14:50:16 +0000 (16:50 +0200)]
Small script to re-encode files that need it to UTF-8

This requires 'iconv' and that 'file' can take the options '-b' and '-i'.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoRemove extra '; \' in apps/Makefile
Richard Levitte [Mon, 13 Jul 2015 13:48:57 +0000 (15:48 +0200)]
Remove extra '; \' in apps/Makefile

Fixes GH#330

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoSet numeric IDs for tar as well
Richard Levitte [Fri, 10 Jul 2015 16:29:17 +0000 (18:29 +0200)]
Set numeric IDs for tar as well

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoStop using tardy
Richard Levitte [Fri, 10 Jul 2015 13:40:53 +0000 (15:40 +0200)]
Stop using tardy

Instead of piping through tardy, and possibly suffering from bugs in certain
versions, use --transform, --owner and --group directly with GNU tar (we
already expect that tar variant).

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agocorrect example
Dr. Stephen Henson [Thu, 9 Jul 2015 18:32:36 +0000 (19:32 +0100)]
correct example

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoExit on error in ecparam
Peter Waltenberg [Thu, 9 Jul 2015 18:57:30 +0000 (14:57 -0400)]
Exit on error in ecparam

Reviewed-by: Tim Hudson <tjh@openssl.org>
9 years agomake stacks
Dr. Stephen Henson [Thu, 9 Jul 2015 11:45:22 +0000 (12:45 +0100)]
make stacks

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoSort @sstacklst correctly.
Dr. Stephen Henson [Thu, 9 Jul 2015 11:44:46 +0000 (12:44 +0100)]
Sort @sstacklst correctly.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoApply some missing updates from previous commits
Matt Caswell [Thu, 9 Jul 2015 08:45:22 +0000 (09:45 +0100)]
Apply some missing updates from previous commits

Reviewed-by: Stephen Henson <steve@openssl.org>
9 years agoUpdate CHANGES and NEWS for the new release
Matt Caswell [Thu, 2 Jul 2015 14:38:32 +0000 (15:38 +0100)]
Update CHANGES and NEWS for the new release

Reviewed-by: Stephen Henson <steve@openssl.org>
9 years agoExtend -show_chain option to verify to show more info
Matt Caswell [Thu, 25 Jun 2015 11:28:28 +0000 (12:28 +0100)]
Extend -show_chain option to verify to show more info

The -show_chain flag to the verify command line app shows information about
the chain that has been built. This commit adds the text "untrusted" against
those certificates that have been used from the untrusted list.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoAdd help text for some verify options
Matt Caswell [Thu, 25 Jun 2015 11:27:05 +0000 (12:27 +0100)]
Add help text for some verify options

Fills in the help text for a number of options to verify that were blank.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoAdd documentation for some missing verify options
Matt Caswell [Thu, 25 Jun 2015 11:34:38 +0000 (12:34 +0100)]
Add documentation for some missing verify options

Fills in a couple of verify options that were lacking documentation.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoReject calls to X509_verify_cert that have not been reinitialised
Matt Caswell [Thu, 25 Jun 2015 08:47:15 +0000 (09:47 +0100)]
Reject calls to X509_verify_cert that have not been reinitialised

The function X509_verify_cert checks the value of |ctx->chain| at the
beginning, and if it is NULL then it initialises it, along with the value
of ctx->untrusted. The normal way to use X509_verify_cert() is to first
call X509_STORE_CTX_init(); then set up various parameters etc; then call
X509_verify_cert(); then check the results; and finally call
X509_STORE_CTX_cleanup(). The initial call to X509_STORE_CTX_init() sets
|ctx->chain| to NULL. The only place in the OpenSSL codebase  where
|ctx->chain| is set to anything other than a non NULL value is in
X509_verify_cert itself. Therefore the only ways that |ctx->chain| could be
non NULL on entry to X509_verify_cert is if one of the following occurs:
1) An application calls X509_verify_cert() twice without re-initialising
in between.
2) An application reaches inside the X509_STORE_CTX structure and changes
the value of |ctx->chain| directly.

With regards to the second of these, we should discount this - it should
not be supported to allow this.

With regards to the first of these, the documentation is not exactly
crystal clear, but the implication is that you must call
X509_STORE_CTX_init() before each call to X509_verify_cert(). If you fail
to do this then, at best, the results would be undefined.

Calling X509_verify_cert() with |ctx->chain| set to a non NULL value is
likely to have unexpected results, and could be dangerous. This commit
changes the behaviour of X509_verify_cert() so that it causes an error if
|ctx->chain| is anything other than NULL (because this indicates that we
have not been initialised properly). It also clarifies the associated
documentation. This is a follow up commit to CVE-2015-1793.

Reviewed-by: Stephen Henson <steve@openssl.org>
9 years agoAdd test for CVE-2015-1793
Matt Caswell [Wed, 1 Jul 2015 23:15:56 +0000 (00:15 +0100)]
Add test for CVE-2015-1793

This adds a test for CVE-2015-1793. This adds a new test file
verify_extra_test.c, which could form the basis for additional
verification tests.

Reviewed-by: Stephen Henson <steve@openssl.org>
9 years agoFix alternate chains certificate forgery issue
Matt Caswell [Wed, 24 Jun 2015 14:55:36 +0000 (15:55 +0100)]
Fix alternate chains certificate forgery issue

During certificate verfification, OpenSSL will attempt to find an
alternative certificate chain if the first attempt to build such a chain
fails. An error in the implementation of this logic can mean that an
attacker could cause certain checks on untrusted certificates to be
bypassed, such as the CA flag, enabling them to use a valid leaf
certificate to act as a CA and "issue" an invalid certificate.

This occurs where at least one cert is added to the first chain from the
trust store, but that chain still ends up being untrusted. In that case
ctx->last_untrusted is decremented in error.

Patch provided by the BoringSSL project.

CVE-2015-1793

Reviewed-by: Stephen Henson <steve@openssl.org>
9 years agoDocument the nameopt change
Richard Levitte [Tue, 7 Jul 2015 12:50:10 +0000 (14:50 +0200)]
Document the nameopt change

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoMake "oneline" the default for nameopt
Richard Levitte [Tue, 7 Jul 2015 09:13:20 +0000 (11:13 +0200)]
Make "oneline" the default for nameopt

There's no reason why we should default to a output format that is
old, and confusing in some cases.

This affects the commands "ca", "crl", "req" and "x509".

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agodocument -2 return value
Dr. Stephen Henson [Mon, 6 Jul 2015 13:17:49 +0000 (14:17 +0100)]
document -2 return value

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoRelax CCM tag check.
Dr. Stephen Henson [Tue, 9 Jun 2015 22:17:06 +0000 (23:17 +0100)]
Relax CCM tag check.

In CCM mode don't require a tag before initialising decrypt: this allows
the tag length to be set without requiring the tag.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoDup peer_chain properly in SSL_SESSION
Dr. Stephen Henson [Tue, 30 Jun 2015 12:58:25 +0000 (13:58 +0100)]
Dup peer_chain properly in SSL_SESSION

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoCheck for errors with SRP
Dr. Stephen Henson [Thu, 25 Jun 2015 14:07:25 +0000 (15:07 +0100)]
Check for errors with SRP

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agomake update
Dr. Stephen Henson [Thu, 25 Jun 2015 14:06:14 +0000 (15:06 +0100)]
make update

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoUse single master secret generation function.
Dr. Stephen Henson [Wed, 17 Jun 2015 03:10:04 +0000 (04:10 +0100)]
Use single master secret generation function.

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoCheck dgram_sctp_write() return value.
Kurt Roeckx [Sat, 20 Jun 2015 14:46:33 +0000 (16:46 +0200)]
Check dgram_sctp_write() return value.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoCheck BIO_dgram_sctp_wait_for_dry() return value for error
Kurt Roeckx [Sat, 20 Jun 2015 14:28:08 +0000 (16:28 +0200)]
Check BIO_dgram_sctp_wait_for_dry() return value for error

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agomissing break
Dr. Stephen Henson [Thu, 25 Jun 2015 03:05:07 +0000 (04:05 +0100)]
missing break

Reviewed-by: Tim Hudson <tjh@openssl.org>
9 years agoDon't output bogus errors in PKCS12_parse
Dr. Stephen Henson [Wed, 24 Jun 2015 11:28:50 +0000 (12:28 +0100)]
Don't output bogus errors in PKCS12_parse

PR#3923

Reviewed-by: Tim Hudson <tjh@openssl.org>
9 years agoAdd docs for ssl verification parameter functions.
Dr. Stephen Henson [Wed, 17 Jun 2015 14:51:41 +0000 (15:51 +0100)]
Add docs for ssl verification parameter functions.

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoFix windows build
Rich Salz [Tue, 23 Jun 2015 22:33:02 +0000 (18:33 -0400)]
Fix windows build

Move #include's inside the #ifdef.

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoFix PSK client handling.
Dr. Stephen Henson [Mon, 22 Jun 2015 13:03:08 +0000 (14:03 +0100)]
Fix PSK client handling.

The PSK identity hint should be stored in the SSL_SESSION structure
and not in the parent context (which will overwrite values used
by other SSL structures with the same SSL_CTX).

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoAdd PSK GCM ciphersuites from RFC5487
Dr. Stephen Henson [Wed, 17 Jun 2015 13:47:53 +0000 (14:47 +0100)]
Add PSK GCM ciphersuites from RFC5487

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoPSK trace keyex fixes.
Dr. Stephen Henson [Wed, 17 Jun 2015 13:47:27 +0000 (14:47 +0100)]
PSK trace keyex fixes.

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoAvoid duplication.
Dr. Stephen Henson [Sat, 20 Jun 2015 14:44:03 +0000 (15:44 +0100)]
Avoid duplication.

We always free the handshake buffer when digests are freed so move
it into ssl_free_digest_list()

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoTidy up ssl3_digest_cached_records logic.
Dr. Stephen Henson [Tue, 16 Jun 2015 13:44:29 +0000 (14:44 +0100)]
Tidy up ssl3_digest_cached_records logic.

Rewrite ssl3_digest_cached_records handling. Only digest cached records
if digest array is NULL: this means it is safe to call
ssl3_digest_cached_records multiple times (subsequent calls are no op).

Remove flag TLS1_FLAGS_KEEP_HANDSHAKE instead only update handshake buffer
if digest array is NULL.

Add additional "keep" parameter to ssl3_digest_cached_records to indicate
if the handshake buffer should be retained after digesting cached records
(needed for TLS 1.2 client authentication).

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoMore secure storage of key material.
Rich Salz [Fri, 24 Apr 2015 20:39:40 +0000 (16:39 -0400)]
More secure storage of key material.

Add secure heap for storage of private keys (when possible).
Add BIO_s_secmem(), CBIGNUM, etc.
Add BIO_CTX_secure_new so all BIGNUM's in the context are secure.
Contributed by Akamai Technologies under the Corporate CLA.

Reviewed-by: Richard Levitte <levitte@openssl.org>
9 years agoAdd $! to errors, use script basename.
Rich Salz [Tue, 23 Jun 2015 11:27:23 +0000 (07:27 -0400)]
Add $! to errors, use script basename.

Reviewed-by: Richard Levitte <levitte@openssl.org>
9 years agoGH297: Fix NAME section of SSL_CTX_use_serverinfo.pod
Vitezslav Cizek [Tue, 16 Jun 2015 19:57:59 +0000 (15:57 -0400)]
GH297: Fix NAME section of SSL_CTX_use_serverinfo.pod

Signed-off-by: Rich Salz <rsalz@akamai.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoRT3682: Avoid double-free on OCSP parse error
Rich Salz [Sat, 13 Jun 2015 13:29:10 +0000 (09:29 -0400)]
RT3682: Avoid double-free on OCSP parse error

Found by Kurt Cancemi.

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoRT3856: Fix memory leaks in test code
Russell Webb [Sat, 13 Jun 2015 14:35:55 +0000 (10:35 -0400)]
RT3856: Fix memory leaks in test code

Reviewed-by: Matt Caswell <matt@openssl.org>