scrypt 1.2.1 → 2.0.0
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/README.md +8 -8
- data/lib/scrypt.rb +4 -4
- data/lib/scrypt/version.rb +1 -1
- data/spec/scrypt/password_spec.rb +10 -3
- metadata +24 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47be4799daf5f3fd84b4d621688dea4c39ccde5b
|
4
|
+
data.tar.gz: 5bf369b0264bf440229eee7fa05e65227357da68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c17413705aeef9517208e2bf83545fa488aa6b8fade35728cbcdf1e4b3f91a513d756db9ae81b4041e69c30c6c21b22484dff1c2530167f0de4e382612986bde
|
7
|
+
data.tar.gz: 2ccfe62cebda01b2d23a91af9e65cc9b2f64b755c6e602b7612fa43a5448959db9a2ae5b6b2d4529e6e5e5c8a7132830e850c47d85d694d41a24f8d91d73ff93
|
data/README.md
CHANGED
@@ -26,12 +26,12 @@ It works pretty similarly to ruby-bcrypt with a few minor differences, especiall
|
|
26
26
|
require "scrypt"
|
27
27
|
|
28
28
|
# hash a user's password
|
29
|
-
|
29
|
+
password = SCrypt::Password.create("my grand secret")
|
30
30
|
# => "400$8$36$78f4ae6983f76119$37ec6ce55a2b928dc56ff9a7d0cdafbd7dbde49d9282c38a40b1434e88f24cf5"
|
31
31
|
|
32
32
|
# compare to strings
|
33
|
-
|
34
|
-
|
33
|
+
password == "my grand secret" # => true
|
34
|
+
password == "a paltry guess" # => false
|
35
35
|
```
|
36
36
|
|
37
37
|
Password.create takes five options which will determine the key length and salt size, as well as the cost limits of the computation:
|
@@ -63,10 +63,10 @@ SCrypt::Engine.hash_secret "my grand secret", salt
|
|
63
63
|
|
64
64
|
```ruby
|
65
65
|
# store it safely in the user model
|
66
|
-
|
66
|
+
user.update_attribute(:password, @password)
|
67
67
|
|
68
68
|
# read it back later
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
```
|
69
|
+
user.reload!
|
70
|
+
password = SCrypt::Password.new(user.password)
|
71
|
+
password == "my grand secret" # => true
|
72
|
+
```
|
data/lib/scrypt.rb
CHANGED
@@ -150,7 +150,7 @@ module SCrypt
|
|
150
150
|
|
151
151
|
FFI::MemoryPointer.new(:char, key_len) do |buffer|
|
152
152
|
retval = SCrypt::Ext.crypto_scrypt(
|
153
|
-
secret, secret.
|
153
|
+
secret, secret.bytesize, salt, salt.bytesize,
|
154
154
|
n, r, p,
|
155
155
|
buffer, key_len
|
156
156
|
)
|
@@ -188,7 +188,7 @@ module SCrypt
|
|
188
188
|
#
|
189
189
|
class Password < String
|
190
190
|
# The hash portion of the stored password hash.
|
191
|
-
attr_reader :
|
191
|
+
attr_reader :digest
|
192
192
|
# The salt of the store password hash
|
193
193
|
attr_reader :salt
|
194
194
|
# The cost factor used to create the hash.
|
@@ -227,7 +227,7 @@ module SCrypt
|
|
227
227
|
def initialize(raw_hash)
|
228
228
|
if valid_hash?(raw_hash)
|
229
229
|
self.replace(raw_hash)
|
230
|
-
@cost, @salt, @
|
230
|
+
@cost, @salt, @digest = split_hash(self.to_s)
|
231
231
|
else
|
232
232
|
raise Errors::InvalidHash.new("invalid hash")
|
233
233
|
end
|
@@ -235,7 +235,7 @@ module SCrypt
|
|
235
235
|
|
236
236
|
# Compares a potential secret against the hash. Returns true if the secret is the original secret, false otherwise.
|
237
237
|
def ==(secret)
|
238
|
-
super(SCrypt::Engine.hash_secret(secret, @cost + @salt, self.
|
238
|
+
super(SCrypt::Engine.hash_secret(secret, @cost + @salt, self.digest.length / 2))
|
239
239
|
end
|
240
240
|
alias_method :is_password?, :==
|
241
241
|
|
data/lib/scrypt/version.rb
CHANGED
@@ -100,17 +100,17 @@ describe "non-default key lengths" do
|
|
100
100
|
|
101
101
|
it "should enforce a minimum keylength of 16 bytes" do
|
102
102
|
@password = SCrypt::Password.create(@secret, :key_len => 15)
|
103
|
-
@password.
|
103
|
+
@password.digest.length.should eq(16 * 2)
|
104
104
|
end
|
105
105
|
|
106
106
|
it "should allow a keylength of 512 bytes" do
|
107
107
|
@password = SCrypt::Password.create(@secret, :key_len => 512)
|
108
|
-
@password.
|
108
|
+
@password.digest.length.should eq(512 * 2)
|
109
109
|
end
|
110
110
|
|
111
111
|
it "should enforce a maximum keylength of 512 bytes" do
|
112
112
|
@password = SCrypt::Password.create(@secret, :key_len => 513)
|
113
|
-
@password.
|
113
|
+
@password.digest.length.should eq(512 * 2)
|
114
114
|
end
|
115
115
|
|
116
116
|
it "should properly compare a non-standard hash" do
|
@@ -130,3 +130,10 @@ describe "Old-style hashes" do
|
|
130
130
|
(SCrypt::Password.new(@hash) == @secret).should be(true)
|
131
131
|
end
|
132
132
|
end
|
133
|
+
|
134
|
+
describe "Respecting standard ruby behaviors" do
|
135
|
+
it 'should hash as a fixnum' do
|
136
|
+
password = SCrypt::Password.create('')
|
137
|
+
password.hash.should be_kind_of(Fixnum)
|
138
|
+
end
|
139
|
+
end
|
metadata
CHANGED
@@ -1,83 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scrypt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Hogan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi-compiler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.0.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.0.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rdoc
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: awesome_print
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
description: |2
|
@@ -91,16 +91,9 @@ extensions:
|
|
91
91
|
- ext/scrypt/Rakefile
|
92
92
|
extra_rdoc_files: []
|
93
93
|
files:
|
94
|
-
- Rakefile
|
95
|
-
- scrypt.gemspec
|
96
|
-
- README.md
|
97
94
|
- COPYING
|
98
|
-
-
|
99
|
-
-
|
100
|
-
- lib/scrypt.rb
|
101
|
-
- spec/scrypt/engine_spec.rb
|
102
|
-
- spec/scrypt/password_spec.rb
|
103
|
-
- spec/spec_helper.rb
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
104
97
|
- autotest/discover.rb
|
105
98
|
- ext/scrypt/Rakefile
|
106
99
|
- ext/scrypt/crypto_scrypt-sse.c
|
@@ -117,6 +110,13 @@ files:
|
|
117
110
|
- ext/scrypt/sha256.c
|
118
111
|
- ext/scrypt/sha256.h
|
119
112
|
- ext/scrypt/sysendian.h
|
113
|
+
- lib/scrypt.rb
|
114
|
+
- lib/scrypt/scrypt_ext.rb
|
115
|
+
- lib/scrypt/version.rb
|
116
|
+
- scrypt.gemspec
|
117
|
+
- spec/scrypt/engine_spec.rb
|
118
|
+
- spec/scrypt/password_spec.rb
|
119
|
+
- spec/spec_helper.rb
|
120
120
|
homepage: https://github.com/pbhogan/scrypt
|
121
121
|
licenses: []
|
122
122
|
metadata: {}
|
@@ -126,17 +126,17 @@ require_paths:
|
|
126
126
|
- lib
|
127
127
|
required_ruby_version: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- -
|
129
|
+
- - ">="
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '0'
|
132
132
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
133
|
requirements:
|
134
|
-
- -
|
134
|
+
- - ">="
|
135
135
|
- !ruby/object:Gem::Version
|
136
136
|
version: '0'
|
137
137
|
requirements: []
|
138
138
|
rubyforge_project: scrypt
|
139
|
-
rubygems_version: 2.
|
139
|
+
rubygems_version: 2.2.2
|
140
140
|
signing_key:
|
141
141
|
specification_version: 4
|
142
142
|
summary: scrypt password hashing algorithm.
|