Skip to content

Commit

Permalink
Remove dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
buggmagnet committed Mar 26, 2024
1 parent 20c8fae commit 9de0959
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func receivePostQuantumKey(rawPacketTunnel: UnsafeMutableRawPointer, rawPreshare
}

let presharedKey = Data(bytes: rawPresharedKey, count: 32)
if let key = PreSharedKey(rawValue: presharedKey) {
if let key = PreSharedKey(rawValue: presharedKey) {
postQuantumKeyReceiver.receivePostQuantumKey(key)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ void handle_recv(const uint8_t *data, uintptr_t data_len, const void *sender);
/**
* Entry point for exchanging post quantum keys on iOS.
* The TCP connection must be created to go through the tunnel.
* # Safety
* This function is safe to call
*/
const void *negotiate_post_quantum_key(const uint8_t *public_key,
const uint8_t *ephemeral_public_key,
Expand Down
9 changes: 0 additions & 9 deletions ios/MullvadTypes/Protocols/PostQuantumKeyReceiving.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,3 @@ public protocol PostQuantumKeyReceiving {
public enum PostQuantumKeyReceivingError: Error {
case invalidKey
}

public extension PostQuantumKeyReceiving {
func receivePostQuantumKey(_ keyData: Data) throws {
guard let key = PreSharedKey(rawValue: keyData) else {
throw PostQuantumKeyReceivingError.invalidKey
}
receivePostQuantumKey(key)
}
}
71 changes: 0 additions & 71 deletions ios/PacketTunnel/PacketTunnelProvider/PacketTunnelProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,77 +119,6 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
}
}

// MARK: - Uncomment the next three functions to test Post Quantum Key exchange

// override func startTunnel(options: [String: NSObject]? = nil) async throws {
// let startOptions = parseStartOptions(options ?? [:])
//
// startObservingActorState()
//
// try await startPostQuantumKeyExchange()
// }
//
// func selectGothenburgRelay() throws -> MullvadEndpoint {
// let constraints = RelayConstraints(
// locations: .only(UserSelectedRelays(locations: [.city("se", "got")]))
// )
// let relay = try relaySelector.selectRelay(with: constraints, connectionAttemptFailureCount: 0)
// return relay.endpoint
// }
//
// var pqTCPConnection: NWTCPConnection?
//
// func startPostQuantumKeyExchange() async throws {
// let settingsReader = SettingsReader()
// let settings: Settings = try settingsReader.read()
// let privateKey = settings.privateKey
// let postQuantumSharedKey = PrivateKey() // This will become the new private key of the device
//
// let IPv4Gateway = IPv4Address("10.64.0.1")!
// let gothenburgRelay = try selectGothenburgRelay()
//
// let configurationBuilder = ConfigurationBuilder(
// privateKey: settings.privateKey,
// interfaceAddresses: settings.interfaceAddresses,
// dns: settings.dnsServers,
// endpoint: gothenburgRelay,
// allowedIPs: [
// IPAddressRange(from: "10.64.0.1/8")!,
// ]
// )
//
// try await adapter.start(configuration: configurationBuilder.makeConfiguration())
//
// let negotiator = PostQuantumKeyNegotiatior()
// let gatewayEndpoint = NWHostEndpoint(hostname: "10.64.0.1", port: "1337")
//
// pqTCPConnection = createTCPConnectionThroughTunnel(
// to: gatewayEndpoint,
// enableTLS: false,
// tlsParameters: nil,
// delegate: nil
// )
// guard let pqTCPConnection else { return }
//
// // This will work as long as there is a detached, top-level task here.
// // It might be due to the async runtime environment for `override func startTunnel(options: [String: NSObject]? = nil) async throws`
// // There is a strong chance that the function's async availability was not properly declared by Apple.
// Task.detached {
// for await isViable in pqTCPConnection.viability where isViable == true {
// negotiator.negotiateKey(
// gatewayIP: IPv4Gateway,
// devicePublicKey: privateKey.publicKey,
// presharedKey: postQuantumSharedKey.publicKey,
// packetTunnel: self,
// tcpConnection: self.pqTCPConnection!
// )
// break
// }
// }
// }

// MARK: - End testing Post Quantum key exchange

override func stopTunnel(with reason: NEProviderStopReason) async {
providerLogger.debug("stopTunnel: \(reason)")

Expand Down

0 comments on commit 9de0959

Please sign in to comment.