summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrew Bulhak <andrew.bulhak@mullvad.net>2024-03-18 11:26:51 +0100
committerBug Magnet <marco.nikic@mullvad.net>2024-03-18 15:58:28 +0100
commit80aa18714a065735eb3ea00e11be0eaeb2c0fb12 (patch)
treec733cacb95d7a21110376a7e7fb3c3e15621efae
parent9b9d36a3f912773f2dcc4ba7adf51b03ee5afde4 (diff)
downloadmullvadvpn-80aa18714a065735eb3ea00e11be0eaeb2c0fb12.tar.xz
mullvadvpn-80aa18714a065735eb3ea00e11be0eaeb2c0fb12.zip
Move PacketTunnelProvider extension pass the key to the Actor
-rw-r--r--ios/MullvadTypes/Protocols/PostQuantumKeyReceiving.swift10
-rw-r--r--ios/PacketTunnel/PacketTunnelProvider/PacketTunnelProvider.swift8
-rw-r--r--ios/PacketTunnelCore/Actor/PacketTunnelActor+Public.swift10
3 files changed, 23 insertions, 5 deletions
diff --git a/ios/MullvadTypes/Protocols/PostQuantumKeyReceiving.swift b/ios/MullvadTypes/Protocols/PostQuantumKeyReceiving.swift
index 577e2f3d63..eb696fcca3 100644
--- a/ios/MullvadTypes/Protocols/PostQuantumKeyReceiving.swift
+++ b/ios/MullvadTypes/Protocols/PostQuantumKeyReceiving.swift
@@ -9,17 +9,17 @@
import Foundation
import WireGuardKitTypes
-protocol PostQuantumKeyReceiving {
- func receivePostQuantumKey(_ key: PrivateKey)
+public protocol PostQuantumKeyReceiving {
+ func receivePostQuantumKey(_ key: PreSharedKey)
}
-enum PostQuantumKeyReceivingError: Error {
+public enum PostQuantumKeyReceivingError: Error {
case invalidKey
}
-extension PostQuantumKeyReceiving {
+public extension PostQuantumKeyReceiving {
func receivePostQuantumKey(_ keyData: Data) throws {
- guard let key = PrivateKey(rawValue: keyData) else {
+ guard let key = PreSharedKey(rawValue: keyData) else {
throw PostQuantumKeyReceivingError.invalidKey
}
receivePostQuantumKey(key)
diff --git a/ios/PacketTunnel/PacketTunnelProvider/PacketTunnelProvider.swift b/ios/PacketTunnel/PacketTunnelProvider/PacketTunnelProvider.swift
index ed9c700af8..5b56b1675a 100644
--- a/ios/PacketTunnel/PacketTunnelProvider/PacketTunnelProvider.swift
+++ b/ios/PacketTunnel/PacketTunnelProvider/PacketTunnelProvider.swift
@@ -14,6 +14,7 @@ import MullvadTypes
import NetworkExtension
import PacketTunnelCore
import TunnelObfuscation
+import WireGuardKitTypes
class PacketTunnelProvider: NEPacketTunnelProvider {
private let internalQueue = DispatchQueue(label: "PacketTunnel-internalQueue")
@@ -275,3 +276,10 @@ extension PacketTunnelProvider {
}
}
}
+
+extension PacketTunnelProvider: PostQuantumKeyReceiving {
+ func receivePostQuantumKey(_ key: PreSharedKey) {
+ // TODO: send the key to the actor
+ actor.replacePreSharedKey(key)
+ }
+}
diff --git a/ios/PacketTunnelCore/Actor/PacketTunnelActor+Public.swift b/ios/PacketTunnelCore/Actor/PacketTunnelActor+Public.swift
index b54d397ca4..0d80fb6d58 100644
--- a/ios/PacketTunnelCore/Actor/PacketTunnelActor+Public.swift
+++ b/ios/PacketTunnelCore/Actor/PacketTunnelActor+Public.swift
@@ -7,6 +7,7 @@
//
import Foundation
+import WireGuardKitTypes
/**
Public methods for dispatching commands to Actor.
@@ -51,6 +52,15 @@ extension PacketTunnelActor {
}
/**
+ Issue a new preshared key to the Actor.
+ - Parameter key: the new key
+ */
+
+ nonisolated public func replacePreSharedKey(_ key: PreSharedKey) {
+ commandChannel.send(.replaceDevicePrivateKey(key))
+ }
+
+ /**
Tell actor to enter error state.
*/
nonisolated public func setErrorState(reason: BlockedStateReason) {