From 2afb2244ff978aef0004d28d575ddad1bbb79793 Mon Sep 17 00:00:00 2001 From: Roopesh Chander Date: Thu, 8 Nov 2018 14:48:16 +0530 Subject: [PATCH] Model: Move InterfaceConfiguration.publicKey to Curve25519.swift The code for public key calculation need not be shared with the extension --- WireGuard/Shared/Model/Configuration.swift | 4 ---- WireGuard/WireGuard/Crypto/Curve25519.swift | 6 ++++++ 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) + } +}