From 63e78adb1944e8047d622bc75c5576d10bbc25bb Mon Sep 17 00:00:00 2001 From: Bug Magnet Date: Tue, 27 Aug 2024 13:10:22 +0200 Subject: [PATCH] Address PR feedback --- .../PacketTunnelProvider+TCPConnection.swift | 14 +++++++------- .../Protocols/EphemeralPeerReceiving.swift | 2 +- .../Actor/PacketTunnelActor+PostQuantum.swift | 2 -- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/ios/MullvadRustRuntime/PacketTunnelProvider+TCPConnection.swift b/ios/MullvadRustRuntime/PacketTunnelProvider+TCPConnection.swift index 089edcdac022..dcb7a6c52148 100644 --- a/ios/MullvadRustRuntime/PacketTunnelProvider+TCPConnection.swift +++ b/ios/MullvadRustRuntime/PacketTunnelProvider+TCPConnection.swift @@ -87,32 +87,32 @@ func tcpConnectionReceive( /// If `rawEphemeralKey` is nil, the negotiation is considered failed. /// /// - Parameters: -/// - rawPacketTunnel: A raw pointer to the running instance of `NEPacketTunnelProvider` +/// - rawEphemeralPeerReceiver: A raw pointer to the running instance of `NEPacketTunnelProvider` /// - rawPresharedKey: A raw pointer to the quantum-secure pre shared key /// - rawEphemeralKey: A raw pointer to the ephemeral private key of the device @_cdecl("swift_ephemeral_peer_ready") func receivePostQuantumKey( - rawPostQuantumKeyReceiver: UnsafeMutableRawPointer?, + rawEphemeralPeerReceiver: UnsafeMutableRawPointer?, rawPresharedKey: UnsafeMutableRawPointer?, rawEphemeralKey: UnsafeMutableRawPointer? ) { - guard let rawPostQuantumKeyReceiver else { return } - let postQuantumKeyReceiver = Unmanaged.fromOpaque(rawPostQuantumKeyReceiver) + guard let rawEphemeralPeerReceiver else { return } + let ephemeralPeerReceiver = Unmanaged.fromOpaque(rawEphemeralPeerReceiver) .takeUnretainedValue() // If there are no private keys for the ephemeral peer, then the negotiation either failed, or timed out. guard let rawEphemeralKey, let ephemeralKey = PrivateKey(rawValue: Data(bytes: rawEphemeralKey, count: 32)) else { - postQuantumKeyReceiver.ephemeralPeerExchangeFailed() + ephemeralPeerReceiver.ephemeralPeerExchangeFailed() return } // If there is a pre-shared key, an ephemeral peer was negotiated with Post Quantum options // Otherwise, a Daita enabled ephemeral peer was requested if let rawPresharedKey, let key = PreSharedKey(rawValue: Data(bytes: rawPresharedKey, count: 32)) { - postQuantumKeyReceiver.receivePostQuantumKey(key, ephemeralKey: ephemeralKey) + ephemeralPeerReceiver.receivePostQuantumKey(key, ephemeralKey: ephemeralKey) } else { - postQuantumKeyReceiver.receiveEphemeralPeerPrivateKey(ephemeralKey) + ephemeralPeerReceiver.receiveEphemeralPeerPrivateKey(ephemeralKey) } return } diff --git a/ios/MullvadTypes/Protocols/EphemeralPeerReceiving.swift b/ios/MullvadTypes/Protocols/EphemeralPeerReceiving.swift index a41e0ae588a0..d55ec09f1ff6 100644 --- a/ios/MullvadTypes/Protocols/EphemeralPeerReceiving.swift +++ b/ios/MullvadTypes/Protocols/EphemeralPeerReceiving.swift @@ -1,5 +1,5 @@ // -// PostQuantumKeyReceiving.swift +// EphemeralPeerReceiving.swift // MullvadTypes // // Created by Andrew Bulhak on 2024-03-05. diff --git a/ios/PacketTunnelCore/Actor/PacketTunnelActor+PostQuantum.swift b/ios/PacketTunnelCore/Actor/PacketTunnelActor+PostQuantum.swift index eaf2d67e7407..4bebc5c32446 100644 --- a/ios/PacketTunnelCore/Actor/PacketTunnelActor+PostQuantum.swift +++ b/ios/PacketTunnelCore/Actor/PacketTunnelActor+PostQuantum.swift @@ -97,8 +97,6 @@ extension PacketTunnelActor { preSharedKey: firstHop.configuration.preSharedKey ).makeConfiguration() - // wireguard-go will only turn on daita for the entry peer, - // so pass the daita configuration to the exit peer for consistency let exitConfiguration = try ConfigurationBuilder( privateKey: secondHop.configuration.privateKey, interfaceAddresses: settings.interfaceAddresses,