oweals/openssl.git
9 years agoCheck return value of ssl3_output_cert_chain
Dr. Stephen Henson [Tue, 18 Mar 2014 14:19:22 +0000 (14:19 +0000)]
Check return value of ssl3_output_cert_chain

(cherry picked from commit 66f96fe2d519147097c118d4bf60704c69ed0635)

Reviewed-by: Tim Hudson <tjh@openssl.org>
9 years agoThe dtls1_output_cert_chain function no longer exists so remove it from
Matt Caswell [Wed, 3 Dec 2014 10:33:08 +0000 (10:33 +0000)]
The dtls1_output_cert_chain function no longer exists so remove it from
ssl_locl.h

Reviewed-by: Tim Hudson <tjh@openssl.org>
9 years agoDon't set client_version to the ServerHello version.
Adam Langley [Sat, 13 Dec 2014 20:13:10 +0000 (20:13 +0000)]
Don't set client_version to the ServerHello version.

The client_version needs to be preserved for the RSA key exchange.

This change also means that renegotiation will, like TLS, repeat the old
client_version rather than advertise only the final version. (Either way,
version change on renego is not allowed.) This is necessary in TLS to work
around an SChannel bug, but it's not strictly necessary in DTLS.

(From BoringSSL)

Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit ec1af3c4195c1dfecdd9dc7458850ab1b8b951e0)

9 years agoAdd more meaningful OPENSSL_NO_ECDH error message for suite b mode
Matt Caswell [Tue, 16 Dec 2014 10:53:36 +0000 (10:53 +0000)]
Add more meaningful OPENSSL_NO_ECDH error message for suite b mode

Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit db812f2d70f0695fd53b386fe5e870bef8ca3c22)

9 years agoAdd OPENSSL_NO_ECDH guards
Matt Caswell [Tue, 18 Nov 2014 16:54:07 +0000 (16:54 +0000)]
Add OPENSSL_NO_ECDH guards

Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit af6e2d51bfeabbae827030d4c9d58a8f7477c4a0)

9 years agoRemove extraneous white space, and add some braces
Matt Caswell [Mon, 15 Dec 2014 20:48:33 +0000 (20:48 +0000)]
Remove extraneous white space, and add some braces

Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit 55e530265a7ea8f264717a4e37338cc04eca2007)

9 years agoDTLS fixes for signed/unsigned issues
Matt Caswell [Fri, 12 Dec 2014 15:32:24 +0000 (15:32 +0000)]
DTLS fixes for signed/unsigned issues

Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit 1904d21123849a65dafde1705e6dd5b7c2f420eb)

9 years agoFix unused variable warning
Emilia Kasper [Mon, 15 Dec 2014 12:11:52 +0000 (13:11 +0100)]
Fix unused variable warning

The temporary variable causes unused variable warnings in opt mode with clang,
because the subsequent assert is compiled out.

Reviewed-by: Rich Salz <rsalz@openssl.org>
9 years agoFix memory leak in s2_srvr.c if BUF_MEM_grow fails
Matt Caswell [Fri, 12 Dec 2014 11:05:21 +0000 (11:05 +0000)]
Fix memory leak in s2_srvr.c if BUF_MEM_grow fails

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
9 years agoFixed memory leak if BUF_MEM_grow fails
Matt Caswell [Fri, 12 Dec 2014 11:03:00 +0000 (11:03 +0000)]
Fixed memory leak if BUF_MEM_grow fails

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
9 years agoFixed memory leak in the event of a failure of BUF_MEM_grow
Matt Caswell [Thu, 4 Dec 2014 09:56:16 +0000 (09:56 +0000)]
Fixed memory leak in the event of a failure of BUF_MEM_grow

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 41bf25013032da0eeb111ce3c8fc0946c0e61c41)

9 years agoFix memory leak in SSL_new if errors occur.
Matt Caswell [Thu, 4 Dec 2014 09:46:44 +0000 (09:46 +0000)]
Fix memory leak in SSL_new if errors occur.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 76e6509085ea96df0ca542568ee2596343711307)

9 years agoClarify the return values for SSL_get_shared_curve.
Emilia Kasper [Thu, 4 Dec 2014 14:00:11 +0000 (15:00 +0100)]
Clarify the return values for SSL_get_shared_curve.

Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 376e2ca3e3525290619602dc6013c97c9653c037)

9 years agoAdd extra checks for odd-length EC curve lists.
Emilia Kasper [Mon, 1 Dec 2014 15:55:55 +0000 (16:55 +0100)]
Add extra checks for odd-length EC curve lists.

Odd-length lists should be rejected everywhere upon parsing. Nevertheless,
be extra careful and add guards against off-by-one reads.

Also, drive-by replace inexplicable double-negation with an explicit comparison.

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoMake 'make update' succeed and run it
Emilia Kasper [Fri, 5 Dec 2014 16:45:29 +0000 (17:45 +0100)]
Make 'make update' succeed and run it

