summaryrefslogtreecommitdiff
path: root/lib/libssl/ssl_clnt.c
AgeCommit message (Collapse)Author
2022-01-11Remove peer_pkeys from SSL_SESSION.Joel Sing
peer_pkeys comes from some world where peers can send multiple certificates - in fact, one of each known type. Since we do not live in such a world, get rid of peer_pkeys and simply use peer_cert instead (in both TLSv1.2 and TLSv1.3, both clients and servers can only send a single leaf (aka end-entity) certificate). ok inoguchi@ tb@
2022-01-11Rename 'peer' to 'peer_cert' in SSL_SESSION.Joel Sing
The 'peer' member of SSL_SESSION is the leaf/end-entity certificate provided by our peer. Rename it since 'peer' on its own is unhelpful. ok inoguchi@ tb@
2022-01-11Plumb decode errors through key share parsing code.Joel Sing
Distinguish between decode errors and other errors, so that we can send a SSL_AD_DECODE_ERROR alert when appropriate. Fixes a tlsfuzzer failure, due to it expecting a decode error alert and not receiving one. Prompted by anton@ ok tb@
2022-01-09ssl_check_srvr_ecc_cert_and_alg() only returns 0/1 - test accordingly.Joel Sing
2022-01-09Swap arguments to ssl_check_srvr_ecc_cert_and_alg()Joel Sing
If a libssl function takes an SSL *, it should normally be the first argument.
2022-01-09Clean up ssl3_{send,get}_client_kex_gost()Joel Sing
Fix leaks, use sizeof() instead of hardcoded sizes, actually check return codes, explicit_bzero() the premaster secret on the server side and generally try to kick the GOST kex code into some sort of shape. ok inoguchi@ tb@
2022-01-09Return 0/1 from ssl3_{send,get}_client_kex_gost()Joel Sing
Like other KEX handling functions, there is no need to return anything other than failure/success here. ok inoguchi@ tb@
2022-01-09Remove a comment from Captain Obvious.Joel Sing
2022-01-09Clean up pkey handling in ssl3_get_server_key_exchange()Joel Sing
With TLSv1.2 and earlier, the authentication algorithm used to sign the ServerKeyExchange message is dependent on the cipher suite in use and has nothing to do with the key exchange algorithm. As such, check the authentication algorithm based on the cipher suite in ssl3_get_server_key_exchange() and handle things accordingly. ok inoguchi@ tb@
2022-01-08Merge SESS_CERT into SSL_SESSION.Joel Sing
There is no reason for SESS_CERT to exist - remove it and merge its members into SSL_SESSION for the time being. More clean up to follow. ok inoguchi@ tb@
2022-01-06Convert legacy TLS client to tls_key_share.Joel Sing
This requires adding DHE support to tls_key_share. In doing so, tls_key_share_peer_public() has to lose the group argument and gains an invalid_key argument. The one place that actually needs the group check is tlsext_keyshare_client_parse(), so add code to do this. ok inoguchi@ tb@
2022-01-04Return 0 on failure from send/get kex functions in the legacy stack.Joel Sing
In the legacy stack, a message handling function returns -1 for failure, 0 for need more data and 1 for success (although in extra special cases 2 may also be used). However, the various send/get kex functions only need to indicate success or failure - switch these to return 0 on failure (rather than -1) and use normal result testing. This leaves GOST unchanged for now, as that code is special and needs extra work. ok inoguchi@ tb@
2022-01-04Use normal result testing for tls1_check_curve().Joel Sing
2022-01-04Refactor ssl3_get_server_kex_ecdhe() to separate parsing and validation.Joel Sing
If we receive something other than a "named curve", send a handshake failure alert as we're unable to complete the handshake with the given parameters. If the server responded with a curve that we did not advertise send an illegal parameter alert. ok inoguchi@ tb@
2021-12-09Convert ssl_clnt.c to opaque EVP_MD_CTXTheo Buehler
ok inoguchi jsing
2021-12-04Move the minimum DHE key size check into ssl_kex_peer_params_dhe()Joel Sing
ok inoguchi@ tb@
2021-12-04Check DH public key in ssl_kex_peer_public_dhe().Joel Sing
Call DH_check_pub_key() after decoding the peer public key - this will be needed for the server DHE key exchange, but also benefits the client. ok inoguchi@ tb@
2021-11-29Factor out/rewrite DHE key exchange.Joel Sing
This follows what was done previously for ECDHE EC point key exchange and will allow for deduplication and further code improvement. Convert the TLSv1.2 client to use the new DHE key exchange functions. ok inoguchi@ tb@
2021-11-26Stop reaching into EVP_PKEY in the rest of libssl.Theo Buehler
ok inoguchi jsing
2021-11-19libssl: don't reach for pkey->save_type.Theo Buehler
For some strange historical reason ECDSA_sign() and ECDSA_verify}() have a type argument that they ignore. For another strange historical reason, the type passed to them from libssl is pkey->save_type, which is used to avoid expensive engine lookups when setting the pkey type... Whatever the aforementioned reasons were, we can't access pkey->save_type with the OpenSSL 1.1 API, and this is thus in the way of making EVP_PKEY opaque. Simply pass in 0 instead. ok jsing
2021-10-25Fold SSL_SESSION_INTERNAL back into SSL_SESSION.Joel Sing
ok beck@ tb@
2021-10-23Unhandroll X509_up_ref()Theo Buehler
ok beck jsing
2021-10-23Provide a way to determine our maximum legacy version.Joel Sing
With the introduction of TLSv1.3, we need the ability to determine our maximum legacy version and to track our peer's maximum legacy version. This is needed for both the TLS record layer when using TLSv1.3, plus it is needed for RSA key exhange in TLS prior to TLSv1.3, where the maximum legacy version is incorporated in the pre-master secret to avoid downgrade attacks. This unbreaks RSA KEX for the TLS client when the non-version specific method is used with TLSv1.0 or TLSv1.1 (clearly no one does this). ok tb@
2021-10-23Fold DTLS1_STATE_INTERNAL into DTLS1_STATE.Joel Sing
Now that DTLS1_STATE is opaque, fold DTLS1_STATE_INTERNAL back into DTLS1_STATE and remove D1I() usage. ok tb@
2021-10-23Untangle ssl3_get_message() return values.Joel Sing
This function currently has a long return type that may be <= 0 on error/retry (which is then cast to an int in order to return it up the stack), or it returns the length of the handshake message (on success). This obviously means that 0 can be returned for both success and failure, which is the reason why a separate 'ok' argument has to exist. Untangle this mess by changing the return value to an int that indicates success (1) or error/retry (<= 0). The length never needs to actually be returned as it is already stored in s->internal->init_num (which is where the return value is read from anyway). ok tb@
2021-10-23Change tlsext_tick_lifetime_hint to uint32_t.Joel Sing
Now that SSL_SESSION is opaque, change tlsext_tick_lifetime_hint from long to uint32_t (matching RFC4507), rather than continuing to work around an inappropriate type choice. ok tb@
2021-09-03Ensure that a server hello does not have trailing data.Joel Sing
Found by tlsfuzzer. ok beck@
2021-09-02We need to allow for either a CERTIFICATE or CERTIFICATE_STATUS messageBob Beck
here or we break the handshake with BAD_MESSAGE ok tb@
2021-09-02RFC 6066 section 8 allows the server MAY choose not send the CertificateStatusBob Beck
message, even if it has received a "status_request" extension in the client hello message and has sent a "status_request" extention in the server hello message. Genua found a site that is this broken. This makes it work. ok jsing@
2021-08-30Clean up and simplify info and msg callbacks.Joel Sing
The info and msg callbacks result in duplication - both for code that refers to the function pointers and for the call sites. Avoid this by providing typedefs for the function pointers and pulling the calling sequences into their own functions. ok inoguchi@ tb@
2021-06-30Correct sigalg hash usage when signing content for client verify.Joel Sing
This was inadvertently broken during sigalgs refactoring.
2021-06-29Pull sigalg selection up into ssl3_send_client_verify().Joel Sing
This means that we do sigalg selection for all cases, including those where are are not sending sigalgs. This is needed in order to track our signature type in legacy cases. ok tb@
2021-06-29Track sigalg used by ourselves and our peer in the legacy stack.Joel Sing
This is needed for upcoming API additions.
2021-06-29Convert legacy stack client to ssl_sigalg_for_peer().Joel Sing
ok inoguchi@ tb@
2021-06-29Move the RSA-PSS check for TLSv1.3 to ssl_sigalg_pkey_ok().Joel Sing
Also, rather than passing in a check_curve flag, pass in the SSL * and handle version checks internally to ssl_sigalg_pkey_ok(), simplifying the callers. ok inoguchi@ tb@
2021-06-27Have ssl3_send_client_verify() pass *pkey to called functions.Joel Sing
ssl3_send_client_verify() already has a pointer to the EVP_PKEY for the certificate - pass this as an argument to the functions that it calls, rather than duplicating code/variable declarations.
2021-06-27Change ssl_sigalgs_from_value() to perform sigalg list selection.Joel Sing
Rather that passing in a sigalg list at every call site, pass in the appropriate TLS version and have ssl_sigalgs_from_value() perform the sigalg list selection itself. This allows the sigalg lists to be made internal to the sigalgs code. ok tb@
2021-06-27Rename ssl_sigalg() to ssl_sigalg_from_value().Joel Sing
This makes the code more self-documenting and avoids the ambiguity between ssl_sigalg the struct and ssl_sigalg the function. ok tb@
2021-05-16Make local header inclusion consistent.Joel Sing
Consistently include local headers in the same location, using the same grouping/sorting across all files.
2021-05-16Move DTLS structs/definitions/prototypes to dtls_locl.h.Joel Sing
Now that the DTLS structs are opaque, add a dtls_locl.h header and move internal-only structs from dtls1.h, along with prototypes from ssl_locl.h. Only pull this header in where DTLS code actually exists. ok inoguchi@ tb@
2021-05-16Explicitly include <openssl/opensslconf.h> in files using OPENSSL_NO_*Joel Sing
Where a file references to OPENSSL_NO_* conditions, ensure that we explicitly include <openssl/opensslconf.h> before any references, rather than relying on another header to pull this in.
2021-05-02Clean up tls1_change_cipher_state().Joel Sing
Replace flag gymnastics at call sites with separate read and write, functions which call the common code. Condition on s->server instead of using SSL_ST_ACCEPT, for consistency and more readable code. ok inoguchi@ tb@
2021-05-02Clean up dtls1_reset_seq_numbers().Joel Sing
Rather than doing flag gymnastics, split dtls1_reset_seq_numbers() into separate read and write functions. Move the calls of these functions into tls1_change_cipher_state() so they directly follow the change of cipher state in the record layer, which avoids having to duplicate the calls in the client and server. ok inoguchi@ tb@
2021-04-30Clean up and harden TLSv1.2 master key derivation.Joel Sing
The master key and its length are only stored in one location, so it makes no sense to handle these outside of the derivation function (the current 'out' argument is unused). This simplifies the various call sites. If derivation fails for some reason, fail hard rather than continuing on and hoping that something deals with this correctly later. ok inoguchi@ tb@
2021-04-25Clean up derivation of finished/peer finished.Joel Sing
Make this process more readable by having specific client/server functions, calling the correct one based on s->server. This allows to remove various SSL_ST_ACCEPT/SSL_ST_CONNECT checks, along with duplicate code. ok inoguchi@ tb@
2021-04-21Clean up TLSv1.2 certificate request handshake data.Joel Sing
Currently cert_req is used by clients and cert_request is used by servers. Replace this by a single cert_request used by either client or server. Remove the certificate types as they are currently unused. This also fixes a bug whereby if the number of certificate types exceeds SSL3_CT_NUMBER the number of bytes read in is insufficient, which will break decoding. ok inoguchi@ tb@
2021-04-19Move reuse_message, message_type, message_size and cert_verify into theJoel Sing
TLSv1.2 handshake struct. ok inoguchi@ tb@
2021-04-11Update a stale comment and fix a typo.Theo Buehler
2021-03-27Garbage collect s->internal->typeTheo Buehler
This variable is used in the legacy stack to decide whether we are a server or a client. That's what s->server is for... The new TLSv1.3 stack failed to set s->internal->type, which resulted in hilarious mishandling of previous_{client,server}_finished. Indeed, both client and server would first store the client's verify_data in previous_server_finished and later overwrite it with the server's verify_data. Consequently, renegotiation has been completely broken for more than a year. In fact, server side renegotiation was broken during the 6.5 release cycle. Clearly, no-one uses this. This commit fixes client side renegotiation and restores the previous behavior of SSL_get_client_CA_list(). Server side renegotiation will be fixed in a later commit. ok jsing
2021-03-24Rename new_cipher to cipher.Joel Sing
This is in the SSL_HANDSHAKE struct and is what we're currently negotiating, so there is really nothing more "new" about the cipher than there is the key block or other parts of the handshake data. ok inoguchi@ tb@