Fix Argon2 for building on device

This commit is contained in:
Nora Trapp 2020-01-21 13:23:42 -08:00
parent 658c9c937c
commit 6da4513f13
3 changed files with 19 additions and 7 deletions

View file

@ -8,7 +8,7 @@
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = "Argon2" s.name = "Argon2"
s.version = "1.0.0" s.version = "1.3.0"
s.summary = "A Swift wrapper around the reference Argon2 implementation." s.summary = "A Swift wrapper around the reference Argon2 implementation."
s.description = <<-DESC s.description = <<-DESC
@ -27,15 +27,26 @@ Pod::Spec.new do |s|
s.source_files = s.source_files =
'ios/src/**/*.swift', 'ios/src/**/*.swift',
'phc-winner-argon2/src/argon2.c', 'phc-winner-argon2/src/argon2.c',
'phc-winner-argon2/src/opt.c',
'phc-winner-argon2/src/core.{c,h}', 'phc-winner-argon2/src/core.{c,h}',
'phc-winner-argon2/src/thread.{c,h}', 'phc-winner-argon2/src/thread.{c,h}',
'phc-winner-argon2/src/encoding.{c,h}', 'phc-winner-argon2/src/encoding.{c,h}',
'phc-winner-argon2/src/blake2/blake2.h', 'phc-winner-argon2/src/blake2/blake2.h',
'phc-winner-argon2/src/blake2/blake2b.c', 'phc-winner-argon2/src/blake2/blake2b.c',
'phc-winner-argon2/src/blake2/blake2-impl.h', 'phc-winner-argon2/src/blake2/blake2-impl.h',
'phc-winner-argon2/src/blake2/blamka-round-opt.h',
'phc-winner-argon2/include/**/*.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.public_header_files = 'phc-winner-argon2/include/**/*.h'
s.test_spec 'Tests' do |test_spec| s.test_spec 'Tests' do |test_spec|

View file

@ -32,7 +32,7 @@ iOS Usage
Add the following line to your Podfile: Add the following line to your Podfile:
```ruby ```ruby
pod 'Argon2', git: 'https://github.com/signalapp/Argon2.git' pod 'Argon2', git: 'https://github.com/signalapp/Argon2.git', submodules: true
``` ```
```swift ```swift
@ -43,6 +43,7 @@ let (rawHash, encodedHash) = Argon2.hash(
password: password, password: password,
salt: salt, salt: salt,
desiredLength: 32, desiredLength: 32,
variant: .id variant: .id,
version: .v13
) )
``` ```

View file

@ -149,7 +149,7 @@ public class Argon2 {
/// - salt: The salt to use for hashing /// - salt: The salt to use for hashing
/// - desiredLength: The desired length of the resulting hash /// - desiredLength: The desired length of the resulting hash
/// - variant: The argon2 variant to use /// - 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. /// - 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. /// - Throws: `Argon2.Error` if the input parameters are invalid or hashing fails.
@ -161,7 +161,7 @@ public class Argon2 {
salt: Data, salt: Data,
desiredLength: Int, desiredLength: Int,
variant: Variant, variant: Variant,
version: Version = .latest version: Version
) throws -> (raw: Data, encoded: String) { ) throws -> (raw: Data, encoded: String) {
let passwordBytes = password.withUnsafeBytes { [UInt8]($0) } let passwordBytes = password.withUnsafeBytes { [UInt8]($0) }
let saltBytes = salt.withUnsafeBytes { [UInt8]($0) } let saltBytes = salt.withUnsafeBytes { [UInt8]($0) }