Skip to content

Commit 80aa187

Browse files
acb-mvbuggmagnet
authored andcommitted
Move PacketTunnelProvider extension pass the key to the Actor
1 parent 9b9d36a commit 80aa187

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

ios/MullvadTypes/Protocols/PostQuantumKeyReceiving.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@
99
import Foundation
1010
import WireGuardKitTypes
1111

12-
protocol PostQuantumKeyReceiving {
13-
func receivePostQuantumKey(_ key: PrivateKey)
12+
public protocol PostQuantumKeyReceiving {
13+
func receivePostQuantumKey(_ key: PreSharedKey)
1414
}
1515

16-
enum PostQuantumKeyReceivingError: Error {
16+
public enum PostQuantumKeyReceivingError: Error {
1717
case invalidKey
1818
}
1919

20-
extension PostQuantumKeyReceiving {
20+
public extension PostQuantumKeyReceiving {
2121
func receivePostQuantumKey(_ keyData: Data) throws {
22-
guard let key = PrivateKey(rawValue: keyData) else {
22+
guard let key = PreSharedKey(rawValue: keyData) else {
2323
throw PostQuantumKeyReceivingError.invalidKey
2424
}
2525
receivePostQuantumKey(key)

ios/PacketTunnel/PacketTunnelProvider/PacketTunnelProvider.swift

+8
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import MullvadTypes
1414
import NetworkExtension
1515
import PacketTunnelCore
1616
import TunnelObfuscation
17+
import WireGuardKitTypes
1718

1819
class PacketTunnelProvider: NEPacketTunnelProvider {
1920
private let internalQueue = DispatchQueue(label: "PacketTunnel-internalQueue")
@@ -275,3 +276,10 @@ extension PacketTunnelProvider {
275276
}
276277
}
277278
}
279+
280+
extension PacketTunnelProvider: PostQuantumKeyReceiving {
281+
func receivePostQuantumKey(_ key: PreSharedKey) {
282+
// TODO: send the key to the actor
283+
actor.replacePreSharedKey(key)
284+
}
285+
}

ios/PacketTunnelCore/Actor/PacketTunnelActor+Public.swift

+10
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88

99
import Foundation
10+
import WireGuardKitTypes
1011

1112
/**
1213
Public methods for dispatching commands to Actor.
@@ -50,6 +51,15 @@ extension PacketTunnelActor {
5051
commandChannel.send(.notifyKeyRotated(date))
5152
}
5253

54+
/**
55+
Issue a new preshared key to the Actor.
56+
- Parameter key: the new key
57+
*/
58+
59+
nonisolated public func replacePreSharedKey(_ key: PreSharedKey) {
60+
commandChannel.send(.replaceDevicePrivateKey(key))
61+
}
62+
5363
/**
5464
Tell actor to enter error state.
5565
*/

0 commit comments

Comments
 (0)