argon2 1.2.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a86e0210b4205a94242bc1afce3a43753cf24ae2c262274d48c3bdb9475c03b8
4
- data.tar.gz: 52aa12dec68ee57751a0752fb502441adc37488bf1bfcfe6ebd8250a128dd9c3
3
+ metadata.gz: a60b9c207b41c9617c2ab7a2004431db65a55a66bc32c89565a1640d503434a0
4
+ data.tar.gz: d06a5d2775c37d831d298469d594d9681488adb2d30180294973619efa478e88
5
5
  SHA512:
6
- metadata.gz: bbd74370319320e2b84d6e5ad84f95c512f4d6d7d43ebf804837f47a8073c39d83e0dac72d21dc92586318ee03fc433e651b8ebc670556a6e9ff026ee66647e3
7
- data.tar.gz: 96549bceabc5a7c764afeccd07b937080e9a47fbf9c93c78b34d6d6af60da6eeb6a8a027be0534d44afff4e1af1e59efa50d225c0842efa24156ec1c319d3a6b
6
+ metadata.gz: e63db7eb3b5fbbffa0291308eecd84b55a315986e124cd353bfad0111d86e1bf5072f42a39913a6b5c31730e65159cfe693694ccfd638996b9204d3b7a2a6d24
7
+ data.tar.gz: d81718f30c16eb3b504502f437150cc69964375fa0233512edb97d0bf208ee4903bae1911b957f781b6018b52e81eba113e6488ed3e035a417b9d52f9b6f4844
data/README.md CHANGED
@@ -73,6 +73,8 @@ argon = Argon2::Password.new(t_cost: 2, m_cost: 16, secret: KEY)
73
73
  myhash = argon.create("A password")
74
74
  Argon2::Password.verify_password("A password", myhash, KEY)
