Commit f05e9d6
committed
librustls: add kTLS support
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`.1 parent cbc8308 commit f05e9d6
File tree
9 files changed
+254
-3
lines changed- librustls
- cmake
- src
9 files changed
+254
-3
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
39 | 43 | | |
40 | 44 | | |
41 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
47 | | - | |
| 48 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| |||
54 | 56 | | |
55 | 57 | | |
56 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
57 | 63 | | |
58 | 64 | | |
59 | 65 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
| |||
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
| 76 | + | |
75 | 77 | | |
76 | 78 | | |
77 | 79 | | |
| |||
272 | 274 | | |
273 | 275 | | |
274 | 276 | | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
275 | 289 | | |
276 | 290 | | |
277 | 291 | | |
| |||
529 | 543 | | |
530 | 544 | | |
531 | 545 | | |
| 546 | + | |
532 | 547 | | |
533 | 548 | | |
534 | 549 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
| |||
97 | 99 | | |
98 | 100 | | |
99 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
100 | 113 | | |
101 | 114 | | |
102 | 115 | | |
| |||
302 | 315 | | |
303 | 316 | | |
304 | 317 | | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
305 | 359 | | |
306 | 360 | | |
307 | 361 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
214 | | - | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
215 | 219 | | |
216 | 220 | | |
217 | 221 | | |
| |||
551 | 555 | | |
552 | 556 | | |
553 | 557 | | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
554 | 561 | | |
555 | 562 | | |
556 | 563 | | |
| |||
0 commit comments