summaryrefslogtreecommitdiff
path: root/lib/libssl/ssl_locl.h
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-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-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-08Remove commented out CERT_* defines.Joel Sing
2022-01-08Rename CERT to SSL_CERT and CERT_PKEY to SSL_CERT_PKEY.Joel Sing
Nearly all structs in libssl start with an SSL_ suffix, rename CERT and CERT_PKEY for consistency. ok inoguchi@ tb@
2022-01-07Rename dh_tmp to dhe_params.Joel Sing
Support for non-ephemeral DH was removed a long time ago - as such, the dh_tmp and dh_tmp_cb are used for DHE parameters. Rename them to reflect reality. ok inoguchi@ tb@
2022-01-07Convert legacy server to tls_key_share.Joel Sing
This requires a few more additions to the DHE key share code - we need to be able to either set the DHE parameters or specify the number of key bits for use with auto DHE parameters. Additionally, we need to be able to serialise the DHE parameters to send to the client. This removes the infamous 'tmp' struct from ssl3_state_internal_st. 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-05Rename tls13_key_share to tls_key_share.Joel Sing
In preparation to use the key share code in both the TLSv1.3 and legacy stacks, rename tls13_key_share to tls_key_share, moving it into the shared handshake struct. Further changes will then allow the legacy stack to make use of the same code for ephemeral key exchange. ok inoguchi@ tb@
2021-12-04Clean up and refactor server side DHE key exchange.Joel Sing
Provide ssl_kex_generate_dhe_params_auto() which handles DHE key generation based on parameters determined by the specified key bits. Convert the existing DHE auto parameter selection code into a function that just tells us how many key bits to use. Untangle and rework the server side DHE key exchange to use the ssl_kex_* functions. ok inoguchi@ tb@
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-10-25Use ssl_force_want_read() in the DTLS code.Joel Sing
Also mop up some mostly unhelpful comments while here. ok beck@ tb@
2021-10-25Fold SSL_SESSION_INTERNAL back into SSL_SESSION.Joel Sing
ok beck@ tb@
2021-10-23Add SSL_get0_verified_chain - needed by some new stuffBob Beck
symbol will be exposed with tb@'s forthcoming bump ok tb@
2021-10-23Add new OpenSSL API SSL_CTX_set_num_tickets and friends.Bob Beck
Since we don't support session tickets in LibreSSL at the moment these functions currently do not have any effect. Again, symbols will appear with tb@'s reptar sized bump.. ok tb@
2021-10-23Mop up enc_read_ctx and read_hash.Joel Sing
These are no longer public, so we can mop them up along with the machinery needed to set/clear them. ok beck@ tb@
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-23Add SSL_CTX_set_keylog_callback and SSL_CTX_get_keylog_callbackBob Beck
Some things in ports care about calling these functions. Since we will not provide private key logging functionality they are documented as being for compatibility and that they don't do anything. 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-10-15Move various structs from ssl.h/tls1.h to ssl_locl.h.Joel Sing
These were already under LIBRESSL_INTERNAL hence no ABI change. ok tb@
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-08-30Replace DTLS r_epoch with the read epoch from the TLSv1.2 record layer.Joel Sing
ok inoguchi@ tb@
2021-07-26Dedup dtls1_dispatch_alert()/ssl3_dispatch_alert().Joel Sing
The code for dtls1_dispatch_alert() and ssl3_dispatch_alert() is largely identical - with a bit of reshuffling we can use ssl3_dispatch_alert() for both protocols and remove the ssl_dispatch_alert function pointer. ok inoguchi@ tb@
2021-07-03Do a first pass clean up of SSL_METHOD.Joel Sing
The num_ciphers, get_cipher_by_char and put_cipher_by_char function pointers use the same function for all methods - call ssl3_num_ciphers() directly, absorb ssl3_get_cipher_by_char() into SSL_CIPHER_find() and remove the unused ssl3_put_cipher_by_char() code. ok inoguchi@ tb@
2021-07-01Merge SSL_METHOD_INTERNAL into SSL_METHOD.Joel Sing
Now that SSL_METHOD is opaque and in internal headers, we can remove SSL_METHOD_INTERNAL by merging it back into SSL_METHOD. ok tb@
2021-06-30Move some structs from public to private headers.Joel Sing
Move struct ssl_cipher_st, struct ssl_method_st, struct ssl_session_st and struct ssl3_state_st from public to private headers. These are already under #ifdef LIBRESSL_INTERNAL and are no longer publicly visible. ok inoguchi@ tb@
2021-06-27Track the sigalgs used by ourselves and our peer.Joel Sing
Move the sigalg pointer from SSL_HANDSHAKE_TLS13 to SSL_HANDSHAKE, naming it our_sigalg, adding an equivalent peer_sigalg. Adjust the TLSv1.3 code that records our signature algorithm. Add code to record the signature algorithm used by our peer. Needed for upcoming API additions. ok tb@
2021-06-23Garbage collect prototoype for ssl_parse_serverhello_tlsext() whichTheo Buehler
was removed in t1_lib.c r1.141.
2021-06-19Correctly handle epoch wrapping in dtls1_get_bitmap().Joel Sing
Due to a type bug that has been present in DTLS since the code was first committed in 2005, dtls1_get_bitmap() fails to handle next epoch correctly when the epoch is currently 0xffff (and wraps to zero). For various reasons unknown, the epoch field in the SSL3_RECORD_INTERNAL (formerly SSL3_RECORD) was added as unsigned long (even though the value is an unsigned 16 bit value on the wire, hence cannot exceed 0xffff), however was added to other code as unsigned short. Due to integer promotion, the r_epoch value is incremented by one to become 0x10000, before being cast to an unsigned long and compared to the value pulled from the DTLS record header (which is zero). Strangely 0x10000 != 0, meaning that we drop the DTLS record, instead of queueing it for the next epoch. Fix this issue by using more appropriate types and pulling up the calculation of the next epoch value for improved readability. ok inoguchi@ tb@
2021-06-19Provide the ability to set the initial DTLS epoch value.Joel Sing
This allows for regress to test edge cases for epoch handling. ok tb@
2021-06-13Remove tls1_alert_code().Joel Sing
After running the preprocessor, this function becomes: switch (code) { case 0: return (0); case 10: return (10); case 20: return (20); ... } Its intended purpose was to prevent SSLv3 alerts being sent from TLS code, however now that we've removed "no_certificate" from LibreSSL's reach, it no longer does anything useful. ok tb@
2021-05-16Absorb SSL_AEAD_CTX into struct tls12_record_protection.Joel Sing
The information contained in SSL_AEAD_CTX really belongs in the tls12_record_protection struct. Absorb SSL_AEAD_CTX, using more appropriate types in the process. ok tb@
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-16Avoid pulling ssl_sigalgs.h in via ssl_locl.h.Joel Sing
Forward declare struct sigalg in ssl_locl.h and avoid including ssl_sigalgs.h. Explicitly include ssl_sigalgs.h where it is needed.
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-05Replace DTLS w_epoch with epoch from TLSv1.2 record layer.Joel Sing
ok inoguchi@ tb@
2021-05-05Rewrite TLSv1.2 key block handling.Joel Sing
For TLSv1.2 a single key block is generated, then partitioned into individual secrets for use as IVs and keys. The previous implementation splits this across two functions tls1_setup_key_block() and tls1_change_cipher_state(), which means that the IV and key sizes have to be known in multiple places. This implementation generates and partitions the key block in a single step, meaning that the secrets are then simply handed out when requested. ok inoguchi@ tb@
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-19Remove new_sym_enc and new_aead.Joel Sing
These can be replaced with accessors that allow this information to be retrieved from the new record layer. ok inoguchi@ tb@
2021-04-19Move new_mac_secret_size into the TLSv1.2 handshake struct.Joel Sing
Drop the 'new_' prefix in the process. 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@