argon2 2.0.1 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +70 -0
  3. data/.rubocop.yml +178 -5
  4. data/Changelog.md +7 -0
  5. data/Gemfile +2 -0
  6. data/README.md +29 -17
  7. data/Rakefile +2 -0
  8. data/Steepfile +16 -0
  9. data/argon2.gemspec +13 -7
  10. data/bin/console +5 -4
  11. data/bin/setup +6 -2
  12. data/bin/test +10 -0
  13. data/ext/argon2_wrap/argon_wrap.c +6 -0
  14. data/ext/argon2_wrap/extconf.rb +1 -0
  15. data/ext/argon2_wrap/libargon2_wrap.so +0 -0
  16. data/ext/phc-winner-argon2/.gitignore +1 -0
  17. data/ext/phc-winner-argon2/Argon2.sln +2 -4
  18. data/ext/phc-winner-argon2/LICENSE +2 -2
  19. data/ext/phc-winner-argon2/Makefile +86 -18
  20. data/ext/phc-winner-argon2/README.md +3 -1
  21. data/ext/phc-winner-argon2/include/argon2.h +3 -3
  22. data/ext/phc-winner-argon2/libargon2.pc.in +18 -0
  23. data/ext/phc-winner-argon2/src/argon2.c +2 -2
  24. data/ext/phc-winner-argon2/src/bench.c +4 -4
  25. data/ext/phc-winner-argon2/src/blake2/blake2-impl.h +3 -3
  26. data/ext/phc-winner-argon2/src/blake2/blake2.h +2 -2
  27. data/ext/phc-winner-argon2/src/blake2/blake2b.c +2 -2
  28. data/ext/phc-winner-argon2/src/blake2/blamka-round-opt.h +2 -2
  29. data/ext/phc-winner-argon2/src/blake2/blamka-round-ref.h +2 -2
  30. data/ext/phc-winner-argon2/src/core.c +20 -6
  31. data/ext/phc-winner-argon2/src/core.h +2 -2
  32. data/ext/phc-winner-argon2/src/encoding.c +2 -2
  33. data/ext/phc-winner-argon2/src/encoding.h +2 -2
  34. data/ext/phc-winner-argon2/src/genkat.c +9 -3
  35. data/ext/phc-winner-argon2/src/genkat.h +2 -2
  36. data/ext/phc-winner-argon2/src/opt.c +2 -2
  37. data/ext/phc-winner-argon2/src/ref.c +2 -2
  38. data/ext/phc-winner-argon2/src/run.c +2 -2
  39. data/ext/phc-winner-argon2/src/test.c +2 -2
  40. data/ext/phc-winner-argon2/src/thread.c +2 -2
  41. data/ext/phc-winner-argon2/src/thread.h +2 -2
  42. data/ext/phc-winner-argon2/vs2015/Argon2Opt/Argon2Opt.vcxproj +11 -6
  43. data/ext/phc-winner-argon2/vs2015/Argon2OptBench/Argon2OptBench.vcxproj +11 -6
  44. data/ext/phc-winner-argon2/vs2015/Argon2OptDll/Argon2OptDll.vcxproj +11 -6
  45. data/ext/phc-winner-argon2/vs2015/Argon2OptGenKAT/Argon2OptGenKAT.vcxproj +11 -6
  46. data/ext/phc-winner-argon2/vs2015/Argon2OptTestCI/Argon2OptTestCI.vcxproj +16 -8
  47. data/ext/phc-winner-argon2/vs2015/Argon2Ref/Argon2Ref.vcxproj +25 -8
  48. data/ext/phc-winner-argon2/vs2015/Argon2RefBench/Argon2RefBench.vcxproj +11 -6
  49. data/ext/phc-winner-argon2/vs2015/Argon2RefDll/Argon2RefDll.vcxproj +11 -6
  50. data/ext/phc-winner-argon2/vs2015/Argon2RefGenKAT/Argon2RefGenKAT.vcxproj +11 -6
  51. data/ext/phc-winner-argon2/vs2015/Argon2RefTestCI/Argon2RefTestCI.vcxproj +11 -6
  52. data/lib/argon2/ffi_engine.rb +34 -24
  53. data/lib/argon2/hash_format.rb +49 -0
  54. data/lib/argon2/version.rb +1 -1
  55. data/lib/argon2.rb +15 -7
  56. data/sig/argon2.rbs +16 -0
  57. data/sig/constants.rbs +8 -0
  58. data/sig/version.rbs +4 -0
  59. metadata +59 -39
  60. data/.travis.yml +0 -13
  61. data/ext/argon2_wrap/tests +0 -0
  62. data/ext/phc-winner-argon2/libargon2.pc +0 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2e60d499987fb2252b9b82636c745797f8277855e443927bb196476d513b5ad3
