2022-09-06 19:59:25 +08:00
|
|
|
/*
|
2024-03-20 20:07:54 +08:00
|
|
|
* Copyright 2022-2024 The OpenSSL Project Authors. All Rights Reserved.
|
2022-09-06 19:59:25 +08:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
|
|
|
* this file except in compliance with the License. You can obtain a copy
|
|
|
|
* in the file LICENSE in the source distribution or at
|
|
|
|
* https://www.openssl.org/source/license.html
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef OSSL_QUIC_SSL_H
|
|
|
|
# define OSSL_QUIC_SSL_H
|
|
|
|
|
|
|
|
# include <openssl/ssl.h>
|
2022-11-17 23:33:11 +08:00
|
|
|
# include <openssl/bio.h>
|
2022-09-06 19:59:25 +08:00
|
|
|
# include "internal/quic_record_rx.h" /* OSSL_QRX */
|
|
|
|
# include "internal/quic_ackm.h" /* OSSL_ACKM */
|
2023-05-23 19:23:06 +08:00
|
|
|
# include "internal/quic_channel.h" /* QUIC_CHANNEL */
|
2024-01-18 23:31:41 +08:00
|
|
|
# include "internal/quic_predef.h"
|
2022-09-06 19:59:25 +08:00
|
|
|
|
2022-11-18 00:03:00 +08:00
|
|
|
# ifndef OPENSSL_NO_QUIC
|
|
|
|
|
2022-09-06 19:59:25 +08:00
|
|
|
__owur SSL *ossl_quic_new(SSL_CTX *ctx);
|
2024-01-11 17:17:43 +08:00
|
|
|
__owur SSL *ossl_quic_new_listener(SSL_CTX *ctx, uint64_t flags);
|
2024-04-24 17:03:50 +08:00
|
|
|
__owur SSL *ossl_quic_new_listener_from(SSL *ssl, uint64_t flags);
|
2024-01-18 23:23:38 +08:00
|
|
|
__owur SSL *ossl_quic_new_from_listener(SSL *ssl, uint64_t flags);
|
2024-04-24 17:03:50 +08:00
|
|
|
__owur SSL *ossl_quic_new_domain(SSL_CTX *ctx, uint64_t flags);
|
2025-01-16 00:40:49 +08:00
|
|
|
|
2025-01-28 02:56:40 +08:00
|
|
|
typedef void QTOK;
|
2025-01-16 00:40:49 +08:00
|
|
|
SSL_TOKEN_STORE_HANDLE *ossl_quic_new_token_store(void);
|
|
|
|
void ossl_quic_free_token_store(SSL_TOKEN_STORE_HANDLE *hdl);
|
2025-01-31 01:14:26 +08:00
|
|
|
SSL_TOKEN_STORE_HANDLE *ossl_quic_get0_token_store(SSL_CTX *ctx);
|
|
|
|
int ossl_quic_set1_token_store(SSL_CTX *ctx, SSL_TOKEN_STORE_HANDLE *hdl);
|
2025-01-28 22:41:52 +08:00
|
|
|
int ossl_quic_set_peer_token(SSL_CTX *ctx, BIO_ADDR *peer,
|
|
|
|
const uint8_t *token, size_t token_len);
|
2025-01-16 04:16:24 +08:00
|
|
|
int ossl_quic_get_peer_token(SSL_CTX *ctx, BIO_ADDR *peer,
|
2025-01-17 02:12:15 +08:00
|
|
|
uint8_t **token, size_t *token_len,
|
2025-01-28 02:04:08 +08:00
|
|
|
QTOK **token_free_ptr);
|
|
|
|
void ossl_quic_free_peer_token(QTOK *token);
|
2025-01-16 00:40:49 +08:00
|
|
|
|
2022-09-06 19:59:25 +08:00
|
|
|
__owur int ossl_quic_init(SSL *s);
|
|
|
|
void ossl_quic_deinit(SSL *s);
|
|
|
|
void ossl_quic_free(SSL *s);
|
|
|
|
int ossl_quic_reset(SSL *s);
|
|
|
|
int ossl_quic_clear(SSL *s);
|
|
|
|
__owur int ossl_quic_accept(SSL *s);
|
|
|
|
__owur int ossl_quic_connect(SSL *s);
|
|
|
|
__owur int ossl_quic_read(SSL *s, void *buf, size_t len, size_t *readbytes);
|
|
|
|
__owur int ossl_quic_peek(SSL *s, void *buf, size_t len, size_t *readbytes);
|
2024-01-19 22:52:44 +08:00
|
|
|
__owur int ossl_quic_write_flags(SSL *s, const void *buf, size_t len,
|
|
|
|
uint64_t flags, size_t *written);
|
2022-09-06 19:59:25 +08:00
|
|
|
__owur int ossl_quic_write(SSL *s, const void *buf, size_t len, size_t *written);
|
|
|
|
__owur long ossl_quic_ctrl(SSL *s, int cmd, long larg, void *parg);
|
|
|
|
__owur long ossl_quic_ctx_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg);
|
|
|
|
__owur long ossl_quic_callback_ctrl(SSL *s, int cmd, void (*fp) (void));
|
|
|
|
__owur long ossl_quic_ctx_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp) (void));
|
|
|
|
__owur size_t ossl_quic_pending(const SSL *s);
|
2023-06-12 21:13:33 +08:00
|
|
|
__owur int ossl_quic_key_update(SSL *s, int update_type);
|
|
|
|
__owur int ossl_quic_get_key_update_type(const SSL *s);
|
2023-09-08 00:45:49 +08:00
|
|
|
__owur const SSL_CIPHER *ossl_quic_get_cipher_by_char(const unsigned char *p);
|
2022-09-06 19:59:25 +08:00
|
|
|
__owur int ossl_quic_num_ciphers(void);
|
|
|
|
__owur const SSL_CIPHER *ossl_quic_get_cipher(unsigned int u);
|
|
|
|
int ossl_quic_renegotiate_check(SSL *ssl, int initok);
|
|
|
|
|
2023-04-19 02:30:53 +08:00
|
|
|
int ossl_quic_do_handshake(SSL *s);
|
|
|
|
void ossl_quic_set_connect_state(SSL *s);
|
|
|
|
void ossl_quic_set_accept_state(SSL *s);
|
2022-11-17 23:33:11 +08:00
|
|
|
|
2023-04-19 02:30:53 +08:00
|
|
|
__owur int ossl_quic_has_pending(const SSL *s);
|
2023-05-04 02:01:12 +08:00
|
|
|
__owur int ossl_quic_handle_events(SSL *s);
|
2023-05-04 02:09:05 +08:00
|
|
|
__owur int ossl_quic_get_event_timeout(SSL *s, struct timeval *tv,
|
|
|
|
int *is_infinite);
|
2023-05-04 02:01:12 +08:00
|
|
|
OSSL_TIME ossl_quic_get_event_deadline(SSL *s);
|
2023-04-19 02:30:53 +08:00
|
|
|
__owur int ossl_quic_get_rpoll_descriptor(SSL *s, BIO_POLL_DESCRIPTOR *d);
|
|
|
|
__owur int ossl_quic_get_wpoll_descriptor(SSL *s, BIO_POLL_DESCRIPTOR *d);
|
|
|
|
__owur int ossl_quic_get_net_read_desired(SSL *s);
|
|
|
|
__owur int ossl_quic_get_net_write_desired(SSL *s);
|
|
|
|
__owur int ossl_quic_get_error(const SSL *s, int i);
|
2023-08-31 18:53:32 +08:00
|
|
|
__owur int ossl_quic_want(const SSL *s);
|
2023-04-19 02:30:53 +08:00
|
|
|
__owur int ossl_quic_conn_get_blocking_mode(const SSL *s);
|
|
|
|
__owur int ossl_quic_conn_set_blocking_mode(SSL *s, int blocking);
|
|
|
|
__owur int ossl_quic_conn_shutdown(SSL *s, uint64_t flags,
|
2022-12-13 20:27:05 +08:00
|
|
|
const SSL_SHUTDOWN_EX_ARGS *args,
|
|
|
|
size_t args_len);
|
2023-04-19 02:30:53 +08:00
|
|
|
__owur int ossl_quic_conn_stream_conclude(SSL *s);
|
|
|
|
void ossl_quic_conn_set0_net_rbio(SSL *s, BIO *net_wbio);
|
|
|
|
void ossl_quic_conn_set0_net_wbio(SSL *s, BIO *net_wbio);
|
|
|
|
BIO *ossl_quic_conn_get_net_rbio(const SSL *s);
|
|
|
|
BIO *ossl_quic_conn_get_net_wbio(const SSL *s);
|
|
|
|
__owur int ossl_quic_conn_set_initial_peer_addr(SSL *s,
|
2022-11-17 23:33:11 +08:00
|
|
|
const BIO_ADDR *peer_addr);
|
2023-04-19 02:30:54 +08:00
|
|
|
__owur SSL *ossl_quic_conn_stream_new(SSL *s, uint64_t flags);
|
2023-04-19 02:30:54 +08:00
|
|
|
__owur SSL *ossl_quic_get0_connection(SSL *s);
|
2024-01-11 17:33:36 +08:00
|
|
|
__owur SSL *ossl_quic_get0_listener(SSL *s);
|
2024-04-24 17:03:50 +08:00
|
|
|
__owur SSL *ossl_quic_get0_domain(SSL *s);
|
2024-04-24 17:24:45 +08:00
|
|
|
__owur int ossl_quic_get_domain_flags(const SSL *s, uint64_t *domain_flags);
|
2023-04-19 02:30:55 +08:00
|
|
|
__owur int ossl_quic_get_stream_type(SSL *s);
|
2023-04-19 02:30:55 +08:00
|
|
|
__owur uint64_t ossl_quic_get_stream_id(SSL *s);
|
2023-08-30 20:09:13 +08:00
|
|
|
__owur int ossl_quic_is_stream_local(SSL *s);
|
2023-04-19 02:30:55 +08:00
|
|
|
__owur int ossl_quic_set_default_stream_mode(SSL *s, uint32_t mode);
|
|
|
|
__owur SSL *ossl_quic_detach_stream(SSL *s);
|
|
|
|
__owur int ossl_quic_attach_stream(SSL *conn, SSL *stream);
|
2023-05-09 02:52:45 +08:00
|
|
|
__owur int ossl_quic_set_incoming_stream_policy(SSL *s, int policy,
|
|
|
|
uint64_t aec);
|
2023-04-19 02:30:55 +08:00
|
|
|
__owur SSL *ossl_quic_accept_stream(SSL *s, uint64_t flags);
|
|
|
|
__owur size_t ossl_quic_get_accept_stream_queue_len(SSL *s);
|
2024-01-22 21:16:58 +08:00
|
|
|
__owur int ossl_quic_get_value_uint(SSL *s, uint32_t class_, uint32_t id,
|
|
|
|
uint64_t *value);
|
|
|
|
__owur int ossl_quic_set_value_uint(SSL *s, uint32_t class_, uint32_t id,
|
|
|
|
uint64_t value);
|
2024-01-11 17:33:36 +08:00
|
|
|
__owur SSL *ossl_quic_accept_connection(SSL *ssl, uint64_t flags);
|
|
|
|
__owur size_t ossl_quic_get_accept_connection_queue_len(SSL *ssl);
|
|
|
|
__owur int ossl_quic_listen(SSL *ssl);
|
2022-09-06 19:59:25 +08:00
|
|
|
|
2023-04-19 02:30:56 +08:00
|
|
|
__owur int ossl_quic_stream_reset(SSL *ssl,
|
|
|
|
const SSL_STREAM_RESET_ARGS *args,
|
|
|
|
size_t args_len);
|
|
|
|
|
|
|
|
__owur int ossl_quic_get_stream_read_state(SSL *ssl);
|
|
|
|
__owur int ossl_quic_get_stream_write_state(SSL *ssl);
|
|
|
|
__owur int ossl_quic_get_stream_read_error_code(SSL *ssl,
|
|
|
|
uint64_t *app_error_code);
|
|
|
|
__owur int ossl_quic_get_stream_write_error_code(SSL *ssl,
|
|
|
|
uint64_t *app_error_code);
|
|
|
|
__owur int ossl_quic_get_conn_close_info(SSL *ssl,
|
|
|
|
SSL_CONN_CLOSE_INFO *info,
|
|
|
|
size_t info_len);
|
|
|
|
|
2023-01-16 23:21:29 +08:00
|
|
|
uint64_t ossl_quic_set_options(SSL *s, uint64_t opts);
|
|
|
|
uint64_t ossl_quic_clear_options(SSL *s, uint64_t opts);
|
|
|
|
uint64_t ossl_quic_get_options(const SSL *s);
|
|
|
|
|
2023-07-18 23:12:44 +08:00
|
|
|
/* Modifies write buffer size for a stream. */
|
|
|
|
__owur int ossl_quic_set_write_buffer_size(SSL *s, size_t size);
|
|
|
|
|
2023-02-21 18:18:59 +08:00
|
|
|
/*
|
2023-05-23 19:23:06 +08:00
|
|
|
* Used to override ossl_time_now() for debug purposes. While this may be
|
|
|
|
* overridden at any time, expect strange results if you change it after
|
2023-02-21 18:18:59 +08:00
|
|
|
* connecting.
|
|
|
|
*/
|
2024-09-13 23:00:22 +08:00
|
|
|
int ossl_quic_set_override_now_cb(SSL *s,
|
|
|
|
OSSL_TIME (*now_cb)(void *arg),
|
|
|
|
void *now_cb_arg);
|
2023-02-21 18:18:59 +08:00
|
|
|
|
2023-02-21 18:18:59 +08:00
|
|
|
/*
|
|
|
|
* Condvar waiting in the assist thread doesn't support time faking as it relies
|
|
|
|
* on the OS's notion of time, thus this is used in test code to force a
|
|
|
|
* spurious wakeup instead.
|
|
|
|
*/
|
|
|
|
void ossl_quic_conn_force_assist_thread_wake(SSL *s);
|
|
|
|
|
2023-05-23 19:23:06 +08:00
|
|
|
/* For use by tests only. */
|
|
|
|
QUIC_CHANNEL *ossl_quic_conn_get_channel(SSL *s);
|
2023-06-26 20:47:03 +08:00
|
|
|
|
2023-01-16 23:24:17 +08:00
|
|
|
int ossl_quic_has_pending(const SSL *s);
|
2023-10-17 16:00:58 +08:00
|
|
|
int ossl_quic_get_shutdown(const SSL *s);
|
2023-05-23 19:23:06 +08:00
|
|
|
|
2023-09-08 20:42:53 +08:00
|
|
|
/*
|
2024-01-23 22:13:49 +08:00
|
|
|
* Set qlog diagnostic title. String is copied internally on success and need
|
2023-09-08 20:42:53 +08:00
|
|
|
* not remain allocated. Only has any effect if logging has not already begun.
|
|
|
|
* For use by tests only. Setting this on a context affects any QCSO created
|
|
|
|
* after this is called but does not affect QCSOs already created from a
|
|
|
|
* context.
|
|
|
|
*/
|
|
|
|
int ossl_quic_set_diag_title(SSL_CTX *ctx, const char *title);
|
|
|
|
|
2024-02-02 20:21:28 +08:00
|
|
|
/* APIs used by the polling infrastructure */
|
2024-02-02 20:30:41 +08:00
|
|
|
int ossl_quic_conn_poll_events(SSL *ssl, uint64_t events, int do_tick,
|
|
|
|
uint64_t *revents);
|
2024-05-14 03:20:23 +08:00
|
|
|
int ossl_quic_get_notifier_fd(SSL *ssl);
|
|
|
|
void ossl_quic_enter_blocking_section(SSL *ssl, QUIC_REACTOR_WAIT_CTX *wctx);
|
|
|
|
void ossl_quic_leave_blocking_section(SSL *ssl, QUIC_REACTOR_WAIT_CTX *wctx);
|
2024-02-02 20:21:28 +08:00
|
|
|
|
2022-11-18 00:03:00 +08:00
|
|
|
# endif
|
|
|
|
|
2022-09-06 19:59:25 +08:00
|
|
|
#endif
|