-
Notifications
You must be signed in to change notification settings - Fork 35
librustls: add kTLS support #603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
fc580fb
to
f05e9d6
Compare
I'm really sorry for all the noise. |
No worries, I won't personally have a chance to peek at this PR for a bit so churn on that front is no biggie. However, since you haven't contributed to the repo before the CI runs have to be approved manually, and that's likely a drag on your end. If you want an easier way to iterate without updating this PR you could rename your branch with a |
Will do. Just one question though: Do you know how to gate importing |
Ok, I think it works now. https://github.com/pallas/rustls-ffi/actions/runs/17747096812 |
Hmmm. I think you have the syntax right for adding a platform-conditional dependency in I think you want to deactivate to activate the |
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`.
f05e9d6
to
359a247
Compare
Ok, I turned off the feature by default and it seems to be gated correctly for non-Linux. |
Thanks for the PR and the continued work on the CI front. I think I'd prefer to see the changes supporting secret extraction separated into its own PR if you're amenable to that. I think it'll be easier to review and less controversial and we can probably land that pretty quickly. Happy for other maintainers to weigh in, but personally on the kTLS front I'm not super enthusiastic about exposing
My thinking is that this crate should retain the necessary bits to enable kTLS (like Rustls does upstream), but the FFI for kTLS should be handled in a separate crate (like how kTLS is in rustls/ktls). WDYT? |
I verified that this works in a dependent C program using rustls-ffi. Open to feedback, but please note that I am not familiar with idiomatic rust, having never written in the language before.
Add
rustls_connection_ktls_secrets
, which consumesrustls_connection
to generate tx and rx secrets for kTLS. Secrets are borrowed and passed to a callback.In order to use
rustls_connection_ktls_secrets
, secret extraction must be enabled viarustls_*_config_builder_set_enable_secret_extraction
.