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 +4 -4
- data/README.md +2 -0
- data/ext/argon2_wrap/argon_wrap.c +1 -1
- data/ext/argon2_wrap/test.c +5 -4
- data/lib/argon2.rb +1 -1
- data/lib/argon2/ffi_engine.rb +7 -5
- data/lib/argon2/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a60b9c207b41c9617c2ab7a2004431db65a55a66bc32c89565a1640d503434a0
|
4
|
+
data.tar.gz: d06a5d2775c37d831d298469d594d9681488adb2d30180294973619efa478e88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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,
|
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,
|
data/ext/argon2_wrap/test.c
CHANGED
@@ -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,
|
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
|
-
"$
|
92
|
+
"$argon2id$v=19$m=65536,t=2,p=1$c29tZXNhbHQ$CTFhFdXPJO1aFaMaO6Mm5c8y7cJHAph8ArZWb2GRPPc");
|
92
93
|
|
93
94
|
WRAP_TEST(2, 8, "password",
|
94
|
-
"$
|
95
|
+
"$argon2id$v=19$m=256,t=2,p=1$c29tZXNhbHQ$nf65EOgLrQMR/uIPnA4rEsF5h7TKyQwu9U1bMCHGi/4");
|
95
96
|
|
96
97
|
WRAP_TEST(2, 16, "differentpassword",
|
97
|
-
"$
|
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);
|
data/lib/argon2.rb
CHANGED
data/lib/argon2/ffi_engine.rb
CHANGED
@@ -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,
|
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,
|
43
|
+
buffer, out_len)
|
42
44
|
raise ArgonHashFail, ERRORS[ret.abs] unless ret.zero?
|
43
|
-
result = buffer.read_string(
|
45
|
+
result = buffer.read_string(out_len)
|
44
46
|
end
|
45
47
|
result.unpack('H*').join
|
46
48
|
end
|
47
49
|
|
48
|
-
def self.
|
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
|
data/lib/argon2/version.rb
CHANGED
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:
|
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:
|
11
|
+
date: 2019-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|