Reviewed-by: Dr Stephen Henson <steve@openssl.org>
9 years agoReject elliptic curve lists of odd lengths.
Emilia Kasper [Mon, 1 Dec 2014 14:04:02 +0000 (15:04 +0100)]
Reject elliptic curve lists of odd lengths.

The Supported Elliptic Curves extension contains a vector of NamedCurves
of 2 bytes each, so the total length must be even. Accepting odd-length
lists was observed to lead to a non-exploitable one-byte out-of-bounds
read in the latest development branches (1.0.2 and master). Released
versions of OpenSSL are not affected.

Thanks to Felix Groebert of the Google Security Team for reporting this issue.

Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 33d5ba862939ff8db70a9e36fc9a326fab3e8d98)

9 years agos_client and s_server take -verify_{host,email,ip}, not -check*
Richard Levitte [Sat, 29 Nov 2014 06:08:15 +0000 (07:08 +0100)]
s_client and s_server take -verify_{host,email,ip}, not -check*

RT3596
Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoRemove incorrect code inadvertently introduced through commit 59669b6ab.
Matt Caswell [Thu, 4 Dec 2014 09:22:50 +0000 (09:22 +0000)]
Remove incorrect code inadvertently introduced through commit 59669b6ab.

Reviewed-by: Tim Hudson <tjh@openssl.org>
9 years agoRemove "#if 0" code
Matt Caswell [Wed, 3 Dec 2014 09:21:09 +0000 (09:21 +0000)]
Remove "#if 0" code

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 4bb8eb9ce4f794fecf020a15b54e8505fced0edf)

9 years agoOnly use the fallback mtu after 2 unsuccessful retransmissions if it is less
Matt Caswell [Tue, 2 Dec 2014 11:16:35 +0000 (11:16 +0000)]
Only use the fallback mtu after 2 unsuccessful retransmissions if it is less
than the mtu we are already using

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 047f21593eebbc617a410a208ded01e65ca11028)

9 years agoUpdates to s_client and s_server to remove the constant 28 (for IPv4 header
Matt Caswell [Mon, 1 Dec 2014 23:57:44 +0000 (23:57 +0000)]
Updates to s_client and s_server to remove the constant 28 (for IPv4 header
and UDP header) when setting an mtu. This constant is not always correct (e.g.
if using IPv6). Use the new DTLS_CTRL functions instead.

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 464ce92026bd0c79186cbefa75470f39607110be)

9 years agoIf we really get a situation where the underlying mtu is less than the minimum
Matt Caswell [Tue, 2 Dec 2014 00:16:55 +0000 (00:16 +0000)]
If we really get a situation where the underlying mtu is less than the minimum
we will support then dtls1_do_write can go into an infinite loop. This commit
fixes that.

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit d3d9eef31661633f5b003a9e115c1822f79d1870)

9 years agoFix dtls_query_mtu so that it will always either complete with an mtu that is
Matt Caswell [Mon, 1 Dec 2014 22:18:18 +0000 (22:18 +0000)]
Fix dtls_query_mtu so that it will always either complete with an mtu that is
at least the minimum or it will fail.
There were some instances in dtls1_query_mtu where the final mtu can end up
being less than the minimum, i.e. where the user has set an mtu manually. This
shouldn't be allowed. Also remove dtls1_guess_mtu that, despite having
logic for guessing an mtu, was actually only ever used to work out the minimum
mtu to use.

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 1620a2e49c777f31f2ce57966ae74006b48ad759)

9 years agoRemove instances in libssl of the constant 28 (for size of IPv4 header + UDP)
Matt Caswell [Mon, 1 Dec 2014 23:58:05 +0000 (23:58 +0000)]
Remove instances in libssl of the constant 28 (for size of IPv4 header + UDP)
and instead use the value provided by the underlying BIO. Also provide some
new DTLS_CTRLs so that the library user can set the mtu without needing to
know this constant. These new DTLS_CTRLs provide the capability to set the
link level mtu to be used (i.e. including this IP/UDP overhead). The previous
DTLS_CTRLs required the library user to subtract this overhead first.

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 59669b6abf620d1ed2ef4d1e2df25c998b89b64d)

Conflicts:
ssl/d1_both.c

9 years agoThere are a number of instances throughout the code where the constant 28 is
Matt Caswell [Mon, 1 Dec 2014 23:49:47 +0000 (23:49 +0000)]
There are a number of instances throughout the code where the constant 28 is
used with no explanation. Some of this was introduced as part of RT#1929. The
value 28 is the length of the IP header (20 bytes) plus the UDP header (8
bytes). However use of this constant is incorrect because there may be
instances where a different value is needed, e.g. an IPv4 header is 20 bytes
but an IPv6 header is 40. Similarly you may not be using UDP (e.g. SCTP).
This commit introduces a new BIO_CTRL that provides the value to be used for
this mtu "overhead". It will be used by subsequent commits.

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 0d3ae34df573f477b6b1aaf614d52dcdfcff5fce)

