xml-kit 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/xml/kit/decryption.rb +14 -3
- data/lib/xml/kit/signatures.rb +1 -1
- data/lib/xml/kit/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99b69beb8838a1d4df81f5f634041e58ac6552e7564f9ef644fd3658b3c05c1e
|
4
|
+
data.tar.gz: f324dba7ceda0c3c5a4802c990baa1e56c8e502e47131459b60dc13247d3d578
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a5a0e12f0042f17f367f8e51725013d28db9db0efdf3280dd59d812604fa93ba567fcf6973058ef0a04c9f2bf22517649be27e58bad0e098a9bfc26fdc35073
|
7
|
+
data.tar.gz: 047cc7d2cc323ba170028a767120e89085f1397e72843b7b4035cef26c54a01cb816a5fc48f3d37d030c36afcd9e5e379e4280d573079ca238ce249a374ede2d
|
data/lib/xml/kit/decryption.rb
CHANGED
@@ -26,7 +26,7 @@ module Xml
|
|
26
26
|
|
27
27
|
# Decrypts an EncryptedData section of an XML document.
|
28
28
|
#
|
29
|
-
# @param
|
29
|
+
# @param hash [Hash] the XML document converted to a [Hash] using Hash.from_xml.
|
30
30
|
def decrypt_hash(hash)
|
31
31
|
encrypted_data = hash['EncryptedData']
|
32
32
|
symmetric_key = symmetric_key_from(encrypted_data)
|
@@ -34,6 +34,18 @@ module Xml
|
|
34
34
|
to_plaintext(cipher_text, symmetric_key, encrypted_data["EncryptionMethod"]['Algorithm'])
|
35
35
|
end
|
36
36
|
|
37
|
+
# Decrypts an EncryptedData Nokogiri::XML::Element.
|
38
|
+
#
|
39
|
+
# @param node [Nokogiri::XML::Element.] the XML node to decrypt.
|
40
|
+
def decrypt_node(node)
|
41
|
+
return node unless !node.nil? && "EncryptedData" == node.name
|
42
|
+
|
43
|
+
parent = node.parent
|
44
|
+
grand_parent = parent.parent
|
45
|
+
parent.swap(decrypt_xml(node.to_s))
|
46
|
+
grand_parent
|
47
|
+
end
|
48
|
+
|
37
49
|
private
|
38
50
|
|
39
51
|
def symmetric_key_from(encrypted_data)
|
@@ -44,8 +56,7 @@ module Xml
|
|
44
56
|
begin
|
45
57
|
attempts -= 1
|
46
58
|
return to_plaintext(cipher_text, private_key, encrypted_key["EncryptionMethod"]['Algorithm'])
|
47
|
-
rescue OpenSSL::PKey::RSAError
|
48
|
-
::Xml::Kit.logger.error(error)
|
59
|
+
rescue OpenSSL::PKey::RSAError
|
49
60
|
raise if attempts.zero?
|
50
61
|
end
|
51
62
|
end
|
data/lib/xml/kit/signatures.rb
CHANGED
data/lib/xml/kit/version.rb
CHANGED