4
- data.tar.gz: 041a7dbdaf46f4c0c9ba32622ac17b59be7058e09f27cbe8033bfbb2705f690a
3
+ metadata.gz: 933cdf134b0ac4110cda1cd9a8108a75c0dc6d80e6d2cb68446d93b1898f298a
4
+ data.tar.gz: bcb1c0d25d2a074c59ad5002e2078d0aa344480022f9a658eb297dcbd16b1eb6
5
5
  SHA512:
6
- metadata.gz: 8feed89a1cadb4581f6aadfd842e8f1d2d58e47c0ffe4049cc6ffa3dd0e6c0a4a3fb3df631d39673e2de46e2009165bfdd52dfc4e3b3b319f9b959d70ffc7a83
7
- data.tar.gz: b2ef55f29b6a5da0143cf220eb3bf0fe03b4381defd68befa9d759fce8f03c91b6d77071667095576541b62dbf8535f55026a9c4442f65316510a3fd97cf63f6
6
+ metadata.gz: d17d3f5c0a9162dca09db8ab7a9926becc50ace4527d2ad705db80d44ffdc528d3110853885ee5c042b5142c5cd619fd8c93d6a7dec75fc70d41fbb40661f259
7
+ data.tar.gz: 91fb841e70a470bf760871690c216ae4f305442a063b4c5a5c861fe97510c226db5f8db92cc65e8a93ea459fd42ac735bd216e2dfb333fc334f1e3f21cba3bbf
@@ -0,0 +1,70 @@
1
+ name: Test Suite
2
+
3
+ # Run against all commits and pull requests.
4
+ on: [ push, pull_request ]
5
+
6
+ jobs:
7
+ test_matrix:
8
+
9
+ strategy:
10
+ fail-fast: false
11
+ matrix:
12
+ os:
13
+ - ubuntu
14
+ - macos
15
+ ruby:
16
+ - 2.6
17
+ - 2.7
18
+ - 3.0
19
+ - head
20
+
21
+ runs-on: ${{ matrix.os }}-latest
22
+
23
+ env:
24
+ TEST_CHECKS: 100
25
+
26
+ steps:
27
+ - uses: actions/checkout@v2
28
+ - name: Set up Ruby
29
+ uses: ruby/setup-ruby@v1
30
+ with:
31
+ ruby-version: ${{ matrix.ruby }}
32
+ bundler-cache: true
33
+ - name: Build Argon2 C library
34
+ run: bin/setup
35
+ - name: Test Argon2 C library
36
+ run: bin/test
37
+ - name: Run tests
38
+ run: bundle exec rake test
39
+ - name: Coveralls Parallel
40
+ uses: coverallsapp/github-action@master
41
+ with:
42
+ github-token: ${{ secrets.GITHUB_TOKEN }}
43
+ flag-name: run-${{ matrix.ruby-version }}
44
+ parallel: true
45
+
46
+ rubocop:
47
+
48
+ runs-on: ubuntu-latest
49
+
50
+ steps:
51
+ - uses: actions/checkout@v2
52
+ - name: Set up Ruby
53
+ uses: ruby/setup-ruby@v1
54
+ with:
55
+ ruby-version: 3.0
56
+ bundler-cache: true
57
+ - name: Run rubocop
58
+ run: bundle exec rake rubocop
59
+
60
+ finish:
61
+ runs-on: ubuntu-latest
62
+ needs: [ test_matrix, rubocop ]
63
+ steps:
64
+ - name: Coveralls Finished
65
+ uses: coverallsapp/github-action@master
66
+ with:
67
+ github-token: ${{ secrets.GITHUB_TOKEN }}
68
+ parallel-finished: true
69
+ - name: Wait for status checks
70
+ run: echo "All Green!"
data/.rubocop.yml CHANGED
@@ -1,20 +1,31 @@
1
-
2
1
  Metrics/AbcSize:
