summaryrefslogtreecommitdiff
path: root/lib/xml/kit/decryption.rb
diff options
context:
space:
mode:
authormo <mo.khan@gmail.com>2017-12-30 11:02:10 -0700
committermo <mo.khan@gmail.com>2017-12-30 11:02:10 -0700
commitade47ec96e86aa99625b3964f5351d877e631bb5 (patch)
tree3213ec2463d5f0986fe48e2e1cba27888eab4b2e /lib/xml/kit/decryption.rb
parentc7874cd3561b346f66ac9f17685b32ffbaa6514e (diff)
add encryption spec.
Diffstat (limited to 'lib/xml/kit/decryption.rb')
-rw-r--r--lib/xml/kit/decryption.rb16
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/xml/kit/decryption.rb b/lib/xml/kit/decryption.rb
index d275b9d..fdc1746 100644
--- a/lib/xml/kit/decryption.rb
+++ b/lib/xml/kit/decryption.rb
@@ -13,7 +13,21 @@ module Xml
#
# @param data [Hash] the XML document converted to a [Hash] using Hash.from_xml.
def decrypt(data)
- encrypted_data = data['EncryptedData']
+ decrypt_hash(data)
+ end
+
+ # Decrypts an EncryptedData section of an XML document.
+ #
+ # @param raw_xml [String] the XML document as a string.
+ def decrypt_xml(raw_xml)
+ decrypt(Hash.from_xml(raw_xml))
+ end
+
+ # Decrypts an EncryptedData section of an XML document.
+ #
+ # @param data [Hash] the XML document converted to a [Hash] using Hash.from_xml.
+ def decrypt_hash(hash)
+ encrypted_data = hash['EncryptedData']
symmetric_key = symmetric_key_from(encrypted_data)
cipher_text = Base64.decode64(encrypted_data["CipherData"]["CipherValue"])
to_plaintext(cipher_text, symmetric_key, encrypted_data["EncryptionMethod"]['Algorithm'])