9 years agoThe first call to query the mtu in dtls1_do_write correctly checks that the
Matt Caswell [Mon, 1 Dec 2014 11:41:25 +0000 (11:41 +0000)]
The first call to query the mtu in dtls1_do_write correctly checks that the
mtu that we have received is not less than the minimum. If its less it uses the
minimum instead. The second call to query the mtu does not do that, but
instead uses whatever comes back. We have seen an instance in RT#3592 where we
have got an unreasonably small mtu come back. This commit makes both query
checks consistent.

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 6abb0d1f8e702a0daa9c32b8021d01eda0483018)

9 years agoThe SSL_OP_NO_QUERY_MTU option is supposed to stop the mtu from being
Matt Caswell [Mon, 1 Dec 2014 11:13:15 +0000 (11:13 +0000)]
The SSL_OP_NO_QUERY_MTU option is supposed to stop the mtu from being
automatically updated, and we should use the one provided instead.
Unfortunately there are a couple of locations where this is not respected.

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 001235778a6e9c645dc0507cad6092d99c9af8f5)

9 years agoVerify that we have a sensible message len and fail if not
Matt Caswell [Mon, 1 Dec 2014 11:10:38 +0000 (11:10 +0000)]
Verify that we have a sensible message len and fail if not
RT#3592 provides an instance where the OPENSSL_assert that this commit
replaces can be hit. I was able to recreate this issue by forcing the
underlying BIO to misbehave and come back with very small mtu values. This
happens the second time around the while loop after we have detected that the
MTU has been exceeded following the call to dtls1_write_bytes.

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit cf75017bfd60333ff65edf9840001cd2c49870a3)

9 years agoUse the SSLv23 method by default
Kurt Roeckx [Sat, 29 Nov 2014 15:17:54 +0000 (16:17 +0100)]
Use the SSLv23 method by default

If SSLv2 and SSLv3 are both disabled we still support SSL/TLS.

Reviewed-by: Richard Levitte <levitte@openssl.org>
9 years agoCheck for FindNextFile when defining it rather than FindFirstFile
Richard Levitte [Fri, 28 Nov 2014 22:06:20 +0000 (23:06 +0100)]
Check for FindNextFile when defining it rather than FindFirstFile

Reviewed-by: Matt Caswell <matt@openssl.org>
9 years ago[PR3597] Advance to the next state variant when reusing messages.
Richard Levitte [Fri, 28 Nov 2014 19:40:10 +0000 (20:40 +0100)]
[PR3597] Advance to the next state variant when reusing messages.

Previously, state variant was not advanced, which resulted in state
being stuck in the st1 variant (usually "_A").

This broke certificate callback retry logic when accepting connections
that were using SSLv2 ClientHello (hence reusing the message), because
their state never advanced to SSL3_ST_SR_CLNT_HELLO_C variant required
for the retry code path.

Reported by Yichun Zhang (agentzh).

Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoCorrect some layout issues, convert all remaining tabs to appropriate amounts of...
Richard Levitte [Fri, 28 Nov 2014 15:31:10 +0000 (16:31 +0100)]
Correct some layout issues, convert all remaining tabs to appropriate amounts of spaces.

Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 8123d158ab6f0a6a468748c133e33c2063ff36b5)

9 years agoImproves the proxy certificates howto doc.
Alok Menghrajani [Fri, 14 Nov 2014 18:39:41 +0000 (10:39 -0800)]
Improves the proxy certificates howto doc.

The current documentation contains a bunch of spelling and grammar mistakes. I also
found it hard to understand some paragraphs, so here is my attempt to improve its
readability.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 03b637a730e4a298c360cc143de7564060c06324)

9 years agoFix warning in ssl2_enc
Matt Caswell [Thu, 27 Nov 2014 20:32:21 +0000 (20:32 +0000)]
Fix warning in ssl2_enc

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit f9ea4deba006ee45a61e5f406f12c936b9bc162e)

9 years agoRemove more references to dtls1_enc
Matt Caswell [Thu, 27 Nov 2014 20:31:59 +0000 (20:31 +0000)]
Remove more references to dtls1_enc

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit eceef8fb865eb5de329b27ea472d4fdea4c290fe)

9 years agoCheck EVP_Cipher return values for SSL2
Matt Caswell [Tue, 18 Nov 2014 15:03:55 +0000 (15:03 +0000)]
Check EVP_Cipher return values for SSL2

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 81ec01b21767da5e5f0c03ad79b4d3dc9b632393)

9 years agoDelete unused file
Matt Caswell [Tue, 18 Nov 2014 13:51:20 +0000 (13:51 +0000)]
Delete unused file

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 4b87706d20f0a2fdf2e8f1b90256e141c487ef47)

Conflicts:
ssl/d1_enc.c