3
2
  Max: 20
3
+
4
4
  Metrics/CyclomaticComplexity:
5
5
  Enabled: false
6
+
6
7
  Metrics/PerceivedComplexity:
7
8
  Enabled: false
8
- Metrics/LineLength:
9
+
10
+ Metrics/ParameterLists:
11
+ Max: 5
12
+ Exclude:
13
+ - 'lib/argon2/ffi_engine.rb'
14
+
15
+ Layout/LineLength:
9
16
  Max: 160
17
+ Exclude:
18
+ - 'test/low_level_test.rb'
10
19
 
11
20
  Metrics/MethodLength:
12
21
  Max: 24
22
+ Exclude:
23
+ - 'test/low_level_test.rb'
13
24
 
14
- Layout/AlignParameters:
25
+ Layout/ParameterAlignment:
15
26
  Enabled: false
16
27
 
17
- Layout/AlignArray:
28
+ Layout/ArrayAlignment:
18
29
  Enabled: false
19
30
 
20
31
  # Configuration parameters: Exclude.
@@ -37,7 +48,7 @@ Style/HashSyntax:
37
48
 
38
49
  # Offense count: 1
39
50
  # Cop supports --auto-correct.
40
- Layout/IndentArray:
51
+ Layout/FirstArrayElementIndentation:
41
52
  Exclude:
42
53
  - 'lib/argon2/errors.rb'
43
54
 
@@ -61,3 +72,165 @@ Layout/MultilineMethodCallBraceLayout:
61
72
  - 'lib/argon2.rb'
62
73
  - 'test/low_level_test.rb'
63
74
 
