argon2 1.1.0 → 1.1.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
  SHA1:
3
- metadata.gz: 4db0f3233c1faa582f56da4f70611158490822e6
4
- data.tar.gz: 7261aba06880156bf240786b4b12016f7834d2fa
3
+ metadata.gz: 26929d636f73b4f3c98bde188d48b24b131917fd
4
+ data.tar.gz: 462fc7ac63ca0eae48f305a558ba672f1ebb4e07
5
5
  SHA512:
6
- metadata.gz: f55caacf26f22e15c4a1ab91deca56b65556bc52e0203b78110f48afd9fa94bc398c7b116adbad916309fddd00fe237d16647b162f4b4d3db0cdea44501d93b4
7
- data.tar.gz: 27e7638366fc322d518c7ffaeb48b35b10426c1253794c67cf0e32dcc9ef01ffeaafdfe32f8c2b0ef53ab998319eb94d08d0c7d29012862c63fbdab1e944d2df
6
+ metadata.gz: 30aebe1344c7deba53ae02e8fcbb64f8b5146b5d294e7b9f00988743db773df4e7cad406f4649019cbfe76ecb67e11cf138f7992b833cb20b1c11f0f25e1497f
7
+ data.tar.gz: 4de3263e33b95fd4ed997e1d413ee5446c2008ae4653c390aee0dd8170bfcd3b96f37ea03ef5e667148aff13b496a921368ef40d7b49dfd585e66f5b7a69e2fa
@@ -1,14 +1,13 @@
1
- # This configuration was generated by
2
- #. `rubocop --auto-gen-config`
1
+
3
2
  Metrics/AbcSize:
4
- Max: 18
3
+ Max: 20
5
4
  Metrics/CyclomaticComplexity:
6
5
  Enabled: false
7
6
  Metrics/PerceivedComplexity:
8
7
  Enabled: false
9
- Style/MutableConstant:
10
- Exclude:
11
- - 'test/key_test.rb'
8
+ #Style/MutableConstant:
9
+ # Exclude:
10
+ # - 'test/key_test.rb'
12
11
 
13
12
  Metrics/LineLength:
14
13
  Max: 160
@@ -60,3 +59,9 @@ Style/StringLiterals:
60
59
 
61
60
  Style/WordArray:
62
61
  MinSize: 33
62
+
63
+ Style/MultilineMethodCallBraceLayout:
64
+ Exclude:
65
+ - 'lib/argon2.rb'
66
+ - 'test/low_level_test.rb'
67
+
@@ -1,4 +1,10 @@
1
- ## v1.0.0: 2015-03-07
1
+ ## v1.1.1: 2016-09-21
2
+ - Fix verify against externally created hashes with different salt lengths
3
+
4
+ ## v1.1.0: ?
5
+ - Backward compat with version 1.0 hashes
6
+
7
+ ## v1.0.0: 2016-03-07
2
8
  - API change - 'new' becomes 'create'
3
9
  - Version 1.3 of the Argon2 algorithm pulled in
4
10
 
data/README.md CHANGED
@@ -11,7 +11,7 @@ This Ruby Gem provides FFI bindings, and a simplified interface, to the Argon2 a
11
11
 
12
12
  This project has several key tenants to its design:
13
13
 
14
- * The reference Argon2 implementation is to be used "unaltered". To ensure compliance with this goal, and encourage regular updates from upstream, the upstrema library is implemented as a git submodule, and is intended to stay that way.
14
+ * The reference Argon2 implementation is to be used "unaltered". To ensure compliance with this goal, and encourage regular updates from upstream, the upstream library is implemented as a git submodule, and is intended to stay that way.
15
15
  * The FFI interface is kept as slim as possible, with wrapper classes preferred to implementing context structs in FFI
16
16
  * Security and maintainability take top priority. This can have an impact on platform support. A PR that contains platform specific code paths is unlikely to be accepted.
17
17
  * Tested platforms are MRI Ruby 2.2, 2.3 and JRuby 9000. No assertions are made on other platforms.
