You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add `rustls_connection_ktls_secrets`, which consumes `rustls_connection` to
generate tx and rx secrets for kTLS. Secrets are borrowed and passed to a
callback.
```c
static rustls_io_result
ktls_secrets_callback(void *userdata,
const uint8_t *rx_buf, size_t rx_n,
const uint8_t *tx_buf, size_t tx_n)
{
int result;
int fd = *(int*)userdata;
result = setsockopt(fd, SOL_TCP, TCP_ULP, "tls", 4);
if (result < 0) return result;
result = setsockopt(fd, SOL_TLS, TLS_RX, rx_buf, rx_n);
if (result < 0) return result;
result = setsockopt(fd, SOL_TLS, TLS_TX, tx_buf, tx_n);
if (result < 0) return result;
return 0;
}
```
```c
int fd /* = ... */;
struct rustls_connection * connection /* = ... */;
while (rustls_connection_is_handshaking(connection)) {
/* process reads and writes */
}
while (rustls_connection_wants_write(connection)) {
/* flush outbound packets */
}
rustls_result result = rustls_connection_ktls_secrets(connection
ktls_secrets_callback, &fd);
```
In order to use `rustls_connection_ktls_secrets`, secret extraction must be
enabled via `rustls_*_config_builder_set_enable_secret_extraction`.
0 commit comments