1 1.1 christos /* 2 1.1 christos * Copyright 2022-2025 The OpenSSL Project Authors. All Rights Reserved. 3 1.1 christos * 4 1.1 christos * Licensed under the Apache License 2.0 (the "License"). You may not use 5 1.1 christos * this file except in compliance with the License. You can obtain a copy 6 1.1 christos * in the file LICENSE in the source distribution or at 7 1.1 christos * https://www.openssl.org/source/license.html 8 1.1 christos */ 9 1.1 christos 10 1.1 christos #ifndef OSSL_QUIC_TLS_H 11 1.1.1.2 christos #define OSSL_QUIC_TLS_H 12 1.1 christos 13 1.1.1.2 christos #include <openssl/ssl.h> 14 1.1 christos 15 1.1 christos typedef struct quic_tls_st QUIC_TLS; 16 1.1 christos 17 1.1 christos typedef struct quic_tls_args_st { 18 1.1 christos /* 19 1.1 christos * The "inner" SSL object for the QUIC Connection. Contains an 20 1.1 christos * SSL_CONNECTION 21 1.1 christos */ 22 1.1 christos SSL *s; 23 1.1 christos 24 1.1 christos /* 25 1.1 christos * Called to send data on the crypto stream. We use a callback rather than 26 1.1 christos * passing the crypto stream QUIC_SSTREAM directly because this lets the CSM 27 1.1 christos * dynamically select the correct outgoing crypto stream based on the 28 1.1 christos * current EL. 29 1.1 christos */ 30 1.1 christos int (*crypto_send_cb)(const unsigned char *buf, size_t buf_len, 31 1.1.1.2 christos size_t *consumed, void *arg); 32 1.1 christos void *crypto_send_cb_arg; 33 1.1 christos 34 1.1 christos /* 35 1.1 christos * Call to receive crypto stream data. A pointer to the underlying buffer 36 1.1 christos * is provided, and subsequently released to avoid unnecessary copying of 37 1.1 christos * data. 38 1.1 christos */ 39 1.1 christos int (*crypto_recv_rcd_cb)(const unsigned char **buf, size_t *bytes_read, 40 1.1.1.2 christos void *arg); 41 1.1 christos void *crypto_recv_rcd_cb_arg; 42 1.1 christos int (*crypto_release_rcd_cb)(size_t bytes_read, void *arg); 43 1.1 christos void *crypto_release_rcd_cb_arg; 44 1.1 christos 45 1.1 christos /* 46 1.1 christos * Called when a traffic secret is available for a given TLS protection 47 1.1 christos * level. 48 1.1 christos */ 49 1.1 christos int (*yield_secret_cb)(uint32_t prot_level, int direction /* 0=RX, 1=TX */, 50 1.1.1.2 christos uint32_t suite_id, EVP_MD *md, 51 1.1.1.2 christos const unsigned char *secret, size_t secret_len, 52 1.1.1.2 christos void *arg); 53 1.1 christos void *yield_secret_cb_arg; 54 1.1 christos 55 1.1 christos /* 56 1.1 christos * Called when we receive transport parameters from the peer. 57 1.1 christos * 58 1.1 christos * Note: These parameters are not authenticated until the handshake is 59 1.1 christos * marked as completed. 60 1.1 christos */ 61 1.1 christos int (*got_transport_params_cb)(const unsigned char *params, 62 1.1.1.2 christos size_t params_len, 63 1.1.1.2 christos void *arg); 64 1.1 christos void *got_transport_params_cb_arg; 65 1.1 christos 66 1.1 christos /* 67 1.1 christos * Called when the handshake has been completed as far as the handshake 68 1.1 christos * protocol is concerned, meaning that the connection has been 69 1.1 christos * authenticated. 70 1.1 christos */ 71 1.1 christos int (*handshake_complete_cb)(void *arg); 72 1.1 christos void *handshake_complete_cb_arg; 73 1.1 christos 74 1.1 christos /* 75 1.1 christos * Called when something has gone wrong with the connection as far as the 76 1.1 christos * handshake layer is concerned, meaning that it should be immediately torn 77 1.1 christos * down. Note that this may happen at any time, including after a connection 78 1.1 christos * has been fully established. 79 1.1 christos */ 80 1.1 christos int (*alert_cb)(void *arg, unsigned char alert_code); 81 1.1 christos void *alert_cb_arg; 82 1.1 christos 83 1.1 christos /* Set to 1 if we are running in the server role. */ 84 1.1 christos int is_server; 85 1.1 christos 86 1.1 christos /* Set to 1 if this is an internal use of the QUIC TLS */ 87 1.1 christos int ossl_quic; 88 1.1 christos } QUIC_TLS_ARGS; 89 1.1 christos 90 1.1 christos QUIC_TLS *ossl_quic_tls_new(const QUIC_TLS_ARGS *args); 91 1.1 christos 92 1.1 christos void ossl_quic_tls_free(QUIC_TLS *qtls); 93 1.1 christos 94 1.1 christos int ossl_quic_tls_configure(QUIC_TLS *qtls); 95 1.1 christos 96 1.1 christos /* Advance the state machine */ 97 1.1 christos int ossl_quic_tls_tick(QUIC_TLS *qtls); 98 1.1 christos 99 1.1 christos void ossl_quic_tls_clear(QUIC_TLS *qtls); 100 1.1 christos 101 1.1 christos int ossl_quic_tls_set_transport_params(QUIC_TLS *qtls, 102 1.1.1.2 christos const unsigned char *transport_params, 103 1.1.1.2 christos size_t transport_params_len); 104 1.1 christos 105 1.1 christos int ossl_quic_tls_get_error(QUIC_TLS *qtls, 106 1.1.1.2 christos uint64_t *error_code, 107 1.1.1.2 christos const char **error_msg, 108 1.1.1.2 christos ERR_STATE **error_state); 109 1.1 christos 110 1.1 christos int ossl_quic_tls_is_cert_request(QUIC_TLS *qtls); 111 1.1 christos int ossl_quic_tls_has_bad_max_early_data(QUIC_TLS *qtls); 112 1.1 christos 113 1.1 christos int ossl_quic_tls_set_early_data_enabled(QUIC_TLS *qtls, int enabled); 114 1.1 christos #endif 115