Skip to content

Commit 2f0d4a2

Browse files
committed
add new design plan
1 parent cc0491b commit 2f0d4a2

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

ios/PacketTunnelCore/Actor/PacketTunnelActor.swift

+35
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,41 @@ extension PacketTunnelActor {
150150
}
151151
}
152152

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+
*/
153188
private func negotiatePostQuantumKeyExchange(_ options: StartOptions, nextRelay: NextRelay = .current) async {
154189
// TODO: Should this be the same path as in a reconnection attempt ?
155190
guard case .initial = state else { return }

0 commit comments

Comments
 (0)