9 years agoAdd checks to the return value of EVP_Cipher to prevent silent encryption failure.
Matt Caswell [Tue, 18 Nov 2014 12:56:26 +0000 (12:56 +0000)]
Add checks to the return value of EVP_Cipher to prevent silent encryption failure.

PR#1767

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit fe78f08d1541211566a5656395186bfbdc61b6f8)

9 years agoRemove redundant checks in ssl_cert_dup. This was causing spurious error messages...
Matt Caswell [Thu, 27 Nov 2014 11:06:43 +0000 (11:06 +0000)]
Remove redundant checks in ssl_cert_dup. This was causing spurious error messages when using GOST

PR#3613

Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit fc3968a25ce0c16cab8730ec0d68a59856158029)

9 years agoRemove duplicated code
Matt Caswell [Mon, 17 Nov 2014 14:22:10 +0000 (14:22 +0000)]
Remove duplicated code

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
9 years agoTidy up ocsp help output
Matt Caswell [Thu, 27 Nov 2014 10:15:47 +0000 (10:15 +0000)]
Tidy up ocsp help output

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
(cherry picked from commit 5e31a40f47c6bfd09c718d2af42ba8d8fe6bb932)

Conflicts:
apps/ocsp.c

9 years agoAdd documentation on -timeout option in the ocsp utility
André Guerreiro [Thu, 27 Nov 2014 10:11:33 +0000 (10:11 +0000)]
Add documentation on -timeout option in the ocsp utility

PR#3612

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
(cherry picked from commit de87dd46c1283f899a9ecf4ccc72db74f36afbf2)

9 years agoNetWare compilation fix.
Guenter [Thu, 27 Nov 2014 13:33:47 +0000 (13:33 +0000)]
NetWare compilation fix.

Workaround for NetWare CodeWarrior compiler which doesn't properly lookup
includes when in same directory as the C file which includes it.

PR#3569
Reviewed-by: Stephen Henson <steve@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(cherry picked from commit 333fad9f2de1dea99552fcb424b312ca1a390f85)

9 years agoUpdates to X509_NAME_get_index_by_NID.pod submitted by user Bernardh via the wiki
Matt Caswell [Fri, 12 Sep 2014 05:00:26 +0000 (01:00 -0400)]
Updates to X509_NAME_get_index_by_NID.pod submitted by user Bernardh via the wiki
Minor changes made by Matt Caswell

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
(cherry picked from commit 648495864513da788246f9b75dbbbce0614ed5e8)

9 years agoUpdates to X509_NAME_add_entry_by_txt.pod submitted by user Bernardh via the wiki
Matt Caswell [Sat, 6 Sep 2014 22:48:54 +0000 (23:48 +0100)]
Updates to X509_NAME_add_entry_by_txt.pod submitted by user Bernardh via the wiki
Minor changes made by Matt Caswell.

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
(cherry picked from commit f281b8df704ce0123fa2193f2890a25da1756528)

9 years agoUpdates to EVP_PKEY_encrypt.pod submitted by user Bernardh via the wiki
Matt Caswell [Sat, 6 Sep 2014 22:47:55 +0000 (23:47 +0100)]
Updates to EVP_PKEY_encrypt.pod submitted by user Bernardh via the wiki
Minor changes made by Matt Caswell.

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
(cherry picked from commit 34890ac18eb5ee7bffe9d460480164e1546b491e)

9 years agoAdd include of ssl.h which is required by srtp.h
Matt Caswell [Thu, 27 Nov 2014 12:25:18 +0000 (12:25 +0000)]
Add include of ssl.h which is required by srtp.h

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
(cherry picked from commit f67203836cd4a35c1774b6147e0f2d33eb7b1b6f)

9 years agoFixed memory leak due to incorrect freeing of DTLS reassembly bit mask
Matt Caswell [Tue, 25 Nov 2014 13:36:00 +0000 (13:36 +0000)]
Fixed memory leak due to incorrect freeing of DTLS reassembly bit mask

PR#3608

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 8a35dbb6d89a16d792b79b157b3e89443639ec94)

9 years agoCorrected comments in ssl.h about SSLv23_method and friends
Matt Caswell [Tue, 25 Nov 2014 17:23:24 +0000 (17:23 +0000)]
Corrected comments in ssl.h about SSLv23_method and friends

PR#3574

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
(cherry picked from commit 3a0765882c4b3b67960b7efb203570764dd4ed29)

9 years agoPrint out Suite B status.
Dr. Stephen Henson [Thu, 20 Nov 2014 14:50:54 +0000 (14:50 +0000)]
Print out Suite B status.

When using the -xcert option to test certificate validity print out
if we pass Suite B compliance. We print out "not tested" if we aren't
in Suite B mode.
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 7d4cdededc371854eb36e773ed18204593e994e1)

9 years agoFix SuiteB chain checking logic.
Dr. Stephen Henson [Thu, 20 Nov 2014 14:06:50 +0000 (14:06 +0000)]
Fix SuiteB chain checking logic.

Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 7255ca99df1f2d83d99d113dd5ca54b88d50e72b)

