From c6c8501f6711e3139da5ad8a55077f256465905a Mon Sep 17 00:00:00 2001 From: edward Date: Mon, 8 Apr 2019 20:07:01 +0800 Subject: [PATCH 1/3] Fit on swift5 --- CommonCrypto/module.modulemap | 4 ---- CommonCrypto/shim.h | 1 - Package.swift | 16 ---------------- 3 files changed, 21 deletions(-) delete mode 100644 CommonCrypto/module.modulemap delete mode 100644 CommonCrypto/shim.h diff --git a/CommonCrypto/module.modulemap b/CommonCrypto/module.modulemap deleted file mode 100644 index b70f7d6..0000000 --- a/CommonCrypto/module.modulemap +++ /dev/null @@ -1,4 +0,0 @@ -module CommonCrypto [system] { - header "shim.h" - export * -} diff --git a/CommonCrypto/shim.h b/CommonCrypto/shim.h deleted file mode 100644 index c332624..0000000 --- a/CommonCrypto/shim.h +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/Package.swift b/Package.swift index 5ba29b4..d2868d9 100644 --- a/Package.swift +++ b/Package.swift @@ -2,22 +2,6 @@ import PackageDescription - -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) -let dependencies = [ - Package.Dependency.package(url: "https://github.com/kylef-archive/CommonCrypto.git", from: "1.0.0"), -] -let excludes = ["HMAC/HMACCryptoSwift.swift"] -let targetDependencies: [Target.Dependency] = [] -#else -let dependencies = [ - Package.Dependency.package(url: "https://github.com/krzyzanowskim/CryptoSwift.git", from: "0.8.0"), -] -let excludes = ["HMAC/HMACCommonCrypto.swift"] -let targetDependencies: [Target.Dependency] = ["CryptoSwift"] -#endif - - let package = Package( name: "JWT", products: [ From df25d8f1f360f103d826293110139e3a93ce1b19 Mon Sep 17 00:00:00 2001 From: edward Date: Mon, 8 Apr 2019 20:08:09 +0800 Subject: [PATCH 2/3] Revert "Fit on swift5" This reverts commit c6c8501f6711e3139da5ad8a55077f256465905a. --- CommonCrypto/module.modulemap | 4 ++++ CommonCrypto/shim.h | 1 + Package.swift | 16 ++++++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 CommonCrypto/module.modulemap create mode 100644 CommonCrypto/shim.h diff --git a/CommonCrypto/module.modulemap b/CommonCrypto/module.modulemap new file mode 100644 index 0000000..b70f7d6 --- /dev/null +++ b/CommonCrypto/module.modulemap @@ -0,0 +1,4 @@ +module CommonCrypto [system] { + header "shim.h" + export * +} diff --git a/CommonCrypto/shim.h b/CommonCrypto/shim.h new file mode 100644 index 0000000..c332624 --- /dev/null +++ b/CommonCrypto/shim.h @@ -0,0 +1 @@ +#include diff --git a/Package.swift b/Package.swift index d2868d9..5ba29b4 100644 --- a/Package.swift +++ b/Package.swift @@ -2,6 +2,22 @@ import PackageDescription + +#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) +let dependencies = [ + Package.Dependency.package(url: "https://github.com/kylef-archive/CommonCrypto.git", from: "1.0.0"), +] +let excludes = ["HMAC/HMACCryptoSwift.swift"] +let targetDependencies: [Target.Dependency] = [] +#else +let dependencies = [ + Package.Dependency.package(url: "https://github.com/krzyzanowskim/CryptoSwift.git", from: "0.8.0"), +] +let excludes = ["HMAC/HMACCommonCrypto.swift"] +let targetDependencies: [Target.Dependency] = ["CryptoSwift"] +#endif + + let package = Package( name: "JWT", products: [ From f8ef984eb75e243adf2df14d147e3b6a4e37a53a Mon Sep 17 00:00:00 2001 From: edward Date: Mon, 8 Apr 2019 20:19:56 +0800 Subject: [PATCH 3/3] fit on Xcode10.2 --- CommonCrypto/module.modulemap | 4 ---- CommonCrypto/shim.h | 1 - Package.swift | 18 +----------------- Sources/JWA/HMAC/HMACCommonCrypto.swift | 2 +- 4 files changed, 2 insertions(+), 23 deletions(-) delete mode 100644 CommonCrypto/module.modulemap delete mode 100644 CommonCrypto/shim.h diff --git a/CommonCrypto/module.modulemap b/CommonCrypto/module.modulemap deleted file mode 100644 index b70f7d6..0000000 --- a/CommonCrypto/module.modulemap +++ /dev/null @@ -1,4 +0,0 @@ -module CommonCrypto [system] { - header "shim.h" - export * -} diff --git a/CommonCrypto/shim.h b/CommonCrypto/shim.h deleted file mode 100644 index c332624..0000000 --- a/CommonCrypto/shim.h +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/Package.swift b/Package.swift index 5ba29b4..afc4362 100644 --- a/Package.swift +++ b/Package.swift @@ -1,22 +1,6 @@ // swift-tools-version:4.0 -import PackageDescription - - -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) -let dependencies = [ - Package.Dependency.package(url: "https://github.com/kylef-archive/CommonCrypto.git", from: "1.0.0"), -] -let excludes = ["HMAC/HMACCryptoSwift.swift"] -let targetDependencies: [Target.Dependency] = [] -#else -let dependencies = [ - Package.Dependency.package(url: "https://github.com/krzyzanowskim/CryptoSwift.git", from: "0.8.0"), -] -let excludes = ["HMAC/HMACCommonCrypto.swift"] -let targetDependencies: [Target.Dependency] = ["CryptoSwift"] -#endif - +import PackageDescriptio let package = Package( name: "JWT", diff --git a/Sources/JWA/HMAC/HMACCommonCrypto.swift b/Sources/JWA/HMAC/HMACCommonCrypto.swift index 299fd8a..0bf0184 100644 --- a/Sources/JWA/HMAC/HMACCommonCrypto.swift +++ b/Sources/JWA/HMAC/HMACCommonCrypto.swift @@ -5,7 +5,7 @@ import CommonCrypto extension HMACAlgorithm: SignAlgorithm, VerifyAlgorithm { public func sign(_ message: Data) -> Data { let context = UnsafeMutablePointer.allocate(capacity: 1) - defer { context.deallocate(capacity: 1) } + defer {context.deallocate()} key.withUnsafeBytes() { (buffer: UnsafePointer) in CCHmacInit(context, hash.commonCryptoAlgorithm, buffer, size_t(key.count))