Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conform PacketTunnelProvider to PostQuantumKeyReceiving, updating types... #5967

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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: 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
Loading