pws 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -15,8 +15,9 @@ You can install pws with
15
15
 
16
16
  Run `$ pws --help` for usage information.
17
17
 
18
- On linux, please make sure you've got `xclip` or `xsel` installed (clipboard).
18
+ On Linux, please make sure you've got `xclip` or `xsel` installed (clipboard).
19
19
 
20
+ On MacOS, the KDF might be generated pretty slow. You can work around this issue by using less iterations (see help) or [solving this problem](https://github.com/janlelis/pws/issues/7).
20
21
 
21
22
  Updating from 0.9
22
23
  ---
@@ -12,12 +12,15 @@ ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File:
12
12
  # Hooks
13
13
 
14
14
  BEGIN{
15
- $original_pws_file = ENV["PWS"]
15
+ $original_pws_file = ENV["PWS"]
16
+ $original_iterations = ENV["PWS_ITERATIONS"]
17
+ ENV["PWS_ITERATIONS"] = "2"
16
18
  }
17
19
 
18
20
  END{
19
21
  Clipboard.clear
20
22
  ENV["PWS"] = $original_pws_file
23
+ ENV["PWS_ITERATIONS"] = $original_iterations
21
24
  FileUtils.rm Dir['pws-test-*']
22
25
  }
23
26
 
@@ -4,6 +4,7 @@ require_relative '../format'
4
4
  require 'securerandom'
5
5
  require 'digest/hmac'
6
6
  require 'openssl'
7
+ require 'pbkdf2'
7
8
 
8
9
  class PWS
9
10
  module Format
@@ -121,9 +122,15 @@ class PWS
121
122
  ]
122
123
  end
123
124
 
124
- private
125
+ # support
126
+
127
+ def hmac(key, *strings)
128
+ Digest::HMAC.new(key, Digest::SHA512).update(
129
+ strings.map(&:to_s).join
130
+ ).digest
131
+ end
125
132
 
126
- def kdf(password, salt, iterations)
133
+ def kdf_openssl(password, salt, iterations)
127
134
  OpenSSL::PKCS5::pbkdf2_hmac(
128
135
  password,
129
136
  salt,
@@ -133,12 +140,27 @@ class PWS
133
140
  )
134
141
  end
135
142
 
136
- def hmac(key, *strings)
137
- Digest::HMAC.new(key, Digest::SHA512).update(
138
- strings.map(&:to_s).join
139
- ).digest
143
+ def kdf_ruby(password, salt, iterations)
144
+ PBKDF2.new(
145
+ password: password,
146
+ salt: salt,
147
+ iterations: iterations,
148
+ key_length: 512,
149
+ hash_function: OpenSSL::Digest::SHA512,
150
+ ).bin_string
140
151
  end
141
152
 
153
+ # see gh#7
154
+ begin
155
+ OpenSSL::PKCS5::pbkdf2_hmac("","",2,512,OpenSSL::Digest::SHA512.new)
156
+ rescue NotImplementedError
157
+ alias kdf kdf_ruby
158
+ else
159
+ alias kdf kdf_openssl
160
+ end
161
+
162
+ private
163
+
142
164
  def array_to_data_string(array)
143
165
  array.map{ |e|
144
166
  e = e.to_s
@@ -1,3 +1,3 @@
1
1
  class PWS
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.add_dependency 'clipboard', '~> 1.0.1'
20
20
  s.add_dependency 'zucker', '>= 12.1'
21
21
  s.add_dependency 'paint', '>= 0.8.4'
22
+ s.add_dependency 'pbkdf2'
22
23
  s.add_development_dependency 'rake'
23
24
  s.add_development_dependency 'aruba'
24
25
  s.add_development_dependency 'cucumber'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pws
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-28 00:00:00.000000000 Z
12
+ date: 2012-05-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: clipboard
@@ -59,6 +59,22 @@ dependencies:
59
59
  - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: 0.8.4
62
+ - !ruby/object:Gem::Dependency
63
+ name: pbkdf2
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
62
78
  - !ruby/object:Gem::Dependency
63
79
  name: rake
64
80
  requirement: !ruby/object:Gem::Requirement