From 38a6ba7091bb41e26cb3fcfa9e4bb7cb3e7d6a1d Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Fri, 8 Feb 2019 16:15:10 +0100 Subject: KeyEncoding: rename file to match extension filename style Signed-off-by: Jason A. Donenfeld --- WireGuard/Shared/Model/Data+KeyEncoding.swift | 54 +++++++++++++++++++++++++++ WireGuard/Shared/Model/Key.swift | 54 --------------------------- WireGuard/WireGuard.xcodeproj/project.pbxproj | 20 +++++----- 3 files changed, 64 insertions(+), 64 deletions(-) create mode 100644 WireGuard/Shared/Model/Data+KeyEncoding.swift delete mode 100644 WireGuard/Shared/Model/Key.swift (limited to 'WireGuard') diff --git a/WireGuard/Shared/Model/Data+KeyEncoding.swift b/WireGuard/Shared/Model/Data+KeyEncoding.swift new file mode 100644 index 0000000..a1abdd7 --- /dev/null +++ b/WireGuard/Shared/Model/Data+KeyEncoding.swift @@ -0,0 +1,54 @@ +// SPDX-License-Identifier: MIT +// Copyright © 2018-2019 WireGuard LLC. All Rights Reserved. + +import Foundation + +extension Data { + func isKey() -> Bool { + return self.count == WG_KEY_LEN + } + + func hexKey() -> String? { + if self.count != WG_KEY_LEN { + return nil + } + var out = Data(repeating: 0, count: Int(WG_KEY_LEN_HEX)) + out.withUnsafeMutableBytes { outBytes in + self.withUnsafeBytes { inBytes in + key_to_hex(outBytes, inBytes) + } + } + out.removeLast() + return String(data: out, encoding: .ascii) + } + + init?(hexKey hexString: String) { + self.init(repeating: 0, count: Int(WG_KEY_LEN)) + + if !self.withUnsafeMutableBytes { key_from_hex($0, hexString) } { + return nil + } + } + + func base64Key() -> String? { + if self.count != WG_KEY_LEN { + return nil + } + var out = Data(repeating: 0, count: Int(WG_KEY_LEN_BASE64)) + out.withUnsafeMutableBytes { outBytes in + self.withUnsafeBytes { inBytes in + key_to_base64(outBytes, inBytes) + } + } + out.removeLast() + return String(data: out, encoding: .ascii) + } + + init?(base64Key base64String: String) { + self.init(repeating: 0, count: Int(WG_KEY_LEN)) + + if !self.withUnsafeMutableBytes { key_from_base64($0, base64String) } { + return nil + } + } +} diff --git a/WireGuard/Shared/Model/Key.swift b/WireGuard/Shared/Model/Key.swift deleted file mode 100644 index a1abdd7..0000000 --- a/WireGuard/Shared/Model/Key.swift +++ /dev/null @@ -1,54 +0,0 @@ -// SPDX-License-Identifier: MIT -// Copyright © 2018-2019 WireGuard LLC. All Rights Reserved. - -import Foundation - -extension Data { - func isKey() -> Bool { - return self.count == WG_KEY_LEN - } - - func hexKey() -> String? { - if self.count != WG_KEY_LEN { - return nil - } - var out = Data(repeating: 0, count: Int(WG_KEY_LEN_HEX)) - out.withUnsafeMutableBytes { outBytes in - self.withUnsafeBytes { inBytes in - key_to_hex(outBytes, inBytes) - } - } - out.removeLast() - return String(data: out, encoding: .ascii) - } - - init?(hexKey hexString: String) { - self.init(repeating: 0, count: Int(WG_KEY_LEN)) - - if !self.withUnsafeMutableBytes { key_from_hex($0, hexString) } { - return nil - } - } - - func base64Key() -> String? { - if self.count != WG_KEY_LEN { - return nil - } - var out = Data(repeating: 0, count: Int(WG_KEY_LEN_BASE64)) - out.withUnsafeMutableBytes { outBytes in - self.withUnsafeBytes { inBytes in - key_to_base64(outBytes, inBytes) - } - } - out.removeLast() - return String(data: out, encoding: .ascii) - } - - init?(base64Key base64String: String) { - self.init(repeating: 0, count: Int(WG_KEY_LEN)) - - if !self.withUnsafeMutableBytes { key_from_base64($0, base64String) } { - return nil - } - } -} diff --git a/WireGuard/WireGuard.xcodeproj/project.pbxproj b/WireGuard/WireGuard.xcodeproj/project.pbxproj index 3176d40..7c057b3 100644 --- a/WireGuard/WireGuard.xcodeproj/project.pbxproj +++ b/WireGuard/WireGuard.xcodeproj/project.pbxproj @@ -29,10 +29,10 @@ 5FF7B96521CC95FA00A7DD74 /* PeerConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5FF7B96421CC95FA00A7DD74 /* PeerConfiguration.swift */; }; 5FF7B96621CC95FA00A7DD74 /* PeerConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5FF7B96421CC95FA00A7DD74 /* PeerConfiguration.swift */; }; 6B586C51220CACB600427C51 /* NetworkExtension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6FF4AC462120B9E0002C96EB /* NetworkExtension.framework */; }; - 6B586C53220CBA6D00427C51 /* Key.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B586C52220CBA6D00427C51 /* Key.swift */; }; - 6B586C54220CBA6D00427C51 /* Key.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B586C52220CBA6D00427C51 /* Key.swift */; }; - 6B586C55220CBA6D00427C51 /* Key.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B586C52220CBA6D00427C51 /* Key.swift */; }; - 6B586C56220CBA6D00427C51 /* Key.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B586C52220CBA6D00427C51 /* Key.swift */; }; + 6B586C53220CBA6D00427C51 /* Data+KeyEncoding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B586C52220CBA6D00427C51 /* Data+KeyEncoding.swift */; }; + 6B586C54220CBA6D00427C51 /* Data+KeyEncoding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B586C52220CBA6D00427C51 /* Data+KeyEncoding.swift */; }; + 6B586C55220CBA6D00427C51 /* Data+KeyEncoding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B586C52220CBA6D00427C51 /* Data+KeyEncoding.swift */; }; + 6B586C56220CBA6D00427C51 /* Data+KeyEncoding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B586C52220CBA6D00427C51 /* Data+KeyEncoding.swift */; }; 6B5C5E27220A48D30024272E /* Keychain.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B5C5E26220A48D30024272E /* Keychain.swift */; }; 6B5C5E28220A48D30024272E /* Keychain.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B5C5E26220A48D30024272E /* Keychain.swift */; }; 6B5C5E29220A48D30024272E /* Keychain.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6B5C5E26220A48D30024272E /* Keychain.swift */; }; @@ -248,7 +248,7 @@ 5F9696AF21CD7128008063FE /* TunnelConfiguration+WgQuickConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TunnelConfiguration+WgQuickConfig.swift"; sourceTree = ""; }; 5FF7B96121CC95DE00A7DD74 /* InterfaceConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InterfaceConfiguration.swift; sourceTree = ""; }; 5FF7B96421CC95FA00A7DD74 /* PeerConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PeerConfiguration.swift; sourceTree = ""; }; - 6B586C52220CBA6D00427C51 /* Key.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Key.swift; sourceTree = ""; }; + 6B586C52220CBA6D00427C51 /* Data+KeyEncoding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Data+KeyEncoding.swift"; sourceTree = ""; }; 6B5C5E26220A48D30024272E /* Keychain.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Keychain.swift; sourceTree = ""; }; 6B62E45E220A6FA900EF34A6 /* PrivateDataConfirmation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrivateDataConfirmation.swift; sourceTree = ""; }; 6B707D8321F918D4000A8F73 /* TunnelConfiguration+UapiConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TunnelConfiguration+UapiConfig.swift"; sourceTree = ""; }; @@ -501,7 +501,7 @@ 6F628C3E217F3413003482A3 /* DNSServer.swift */, 5FF7B96121CC95DE00A7DD74 /* InterfaceConfiguration.swift */, 5FF7B96421CC95FA00A7DD74 /* PeerConfiguration.swift */, - 6B586C52220CBA6D00427C51 /* Key.swift */, + 6B586C52220CBA6D00427C51 /* Data+KeyEncoding.swift */, ); path = Model; sourceTree = ""; @@ -1101,7 +1101,7 @@ 5FF7B96621CC95FA00A7DD74 /* PeerConfiguration.swift in Sources */, 5F9696AE21CD6F72008063FE /* String+ArrayConversion.swift in Sources */, 6FFA5D8F2194370D0001E2F7 /* IPAddressRange.swift in Sources */, - 6B586C54220CBA6D00427C51 /* Key.swift in Sources */, + 6B586C54220CBA6D00427C51 /* Data+KeyEncoding.swift in Sources */, 6FFA5D902194370D0001E2F7 /* Endpoint.swift in Sources */, 5FF7B96321CC95DE00A7DD74 /* InterfaceConfiguration.swift in Sources */, 6FFA5D9321943BC90001E2F7 /* DNSResolver.swift in Sources */, @@ -1146,7 +1146,7 @@ 6FCD99B121E0EDA900BA4C82 /* TunnelEditViewController.swift in Sources */, 6FB1BDCA21D50F1700A991BF /* x25519.c in Sources */, 6FB1BDCB21D50F1700A991BF /* Curve25519.swift in Sources */, - 6B586C55220CBA6D00427C51 /* Key.swift in Sources */, + 6B586C55220CBA6D00427C51 /* Data+KeyEncoding.swift in Sources */, 6F9B582921E8D6D100544D02 /* PopupRow.swift in Sources */, 6FB1BDBB21D50F0200A991BF /* Localizable.strings in Sources */, 6FB1BDBC21D50F0200A991BF /* ringlogger.c in Sources */, @@ -1193,7 +1193,7 @@ 6FB1BDA621D4F53300A991BF /* NETunnelProviderProtocol+Extension.swift in Sources */, 6FB1BDA721D4F53300A991BF /* String+ArrayConversion.swift in Sources */, 6FB1BDA921D4F53300A991BF /* TunnelConfiguration.swift in Sources */, - 6B586C56220CBA6D00427C51 /* Key.swift in Sources */, + 6B586C56220CBA6D00427C51 /* Data+KeyEncoding.swift in Sources */, 6FB1BDAA21D4F53300A991BF /* IPAddressRange.swift in Sources */, 6FB1BDAB21D4F53300A991BF /* Endpoint.swift in Sources */, 6FB1BDAC21D4F53300A991BF /* DNSServer.swift in Sources */, @@ -1216,7 +1216,7 @@ 5F45417D21C1B23600994C13 /* UITableViewCell+Reuse.swift in Sources */, 5F45419221C2D55800994C13 /* CheckmarkCell.swift in Sources */, 6FE254FF219C60290028284D /* ZipExporter.swift in Sources */, - 6B586C53220CBA6D00427C51 /* Key.swift in Sources */, + 6B586C53220CBA6D00427C51 /* Data+KeyEncoding.swift in Sources */, 6F693A562179E556008551C1 /* Endpoint.swift in Sources */, 6FDEF7E62185EFB200D8FBF6 /* QRScanViewController.swift in Sources */, 6FFA5D952194454A0001E2F7 /* NETunnelProviderProtocol+Extension.swift in Sources */, -- cgit v1.2.3-59-g8ed1b