File tree 3 files changed +23
-5
lines changed
PacketTunnel/PacketTunnelProvider
3 files changed +23
-5
lines changed Original file line number Diff line number Diff line change 9
9
import Foundation
10
10
import WireGuardKitTypes
11
11
12
- protocol PostQuantumKeyReceiving {
13
- func receivePostQuantumKey( _ key: PrivateKey )
12
+ public protocol PostQuantumKeyReceiving {
13
+ func receivePostQuantumKey( _ key: PreSharedKey )
14
14
}
15
15
16
- enum PostQuantumKeyReceivingError : Error {
16
+ public enum PostQuantumKeyReceivingError : Error {
17
17
case invalidKey
18
18
}
19
19
20
- extension PostQuantumKeyReceiving {
20
+ public extension PostQuantumKeyReceiving {
21
21
func receivePostQuantumKey( _ keyData: Data ) throws {
22
- guard let key = PrivateKey ( rawValue: keyData) else {
22
+ guard let key = PreSharedKey ( rawValue: keyData) else {
23
23
throw PostQuantumKeyReceivingError . invalidKey
24
24
}
25
25
receivePostQuantumKey ( key)
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import MullvadTypes
14
14
import NetworkExtension
15
15
import PacketTunnelCore
16
16
import TunnelObfuscation
17
+ import WireGuardKitTypes
17
18
18
19
class PacketTunnelProvider : NEPacketTunnelProvider {
19
20
private let internalQueue = DispatchQueue ( label: " PacketTunnel-internalQueue " )
@@ -275,3 +276,10 @@ extension PacketTunnelProvider {
275
276
}
276
277
}
277
278
}
279
+
280
+ extension PacketTunnelProvider : PostQuantumKeyReceiving {
281
+ func receivePostQuantumKey( _ key: PreSharedKey ) {
282
+ // TODO: send the key to the actor
283
+ actor . replacePreSharedKey ( key)
284
+ }
285
+ }
Original file line number Diff line number Diff line change 7
7
//
8
8
9
9
import Foundation
10
+ import WireGuardKitTypes
10
11
11
12
/**
12
13
Public methods for dispatching commands to Actor.
@@ -50,6 +51,15 @@ extension PacketTunnelActor {
50
51
commandChannel. send ( . notifyKeyRotated( date) )
51
52
}
52
53
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
+
53
63
/**
54
64
Tell actor to enter error state.
55
65
*/
You can’t perform that action at this time.
0 commit comments