75
+ Gemspec/RequiredRubyVersion:
76
+ Enabled: false
77
+
78
+ Layout/BeginEndAlignment: # (new in 0.91)
79
+ Enabled: true
80
+ Layout/EmptyLinesAroundAttributeAccessor: # (new in 0.83)
81
+ Enabled: true
82
+ Layout/SpaceAroundMethodCallOperator: # (new in 0.82)
83
+ Enabled: true
84
+ Lint/BinaryOperatorWithIdenticalOperands: # (new in 0.89)
85
+ Enabled: true
86
+ Lint/ConstantDefinitionInBlock: # (new in 0.91)
87
+ Enabled: true
88
+ Lint/DeprecatedOpenSSLConstant: # (new in 0.84)
89
+ Enabled: true
90
+ Lint/DuplicateElsifCondition: # (new in 0.88)
91
+ Enabled: true
92
+ Lint/DuplicateRequire: # (new in 0.90)
93
+ Enabled: true
94
+ Lint/DuplicateRescueException: # (new in 0.89)
95
+ Enabled: true
96
+ Lint/EmptyConditionalBody: # (new in 0.89)
97
+ Enabled: true
98
+ Lint/EmptyFile: # (new in 0.90)
99
+ Enabled: true
100
+ Lint/FloatComparison: # (new in 0.89)
101
+ Enabled: true
102
+ Lint/IdentityComparison: # (new in 0.91)
103
+ Enabled: true
104
+ Lint/MissingSuper: # (new in 0.89)
105
+ Enabled: true
106
+ Lint/MixedRegexpCaptureTypes: # (new in 0.85)
107
+ Enabled: true
108
+ Lint/OutOfRangeRegexpRef: # (new in 0.89)
109
+ Enabled: true
110
+ Lint/RaiseException: # (new in 0.81)
111
+ Enabled: true
112
+ Lint/SelfAssignment: # (new in 0.89)
113
+ Enabled: true
114
+ Lint/StructNewOverride: # (new in 0.81)
115
+ Enabled: true
116
+ Lint/TopLevelReturnWithArgument: # (new in 0.89)
117
+ Enabled: true
118
+ Lint/TrailingCommaInAttributeDeclaration: # (new in 0.90)
119
+ Enabled: true
120
+ Lint/UnreachableLoop: # (new in 0.89)
121
+ Enabled: true
122
+ Lint/UselessMethodDefinition: # (new in 0.90)
123
+ Enabled: true
124
+ Lint/UselessTimes: # (new in 0.91)
125
+ Enabled: true
126
+ Style/AccessorGrouping: # (new in 0.87)
127
+ Enabled: true
128
+ Style/ArrayCoercion: # (new in 0.88)
129
+ Enabled: true
130
+ Style/BisectedAttrAccessor: # (new in 0.87)
131
+ Enabled: true
132
+ Style/CaseLikeIf: # (new in 0.88)
133
+ Enabled: true
134
+ Style/CombinableLoops: # (new in 0.90)
135
+ Enabled: true
136
+ Style/ExplicitBlockArgument: # (new in 0.89)
137
+ Enabled: true
138
+ Style/ExponentialNotation: # (new in 0.82)
139
+ Enabled: true
140
+ Style/GlobalStdStream: # (new in 0.89)
141
+ Enabled: true
142
+ Style/HashAsLastArrayItem: # (new in 0.88)
143
+ Enabled: true
144
+ Style/HashEachMethods: # (new in 0.80)
145
+ Enabled: true
146
+ Style/HashLikeCase: # (new in 0.88)
147
+ Enabled: true
148
+ Style/HashTransformKeys: # (new in 0.80)
149
+ Enabled: true
150
+ Style/HashTransformValues: # (new in 0.80)
151
+ Enabled: true
152
+ Style/KeywordParametersOrder: # (new in 0.90)
153
+ Enabled: true
154
+ Style/OptionalBooleanParameter: # (new in 0.89)
155
+ Enabled: true
156
+ Style/RedundantAssignment: # (new in 0.87)
157
+ Enabled: true
158
+ Style/RedundantFetchBlock: # (new in 0.86)
159
+ Enabled: true
160
+ Style/RedundantFileExtensionInRequire: # (new in 0.88)
161
+ Enabled: true
162
+ Style/RedundantRegexpCharacterClass: # (new in 0.85)
163
+ Enabled: true
164
+ Style/RedundantRegexpEscape: # (new in 0.85)
165
+ Enabled: true
166
+ Style/RedundantSelfAssignment: # (new in 0.90)
167
+ Enabled: true
168
+ Style/SingleArgumentDig: # (new in 0.89)
169
+ Enabled: true
170
+ Style/SlicingWithRange: # (new in 0.83)
171
+ Enabled: true
172
+ Style/SoleNestedConditional: # (new in 0.89)
173
+ Enabled: true
174
+ Style/StringConcatenation: # (new in 0.89)
175
+ Enabled: true
176
+
177
+ Layout/SpaceBeforeBrackets: # (new in 1.7)
178
+ Enabled: true
179
+ Lint/AmbiguousAssignment: # (new in 1.7)
180
+ Enabled: true
181
+ Lint/DuplicateBranch: # (new in 1.3)
182
+ Enabled: true
183
+ Lint/DuplicateRegexpCharacterClassElement: # (new in 1.1)
184
+ Enabled: true
185
+ Lint/EmptyBlock: # (new in 1.1)
186
+ Enabled: true
187
+ Lint/EmptyClass: # (new in 1.3)
188
+ Enabled: true
189
+ Lint/NoReturnInBeginEndBlocks: # (new in 1.2)
190
+ Enabled: true
191
+ Lint/ToEnumArguments: # (new in 1.1)
192
+ Enabled: true
193
+ Lint/UnexpectedBlockArity: # (new in 1.5)
194
+ Enabled: true
195
+ Lint/UnmodifiedReduceAccumulator: # (new in 1.1)
196
+ Enabled: true
197
+ Style/ArgumentsForwarding: # (new in 1.1)
198
+ Enabled: true
199
+ Style/CollectionCompact: # (new in 1.2)
200
+ Enabled: true
201
+ Style/DocumentDynamicEvalDefinition: # (new in 1.1)
202
+ Enabled: true
203
+ Style/HashExcept: # (new in 1.7)
204
+ Enabled: true
205
+ Style/NegatedIfElseCondition: # (new in 1.2)
206
+ Enabled: true
207
+ Style/NilLambda: # (new in 1.3)
208
+ Enabled: true
209
+ Style/RedundantArgument: # (new in 1.4)
210
+ Enabled: true
211
+ Style/SwapValues: # (new in 1.1)
212
+ Enabled: true
213
+ Gemspec/DateAssignment: # (new in 1.10)
214
+ Enabled: true
215
+ Lint/DeprecatedConstants: # (new in 1.8)
216
+ Enabled: true
217
+ Lint/LambdaWithoutLiteralBlock: # (new in 1.8)
218
+ Enabled: true
219
+ Lint/NumberedParameterAssignment: # (new in 1.9)
220
+ Enabled: true
221
+ Lint/OrAssignmentToConstant: # (new in 1.9)
222
+ Enabled: true
223
+ Lint/RedundantDirGlobSort: # (new in 1.8)
224
+ Enabled: true
225
+ Lint/SymbolConversion: # (new in 1.9)
226
+ Enabled: true
227
+ Lint/TripleQuotes: # (new in 1.9)
228
+ Enabled: true
229
+ Style/EndlessMethod: # (new in 1.8)
230
+ Enabled: true
231
+ Style/HashConversion: # (new in 1.10)
232
+ Enabled: true
233
+ Style/IfWithBooleanLiteralBranches: # (new in 1.9)
234
+ Enabled: true
235
+ Style/StringChars: # (new in 1.12)
236
+ Enabled: true
data/Changelog.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## v2.1.0: 2021-04-09
2
+ - Introduce RBS types
3
+ - Expose p parameter
4
+
5
+ ## v2.0.3: 2021-01-02
6
+ - Address potential memory leak. Unlikely to be exploitable.
7
+
1
8
  ## v2.0.0: 2019-01-06
