|
7 | 7 | * Port used by the tunnel config service.
|
8 | 8 | */
|
9 | 9 | #define CONFIG_SERVICE_PORT 1337
|
10 |
| - |
11 |
| -typedef struct PostQuantumCancelToken { |
12 |
| - void *context; |
13 |
| -} PostQuantumCancelToken; |
14 |
| - |
15 |
| -/** |
16 |
| - * Called by the Swift side to signal that the quantum-secure key exchange should be cancelled. |
17 |
| - * |
18 |
| - * # Safety |
19 |
| - * `sender` must be pointing to a valid instance of a `PostQuantumCancelToken` created by the |
20 |
| - * `PacketTunnelProvider`. |
21 |
| - */ |
22 |
| -void cancel_post_quantum_key_exchange(const struct PostQuantumCancelToken *sender); |
23 |
| - |
24 |
| -/** |
25 |
| - * Called by the Swift side to signal that the Rust `PostQuantumCancelToken` can be safely dropped |
26 |
| - * from memory. |
27 |
| - * |
28 |
| - * # Safety |
29 |
| - * `sender` must be pointing to a valid instance of a `PostQuantumCancelToken` created by the |
30 |
| - * `PacketTunnelProvider`. |
31 |
| - */ |
32 |
| -void drop_post_quantum_key_exchange_token(const struct PostQuantumCancelToken *sender); |
33 |
| - |
34 |
| -/** |
35 |
| - * Called by Swift whenever data has been written to the in-tunnel TCP connection when exchanging |
36 |
| - * quantum-resistant pre shared keys. |
37 |
| - * |
38 |
| - * If `bytes_sent` is 0, this indicates that the connection was closed or that an error occurred. |
39 |
| - * |
40 |
| - * # Safety |
41 |
| - * `sender` must be pointing to a valid instance of a `write_tx` created by the `IosTcpProvider` |
42 |
| - * Callback to call when the TCP connection has written data. |
43 |
| - */ |
44 |
| -void handle_sent(uintptr_t bytes_sent, const void *sender); |
45 |
| - |
46 |
| -/** |
47 |
| - * Called by Swift whenever data has been read from the in-tunnel TCP connection when exchanging |
48 |
| - * quantum-resistant pre shared keys. |
49 |
| - * |
50 |
| - * If `data` is null or empty, this indicates that the connection was closed or that an error |
51 |
| - * occurred. An empty buffer is sent to the underlying reader to signal EOF. |
52 |
| - * |
53 |
| - * # Safety |
54 |
| - * `sender` must be pointing to a valid instance of a `read_tx` created by the `IosTcpProvider` |
55 |
| - * |
56 |
| - * Callback to call when the TCP connection has received data. |
57 |
| - */ |
58 |
| -void handle_recv(const uint8_t *data, uintptr_t data_len, const void *sender); |
59 |
| - |
60 |
| -/** |
61 |
| - * Entry point for exchanging post quantum keys on iOS. |
62 |
| - * The TCP connection must be created to go through the tunnel. |
63 |
| - * # Safety |
64 |
| - * `public_key` and `ephemeral_key` must be valid respective `PublicKey` and `PrivateKey` types. |
65 |
| - * They will not be valid after this function is called, and thus must be copied here. |
66 |
| - * `packet_tunnel` and `tcp_connection` must be valid pointers to a packet tunnel and a TCP |
67 |
| - * connection instances. |
68 |
| - * `cancel_token` should be owned by the caller of this function. |
69 |
| - */ |
70 |
| -int32_t negotiate_post_quantum_key(const uint8_t *public_key, |
71 |
| - const uint8_t *ephemeral_key, |
72 |
| - const void *packet_tunnel, |
73 |
| - const void *tcp_connection, |
74 |
| - struct PostQuantumCancelToken *cancel_token, |
75 |
| - uint64_t post_quantum_key_exchange_timeout); |
76 |
| - |
77 |
| -/** |
78 |
| - * Called when there is data to send on the TCP connection. |
79 |
| - * The TCP connection must write data on the wire, then call the `handle_sent` function. |
80 |
| - */ |
81 |
| -extern void swift_nw_tcp_connection_send(const void *connection, |
82 |
| - const void *data, |
83 |
| - uintptr_t data_len, |
84 |
| - const void *sender); |
85 |
| - |
86 |
| -/** |
87 |
| - * Called when there is data to read on the TCP connection. |
88 |
| - * The TCP connection must read data from the wire, then call the `handle_read` function. |
89 |
| - */ |
90 |
| -extern void swift_nw_tcp_connection_read(const void *connection, const void *sender); |
91 |
| - |
92 |
| -/** |
93 |
| - * Called when the preshared post quantum key is ready. |
94 |
| - * `raw_preshared_key` might be NULL if the key negotiation failed. |
95 |
| - */ |
96 |
| -extern void swift_post_quantum_key_ready(const void *raw_packet_tunnel, |
97 |
| - const uint8_t *raw_preshared_key, |
98 |
| - const uint8_t *raw_ephemeral_private_key); |
0 commit comments