Skip to content

Commit

Permalink
Explicitely pass only 32 bytes of key to encryptor (Ruby 2.4 compat)
Browse files Browse the repository at this point in the history
Closes #19
  • Loading branch information
janlelis committed Feb 6, 2017
1 parent a32a4c5 commit 9cc728a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
== 1.0.7
* Ruby 2.4 compat (explicitely only pass 32 bytes of the encryption key)

== 1.0.6
* Ruby 2.2 compat (remove digest/hmac)

Expand Down
2 changes: 1 addition & 1 deletion lib/pws/format/0.9.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def decrypt(saved_data, options = {})
iv, encrypted_data = saved_data.unpack('a16 a*')
PWS::Encryptor.decrypt(
encrypted_data,
key: sha(options[:password]),
key: sha(options[:password])[0...32],
iv: iv,
)
end
Expand Down
4 changes: 2 additions & 2 deletions lib/pws/format/1.0.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def encrypt(unencrypted_data, options = {})

encrypted_data = Encryptor.encrypt(
unencrypted_data,
key: encryption_key,
key: encryption_key[0...32],
iv: iv,
)

Expand Down Expand Up @@ -90,7 +90,7 @@ def decrypt(saved_data, options = {})
begin
unencrypted_data = Encryptor.decrypt(
encrypted_data,
key: encryption_key,
key: encryption_key[0...32],
iv: iv,
)
rescue OpenSSL::Cipher::CipherError
Expand Down

0 comments on commit 9cc728a

Please sign in to comment.