aboutsummaryrefslogtreecommitdiff
path: root/ssl/ssl_lib.c
AgeCommit message (Collapse)AuthorFilesLines
2016-11-04Rename all "read" variables with "readbytes"Matt Caswell1-12/+12
Travis is reporting one file at a time shadowed variable warnings where "read" has been used. This attempts to go through all of libssl and replace "read" with "readbytes" to fix all the problems in one go. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-11-04Fix misc size_t issues causing Windows warnings in 64 bitMatt Caswell1-25/+32
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-11-04Convert SSL BIO to use SSL_write_ex().Matt Caswell1-59/+56
We also modify the SSL_get_error() function to handle the fact that with SSL_write_ex() the error return is 0 not -1, and fix some bugs in the SSL BIO reading. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-11-04Fix some missed size_t updatesMatt Caswell1-3/+7
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-11-04Convert some libssl local functions to size_tMatt Caswell1-1/+1
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-11-04Update numerous misc libssl fields to be size_tMatt Caswell1-1/+1
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-11-04Convert master_secret_size code to size_tMatt Caswell1-15/+16
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-11-04Convert some misc record layer functions for size_tMatt Caswell1-1/+1
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-11-04Convert libssl writing for size_tMatt Caswell1-11/+36
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-11-04Further libssl size_t-ify of readingMatt Caswell1-8/+58
Writing still to be done Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-11-02Convert a big "if" into a "switch"Matt Caswell1-10/+21
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-11-02Add the SSL_METHOD for TLSv1.3 and all other base changes requiredMatt Caswell1-1/+3
Includes addition of the various options to s_server/s_client. Also adds one of the new TLS1.3 ciphersuites. This isn't "real" TLS1.3!! It's identical to TLS1.2 apart from the protocol and the ciphersuite...and the ciphersuite is just a renamed TLS1.2 one (not a "real" TLS1.3 ciphersuite). Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-11-01Add SSL_CTX_set1_cert_store()Todd Short1-0/+7
For convenience, combine getting a new ref for the new SSL_CTX with assigning the store and freeing the old one. Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1755)
2016-09-21Revert "Constify code about X509_VERIFY_PARAM"Rich Salz1-1/+1
This reverts commit 81f9ce1e1965e0e33db6d2391285c4c1b6af0434. Reviewed-by: Matt Caswell <matt@openssl.org>
2016-09-18Constify code about X509_VERIFY_PARAMFdaSilvaYY1-1/+1
Reviewed-by: Viktor Dukhovni <viktor@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1594)
2016-08-24Fix comment about return value of ct_extract_tls_extension_sctsRob Percival1-1/+1
Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
2016-08-18Indent ssl/Emilia Kasper1-104/+105
Run util/openssl-format-source on ssl/ Some comments and hand-formatted tables were fixed up manually by disabling auto-formatting. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-08-15Improves CTLOG_STORE settersRob Percival1-3/+3
Changes them to have clearer ownership semantics, as suggested in https://github.com/openssl/openssl/pull/1372#discussion_r73232196. Reviewed-by: Emilia Käsper <emilia@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1408)
2016-08-04Fix SSL_export_keying_material() for DTLS1_BAD_VERDavid Woodhouse1-1/+1
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-07-29Simplify and rename SSL_set_rbio() and SSL_set_wbio()Matt Caswell1-15/+50
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-29Don't double free the write bioMatt Caswell1-1/+1
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-20Never expose ssl->bbio in the public API.Matt Caswell1-57/+55
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.FdaSilvaYY1-7/+7
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-12Perform DANE-EE(3) name checks by defaultViktor Dukhovni1-0/+37
In light of potential UKS (unknown key share) attacks on some applications, primarily browsers, despite RFC761, name checks are by default applied with DANE-EE(3) TLSA records. Applications for which UKS is not a problem can optionally disable DANE-EE(3) name checks via the new SSL_CTX_dane_set_flags() and friends. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-06-22Spelling... and more spellingFdaSilvaYY1-2/+2
Reviewed-by: Kurt Roeckx <kurt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1245)
2016-06-11Don't compare a just free()d pointerKurt Roeckx1-1/+1
Found by tis-interpreter Reviewed-by: Rich Salz <rsalz@openssl.org> GH: #1173
2016-06-08Add some accessor API'sRich Salz1-0/+5
GH1098: Add X509_get_pathlen() (and a test) GH1097: Add SSL_is_dtls() function. Documented. Reviewed-by: Matt Caswell <matt@openssl.org>
2016-06-08Always use session_ctx when removing a sessionTodd Short1-3/+3
Sessions are stored on the session_ctx, which doesn't change after SSL_set_SSL_CTX(). Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
2016-05-31return error in ct_move_scts()Dr. Stephen Henson1-1/+1
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
2016-05-20Simplify SSL BIO buffering logicMatt Caswell1-15/+8
The write BIO for handshake messages is bufferred so that we only write out to the network when we have a complete flight. There was some complexity in the buffering logic so that we switched buffering on and off at various points through out the handshake. The only real reason to do this was historically it complicated the state machine when you wanted to flush because you had to traverse through the "flush" state (in order to cope with NBIO). Where we knew up front that there was only going to be one message in the flight we switched off buffering to avoid that. In the new state machine there is no longer a need for a flush state so it is simpler just to have buffering on for the whole handshake. This also gives us the added benefit that we can simply call flush after every flight even if it only has one message in it. This means that BIO authors can implement their own buffering strategies and not have to be aware of the state of the SSL object (previously they would have to switch off their own buffering during the handshake because they could not rely on a flush being received when they really needed to write data out). This last point addresses GitHub Issue #322. Reviewed-by: Andy Polyakov <appro@openssl.org>
2016-05-19When strict SCT fails record verification failureViktor Dukhovni1-0/+17
Since with SSL_VERIFY_NONE, the connection may continue and the session may even be cached, we should save some evidence that the chain was not sufficiently verified and would have been rejected with SSL_VERIFY_PEER. To that end when a CT callback returs failure we set the verify result to X509_V_ERR_NO_VALID_SCTS. Note: We only run the CT callback in the first place if the verify result is still X509_V_OK prior to start of the callback. RT #4502 Reviewed-by: Tim Hudson <tjh@openssl.org>
2016-05-17Copyright consolidation 01/10Rich Salz1-109/+6
Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Kurt Roeckx <kurt@openssl.org>
2016-05-16session tickets: Use sizeof() for the various fieldsTJ Saunders1-4/+4
Signed-off-by: Kurt Roeckx <kurt@roeckx.be> Reviewed-by: Matt Caswell <matt@openssl.org> GH: #515, MR: #2153
2016-05-16Add SSL_client_version() getter functionAlessandro Ghedini1-3/+8
Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Tim Hudson <tjh@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
2016-05-16Propagate tlsext_status_type from SSL_CTX to SSLjfigus1-1/+3
To allow OCSP stapling to work with libcurl. Github PR #200 Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
2016-05-16Unify <TYPE>_up_ref methods signature and behaviour.FdaSilvaYY1-4/+16
Add a status return value instead of void. Add some sanity checks on reference counter value. Update the docs. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
2016-05-09fix tab-space mixed indentationFdaSilvaYY1-4/+4
No code change Reviewed-by: Kurt Roeckx <kurt@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
2016-05-05Handle no async jobs in libsslMatt Caswell1-47/+55
If the application has limited the size of the async pool using ASYNC_init_thread() then we could run out of jobs while trying to start a libssl io operation. However libssl was failing to handle this and treating it like a fatal error. It should not be fatal...we just need to retry when there are jobs available again. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-04-28Add checks on CRYPTO_new_ex_data return valueFdaSilvaYY1-2/+4
Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/996)
2016-04-28various spelling fixesFdaSilvaYY1-1/+1
Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/952)
2016-04-28Don't leak memory on error path in dane_ctx_enable()Matt Caswell1-0/+1
The function dane_ctx_enable() allocated some memory that it did not free in an error path. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-04-27split_send_fragment should always be less than or equal to max_send_fragmentMatt Caswell1-1/+1
A bug meant that SSL_CTRL_SET_MAX_SEND_FRAGMENT was not adjusting split_send_fragment properly. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-04-22Enabled DANE only when at least one TLSA RR was addedViktor Dukhovni1-2/+14
It is up to the caller of SSL_dane_tlsa_add() to take appropriate action when no records are added successfully or adding some records triggers an internal error (negative return value). With this change the caller can continue with PKIX if desired when none of the TLSA records are usable, or take some appropriate action if DANE is required. Also fixed the internal ssl_dane_dup() function to properly initialize the TLSA RR stack in the target SSL handle. Errors in ssl_dane_dup() are no longer ignored. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-04-11Add SSL_CTX_get_ciphers()Kazuki Yamaguchi1-0/+9
Add an accessor for SSL_CTX. Since libssl was made opaque, there is no way for users to access the cipher_list, while users can set the cipher_list by SSL_CTX_set_cipher_list(). Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-04-08Add SSL_DANE typedef for consistency.Rich Salz1-8/+8
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
2016-04-07Clean-up *_DEBUG options.Andy Polyakov1-9/+1
Since NDEBUG is defined unconditionally on command line for release builds, we can omit *_DEBUG options in favour of effective "all-on" in debug builds exercised though CI. Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Emilia Käsper <emilia@openssl.org>
2016-04-07Suppress CT callback as appropriateViktor Dukhovni1-31/+107
Suppress CT callbacks with aNULL or PSK ciphersuites that involve no certificates. Ditto when the certificate chain is validated via DANE-TA(2) or DANE-EE(3) TLSA records. Also skip SCT processing when the chain is fails verification. Move and consolidate CT callbacks from libcrypto to libssl. We also simplify the interface to SSL_{,CTX_}_enable_ct() which can specify either a permissive mode that just collects information or a strict mode that requires at least one valid SCT or else asks to abort the connection. Simplified SCT processing and options in s_client(1) which now has just a simple pair of "-noct" vs. "-ct" options, the latter enables the permissive callback so that we can complete the handshake and report all relevant information. When printing SCTs, print the validation status if set and not valid. Signed-off-by: Rob Percival <robpercival@google.com> Reviewed-by: Emilia Käsper <emilia@openssl.org>
2016-04-06Fix no-ocspMatt Caswell1-0/+7
Misc fixes for no-ocsp Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-04-04Revert "various spelling fixes"Rich Salz1-1/+1
This reverts commit 620d540bd47a96fb6905fbbdd8ea5167a8841a3e. It wasn't reviewed. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-04-04various spelling fixesFdaSilvaYY1-1/+1
Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org>