From 6da4513f13d60b8ae00348284d02f714c481d4d4 Mon Sep 17 00:00:00 2001 From: Nora Trapp Date: Tue, 21 Jan 2020 13:23:42 -0800 Subject: [PATCH] Fix Argon2 for building on device --- Argon2.podspec | 17 ++++++++++++++--- README.md | 5 +++-- ios/src/Argon2.swift | 4 ++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Argon2.podspec b/Argon2.podspec index 46ad7c0..043185d 100644 --- a/Argon2.podspec +++ b/Argon2.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = "Argon2" - s.version = "1.0.0" + s.version = "1.3.0" s.summary = "A Swift wrapper around the reference Argon2 implementation." s.description = <<-DESC @@ -27,15 +27,26 @@ Pod::Spec.new do |s| s.source_files = 'ios/src/**/*.swift', 'phc-winner-argon2/src/argon2.c', - 'phc-winner-argon2/src/opt.c', 'phc-winner-argon2/src/core.{c,h}', 'phc-winner-argon2/src/thread.{c,h}', 'phc-winner-argon2/src/encoding.{c,h}', 'phc-winner-argon2/src/blake2/blake2.h', 'phc-winner-argon2/src/blake2/blake2b.c', 'phc-winner-argon2/src/blake2/blake2-impl.h', - 'phc-winner-argon2/src/blake2/blamka-round-opt.h', 'phc-winner-argon2/include/**/*.h' + s.osx.source_files = + 'phc-winner-argon2/src/opt.c', + 'phc-winner-argon2/src/blake2/blamka-round-opt.h' + s.ios.source_files = + 'phc-winner-argon2/src/ref.c', + 'phc-winner-argon2/src/blake2/blamka-round-ref.h' + s.tvos.source_files = + 'phc-winner-argon2/src/ref.c', + 'phc-winner-argon2/src/blake2/blamka-round-ref.h' + s.watchos.source_files = + 'phc-winner-argon2/src/ref.c', + 'phc-winner-argon2/src/blake2/blamka-round-ref.h' + s.public_header_files = 'phc-winner-argon2/include/**/*.h' s.test_spec 'Tests' do |test_spec| diff --git a/README.md b/README.md index 38433bf..19d7af1 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ iOS Usage Add the following line to your Podfile: ```ruby -pod 'Argon2', git: 'https://github.com/signalapp/Argon2.git' +pod 'Argon2', git: 'https://github.com/signalapp/Argon2.git', submodules: true ``` ```swift @@ -43,6 +43,7 @@ let (rawHash, encodedHash) = Argon2.hash( password: password, salt: salt, desiredLength: 32, - variant: .id + variant: .id, + version: .v13 ) ``` diff --git a/ios/src/Argon2.swift b/ios/src/Argon2.swift index 1866ebe..fe7c6f4 100644 --- a/ios/src/Argon2.swift +++ b/ios/src/Argon2.swift @@ -149,7 +149,7 @@ public class Argon2 { /// - salt: The salt to use for hashing /// - desiredLength: The desired length of the resulting hash /// - variant: The argon2 variant to use - /// - version: The argon2 version to use, defaults to `latest` + /// - version: The argon2 version to use /// /// - Returns: A tuple containing the raw hash value and encoded hash for the given input parameters. /// - Throws: `Argon2.Error` if the input parameters are invalid or hashing fails. @@ -161,7 +161,7 @@ public class Argon2 { salt: Data, desiredLength: Int, variant: Variant, - version: Version = .latest + version: Version ) throws -> (raw: Data, encoded: String) { let passwordBytes = password.withUnsafeBytes { [UInt8]($0) } let saltBytes = salt.withUnsafeBytes { [UInt8]($0) }