aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2018-11-08 14:48:16 +0530
committerRoopesh Chander <roop@roopc.net>2018-11-08 14:48:25 +0530
commita473dfe4f88055e4ce459a1931c9ce823e4994fc (patch)
tree8c92e607e87d4c8242e4de349341d8953f54dfb9 /WireGuard
parentMove logic to extension: Move PacketTunnelOptionsGenerator to the extension (diff)
downloadwireguard-apple-a473dfe4f88055e4ce459a1931c9ce823e4994fc.tar.xz
wireguard-apple-a473dfe4f88055e4ce459a1931c9ce823e4994fc.zip
Model: Move InterfaceConfiguration.publicKey to Curve25519.swift
The code for public key calculation need not be shared with the extension Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'WireGuard')
-rw-r--r--WireGuard/Shared/Model/Configuration.swift4
-rw-r--r--WireGuard/WireGuard/Crypto/Curve25519.swift6
2 files changed, 6 insertions, 4 deletions
diff --git a/WireGuard/Shared/Model/Configuration.swift b/WireGuard/Shared/Model/Configuration.swift
index 2df363b..cbe4271 100644
--- a/WireGuard/Shared/Model/Configuration.swift
+++ b/WireGuard/Shared/Model/Configuration.swift
@@ -21,10 +21,6 @@ struct InterfaceConfiguration: Codable {
var mtu: UInt16?
var dns: [DNSServer] = []
- var publicKey: Data {
- return Curve25519.generatePublicKey(fromPrivateKey: privateKey)
- }
-
init(name: String, privateKey: Data) {
self.name = name
self.privateKey = privateKey
diff --git a/WireGuard/WireGuard/Crypto/Curve25519.swift b/WireGuard/WireGuard/Crypto/Curve25519.swift
index e0f9c0f..84c35d3 100644
--- a/WireGuard/WireGuard/Crypto/Curve25519.swift
+++ b/WireGuard/WireGuard/Crypto/Curve25519.swift
@@ -25,3 +25,9 @@ struct Curve25519 {
return publicKey
}
}
+
+extension InterfaceConfiguration {
+ var publicKey: Data {
+ return Curve25519.generatePublicKey(fromPrivateKey: privateKey)
+ }
+}