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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a60b9c207b41c9617c2ab7a2004431db65a55a66bc32c89565a1640d503434a0
4
- data.tar.gz: d06a5d2775c37d831d298469d594d9681488adb2d30180294973619efa478e88
3
+ metadata.gz: 2e60d499987fb2252b9b82636c745797f8277855e443927bb196476d513b5ad3
4
+ data.tar.gz: 041a7dbdaf46f4c0c9ba32622ac17b59be7058e09f27cbe8033bfbb2705f690a
5
5
  SHA512:
6
- metadata.gz: e63db7eb3b5fbbffa0291308eecd84b55a315986e124cd353bfad0111d86e1bf5072f42a39913a6b5c31730e65159cfe693694ccfd638996b9204d3b7a2a6d24
7
- data.tar.gz: d81718f30c16eb3b504502f437150cc69964375fa0233512edb97d0bf208ee4903bae1911b957f781b6018b52e81eba113e6488ed3e035a417b9d52f9b6f4844
6
+ metadata.gz: 8feed89a1cadb4581f6aadfd842e8f1d2d58e47c0ffe4049cc6ffa3dd0e6c0a4a3fb3df631d39673e2de46e2009165bfdd52dfc4e3b3b319f9b959d70ffc7a83
7
+ data.tar.gz: b2ef55f29b6a5da0143cf220eb3bf0fe03b4381defd68befa9d759fce8f03c91b6d77071667095576541b62dbf8535f55026a9c4442f65316510a3fd97cf63f6
@@ -6,8 +6,7 @@ rvm:
6
6
  - 2.3.3
7
7
  - jruby-9000
8
8
  before_install:
9
- - gem install bundler
10
- - gem update --system
9
+ - gem install bundler -v "~>1.0"
11
10
  install: bin/setup
12
11
  script:
13
12
  - cd ext/argon2_wrap/ && make test && cd ../..
@@ -1,3 +1,6 @@
1
+ ## v2.0.0: 2019-01-06
2
+ - Defaults to Argon2id for new hashes
3
+
1
4
  ## v1.2.0: 2018-11-29
2
5
  - Support for verifying Argon2id format
3
6
 
@@ -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
 
@@ -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
- # Supports argon2i and argon2id formats.
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
@@ -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
@@ -3,5 +3,5 @@
3
3
  # Standard Gem version constant.
4
4
 
5
5
  module Argon2
6
- VERSION = "2.0.0".freeze
6
+ VERSION = "2.0.1".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: 2.0.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-06 00:00:00.000000000 Z
11
+ date: 2019-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi