argon2 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -2
- data/Changelog.md +3 -0
- data/ext/argon2_wrap/test.c +0 -1
- data/lib/argon2.rb +6 -3
- data/lib/argon2/ffi_engine.rb +22 -0
- 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: 2e60d499987fb2252b9b82636c745797f8277855e443927bb196476d513b5ad3
|
4
|
+
data.tar.gz: 041a7dbdaf46f4c0c9ba32622ac17b59be7058e09f27cbe8033bfbb2705f690a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8feed89a1cadb4581f6aadfd842e8f1d2d58e47c0ffe4049cc6ffa3dd0e6c0a4a3fb3df631d39673e2de46e2009165bfdd52dfc4e3b3b319f9b959d70ffc7a83
|
7
|
+
data.tar.gz: b2ef55f29b6a5da0143cf220eb3bf0fe03b4381defd68befa9d759fce8f03c91b6d77071667095576541b62dbf8535f55026a9c4442f65316510a3fd97cf63f6
|
data/.travis.yml
CHANGED
data/Changelog.md
CHANGED
data/ext/argon2_wrap/test.c
CHANGED
@@ -83,7 +83,6 @@ int main()
|
|
83
83
|
pwd = strdup(PWD); \
|
84
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); \
|
87
86
|
assert(memcmp(out2, REF, strlen(REF)) == 0); \
|
88
87
|
printf( "Ref test: %s: PASS\n", REF);
|
89
88
|
|
data/lib/argon2.rb
CHANGED
@@ -32,10 +32,13 @@ module Argon2
|
|
32
32
|
argon2.create(pass)
|
33
33
|
end
|
34
34
|
|
35
|
+
# Supports 1 and argon2id formats.
|
36
|
+
def self.valid_hash?(hash)
|
37
|
+
/^\$argon2i.{,113}/ =~ hash
|
38
|
+
end
|
39
|
+
|
35
40
|
def self.verify_password(pass, hash, secret = nil)
|
36
|
-
|
37
|
-
raise ArgonHashFail, "Invalid hash" unless
|
38
|
-
/^\$argon2i.{,113}/ =~ hash
|
41
|
+
raise ArgonHashFail, "Invalid hash" unless valid_hash?(hash)
|
39
42
|
|
40
43
|
Argon2::Engine.argon2_verify(pass, hash, secret)
|
41
44
|
end
|
data/lib/argon2/ffi_engine.rb
CHANGED
@@ -16,6 +16,14 @@ module Argon2
|
|
16
16
|
:uint, :uint, :uint, :pointer,
|
17
17
|
:size_t, :pointer, :size_t, :pointer, :size_t], :int, :blocking => true
|
18
18
|
|
19
|
+
# int argon2id_hash_raw(const uint32_t t_cost, const uint32_t m_cost,
|
20
|
+
# const uint32_t parallelism, const void *pwd,
|
21
|
+
# const size_t pwdlen, const void *salt,
|
22
|
+
# const size_t saltlen, void *hash, const size_t hashlen)
|
23
|
+
attach_function :argon2id_hash_raw, [
|
24
|
+
:uint, :uint, :uint, :pointer,
|
25
|
+
:size_t, :pointer, :size_t, :pointer, :size_t], :int, :blocking => true
|
26
|
+
|
19
27
|
# void argon2_wrap(uint8_t *out, char *pwd, size_t pwdlen,
|
20
28
|
# uint8_t *salt, uint32_t saltlen, uint32_t t_cost,
|
21
29
|
# uint32_t m_cost, uint32_t lanes,
|
@@ -47,6 +55,20 @@ module Argon2
|
|
47
55
|
result.unpack('H*').join
|
48
56
|
end
|
49
57
|
|
58
|
+
def self.hash_argon2id(password, salt, t_cost, m_cost, out_len = nil)
|
59
|
+
out_len = (out_len || Constants::OUT_LEN).to_i
|
60
|
+
raise ArgonHashFail, "Invalid output length" if out_len < 1
|
61
|
+
result = ''
|
62
|
+
FFI::MemoryPointer.new(:char, out_len) do |buffer|
|
63
|
+
ret = Ext.argon2id_hash_raw(t_cost, 1 << m_cost, 1, password,
|
64
|
+
password.length, salt, salt.length,
|
65
|
+
buffer, out_len)
|
66
|
+
raise ArgonHashFail, ERRORS[ret.abs] unless ret.zero?
|
67
|
+
result = buffer.read_string(out_len)
|
68
|
+
end
|
69
|
+
result.unpack('H*').join
|
70
|
+
end
|
71
|
+
|
50
72
|
def self.hash_argon2id_encode(password, salt, t_cost, m_cost, secret)
|
51
73
|
result = ''
|
52
74
|
secretlen = secret.nil? ? 0 : secret.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: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Technion
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|