lib/gibberish/aes.rb in gibberish-2.0.0 vs lib/gibberish/aes.rb in gibberish-2.1.0

- old
+ new

@@ -156,12 +156,12 @@ end def decrypt(h) begin h = JSON.parse(h, {:symbolize_names => true}) - rescue - raise "Unable to parse JSON of crypted text" + rescue => e + raise "Unable to parse JSON of crypted text. #{e.inspect}" end check_cipher_options(h) key = OpenSSL::PKCS5.pbkdf2_hmac(@password, Base64.decode64(h[:salt]), h[:iter], h[:ks]/8, 'SHA256') iv = Base64.decode64(h[:iv]) ct = Base64.decode64(h[:ct]) @@ -169,20 +169,20 @@ ct = ct[0,ct.length-h[:ts]/8] cipherMode = "#{h[:cipher]}-#{h[:ks]}-#{h[:mode]}" begin c = OpenSSL::Cipher.new(cipherMode) rescue RuntimeError => e - raise "OpenSSL error when initializing: #{e.message}" + raise "OpenSSL error when initializing: #{e.inspect}" end c.decrypt c.key = key c.iv = iv c.auth_tag = tag; c.auth_data = h[:adata] || "" begin out = c.update(ct) + c.final(); rescue OpenSSL::Cipher::CipherError => e - raise DecryptionError.new(); + raise DecryptionError.new(e.inspect); end return Plaintext.new(out.force_encoding('utf-8'), h[:adata]) end # Assume the worst