9 years agoDo not resume a session if the negotiated protocol version does not match
David Benjamin [Thu, 20 Nov 2014 15:22:40 +0000 (16:22 +0100)]
Do not resume a session if the negotiated protocol version does not match
the session's version (server).

See also BoringSSL's commit bdf5e72f50e25f0e45e825c156168766d8442dde.

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
(cherry picked from commit 9e189b9dc10786c755919e6792e923c584c918a1)

9 years agoWhen using EVP_PKEY_derive with a KDF set, a negative error from
Matt Caswell [Wed, 19 Nov 2014 20:09:19 +0000 (20:09 +0000)]
When using EVP_PKEY_derive with a KDF set, a negative error from
ECDH_compute_key is silently ignored and the KDF is run on duff data

Thanks to github user tomykaira for the suggested fix.

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
(cherry picked from commit 8d02bebddf4b69f7f260adfed4be4f498dcbd16c)

9 years agoClean up CHANGES
Emilia Kasper [Thu, 20 Nov 2014 11:20:02 +0000 (12:20 +0100)]
Clean up CHANGES

Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 31832e8ff1a3e731ea9fab41aef071a12709cf33)

Conflicts:
CHANGES

9 years agoEnsure SSL3_FLAGS_CCS_OK (or d1->change_cipher_spec_ok for DTLS) is reset
Emilia Kasper [Wed, 19 Nov 2014 16:01:36 +0000 (17:01 +0100)]
Ensure SSL3_FLAGS_CCS_OK (or d1->change_cipher_spec_ok for DTLS) is reset
once the ChangeCipherSpec message is received. Previously, the server would
set the flag once at SSL3_ST_SR_CERT_VRFY and again at SSL3_ST_SR_FINISHED.
This would allow a second CCS to arrive and would corrupt the server state.

(Because the first CCS would latch the correct keys and subsequent CCS
messages would have to be encrypted, a MitM attacker cannot exploit this,
though.)

Thanks to Joeri de Ruiter for reporting this issue.

Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit e94a6c0ede623960728415b68650a595e48f5a43)

9 years agoAlways require an advertised NewSessionTicket message.
Emilia Kasper [Wed, 19 Nov 2014 15:40:27 +0000 (16:40 +0100)]
Always require an advertised NewSessionTicket message.

The server must send a NewSessionTicket message if it advertised one
in the ServerHello, so make a missing ticket message an alert
in the client.

An equivalent change was independently made in BoringSSL, see commit
6444287806d801b9a45baf1f6f02a0e3a16e144c.

Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit de2c7504ebd4ec15334ae151a31917753468f86f)

9 years agoRemove ssl3_check_finished.
Emilia Kasper [Wed, 19 Nov 2014 15:28:11 +0000 (16:28 +0100)]
Remove ssl3_check_finished.

The client sends a session ID with the session ticket, and uses
the returned ID to detect resumption, so we do not need to peek
at handshake messages: s->hit tells us explicitly if we're resuming.

An equivalent change was independently made in BoringSSL, see commit
407886f589cf2dbaed82db0a44173036c3bc3317.

Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 980bc1ec6114f5511b20c2e6ca741e61a39b99d6)

Conflicts:
ssl/s3_clnt.c

9 years agoSet s->hit when resuming from external pre-shared secret.
Emilia Kasper [Wed, 19 Nov 2014 14:56:27 +0000 (15:56 +0100)]
Set s->hit when resuming from external pre-shared secret.

The same change was independently made in BoringSSL, see commit
9eaeef81fa2d4fd6246dc02b6203fa936a5eaf67

Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 7b3ba508af5c86afe43e28174aa3c53a0a24f4d9)

9 years agoReset s->tlsext_ticket_expected in ssl_scan_serverhello_tlsext.
Emilia Kasper [Wed, 19 Nov 2014 14:42:43 +0000 (15:42 +0100)]
Reset s->tlsext_ticket_expected in ssl_scan_serverhello_tlsext.
This ensures that it's zeroed even if the SSL object is reused
(as in ssltest.c). It also ensures that it applies to DTLS, too.

Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit a06cd5d056c6a5b1d161786873e21a5e53d554d8)

9 years agoFix s_server -ssl2. Previously this reported "Error setting EC curve"
Matt Caswell [Wed, 19 Nov 2014 16:02:49 +0000 (16:02 +0000)]
Fix s_server -ssl2. Previously this reported "Error setting EC curve"

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
(cherry picked from commit 13d568661c14f71b3c6af263e1b60b92be738f57)

9 years agoNew option no-ssl3-method which removes SSLv3_*method
Dr. Stephen Henson [Wed, 29 Oct 2014 12:51:31 +0000 (12:51 +0000)]
New option no-ssl3-method which removes SSLv3_*method

When no-ssl3 is set only make SSLv3 disabled by default. Retain -ssl3
options for s_client/s_server/ssltest.

