Skip to content

Commit

Permalink
Move PacketTunnelProvider extension pass the key to the Actor
Browse files Browse the repository at this point in the history
  • Loading branch information
acb-mv authored and buggmagnet committed Mar 18, 2024
1 parent 9b9d36a commit 80aa187
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
10 changes: 5 additions & 5 deletions ios/MullvadTypes/Protocols/PostQuantumKeyReceiving.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import MullvadTypes
import NetworkExtension
import PacketTunnelCore
import TunnelObfuscation
import WireGuardKitTypes

class PacketTunnelProvider: NEPacketTunnelProvider {
private let internalQueue = DispatchQueue(label: "PacketTunnel-internalQueue")
Expand Down Expand Up @@ -275,3 +276,10 @@ extension PacketTunnelProvider {
}
}
}

extension PacketTunnelProvider: PostQuantumKeyReceiving {
func receivePostQuantumKey(_ key: PreSharedKey) {
// TODO: send the key to the actor

Check warning on line 282 in ios/PacketTunnel/PacketTunnelProvider/PacketTunnelProvider.swift

View workflow job for this annotation

GitHub Actions / End to end tests

Todo Violation: TODOs should be resolved (send the key to the actor) (todo)

Check warning on line 282 in ios/PacketTunnel/PacketTunnelProvider/PacketTunnelProvider.swift

View workflow job for this annotation

GitHub Actions / End to end tests

Todo Violation: TODOs should be resolved (send the key to the actor) (todo)
actor.replacePreSharedKey(key)
}
}
10 changes: 10 additions & 0 deletions ios/PacketTunnelCore/Actor/PacketTunnelActor+Public.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import Foundation
import WireGuardKitTypes

/**
Public methods for dispatching commands to Actor.
Expand Down Expand Up @@ -50,6 +51,15 @@ extension PacketTunnelActor {
commandChannel.send(.notifyKeyRotated(date))
}

/**
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.
*/
Expand Down

0 comments on commit 80aa187

Please sign in to comment.