75
75
  ```
76
+ ## Version 2.0 - Argon 2id
77
+ Version 2.x upwards will now default to the Argon2id hash format. This is consistent with current recommendations regarding Argon2 usage. It remains capable of verifying existing hashes.
76
78
 
77
79
  ## Important notes regarding version 1.0 upgrade
78
80
  Version 1.0.0 included a major version bump over 0.1.4 due to several breaking changes. The first of these was an API change, which you can read the background on [here](https://github.com/technion/ruby-argon2/issues/9).
@@ -93,7 +93,7 @@ int argon2_wrap(char *out, const char *pwd, size_t pwd_length,
93
93
  uint32_t lanes, uint8_t *secret, size_t secretlen)
94
94
  {
95
95
  return argon2_wrap_version(out, pwd, pwd_length, salt, saltlen,
96
- t_cost, m_cost, lanes, secret, secretlen, ARGON2_VERSION_13, Argon2_i);
96
+ t_cost, m_cost, lanes, secret, secretlen, ARGON2_VERSION_13, Argon2_id);
97
97
  }
98
98
 
99
99
  int wrap_argon2_verify(const char *encoded, const char *pwd,
@@ -81,20 +81,21 @@ int main()
81
81
 
82
82
  #define WRAP_TEST(T, M, PWD, REF) \
83
83
  pwd = strdup(PWD); \
84
- argon2_wrap(out2, pwd, strlen(PWD), salt, sizeof(salt),T, 1<<M, 1, NULL, 0); \
84
+ argon2_wrap(out2, pwd, strlen(PWD), salt, strlen((const char *)salt),T, 1<<M, 1, NULL, 0); \
85
85
  free(pwd); \
86
+ fprintf(stderr,out2); \
86
87
  assert(memcmp(out2, REF, strlen(REF)) == 0); \
87
88
  printf( "Ref test: %s: PASS\n", REF);
88
89
 
89
90
  memcpy(salt, "somesalt", 8);
90
91
  WRAP_TEST(2, 16, "password",
91
- "$argon2i$v=19$m=65536,t=2,p=1$c29tZXNhbHQAAAAAAAAAAA$HH7u+eDpabMCRyL8hkocqfbKINpz+b8/FzGIG+riA54");
92
+ "$argon2id$v=19$m=65536,t=2,p=1$c29tZXNhbHQ$CTFhFdXPJO1aFaMaO6Mm5c8y7cJHAph8ArZWb2GRPPc");
92
93
 
93
94
  WRAP_TEST(2, 8, "password",
94
- "$argon2i$v=19$m=256,t=2,p=1$c29tZXNhbHQAAAAAAAAAAA$3+v51OrdaFn0zGqbsgBD/Z2n4eNr2s27BcpWn0Yyafg");
95
+ "$argon2id$v=19$m=256,t=2,p=1$c29tZXNhbHQ$nf65EOgLrQMR/uIPnA4rEsF5h7TKyQwu9U1bMCHGi/4");
95
96
 
96
97
  WRAP_TEST(2, 16, "differentpassword",
97
- "$argon2i$v=19$m=65536,t=2,p=1$c29tZXNhbHQAAAAAAAAAAA$studfA0SiJUa7EtuHNODXqKafaKsE+b0hVSiaxJxRvk");
98
+ "$argon2id$v=19$m=65536,t=2,p=1$c29tZXNhbHQ$C4TWUs9rDEvq7w3+J4umqA32aWKB1+DSiRuBfYxFj94");
98
99
 
99
100
  ret = wrap_argon2_verify("$argon2i$v=19$m=256,t=2,p=1$c29tZXNhbHQAAAAAAAAAAA$3+v51OrdaFn0zGqbsgBD/Z2n4eNr2s27BcpWn0Yyafg", "password",
100
101
  strlen("password"), NULL, 0);
@@ -22,7 +22,7 @@ module Argon2
22
22
  raise ArgonHashFail, "Invalid password (expected string)" unless
23
23
  pass.is_a?(String)
24
24
 
25
- Argon2::Engine.hash_argon2i_encode(
25
+ Argon2::Engine.hash_argon2id_encode(
26
26
  pass, @salt, @t_cost, @m_cost, @secret)
27
27
  end
28
28
 
@@ -33,19 +33,21 @@ module Argon2
33
33
  # The engine class shields users from the FFI interface.
34
34
  # It is generally not advised to directly use this class.
35
35
  class Engine
36
- def self.hash_argon2i(password, salt, t_cost, m_cost)
36
+ def self.hash_argon2i(password, salt, t_cost, m_cost, out_len = nil)
37
+ out_len = (out_len || Constants::OUT_LEN).to_i
38
+ raise ArgonHashFail, "Invalid output length" if out_len < 1
37
39
  result = ''
38
- FFI::MemoryPointer.new(:char, Constants::OUT_LEN) do |buffer|
40
+ FFI::MemoryPointer.new(:char, out_len) do |buffer|
39
41
  ret = Ext.argon2i_hash_raw(t_cost, 1 << m_cost, 1, password,
40
42
  password.length, salt, salt.length,
41
- buffer, Constants::OUT_LEN)
43
+ buffer, out_len)
42
44
  raise ArgonHashFail, ERRORS[ret.abs] unless ret.zero?
43
- result = buffer.read_string(Constants::OUT_LEN)
45
+ result = buffer.read_string(out_len)
44
46
  end
45
47
  result.unpack('H*').join
46
48
  end
47
49
 
48
- def self.hash_argon2i_encode(password, salt, t_cost, m_cost, secret)
50
+ def self.hash_argon2id_encode(password, salt, t_cost, m_cost, secret)
49
51
  result = ''
50
52
  secretlen = secret.nil? ? 0 : secret.bytesize
51
53
  passwordlen = password.nil? ? 0 : password.bytesize
@@ -3,5 +3,5 @@
3
3
  # Standard Gem version constant.
4
4
 
5
5
  module Argon2
6
- VERSION = "1.2.0".freeze
6
+ VERSION = "2.0.0".freeze
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: argon2
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Technion
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-04 00:00:00.000000000 Z
11
+ date: 2019-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi