lib/yoti/ssl.rb in yoti-1.3.1 vs lib/yoti/ssl.rb in yoti-1.4.0

- old
+ new

@@ -24,12 +24,12 @@ def decrypt_token(encrypted_connect_token) raise SslError, 'Encrypted token cannot be nil.' unless encrypted_connect_token begin private_key.private_decrypt(Base64.urlsafe_decode64(encrypted_connect_token)) - rescue StandardError => error - raise SslError, "Could not decrypt token. #{error}" + rescue StandardError => e + raise SslError, "Could not decrypt token. #{e}" end end # Extracts the public key from pem key, converts it to a DER base 64 encoded value # @return [String] base 64 encoded anthentication key @@ -49,23 +49,23 @@ # Uses the decrypted receipt key and the current user's iv to decode the text # @param key [String] base 64 decoded key # @param iv [String] base 64 decoded iv # @param text [String] base 64 decoded cyphered text # @return [String] base 64 decoded deciphered text - def decipher(key, iv, text) + def decipher(key, user_iv, text) ssl_decipher = OpenSSL::Cipher.new('AES-256-CBC') ssl_decipher.decrypt ssl_decipher.key = key - ssl_decipher.iv = iv + ssl_decipher.iv = user_iv ssl_decipher.update(text) + ssl_decipher.final end private def private_key @private_key ||= OpenSSL::PKey::RSA.new(pem) - rescue StandardError => error - raise SslError, "The secure key is invalid. #{error}" + rescue StandardError => e + raise SslError, "The secure key is invalid. #{e}" end end end end