When no-ssl3-method is set SSLv3_*method() is removed and all -ssl3
options.

We should document this somewhere, e.g. wiki, FAQ or manual page.
Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit 3881d8106df732fc433d30446625dfa2396da42d)

9 years agoFix excert logic.
Dr. Stephen Henson [Mon, 17 Nov 2014 16:30:51 +0000 (16:30 +0000)]
Fix excert logic.

If no keyfile has been specified use the certificate file instead.

Fix typo: we need to check the chain is not NULL, not the chain file.
Reviewed-by: Matt Caswell <matt@openssl.org>
9 years agoProcess signature algorithms before deciding on certificate.
Dr. Stephen Henson [Mon, 17 Nov 2014 16:52:59 +0000 (16:52 +0000)]
Process signature algorithms before deciding on certificate.

The supported signature algorithms extension needs to be processed before
the certificate to use is decided and before a cipher is selected (as the
set of shared signature algorithms supported may impact the choice).
Reviewed-by: Matt Caswell <matt@openssl.org>
10 years agoAdded RFC 7027 references
Matt Caswell [Mon, 17 Nov 2014 23:07:08 +0000 (23:07 +0000)]
Added RFC 7027 references

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
10 years agoFixed cms-test.pl for no-ec2m
Matt Caswell [Wed, 12 Nov 2014 10:05:01 +0000 (10:05 +0000)]
Fixed cms-test.pl for no-ec2m

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
10 years agoAdded OPENSSL_NO_EC2M guards around the default EC curves
Matt Caswell [Mon, 10 Nov 2014 23:29:44 +0000 (23:29 +0000)]
Added OPENSSL_NO_EC2M guards around the default EC curves

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
10 years agoDon't use msg on error.
Jan Hykel [Sun, 16 Nov 2014 16:51:17 +0000 (16:51 +0000)]
Don't use msg on error.

Don't attempt to access msg structure if recvmsg returns an error.

PR#3483
Reviewed-by: Stephen Henson <steve@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 012aa9ec76b158179b4de44bb5de8b8472045eac)

10 years agoFix cross reference table generator.
Dr. Stephen Henson [Sat, 1 Nov 2014 00:10:56 +0000 (00:10 +0000)]
Fix cross reference table generator.

If the hash or public key algorithm is "undef" the signature type
will receive special handling and shouldn't be included in the
cross reference table.
Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 55f7fb8848b6e4bec291724a479e1580d6f407d6)

10 years agoFixes a minor typo in the EVP docs.
Alok Menghrajani [Tue, 11 Nov 2014 22:39:11 +0000 (14:39 -0800)]
Fixes a minor typo in the EVP docs.

Out is the buffer which needs to contain at least inl + cipher_block_size - 1 bytes. Outl
is just an int*.

Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit 5211e094dec9486a540ac480f345df1a8d2b2862)

10 years agoCorrect timestamp output when clock_precision_digits > 0
Michal Bozon [Wed, 12 Nov 2014 15:59:04 +0000 (15:59 +0000)]
Correct timestamp output when clock_precision_digits > 0

PR#3535

Reviewed-by: Stephen Henson <steve@openssl.org>
10 years agoFix free of garbage pointer. PR#3595
Matt Caswell [Wed, 12 Nov 2014 11:18:09 +0000 (11:18 +0000)]
Fix free of garbage pointer. PR#3595

Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit e04d426bf98ebb22abf0f15b6f09d333a6e8b2ad)

10 years agoFix warning about negative unsigned intergers
Kurt Roeckx [Mon, 10 Nov 2014 18:03:03 +0000 (19:03 +0100)]
Fix warning about negative unsigned intergers

Reviewed-by: Richard Levitte <levitte@openssl.org>
10 years agoFix datarace reported by valgrind/helgrind
Russell Coker [Thu, 25 Jun 2009 05:59:32 +0000 (15:59 +1000)]
Fix datarace reported by valgrind/helgrind

This doesn't really fix the datarace but changes it so it can only happens
once. This isn't really a problem since we always just set it to the same
value. We now just stop writing it after the first time.

PR3584, https://bugs.debian.org/534534

Signed-off-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Rich Salz <rsalz@openssl.org>
10 years agoAllow ECDHE and DHE as forward-compatible aliases for EECDH and EDH
Daniel Kahn Gillmor [Mon, 12 May 2014 18:17:22 +0000 (14:17 -0400)]
Allow ECDHE and DHE as forward-compatible aliases for EECDH and EDH

see RT #3203

Future versions of OpenSSL use the canonical terms "ECDHE" and "DHE"
as configuration strings and compilation constants.  This patch
introduces aliases so that the stable 1.0.2 branch can be
forward-compatible with code and configuration scripts that use the
normalized terms, while avoiding changing any library output for
stable users.

Signed-off-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Matt Caswell <matt@openssl.org>
10 years agoarmv4cpuid.S: fix compilation error in pre-ARMv7 build.
Andy Polyakov [Thu, 30 Oct 2014 19:24:29 +0000 (20:24 +0100)]
armv4cpuid.S: fix compilation error in pre-ARMv7 build.

