summaryrefslogtreecommitdiffstats
path: root/ssl
AgeCommit message (Collapse)Author
2016-08-06Fix CIPHER_DEBUGJimC
Commit 3eb2aff renamed a field of ssl_cipher_st from algorithm_ssl -> min_tls but neglected to update the fprintf reference which is included by -DCIPHER_DEBUG Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1417)
2016-08-05spelling fixes, just comments and readme.klemens
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1413)
2016-08-05Remove OPENSSL_NO_STDIO guards around certain SSL cert/key functionsRichard Levitte
These functions are: SSL_use_certificate_file SSL_use_RSAPrivateKey_file SSL_use_PrivateKey_file SSL_CTX_use_certificate_file SSL_CTX_use_RSAPrivateKey_file SSL_CTX_use_PrivateKey_file SSL_use_certificate_chain_file Internally, they use BIO_s_file(), which is defined and implemented at all times, even when OpenSSL is configured no-stdio. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-08-04Fix ubsan 'left shift of negative value -1' error in satsub64be()David Woodhouse
Baroque, almost uncommented code triggers behaviour which is undefined by the C standard. You might quite reasonably not care that the code was broken on ones-complement machines, but if we support a ubsan build then we need to at least pretend to care. It looks like the special-case code for 64-bit big-endian is going to behave differently (and wrongly) on wrap-around, because it treats the values as signed. That seems wrong, and allows replay and other attacks. Surely you need to renegotiate and start a new epoch rather than wrapping around to sequence number zero again? Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
2016-08-04Make DTLS1_BAD_VER work with DTLS_client_method()David Woodhouse
DTLSv1_client_method() is deprecated, but it was the only way to obtain DTLS1_BAD_VER support. The SSL_OP_CISCO_ANYCONNECT hack doesn't work with DTLS_client_method(), and it's relatively non-trivial to make it work without expanding the hack into lots of places. So deprecate SSL_OP_CISCO_ANYCONNECT with DTLSv1_client_method(), and make it work with SSL_CTX_set_{min,max}_proto_version(DTLS1_BAD_VER) instead. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
2016-08-04Fix cipher support for DTLS1_BAD_VERDavid Woodhouse
Commit 3eb2aff40 ("Add support for minimum and maximum protocol version supported by a cipher") disabled all ciphers for DTLS1_BAD_VER. That wasn't helpful. Give them back. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
2016-08-04Fix DTLS_VERSION_xx() comparison macros for DTLS1_BAD_VERDavid Woodhouse
DTLS version numbers are strange and backwards, except DTLS1_BAD_VER so we have to make a special case for it. This does leave us with a set of macros which will evaluate their arguments more than once, but it's not a public-facing API and it's not like this is the kind of thing where people will be using DTLS_VERSION_LE(x++, y) anyway. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
2016-08-04Fix ossl_statem_client_max_message_size() for DTLS1_BAD_VERDavid Woodhouse
The Change Cipher Spec message in this ancient pre-standard version of DTLS that Cisco are unfortunately still using in their products, is 3 bytes. Allow it. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
2016-08-04Fix SSL_export_keying_material() for DTLS1_BAD_VERDavid Woodhouse
Commit d8e8590e ("Fix missing return value checks in SCTP") made the DTLS handshake fail, even for non-SCTP connections, if SSL_export_keying_material() fails. Which it does, for DTLS1_BAD_VER. Apply the trivial fix to make it succeed, since there's no real reason why it shouldn't even though we never need it. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
2016-08-01peer_tmp doesn't exist if no-ec no-dh.Ben Laurie
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-07-30Fix crash as a result of MULTIBLOCKMatt Caswell
The MULTIBLOCK code uses a "jumbo" sized write buffer which it allocates and then frees later. Pipelining however introduced multiple pipelines. It keeps track of how many pipelines are initialised using numwpipes. Unfortunately the MULTIBLOCK code was not updating this when in deallocated its buffers, leading to a buffer being marked as initialised but set to NULL. RT#4618 Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-07-29Simplify and rename SSL_set_rbio() and SSL_set_wbio()Matt Caswell
SSL_set_rbio() and SSL_set_wbio() are new functions in 1.1.0 and really should be called SSL_set0_rbio() and SSL_set0_wbio(). The old implementation was not consistent with what "set0" means though as there were special cases around what happens if the rbio and wbio are the same. We were only ever taking one reference on the BIO, and checking everywhere whether the rbio and wbio are the same so as not to double free. A better approach is to rename the functions to SSL_set0_rbio() and SSL_set0_wbio(). If an existing BIO is present it is *always* freed regardless of whether the rbio and wbio are the same or not. It is therefore the callers responsibility to ensure that a reference is taken for *each* usage, i.e. one for the rbio and one for the wbio. The legacy function SSL_set_bio() takes both the rbio and wbio in one go and sets them both. We can wrap up the old behaviour in the implementation of that function, i.e. previously if the rbio and wbio are the same in the call to this function then the caller only needed to ensure one reference was passed. This behaviour is retained by internally upping the ref count. This commit was inspired by BoringSSL commit f715c423224. RT#4572 Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-07-29Fix BIO_pop for SSL BIOsMatt Caswell
The BIO_pop implementation assumes that the rbio still equals the next BIO in the chain. While this would normally be the case, it is possible that it could have been changed directly by the application. It also does not properly cater for the scenario where the buffering BIO is still in place for the write BIO. Most of the existing BIO_pop code for SSL BIOs can be replaced by a single call to SSL_set_bio(). This is equivalent to the existing code but additionally handles the scenario where the rbio has been changed or the buffering BIO is still in place. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-07-29Fix BIO_push ref counting for SSL BIOMatt Caswell
When pushing a BIO onto an SSL BIO we set the rbio and wbio for the SSL object to be the BIO that has been pushed. Therefore we need to up the ref count for that BIO. The existing code was uping the ref count on the wrong BIO. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-07-29Don't double free the write bioMatt Caswell
When setting the read bio we free up any old existing one. However this can lead to a double free if the existing one is the same as the write bio. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-07-29Make the checks for an SSLv2 style record stricterMatt Caswell
SSLv2 is no longer supported in 1.1.0, however we *do* still accept an SSLv2 style ClientHello, as long as we then subsequently negotiate a protocol version >= SSLv3. The record format for SSLv2 style ClientHellos is quite different to SSLv3+. We only accept this format in the first record of an initial ClientHello. Previously we checked this by confirming s->first_packet is set and s->server is true. However, this really only tells us that we are dealing with an initial ClientHello, not that it is the first record (s->first_packet is badly named...it really means this is the first message). To check this is the first record of the initial ClientHello we should also check that we've not received any data yet (s->init_num == 0), and that we've not had any empty records. GitHub Issue #1298 Reviewed-by: Emilia Käsper <emilia@openssl.org>
2016-07-25zero pad DHE public key in ServerKeyExchange message for interoprussor
Some versions of the Microsoft TLS stack have problems when the DHE public key is encoded with fewer bytes than the DHE prime. There's some public acknowledgement of the bug at these links: https://connect.microsoft.com/IE/feedback/details/1253526/tls-serverkeyexchange-with-1024-dhe-may-encode-dh-y-as-127-bytes-breaking-internet-explorer-11 https://connect.microsoft.com/IE/feedback/details/1104905/wininet-calculation-of-mac-in-tls-handshake-intermittently-fails-for-dhe-rsa-key-exchange This encoding issue also causes the same errors with 2048-bit DHE, if the public key is encoded in fewer than 256 bytes and includes the TLS stack on Windows Phone 8.x. Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1320)
2016-07-25Enforce and explicit some const castingFdaSilvaYY
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1300)
2016-07-23Correct misspelt OPENSSL_NO_SRPRichard Levitte
RT#4619 Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-07-22Send alert for bad DH CKEDr. Stephen Henson
RT#4511 Reviewed-by: Matt Caswell <matt@openssl.org>
2016-07-22Have load_buildtin_compression in ssl/ssl_ciph.c return RUN_ONCE resultRichard Levitte
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-07-20Check for errors allocating the error strings.Kurt Roeckx
Reviewed-by: Richard Levitte <levitte@openssl.org> GH: #1330
2016-07-20Never expose ssl->bbio in the public API.Matt Caswell
This is adapted from BoringSSL commit 2f87112b963. This fixes a number of bugs where the existence of bbio was leaked in the public API and broke things. - SSL_get_wbio returned the bbio during the handshake. It must always return the BIO the consumer configured. In doing so, some internal accesses of SSL_get_wbio should be switched to ssl->wbio since those want to see bbio. - The logic in SSL_set_rfd, etc. (which I doubt is quite right since SSL_set_bio's lifetime is unclear) would get confused once wbio got wrapped. Those want to compare to SSL_get_wbio. - If SSL_set_bio was called mid-handshake, bbio would get disconnected and lose state. It forgets to reattach the bbio afterwards. Unfortunately, Conscrypt does this a lot. It just never ended up calling it at a point where the bbio would cause problems. - Make more explicit the invariant that any bbio's which exist are always attached. Simplify a few things as part of that. RT#4572 Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-07-20Fix a few if(, for(, while( inside code.FdaSilvaYY
Fix some indentation at the same time Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1292)
2016-07-20Sanity check in ssl_get_algorithm2().Dr. Stephen Henson
RT#4600 Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-07-20Send alert on CKE error.Dr. Stephen Henson
RT#4610 Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-07-19Change all our uses of CRYPTO_THREAD_run_once to use RUN_ONCE insteadRichard Levitte
That way, we have a way to check if the init function was successful or not. Reviewed-by: Kurt Roeckx <kurt@openssl.org>
2016-07-19Fix two bugs in clienthello processingEmilia Kasper
- Always process ALPN (previously there was an early return in the certificate status handling) - Don't send a duplicate alert. Previously, both ssl_check_clienthello_tlsext_late and its caller would send an alert. Consolidate alert sending code in the caller. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-07-19SSL test framework: port NPN and ALPN testsEmilia Kasper
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-07-19Update error codes following tls_process_key_exchange() refactorMatt Caswell
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-07-19Tidy up tls_process_key_exchange()Matt Caswell
After the refactor of tls_process_key_exchange(), this commit tidies up some loose ends. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-07-19Split out ECDHE from tls_process_key_exchange()Matt Caswell
Continuing from the previous commit. Refactor tls_process_key_exchange() to split out into a separate function the ECDHE aspects. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-07-19Split out DHE from tls_process_key_exchange()Matt Caswell
Continuing from the previous commit. Refactor tls_process_key_exchange() to split out into a separate function the DHE aspects. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-07-19Split out SRP from tls_process_key_exchange()Matt Caswell
Continuing from the previous commit. Refactor tls_process_key_exchange() to split out into a separate function the SRP aspects. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-07-19Split out the PSK preamble from tls_process_key_exchange()Matt Caswell
The tls_process_key_exchange() function is too long. This commit starts the process of splitting it up by moving the PSK preamble code to a separate function. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-07-19Move the PSK preamble for tls_process_key_exchange()Matt Caswell
The function tls_process_key_exchange() is too long. This commit moves the PSK preamble processing out to a separate function. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-07-19Narrow scope of locals vars in tls_process_key_exchange()Matt Caswell
Narrow the scope of the local vars in preparation for split up this function. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-07-19Remove sessions from external cache, even if internal cache not used.Matt Caswell
If the SSL_SESS_CACHE_NO_INTERNAL_STORE cache mode is used then we weren't removing sessions from the external cache, e.g. if an alert occurs the session is supposed to be automatically removed. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-07-19make updateRichard Levitte
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-07-19Fixup a few SSLerr calls in ssl/statem/Richard Levitte
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-07-18Refactor Identity Hint handlingMatt Caswell
Don't call strncpy with strlen of the source as the length. Don't call strlen multiple times. Eventually we will want to replace this with a proper PACKET style handling (but for construction of PACKETs instead of just reading them as it is now). For now though this is safe because PSK_MAX_IDENTITY_LEN will always fit into the destination buffer. This addresses an OCAP Audit issue. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-07-18Fix up error codes after splitting up tls_construct_key_exchange()Matt Caswell
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-07-18Some tidy ups after the CKE construction refactorMatt Caswell
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-07-18Split out SRP CKE construction into a separate functionMatt Caswell
Continuing previous commit to break up the tls_construct_client_key_exchange() function. This splits out the SRP code. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-07-18Split out GOST CKE construction into a separate functionMatt Caswell
Continuing previous commit to break up the tls_construct_client_key_exchange() function. This splits out the GOST code. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-07-18Split out DHE CKE construction into a separate functionMatt Caswell
Continuing previous commit to break up the tls_construct_client_key_exchange() function. This splits out the ECDHE code. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-07-18Split out DHE CKE construction into a separate functionMatt Caswell
Continuing previous commit to break up the tls_construct_client_key_exchange() function. This splits out the DHE code. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-07-18Split out CKE construction PSK pre-amble and RSA into a separate functionMatt Caswell
The tls_construct_client_key_exchange() function is too long. This splits out the construction of the PSK pre-amble into a separate function as well as the RSA construction. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-07-18Narrow the scope of local variables in tls_construct_client_key_exchange()Matt Caswell
This is in preparation for splitting up this over long function. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-07-18Fix bug with s2n et al macrosMatt Caswell
The parameters should have parens around them when used. Reviewed-by: Richard Levitte <levitte@openssl.org>