-
Notifications
You must be signed in to change notification settings - Fork 372
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Define the PostQuantumKeyReceiving protocol, along with an extension …
…to decode Data
- Loading branch information
1 parent
b90afeb
commit c6a33d6
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// PostQuantumKeyReceiving.swift | ||
// MullvadTypes | ||
// | ||
// Created by Andrew Bulhak on 2024-03-05. | ||
// Copyright © 2024 Mullvad VPN AB. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import WireGuardKitTypes | ||
|
||
protocol PostQuantumKeyReceiving { | ||
func receivePostQuantumKey(_ key: PrivateKey) | ||
} | ||
|
||
enum PostQuantumKeyReceivingError: Error { | ||
case invalidKey | ||
} | ||
|
||
extension PostQuantumKeyReceiving { | ||
func receivePostQuantumKey(_ keyData: Data) throws { | ||
guard let key = PrivateKey(rawValue: keyData) else { | ||
throw PostQuantumKeyReceivingError.invalidKey | ||
} | ||
receivePostQuantumKey(key) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters