aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2019-04-09 11:11:28 +0530
committerRoopesh Chander <roop@roopc.net>2019-04-09 11:25:04 +0530
commitcef3957875230874e5c45442b01ca295d373ac41 (patch)
treeab6809aa4bdd5ed78b7a02697126f0e17701100c /WireGuard/WireGuard
parentSwift 5 migration: Fix switch warnings (diff)
downloadwireguard-apple-cef3957875230874e5c45442b01ca295d373ac41.tar.xz
wireguard-apple-cef3957875230874e5c45442b01ca295d373ac41.zip
Swift 5 migration: Handle changes in Data's pointer interface
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'WireGuard/WireGuard')
-rw-r--r--WireGuard/WireGuard/Crypto/Curve25519.swift6
-rw-r--r--WireGuard/WireGuard/Tunnel/TunnelsManager.swift2
-rw-r--r--WireGuard/WireGuard/ZipArchive/ZipArchive.swift2
3 files changed, 5 insertions, 5 deletions
diff --git a/WireGuard/WireGuard/Crypto/Curve25519.swift b/WireGuard/WireGuard/Crypto/Curve25519.swift
index d498a64..602cd2d 100644
--- a/WireGuard/WireGuard/Crypto/Curve25519.swift
+++ b/WireGuard/WireGuard/Crypto/Curve25519.swift
@@ -9,7 +9,7 @@ struct Curve25519 {
static func generatePrivateKey() -> Data {
var privateKey = Data(repeating: 0, count: TunnelConfiguration.keyLength)
- privateKey.withUnsafeMutableBytes { bytes in
+ privateKey.withUnsafeMutableUInt8Bytes { bytes in
curve25519_generate_private_key(bytes)
}
assert(privateKey.count == TunnelConfiguration.keyLength)
@@ -19,8 +19,8 @@ struct Curve25519 {
static func generatePublicKey(fromPrivateKey privateKey: Data) -> Data {
assert(privateKey.count == TunnelConfiguration.keyLength)
var publicKey = Data(repeating: 0, count: TunnelConfiguration.keyLength)
- privateKey.withUnsafeBytes { privateKeyBytes in
- publicKey.withUnsafeMutableBytes { bytes in
+ privateKey.withUnsafeUInt8Bytes { privateKeyBytes in
+ publicKey.withUnsafeMutableUInt8Bytes { bytes in
curve25519_derive_public_key(bytes, privateKeyBytes)
}
}
diff --git a/WireGuard/WireGuard/Tunnel/TunnelsManager.swift b/WireGuard/WireGuard/Tunnel/TunnelsManager.swift
index b0bf0cb..ce8008c 100644
--- a/WireGuard/WireGuard/Tunnel/TunnelsManager.swift
+++ b/WireGuard/WireGuard/Tunnel/TunnelsManager.swift
@@ -486,7 +486,7 @@ class TunnelContainer: NSObject {
completionHandler(tunnelConfiguration)
return
}
- guard nil != (try? session.sendProviderMessage(Data(bytes: [ 0 ]), responseHandler: {
+ guard nil != (try? session.sendProviderMessage(Data([ UInt8(0) ]), responseHandler: {
guard self.status != .inactive, let data = $0, let base = self.tunnelConfiguration, let settings = String(data: data, encoding: .utf8) else {
completionHandler(self.tunnelConfiguration)
return
diff --git a/WireGuard/WireGuard/ZipArchive/ZipArchive.swift b/WireGuard/WireGuard/ZipArchive/ZipArchive.swift
index 2cca880..85623da 100644
--- a/WireGuard/WireGuard/ZipArchive/ZipArchive.swift
+++ b/WireGuard/WireGuard/ZipArchive/ZipArchive.swift
@@ -31,7 +31,7 @@ class ZipArchive {
let fileName = input.fileName
let contents = input.contents
zipOpenNewFileInZip(zipFile, fileName.cString(using: .utf8), nil, nil, 0, nil, 0, nil, Z_DEFLATED, Z_DEFAULT_COMPRESSION)
- contents.withUnsafeBytes { (ptr: UnsafePointer<UInt8>) -> Void in
+ contents.withUnsafeUInt8Bytes { ptr -> Void in
zipWriteInFileInZip(zipFile, UnsafeRawPointer(ptr), UInt32(contents.count))
}
zipCloseFileInZip(zipFile)