PR: 3474
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
(cherry picked from commit 6696203963ba209fbbef12098e6eb6f364379c65)

10 years agomd32_common.h: address compiler warning in HOST_c2l.
Andy Polyakov [Wed, 29 Oct 2014 09:48:39 +0000 (10:48 +0100)]
md32_common.h: address compiler warning in HOST_c2l.

Reviewed-by: Stephen Henson <steve@openssl.org>
(cherry picked from commit d45282fc7cd9b97ed1479f8b8af713337fce57f5)

10 years agoUse only unsigned arithmetic in constant-time operations
Samuel Neves [Fri, 3 Oct 2014 23:13:36 +0000 (00:13 +0100)]
Use only unsigned arithmetic in constant-time operations

Signed-off-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Emilia Käsper <emilia@openssl.org>
10 years agoTighten session ticket handling
Emilia Kasper [Tue, 28 Oct 2014 16:35:59 +0000 (17:35 +0100)]
Tighten session ticket handling

Tighten client-side session ticket handling during renegotiation:
ensure that the client only accepts a session ticket if the server sends
the extension anew in the ServerHello. Previously, a TLS client would
reuse the old extension state and thus accept a session ticket if one was
announced in the initial ServerHello.

Reviewed-by: Bodo Moeller <bodo@openssl.org>
(cherry picked from commit d663df2399d1d9d6015bcfd2ec87b925ea3558a2)

10 years agoSync CHANGES
Emilia Kasper [Mon, 27 Oct 2014 15:57:34 +0000 (16:57 +0100)]
Sync CHANGES

Reviewed-by: Rich Salz <rsalz@openssl.org>
10 years agoFix ssltest logic when some protocols are compiled out.
Emilia Kasper [Mon, 27 Oct 2014 15:25:17 +0000 (16:25 +0100)]
Fix ssltest logic when some protocols are compiled out.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Geoff Thorpe <geoff@openssl.org>
(cherry picked from commit fd28a41ec899eb8749e21d11441fd4df35ed9a07)

Conflicts:
ssl/ssltest.c

10 years agoCopy negotiated parameters in SSL_set_SSL_CTX.
Dr. Stephen Henson [Wed, 8 Oct 2014 23:23:34 +0000 (00:23 +0100)]
Copy negotiated parameters in SSL_set_SSL_CTX.

SSL_set_SSL_CTX is used to change the SSL_CTX for SNI, keep the
supported signature algorithms and raw cipherlist.
Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit 14e14bf6964965d02ce89805d9de867f000095aa)

10 years agoProcess signature algorithms in ClientHello late.
Dr. Stephen Henson [Thu, 9 Oct 2014 19:37:27 +0000 (20:37 +0100)]
Process signature algorithms in ClientHello late.

Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit c800c27a8c47c8e63254ec594682452c296f1e8e)

Conflicts:

ssl/ssl.h
ssl/ssl_err.c
ssl/ssl_locl.h

10 years agoParse custom extensions after SNI.
Dr. Stephen Henson [Mon, 20 Oct 2014 16:17:52 +0000 (17:17 +0100)]
Parse custom extensions after SNI.

Since SNI will typically switch the SSL_CTX structure to the one
corresponding to the appopriate server we need to parse custom
extensions using the switched SSL_CTX not the original one. This
is done by parsing custom extensions *after* SNI.
Reviewed-by: Emilia Käsper <emilia@openssl.org>
10 years agoAdd missing credit.
Andy Polyakov [Wed, 22 Oct 2014 07:35:51 +0000 (09:35 +0200)]
Add missing credit.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 9f4bd9d5f932078c485a98f39c3313481898738a)

10 years agoFix and improve SSL_MODE_SEND_FALLBACK_SCSV documentation.
Bodo Moeller [Tue, 21 Oct 2014 20:39:26 +0000 (22:39 +0200)]
Fix and improve SSL_MODE_SEND_FALLBACK_SCSV documentation.

Reviewed-by: Rich Salz <rsalz@openssl.org>
10 years agoWhen processing ClientHello.cipher_suites, don't ignore cipher suites
Bodo Moeller [Tue, 21 Oct 2014 20:32:09 +0000 (22:32 +0200)]
When processing ClientHello.cipher_suites, don't ignore cipher suites
listed after TLS_FALLBACK_SCSV.

RT: 3575
Reviewed-by: Emilia Kasper <emilia@openssl.org>
10 years agoKeep old method in case of an unsupported protocol
Kurt Roeckx [Tue, 21 Oct 2014 18:45:15 +0000 (20:45 +0200)]
Keep old method in case of an unsupported protocol

When we're configured with no-ssl3 and we receive an SSL v3 Client Hello, we set
the method to NULL.  We didn't used to do that, and it breaks things.  This is a
regression introduced in 62f45cc27d07187b59551e4fad3db4e52ea73f2c.  Keep the old
method since the code is not able to deal with a NULL method at this time.

