@@ -150,6 +150,41 @@ extension PacketTunnelActor {
150
150
}
151
151
}
152
152
153
+ struct QuantumKeyNegotiatior {
154
+ let packetTunnel : NEPacketTunnelProvider
155
+ private let tcpConnectionInsideTunnel : NWTCPConnection
156
+
157
+ func setupKVOForTCPConnection( _ connection: NWTCPConnection ) { }
158
+
159
+ func negotiatePostQuantumKeyExchange(
160
+ relayAddress: IPv4Address ,
161
+ devicePublicKey: PublicKey ,
162
+ presharedKey: PublicKey
163
+ ) -> PrivateKey ? /* pre shared key to use*/ {
164
+ nil
165
+ }
166
+ }
167
+
168
+ /*
169
+ - New Design of the functionality
170
+ - Enter the negotiatePostQuantumKey state
171
+ - Configure Wireguard to connect to the gateway (10.64.0.1/32)
172
+ - Open the TCP Connection inside the tunnel `createTCPConnectionThroughTunnel(to:enableTLS:tlsParameters:delegate:)`
173
+ - Setup KVO on the TCP Connection
174
+ - Wait for the connection to be in a connected state
175
+ - Call the rust function to exchange keys
176
+ - Use the returned preshared-key to reconfigure the WireGuard adapter
177
+ - Send the .start message to the Packet Tunnel Actor with the new preshared key
178
+ - Try writing the new preshared private key to the settings, where it will be read when we send the `.start` message
179
+ let postQuantumConfiguration = ConfigurationBuilder(
180
+ privateKey: RETURNED_PRE_SHARED_KEY,
181
+ interfaceAddresses: settings.interfaceAddresses, allowedIPs: [
182
+ IPAddressRange(from: "0.0.0.0/0")!,
183
+ IPAddressRange(from: "::/0")!,
184
+ ]
185
+ )
186
+
187
+ */
153
188
private func negotiatePostQuantumKeyExchange( _ options: StartOptions , nextRelay: NextRelay = . current) async {
154
189
// TODO: Should this be the same path as in a reconnection attempt ?
155
190
guard case . initial = state else { return }
0 commit comments