From 9ed386c40a128ba4f225adeaad188080120a5d90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zsolt=20Va=CC=81radi?= Date: Wed, 13 Apr 2022 07:46:38 +0200 Subject: [PATCH 1/6] Replace SecCopyRandomBytes with Swift 4.2+ random According to its [documentation](https://developer.apple.com/documentation/swift/systemrandomnumbergenerator) and of the functions underneath, this new default is also producing cryptographically secure random values. It also supports Linux. --- Sources/Swift/Salt.swift | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/Sources/Swift/Salt.swift b/Sources/Swift/Salt.swift index 7deb149..1d5472d 100644 --- a/Sources/Swift/Salt.swift +++ b/Sources/Swift/Salt.swift @@ -5,7 +5,6 @@ import Foundation -import Security /// A class to wrap around Salts in argon2. allowing cryptographically secure generation of salts as well as utilization of premade salts public class Salt { @@ -30,15 +29,7 @@ public class Salt { - Returns: A `Salt` object containing a random byte array of the specified length */ public static func newSalt(length: Int = 16) -> Salt { - // Set a byte array - var bytes = [UInt8](repeating: 0, count: length) - // Set random generated numbers to the byte array - let status = SecRandomCopyBytes(kSecRandomDefault, bytes.count, &bytes) - // Ensure the copy was a success - if status != errSecSuccess { - fatalError("SecRandomCopyBytes failed with error code: \(status)") - } - // Return the salt + let bytes = Array((0.. Date: Wed, 13 Apr 2022 12:47:53 -0400 Subject: [PATCH 2/6] bump version for 1.0.3 --- Argon2Swift.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Argon2Swift.podspec b/Argon2Swift.podspec index 29a607c..78f0388 100644 --- a/Argon2Swift.podspec +++ b/Argon2Swift.podspec @@ -16,7 +16,7 @@ Pod::Spec.new do |spec| # spec.name = "Argon2Swift" - spec.version = "1.0.2" + spec.version = "1.0.3" spec.summary = "A Swift wrapper around the Argon2 reference implementation." spec.swift_version = "5.0" From 2f5799c234b7ceeefdf631b709a47afacc5704d2 Mon Sep 17 00:00:00 2001 From: Tejas Mehta Date: Wed, 13 Apr 2022 12:55:02 -0400 Subject: [PATCH 3/6] fix a typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 219995c..402c5d2 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ pod Argon2Swift ## Installation (SPM) -Argon2Swift can be installed via SPM (Swift Package Mangeer) by adding the following to your depencencies: +Argon2Swift can be installed via SPM (Swift Package Manger) by adding the following to your depencencies: ```swift .package(url: "https://github.com/tmthecoder/Argon2Swift.git", .branch("main")) From 7ca94d38e843ccb06cf47fe807cf9e0363f911dc Mon Sep 17 00:00:00 2001 From: Tejas Mehta Date: Tue, 14 Mar 2023 14:30:17 -0400 Subject: [PATCH 4/6] Make bytes public in salt (getter) --- Sources/Swift/Salt.swift | 2 +- Tests/XCTestManifests.swift | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 Tests/XCTestManifests.swift diff --git a/Sources/Swift/Salt.swift b/Sources/Swift/Salt.swift index 1d5472d..38db24f 100644 --- a/Sources/Swift/Salt.swift +++ b/Sources/Swift/Salt.swift @@ -10,7 +10,7 @@ import Foundation public class Salt { /// The byte-array that the salt class wraps around - let bytes: Data + public let bytes: Data /** Initializes a new `Salt` object with the provided byte array diff --git a/Tests/XCTestManifests.swift b/Tests/XCTestManifests.swift new file mode 100644 index 0000000..17311b6 --- /dev/null +++ b/Tests/XCTestManifests.swift @@ -0,0 +1,20 @@ +#if !canImport(ObjectiveC) +import XCTest + +extension Argon2SwiftTests { + // DO NOT MODIFY: This is autogenerated, use: + // `swift test --generate-linuxmain` + // to regenerate. + static let __allTests__Argon2SwiftTests = [ + ("testArgon2d", testArgon2d), + ("testArgon2i", testArgon2i), + ("testArgon2id", testArgon2id), + ] +} + +public func __allTests() -> [XCTestCaseEntry] { + return [ + testCase(Argon2SwiftTests.__allTests__Argon2SwiftTests), + ] +} +#endif From a6cd1dd8afe660ab6254da72566c2b7baf163e2e Mon Sep 17 00:00:00 2001 From: Tejas Mehta Date: Tue, 14 Mar 2023 14:34:01 -0400 Subject: [PATCH 5/6] bump version --- Argon2Swift.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Argon2Swift.podspec b/Argon2Swift.podspec index 78f0388..263d30c 100644 --- a/Argon2Swift.podspec +++ b/Argon2Swift.podspec @@ -16,7 +16,7 @@ Pod::Spec.new do |spec| # spec.name = "Argon2Swift" - spec.version = "1.0.3" + spec.version = "1.0.4" spec.summary = "A Swift wrapper around the Argon2 reference implementation." spec.swift_version = "5.0" From 53543623fefe68461b7eeea03d7f96677c2fd76d Mon Sep 17 00:00:00 2001 From: Tejas Mehta Date: Wed, 15 Mar 2023 18:21:49 -0400 Subject: [PATCH 6/6] Fix pod failure --- Argon2Swift.podspec | 2 +- Argon2Swift.xcodeproj/project.pbxproj | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Argon2Swift.podspec b/Argon2Swift.podspec index 263d30c..9bcea10 100644 --- a/Argon2Swift.podspec +++ b/Argon2Swift.podspec @@ -81,7 +81,7 @@ Pod::Spec.new do |spec| 'Sources/Argon2/src/blake2-impl.h' spec.source_files = - 'Sources/**/*.swift', + 'Sources/Swift/*.swift', 'Sources/Argon2Swift.h', 'Sources/Argon2/src/argon2.c', 'Sources/Argon2/src/core.{c,h}', diff --git a/Argon2Swift.xcodeproj/project.pbxproj b/Argon2Swift.xcodeproj/project.pbxproj index 3dbdd96..4462dd2 100644 --- a/Argon2Swift.xcodeproj/project.pbxproj +++ b/Argon2Swift.xcodeproj/project.pbxproj @@ -22,6 +22,7 @@ /* Begin PBXBuildFile section */ A44E754B25EC75ED00137A6F /* core.c in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_14 /* core.c */; }; + A47CA85929C0F79B00871A20 /* Package.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_6 /* Package.swift */; }; OBJ_44 /* argon2.c in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_10 /* argon2.c */; }; OBJ_46 /* blake2b.c in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_13 /* blake2b.c */; }; OBJ_48 /* encoding.c in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_15 /* encoding.c */; }; @@ -35,7 +36,6 @@ OBJ_66 /* Argon2Version.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_31 /* Argon2Version.swift */; }; OBJ_67 /* Salt.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_32 /* Salt.swift */; }; OBJ_69 /* Argon2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = "Argon2Swift::Argon2::Product" /* Argon2.framework */; }; - OBJ_76 /* Package.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_6 /* Package.swift */; }; OBJ_87 /* Argon2SwiftTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_34 /* Argon2SwiftTests.swift */; }; OBJ_89 /* Argon2Swift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = "Argon2Swift::Argon2Swift::Product" /* Argon2Swift.framework */; }; OBJ_90 /* Argon2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = "Argon2Swift::Argon2::Product" /* Argon2.framework */; }; @@ -92,7 +92,7 @@ OBJ_31 /* Argon2Version.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Argon2Version.swift; sourceTree = ""; }; OBJ_32 /* Salt.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Salt.swift; sourceTree = ""; }; OBJ_34 /* Argon2SwiftTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Argon2SwiftTests.swift; sourceTree = ""; }; - OBJ_6 /* Package.swift */ = {isa = PBXFileReference; explicitFileType = sourcecode.swift; path = Package.swift; sourceTree = ""; }; + OBJ_6 /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Package.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -354,7 +354,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 0; files = ( - OBJ_76 /* Package.swift in Sources */, + A47CA85929C0F79B00871A20 /* Package.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; };