CVE-2014-3569, PR#3571

Reviewed-by: Emilia Käsper <emilia@openssl.org>
(cherry picked from commit 392fa7a952e97d82eac6958c81ed1e256e6b8ca5)

10 years agono-ssl2 with no-ssl3 does not mean drop the ssl lib
Tim Hudson [Mon, 20 Oct 2014 05:12:17 +0000 (15:12 +1000)]
no-ssl2 with no-ssl3 does not mean drop the ssl lib

Reviewed-by: Geoff Thorpe <geoff@openssl.org>
(cherry picked from commit c882abd52269a59ed8e0510e5febf667428ece85)

10 years agoRT3547: Add missing static qualifier
Kurt Cancemi [Sun, 28 Sep 2014 19:28:49 +0000 (15:28 -0400)]
RT3547: Add missing static qualifier

Reviewed-by: Ben Laurie <ben@openssl.org>
(cherry picked from commit 87d388c955c14a7c1371f9c7555fb429a406a3d3)

10 years agoUpdates to NEWS file
Matt Caswell [Wed, 15 Oct 2014 11:25:16 +0000 (12:25 +0100)]
Updates to NEWS file

Reviewed-by: Dr Stephen Henson <steve@openssl.org>
10 years agoUpdates to CHANGES file
Matt Caswell [Wed, 15 Oct 2014 09:48:13 +0000 (10:48 +0100)]
Updates to CHANGES file

Reviewed-by: Bodo Möller <bodo@openssl.org>
10 years agoFix no-ssl3 configuration option
Geoff Thorpe [Wed, 15 Oct 2014 07:25:50 +0000 (03:25 -0400)]
Fix no-ssl3 configuration option

CVE-2014-3568

Reviewed-by: Emilia Kasper <emilia@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
10 years agoFix for session tickets memory leak.
Dr. Stephen Henson [Wed, 15 Oct 2014 00:53:55 +0000 (01:53 +0100)]
Fix for session tickets memory leak.

CVE-2014-3567

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 5dc6070a03779cd524f0e67f76c945cb0ac38320)

10 years agoFix SRTP compile issues for windows
Matt Caswell [Wed, 15 Oct 2014 00:23:07 +0000 (01:23 +0100)]
Fix SRTP compile issues for windows

Related to CVE-2014-3513

This fix was developed by the OpenSSL Team

Reviewed-by: Tim Hudson <tjh@openssl.org>
Conflicts:
util/mkdef.pl
util/ssleay.num

Conflicts:
util/mkdef.pl

10 years agoFix for SRTP Memory Leak
Matt Caswell [Wed, 15 Oct 2014 00:03:32 +0000 (01:03 +0100)]
Fix for SRTP Memory Leak

CVE-2014-3513

This issue was reported to OpenSSL on 26th September 2014, based on an original
issue and patch developed by the LibreSSL project. Further analysis of the issue
was performed by the OpenSSL team.

The fix was developed by the OpenSSL team.

Reviewed-by: Tim Hudson <tjh@openssl.org>
10 years agoFix SSL_R naming inconsistency.
Bodo Moeller [Wed, 15 Oct 2014 12:48:00 +0000 (14:48 +0200)]
Fix SSL_R naming inconsistency.

Reviewed-by: Tim Hudson <tjh@openssl.org>
10 years agoaesni-x86_64.pl: make ECB subroutine Windows ABI compliant.
Andy Polyakov [Wed, 15 Oct 2014 09:10:08 +0000 (11:10 +0200)]
aesni-x86_64.pl: make ECB subroutine Windows ABI compliant.

RT: 3553
Reviewed-by: Emilia Kasper <emilia@openssl.org>
(cherry picked from commit 69d5747f90136aa026a96204f26ab39549dfc69b)

10 years agoAdd TLS_FALLBACK_SCSV documentation, and move s_client -fallback_scsv
Bodo Moeller [Wed, 15 Oct 2014 08:50:53 +0000 (10:50 +0200)]
Add TLS_FALLBACK_SCSV documentation, and move s_client -fallback_scsv
handling out of #ifndef OPENSSL_NO_DTLS1 section.

Reviewed-by: Rich Salz <rsalz@openssl.org>
10 years agoOop: revert unintentional change committed along with
Bodo Moeller [Wed, 15 Oct 2014 02:50:13 +0000 (04:50 +0200)]
Oop: revert unintentional change committed along with
TLS_FALLBACK_SCSV support, restoring a reviewed state instead.

Reviewed-by: Stephen Henson (steve@openssl.org)
10 years agoSupport TLS_FALLBACK_SCSV.
Bodo Moeller [Wed, 15 Oct 2014 02:04:55 +0000 (04:04 +0200)]
Support TLS_FALLBACK_SCSV.

Reviewed-by: Rich Salz <rsalz@openssl.org>