2
9
  - Defaults to Argon2id for new hashes
3
10
 
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in argon2.gemspec
data/README.md CHANGED
@@ -2,23 +2,21 @@
2
2
 
3
3
  This Ruby Gem provides FFI bindings, and a simplified interface, to the Argon2 algorithm. [Argon2](https://github.com/P-H-C/phc-winner-argon2) is the official winner of the Password Hashing Competition, a several year project to identify a successor to bcrypt/PBKDF/scrypt methods of securely storing passwords. This is an independant project and not official from the PHC team.
4
4
 
5
-
6
- [![Build Status](https://travis-ci.org/technion/ruby-argon2.svg?branch=master)](https://travis-ci.org/technion/ruby-argon2)
5
+ ![Build Status](https://github.com/technion/ruby-argon2/workflows/Test%20Suite/badge.svg)
7
6
  [![Code Climate](https://codeclimate.com/github/technion/ruby-argon2/badges/gpa.svg)](https://codeclimate.com/github/technion/ruby-argon2)
8
7
  [![Coverage Status](https://coveralls.io/repos/github/technion/ruby-argon2/badge.svg)](https://coveralls.io/github/technion/ruby-argon2)
9
8
 
10
9
  ## Design
11
10
 
12
- This project has several key tenants to its design:
11
+ This project has several key tenets to its design:
13
12
 
14
13
  * 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
14
  * The FFI interface is kept as slim as possible, with wrapper classes preferred to implementing context structs in FFI
16
15
  * 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
16
  * Tested platforms are MRI Ruby 2.2, 2.3 and JRuby 9000. No assertions are made on other platforms.
18
17
  * Errors from the C interface are raised as Exceptions. There are a lot of exception classes, but they tend to relate to things like very broken input, and code bugs. Calls to this library should generally not require a rescue.
19
- * Test suits should aim for 100% code coverage.
18
+ * Test suites should aim for 100% code coverage.
20
19
  * Default work values should not be considered constants. I will increase them from time to time.
21
- * Not exposing the threads parameter is a design choice. I believe there is significant risk, and minimal gain in using a value other than '1'. Four threads on a four core box completely ties up the entire server to process one user logon. If you want more security, increase m_cost.
22
20
  * Many Rubocop errors have been disabled, but any commit should avoid new alerts or demonstrate their necessity.
23
21
 
24
22
  ## Usage
@@ -32,7 +30,7 @@ require 'argon2'
32
30
  To generate a hash using specific time and memory cost:
33
31
 
34
32
  ```ruby
35
- hasher = Argon2::Password.new(t_cost: 2, m_cost: 16)
33
+ hasher = Argon2::Password.new(t_cost: 2, m_cost: 16, p_cost: 1)
36
34
  hasher.create("password")
37
35
  => "$argon2i$v=19$m=65536,t=2,p=1$jL7lLEAjDN+pY2cG1N8D2g$iwj1ueduCvm6B9YVjBSnAHu+6mKzqGmDW745ALR38Uo"
38
36
  ```
@@ -44,8 +42,7 @@ hasher = Argon2::Password.new
44
42
  hasher.create("password")
45
43
  ```
46
44
 
47
- If you follow this pattern, it is important to create a new `Argon2::Password` every time you generate a hash, in order to ensure a unique salt. See [issue 23](https://github.com/technion/ruby-argon2/issues/23) for more information.
48
- Alternatively, use this shotcut:
45
+ Alternatively, use this shortcut:
49
46
 
50
47
  ```ruby
51
48
  Argon2::Password.create("password")
@@ -73,6 +70,17 @@ argon = Argon2::Password.new(t_cost: 2, m_cost: 16, secret: KEY)
73
70
  myhash = argon.create("A password")
74
71
  Argon2::Password.verify_password("A password", myhash, KEY)
75
72
  ```
73
+ ## Ruby 3 Types
74
+ I am now shipping signatures in sig/. The following command sets up a testing interface.
75
+ ```sh
76
+ RBS_TEST_TARGET="Argon2::*" bundle exec ruby -r rbs/test/setup bin/console
77
+ ```
78
+ You should also be able to pass Steep checks:
79
+ ```sh
80
+ steep check
81
+ ```
82
+ These tools will need to be installed manually at this time and will be added to Gemfiles after much further testing.
83
+
76
84
  ## Version 2.0 - Argon 2id
77
85
  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.
78
86
 
@@ -81,7 +89,7 @@ Version 1.0.0 included a major version bump over 0.1.4 due to several breaking c
81
89
 
82
90
  The second of these is that the reference Argon2 implementation introduced an algorithm change, which produces a hash which is not backwards compatible. This is documented on [this PR on the C library](https://github.com/P-H-C/phc-winner-argon2/pull/115). This was a regrettable requirement to address a security concern in the algorithm itself. The two versions of the Argon2 algorithm are numbered 1.0 and 1.3 respectively.
83
91
 
84
- Shortly after this, version 1.0.0 of this gem was released with this breaking change, supporting only Argon2 v1.3. Further time later, the official encoding format was updated, with a spec that included the version number, and the library introduced backward compatibility. This should remove the likelyhood of such breaking changes in future. Version 1.1.0 will silently introduce the current version number in hashes, in order to avoid a further compatibility break.
92
+ Shortly after this, version 1.0.0 of this gem was released with this breaking change, supporting only Argon2 v1.3. Further time later, the official encoding format was updated, with a spec that included the version number, and the library introduced backward compatibility. This should remove the likelihood of such breaking changes in future.
85
93
 
86
94
 
87
95
  ## Platform Issues
@@ -92,6 +100,8 @@ Windows is not. Nobody anywhere has the resources to support Ruby FFI code on Wi
92
100
 
93
101
  grsec introduces certain challenges. Please see [documentation here](https://github.com/technion/ruby-argon2/issues/15).
94
102
 
103
+ See the .travis.yml file to see currently tested and supported Ruby versions.
104
+
95
105
  ## RubyDocs documentation
96
106
 
97
107
  [The usual URL](http://www.rubydoc.info/gems/argon2) will provide detailed documentation.
@@ -109,7 +119,7 @@ Although the low level C contains support for "secure memory wipe", any code hit
109
119
 
110
120
  ### Work maximums may be tighter than reference
111
121
 
112
- The reference implementation is aimed to provide secure hashing for many years. This implementation doesn't want you to DoS yourself in the meantime. Accordingly, some limits artificial limits exist on work powers. This gem can be much more agile in raising these as technology progresses.
122
+ The reference implementation is aimed to provide secure hashing for many years. This implementation doesn't want you to DoS yourself in the meantime. Accordingly, some artificial limits exist on work powers. This gem can be much more agile in raising these as technology progresses.
113
123
 
114
124
  ### Salts in general
115
125
 
@@ -122,17 +132,19 @@ Any form of contribution is appreciated, however, please review [CONTRIBUTING.md
122
132
 
123
133
  ## Building locally/Tests
124
134
 
125
- To build the gem locally, you will need to checkout the submodule and build it manually:
135
+ To build the gem locally, you will need to run the setup script:
136
+
137
+ ```shell
138
+ ./bin/setup
139
+ ```
140
+
141
+ You can test that the Argon2 C library was properly imported by running the C test suite:
126
142
 
127
143
  ```shell
128
- git submodule update --init --recursive
129
- bundle install
130
- cd ext/argon2_wrap/
131
- make
132
- cd ../..
144
+ ./bin/test
133
145
  ```
134
146
 
135
- The test harness includes a property based test. To more strenuously perform this test, you can tune the iterations parameter:
147
+ The ruby wrapper test suite includes a property based test. To more strenuously perform this test, you can tune the iterations parameter:
136
148
 
137
149
  ```shell
138
150
  TEST_CHECKS=10000 bundle exec rake test
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
4
  require "rake/testtask"
3
5
  require 'rubocop/rake_task'
data/Steepfile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ target :lib do
4
+ signature "sig"
5
+
6
+ check "argon2.rb"
7
+ check "lib" # Directory name
8
+ ignore "lib/argon2/ffi_engine.rb"
9
+ ignore "lib/argon2/errors.rb"
10
+ end
11
+
12
+ target :spec do
13
+ signature "sig", "sig-private"
14
+
15
+ check "spec"
16
+ end
data/argon2.gemspec CHANGED
@@ -1,4 +1,6 @@
1
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
2
4
 
3
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
6
  require 'argon2/version'
@@ -9,6 +11,8 @@ Gem::Specification.new do |spec|
9
11
  spec.authors = ["Technion"]
10
12
  spec.email = ["technion@lolware.net"]
11
13
 
14
+ spec.required_ruby_version = '>= 2.6.0'
15
+
12
16
  spec.summary = 'Argon2 Password hashing binding'
13
17
  spec.description = 'Argon2 FFI binding'
14
18
  spec.homepage = 'https://github.com/technion/ruby-argon2'
@@ -20,13 +24,15 @@ Gem::Specification.new do |spec|
20
24
  spec.bindir = "exe"
21
25
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
26
  spec.require_paths = ["lib"]
23
- spec.add_dependency 'ffi', '~> 1.9'
24
- spec.add_dependency 'ffi-compiler', '~> 0.1'
27
+ spec.add_dependency 'ffi', '~> 1.14'
28
+ spec.add_dependency 'ffi-compiler', '~> 1.0'
25
29
 
26
- spec.add_development_dependency "bundler", '~> 1.10', '>= 1.10.5'
27
- spec.add_development_dependency "coveralls", '~> 0.8'
30
+ spec.add_development_dependency "bundler", '~> 2.0'
28
31
  spec.add_development_dependency "minitest", '~> 5.8'
29
- spec.add_development_dependency "rake", '~> 10.4', '>= 10.4.2'
30
- spec.add_development_dependency "rubocop", '~> 0.49'
32
+ spec.add_development_dependency "rake", '~> 13.0.1'
33
+ spec.add_development_dependency "rubocop", '~> 1.7'
34
+ spec.add_development_dependency "simplecov", '~> 0.20'
35
+ spec.add_development_dependency "simplecov-lcov", '~> 0.8'
36
+ spec.add_development_dependency "steep", "~> 0.43.1"
31
37
  spec.extensions << 'ext/argon2_wrap/extconf.rb'
32
38
  end
data/bin/console CHANGED
@@ -1,14 +1,15 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "argon2"
4
+ require 'bundler/setup'
5
+ require 'argon2'
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
8
9
 
9
10
  # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
+ # require 'pry'
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
+ require 'irb'
14
15
  IRB.start
data/bin/setup CHANGED
@@ -1,10 +1,14 @@
1
1
  #!/bin/bash
2
+ # Exit the script immediately if a command fails
2
3
  set -euo pipefail
4
+ # Internal Field Separator
3
5
  IFS=$'\n\t'
4
6
 
7
+ # Initialize Git Submodules
8
+ git submodule update --init --recursive
9
+
10
+ # Build the Argon2 C Library. Git submodules must be initialized first!
5
11
  bundle install
6
12
  cd ext/argon2_wrap/
7
13
  make
8
14
  cd ../..
9
-
10
- # Do any other automated setup that you need to do here
data/bin/test ADDED
@@ -0,0 +1,10 @@
1
+ #!/bin/bash
2
+ # Exit the script immediately if a command fails
3
+ set -euo pipefail
4
+ # Internal Field Separator
5
+ IFS=$'\n\t'
6
+
7
+ # Run the Argon2 C Library tests
8
+ cd ext/argon2_wrap/
9
+ make test
10
+ cd ../..
@@ -73,6 +73,8 @@ int argon2_wrap_version(char *out, const char *pwd, size_t pwd_length,
73
73
  result = argon2i_ctx(&context);
74
74
  } else if (type == Argon2_id) {
75
75
  result = argon2id_ctx(&context);
76
+ } else if (type == Argon2_d) {
77
+ result = argon2d_ctx(&context);
76
78
  } else {
77
79
  // Unsupported type
78
80
  return ARGON2_ENCODING_FAIL;
@@ -124,8 +126,12 @@ int wrap_argon2_verify(const char *encoded, const char *pwd,
124
126
  type = Argon2_id;
125
127
  } else if (memcmp(encoded, "$argon2i", strlen("$argon2i")) == 0) {
126
128
  type = Argon2_i;
129
+ } else if (memcmp(encoded, "$argon2d", strlen("$argon2d")) == 0) {
130
+ type = Argon2_d;
127
131
  } else {
128
132
  // Other types not yet supported
133
+ free(ctx.salt);
134
+ free(ctx.out);
129
135
  return ARGON2_DECODING_FAIL;
130
136
  }
131
137
 
@@ -1 +1,2 @@
1
+ # frozen_string_literal: true
1
2
  #I must admit I have no understanding of why this empty file works.
Binary file
@@ -2,6 +2,7 @@ argon2
2
2
  libargon2.a
3
3
  libargon2.so*
4
4
  libargon2.dylib
5
+ libargon2.pc
5
6
  .DS_Store
6
7
  src/*.o
7
8
  src/blake2/*.o
@@ -1,8 +1,6 @@
1
1
  
2
- Microsoft Visual Studio Solution File, Format Version 12.00
3
- # Visual Studio 14
4
- VisualStudioVersion = 14.0.25420.1
5
- MinimumVisualStudioVersion = 10.0.40219.1
2
+ Microsoft Visual Studio Solution File, Format Version 11.00
3
+ # Visual Studio 2010
6
4
  Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Argon2OptTestCI", "vs2015\Argon2OptTestCI\Argon2OptTestCI.vcxproj", "{12956597-5E42-433A-93F3-D4EFF50AA207}"
7
5
  EndProject
8
6
  Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Argon2RefTestCI", "vs2015\Argon2RefTestCI\Argon2RefTestCI.vcxproj", "{8A1F7F84-34AF-4DB2-9D58-D4823DFE79E9}"
@@ -7,8 +7,8 @@ You may use this work under the terms of a Creative Commons CC0 1.0
7
7
  License/Waiver or the Apache Public License 2.0, at your option. The terms of
8
8
  these licenses can be found at:
9
9
 
10
- - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0
11
- - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0
10
+ - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
11
+ - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
12
12
 
13
13
  The terms of the licenses are reproduced below.
14
14