data/Rakefile CHANGED
@@ -7,6 +7,7 @@ RuboCop::RakeTask.new
7
7
  Rake::TestTask.new(:test) do |t|
8
8
  t.libs << "test"
9
9
  t.libs << "lib"
10
+ t.warning = true
10
11
  t.test_files = FileList['test/**/*_test.rb']
11
12
  end
12
13
 
@@ -20,7 +20,7 @@
20
20
  #define THREADS_DEF 1
21
21
  #define OUT_LEN 32
22
22
  #define SALT_LEN 16
23
- #define ENCODE_LEN 112
23
+ #define ENCODE_LEN 96 /* Does not include SALT LEN */
24
24
 
25
25
  /* Workaround for https://github.com/technion/ruby-argon2/issues/8. Hopefully temporary */
26
26
  static int wrap_compare(const uint8_t *b1, const uint8_t *b2, size_t len) {
@@ -34,8 +34,8 @@ static int wrap_compare(const uint8_t *b1, const uint8_t *b2, size_t len) {
34
34
  }
35
35
 
36
36
  unsigned int argon2_wrap(char *out, const char *pwd, size_t pwd_length,
37
- uint8_t *salt, uint32_t t_cost, uint32_t m_cost, uint32_t lanes,
38
- uint8_t *secret, size_t secretlen)
37
+ uint8_t *salt, uint32_t saltlen, uint32_t t_cost, uint32_t m_cost,
38
+ uint32_t lanes, uint8_t *secret, size_t secretlen)
39
39
  {
40
40
  uint8_t hash[OUT_LEN];
41
41
  argon2_context context;
@@ -53,7 +53,7 @@ unsigned int argon2_wrap(char *out, const char *pwd, size_t pwd_length,
53
53
  context.pwd = (uint8_t *)pwd;
54
54
  context.pwdlen = pwd_length;
55
55
  context.salt = salt;
56
- context.saltlen = SALT_LEN;
56
+ context.saltlen = saltlen;
57
57
  context.secret = secret;
58
58
  context.secretlen = secretlen;
59
59
  context.ad = NULL;
@@ -71,7 +71,7 @@ unsigned int argon2_wrap(char *out, const char *pwd, size_t pwd_length,
71
71
  if (result != ARGON2_OK)
72
72
  return result;
73
73
 
74
- encode_string(out, ENCODE_LEN, &context, Argon2_i);
74
+ encode_string(out, ENCODE_LEN + saltlen, &context, Argon2_i);
75
75
  return ARGON2_OK;
76
76
  }
77
77
 
@@ -81,7 +81,7 @@ int wrap_argon2_verify(const char *encoded, const char *pwd,
81
81
  {
82
82
  argon2_context ctx;
83
83
  int ret;
84
- char out[ENCODE_LEN];
84
+ char *out;
85
85
  memset(&ctx, 0, sizeof(argon2_context));
86
86
  size_t encoded_len;
87
87
 
@@ -108,7 +108,15 @@ int wrap_argon2_verify(const char *encoded, const char *pwd,
108
108
  return ARGON2_DECODING_FAIL;
109
109
  }
110
110
 
111
- ret = argon2_wrap(out, pwd, pwdlen, ctx.salt, ctx.t_cost,
111
+ out = malloc(ENCODE_LEN + ctx.saltlen);
112
+ if(!out) {
113
+ free(ctx.ad);
114
+ free(ctx.salt);
115
+ free(ctx.out);
116
+ return ARGON2_DECODING_FAIL;
117
+ }
118
+
119
+ ret = argon2_wrap(out, pwd, pwdlen, ctx.salt, ctx.saltlen, ctx.t_cost,
112
120
  ctx.m_cost, ctx.lanes, secret, secretlen);
113
121
 
114
122
  free(ctx.ad);
@@ -117,9 +125,11 @@ int wrap_argon2_verify(const char *encoded, const char *pwd,
117
125
  if (ret != ARGON2_OK || wrap_compare((uint8_t*)out, (uint8_t*)encoded,
118
126
  strlen(encoded))) {
119
127
  free(ctx.out);
128
+ free(out);
120
129
  return ARGON2_DECODING_FAIL;
121
130
  }
122
131
  free(ctx.out);
132
+ free(out);
123
133
 
124
134
  return ARGON2_OK;
125
135
  }
@@ -37,8 +37,8 @@ int argon2i_hash_raw(const uint32_t t_cost, const uint32_t m_cost,
37
37
  */
38
38
 
39
39
  unsigned int argon2_wrap(char *out, const char *pwd, size_t pwd_length,
40
- uint8_t *salt, uint32_t t_cost, uint32_t m_cost, uint32_t lanes,
41
- uint8_t *secret, size_t secretlen);
40
+ uint8_t *salt, uint32_t saltlen, uint32_t t_cost, uint32_t m_cost,
41
+ uint32_t lanes, uint8_t *secret, size_t secretlen);
42
42
 
43
43
  int wrap_argon2_verify(const char *encoded, const char *pwd,
44
44
  const size_t pwdlen,
@@ -81,7 +81,7 @@ 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, T, 1<<M, 1, NULL, 0); \
84
+ argon2_wrap(out2, pwd, strlen(PWD), salt, sizeof(salt),T, 1<<M, 1, NULL, 0); \
85
85
  free(pwd); \
86
86
  assert(memcmp(out2, REF, strlen(REF)) == 0); \
87
87
  printf( "Ref test: %s: PASS\n", REF);
@@ -16,12 +16,12 @@ module Argon2
16
16
  :uint, :uint, :uint, :pointer,
17
17
  :size_t, :pointer, :size_t, :pointer, :size_t], :int, :blocking => true
18
18
 
19
- # void argon2_wrap(uint8_t *out, char *pwd, size_it pwdlen,
20
- # uint8_t *salt, uint32_t t_cost,
19
+ # void argon2_wrap(uint8_t *out, char *pwd, size_t pwdlen,
20
+ # uint8_t *salt, uint32_t saltlen, uint32_t t_cost,
21
21
  # uint32_t m_cost, uint32_t lanes,
22
22
  # uint8_t *secret, uint32_t secretlen)
23
23
  attach_function :argon2_wrap, [
24
- :pointer, :pointer, :size_t, :pointer, :uint,
24
+ :pointer, :pointer, :size_t, :pointer, :uint, :uint,
25
25
  :uint, :uint, :pointer, :size_t], :uint, :blocking => true
26
26
 
27
27
  # int argon2i_verify(const char *encoded, const void *pwd,
@@ -54,7 +54,7 @@ module Argon2
54
54
  end
55
55
  FFI::MemoryPointer.new(:char, Constants::ENCODE_LEN) do |buffer|
56
56
  ret = Ext.argon2_wrap(buffer, password, passwordlen,
57
- salt, t_cost, (1 << m_cost),
57
+ salt, salt.length, t_cost, (1 << m_cost),
58
58
  1, secret, secretlen)
59
59
  raise ArgonHashFail, ERRORS[ret.abs] unless ret == 0
60
60
  result = buffer.read_string(Constants::ENCODE_LEN)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  # Standard Gem version constant.
3
3
  module Argon2
4
- VERSION = "1.1.0".freeze
4
+ VERSION = "1.1.1".freeze
5
5
  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.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Technion
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-01 00:00:00.000000000 Z
11
+ date: 2016-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -146,6 +146,7 @@ files:
146
146
  - ext/argon2_wrap/extconf.rb
147
147
  - ext/argon2_wrap/libargon2_wrap.so
148
148
  - ext/argon2_wrap/test.c
149
+ - ext/argon2_wrap/tests
149
150
  - ext/phc-winner-argon2/.git
150
151
  - ext/phc-winner-argon2/.gitattributes
151
152
  - ext/phc-winner-argon2/.gitignore