lib/keyring/encryptor/aes.rb in attr_keyring-0.5.2 vs lib/keyring/encryptor/aes.rb in attr_keyring-0.5.3
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
module Keyring
module Encryptor
module AES
class Base
def self.build_cipher
@@ -33,10 +35,12 @@
iv = encrypted_payload[0...16]
encrypted = encrypted_payload[16..-1]
expected_hmac = hmac_digest(key.signing_key, encrypted_payload)
- raise InvalidAuthentication, "Expected HMAC to be #{Base64.strict_encode64(expected_hmac)}; got #{Base64.strict_encode64(hmac)} instead" unless verify_signature(expected_hmac, hmac)
+ unless verify_signature(expected_hmac, hmac)
+ raise InvalidAuthentication, "Expected HMAC to be #{Base64.strict_encode64(expected_hmac)}; got #{Base64.strict_encode64(hmac)} instead" # rubocop:disable Metrics/LineLength
+ end
cipher.iv = iv
cipher.key = key.encryption_key
cipher.update(encrypted) + cipher.final
end