lib/lockbox/aes_gcm.rb in lockbox-0.4.9 vs lib/lockbox/aes_gcm.rb in lockbox-0.5.0

- old
+ new

@@ -41,14 +41,13 @@ # If no associated data shall be used, this method must still be called with a value of "" # When decrypting, set it only after calling #decrypt, #key=, #iv= and #auth_tag= first. cipher.auth_data = associated_data || "" begin - if ciphertext.to_s.empty? - cipher.final - else - cipher.update(ciphertext) + cipher.final - end + message = String.new + message << cipher.update(ciphertext) unless ciphertext.to_s.empty? + message << cipher.final + message rescue OpenSSL::Cipher::CipherError fail_decryption end end