xmlenc 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/xmlenc/encrypted_key.rb +11 -2
- data/lib/xmlenc/version.rb +1 -1
- data/spec/fixtures/encrypted_document_no_ref_list.xml +112 -0
- data/spec/lib/xmlenc/encrypted_key_spec.rb +14 -2
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4453557d61e71a970c57c65ff1bd18a97ad5614c
|
4
|
+
data.tar.gz: 792f1da07197cba184dae87839e98dd659c5fd89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a0149a730a4c597ae1fa2a3b865000ad787c6886537b1ad4c869c02476c67d774cd41eefad3e882b68c7d29809c62529be986584bcd5d1cdc6cb33c66a78455
|
7
|
+
data.tar.gz: 3a14e7b3140f671ee620122133547c0cf43f3092172585619932a26042ee09c40b2b487f22afc9e5e4e3000c9995e3a1e66054181375d602b4941e2cbde3bbcc
|
data/lib/xmlenc/encrypted_key.rb
CHANGED
@@ -43,11 +43,20 @@ module Xmlenc
|
|
43
43
|
private
|
44
44
|
|
45
45
|
def referenced_node
|
46
|
-
|
46
|
+
if reference_uri
|
47
|
+
document.at_xpath("//xenc:EncryptedData[@Id='#{reference_uri}']", NAMESPACES)
|
48
|
+
else
|
49
|
+
#document.at_xpath("//xenc:EncryptedData", NAMESPACES)
|
50
|
+
@node.at_xpath('ancestor::xenc:EncryptedData', Xmlenc::NAMESPACES)
|
51
|
+
end
|
47
52
|
end
|
48
53
|
|
49
54
|
def reference_uri
|
50
|
-
at_xpath('./xenc:ReferenceList/xenc:DataReference')
|
55
|
+
if at_xpath('./xenc:ReferenceList/xenc:DataReference')
|
56
|
+
at_xpath('./xenc:ReferenceList/xenc:DataReference')['URI'][1..-1]
|
57
|
+
else
|
58
|
+
nil
|
59
|
+
end
|
51
60
|
end
|
52
61
|
|
53
62
|
def at_xpath(xpath)
|
data/lib/xmlenc/version.rb
CHANGED
@@ -0,0 +1,112 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<PaymentInfo xmlns="http://example.org/paymentv2">
|
3
|
+
<Name>John Smith</Name>
|
4
|
+
<EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element" xmlns="http://www.w3.org/2001/04/xmlenc#" ID="first_data">
|
5
|
+
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"/>
|
6
|
+
<ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
|
7
|
+
<EncryptedKey xmlns="http://www.w3.org/2001/04/xmlenc#" ID="first_key">
|
8
|
+
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5"/>
|
9
|
+
<ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
|
10
|
+
<ds:KeyName>my-rsa-key</ds:KeyName>
|
11
|
+
<ds:X509Data>
|
12
|
+
<ds:X509Certificate>
|
13
|
+
MIIDzTCCArWgAwIBAgIBATANBgkqhkiG9w0BAQQFADCBljELMAkGA1UEBhMCVVMx
|
14
|
+
CzAJBgNVBAgTAk5ZMRIwEAYDVQQHEwlNYW5oYXR0YW4xFTATBgNVBAoTDExhdmEg
|
15
|
+
U3VwcmVtZTEUMBIGA1UECxMLSGVhZCBPZmZpY2UxFDASBgNVBAMTC1JTQSBUZXN0
|
16
|
+
IENBMSMwIQYJKoZIhvcNAQkBFhR0ZWNoQGxhdmFzdXByZW1lLm9yZzAeFw0wMjAx
|
17
|
+
MzExNjI5NDNaFw00MzAyMjUxNjI5NDNaMIGWMQswCQYDVQQGEwJVUzELMAkGA1UE
|
18
|
+
CBMCTlkxEjAQBgNVBAcTCU1hbmhhdHRhbjEVMBMGA1UEChMMTGF2YSBTdXByZW1l
|
19
|
+
M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35
|
+
</ds:X509Data>
|
36
|
+
</ds:KeyInfo>
|
37
|
+
<CipherData>
|
38
|
+
<CipherValue>
|
39
|
+
cCxxYh3xGBTqlXbhmKxWzNMlHeE28E7vPrMyM5V4T+t1Iy2csj1BoQ7cqBjEhqEy
|
40
|
+
Eot4WNRYsY7P44mWBKurj2mdWQWgoxHvtITP9AR3JTMxUo3TF5ltW76DLDsEvWlE
|
41
|
+
uZKam0PYj6lYPKd4npUULeZyR/rDRrth/wFIBD8vbQlUsBHapNT9MbQfSKZemOuT
|
42
|
+
UJL9PNgsosySpKrX564oQw398XsxfTFxi4hqbdqzA/CLL418X01hUjIHdyv6XnA2
|
43
|
+
98Bmfv9WMPpX05udR4raDv5X8NWxjH00hAhasM3qumxoyCT6mAGfqvE23I+OXtrN
|
44
|
+
lUvE9mMjANw4zweCHsOcfw==
|
45
|
+
</CipherValue>
|
46
|
+
</CipherData>
|
47
|
+
</EncryptedKey>
|
48
|
+
</ds:KeyInfo>
|
49
|
+
<CipherData>
|
50
|
+
<CipherValue>
|
51
|
+
u2vogkwlvFqeknJ0lYTBZkWS/eX8LR1fDPFMfyK1/UY0EyZfHvbONfDHcC/HLv/f
|
52
|
+
aAOOO2Y0GqsknP0LYT1OznkiJrzx134cmJCgbyrYXd3Mp21Pq3rs66JJ34Qt3/+I
|
53
|
+
EyJBUSMT8TdT3fBD44BtOqH2op/hy2g3hQPFZul4GiHBEnNJL/4nU1yad3bMvtAB
|
54
|
+
mzhx80lJvPGLcruj5V77WMvkvZfoeEqMq4qPWK02ZURsJsq0iZcJDi39NB7OCiON
|
55
|
+
</CipherValue>
|
56
|
+
</CipherData>
|
57
|
+
</EncryptedData>
|
58
|
+
<EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element" xmlns="http://www.w3.org/2001/04/xmlenc#" ID="second_data">
|
59
|
+
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"/>
|
60
|
+
<ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
|
61
|
+
<EncryptedKey xmlns="http://www.w3.org/2001/04/xmlenc#" ID="second_key">
|
62
|
+
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5"/>
|
63
|
+
<ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
|
64
|
+
<ds:KeyName>my-rsa-key</ds:KeyName>
|
65
|
+
<ds:X509Data>
|
66
|
+
<ds:X509Certificate>
|
67
|
+
MIIDzTCCArWgAwIBAgIBATANBgkqhkiG9w0BAQQFADCBljELMAkGA1UEBhMCVVMx
|
68
|
+
CzAJBgNVBAgTAk5ZMRIwEAYDVQQHEwlNYW5oYXR0YW4xFTATBgNVBAoTDExhdmEg
|
69
|
+
U3VwcmVtZTEUMBIGA1UECxMLSGVhZCBPZmZpY2UxFDASBgNVBAMTC1JTQSBUZXN0
|
70
|
+
IENBMSMwIQYJKoZIhvcNAQkBFhR0ZWNoQGxhdmFzdXByZW1lLm9yZzAeFw0wMjAx
|
71
|
+
MzExNjI5NDNaFw00MzAyMjUxNjI5NDNaMIGWMQswCQYDVQQGEwJVUzELMAkGA1UE
|
72
|
+
CBMCTlkxEjAQBgNVBAcTCU1hbmhhdHRhbjEVMBMGA1UEChMMTGF2YSBTdXByZW1l
|
73
|
+
MRQwEgYDVQQLEwtIZWFkIE9mZmljZTEUMBIGA1UEAxMLUlNBIFRlc3QgQ0ExIzAh
|
74
|
+
BgkqhkiG9w0BCQEWFHRlY2hAbGF2YXN1cHJlbWUub3JnMIIBIjANBgkqhkiG9w0B
|
75
|
+
AQEFAAOCAQ8AMIIBCgKCAQEAgj3TOyUtgg99oEfsm8h9JTZBxUkzYkXVUOHxIwnk
|
76
|
+
Fwp4y9ZnrGja/j+kpRyKvYP5CkNdq0e58/r7GLXj45iqd03XjsFNTdjy4OIOgf7J
|
77
|
+
xMG7z+hEB1LT2swTs10GILFWPByRl3/BEsnekLZdoqNoJrvnttVkxgu3x80Ji3/A
|
78
|
+
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9WMPpX05udR4raDv5X8NWxjH00hAhasM3qumxoyCT6mAGfqvE23I+OXtrN
|
98
|
+
lUvE9mMjANw4zweCHsOcfw==
|
99
|
+
</CipherValue>
|
100
|
+
</CipherData>
|
101
|
+
</EncryptedKey>
|
102
|
+
</ds:KeyInfo>
|
103
|
+
<CipherData>
|
104
|
+
<CipherValue>
|
105
|
+
u2vogkwlvFqeknJ0lYTBZkWS/eX8LR1fDPFMfyK1/UY0EyZfHvbONfDHcC/HLv/f
|
106
|
+
aAOOO2Y0GqsknP0LYT1OznkiJrzx134cmJCgbyrYXd3Mp21Pq3rs66JJ34Qt3/+I
|
107
|
+
EyJBUSMT8TdT3fBD44BtOqH2op/hy2g3hQPFZul4GiHBEnNJL/4nU1yad3bMvtAB
|
108
|
+
mzhx80lJvPGLcruj5V77WMvkvZfoeEqMq4qPWK02ZURsJsq0iZcJDi39NB7OCiON
|
109
|
+
</CipherValue>
|
110
|
+
</CipherData>
|
111
|
+
</EncryptedData>
|
112
|
+
</PaymentInfo>
|
@@ -33,8 +33,20 @@ describe Xmlenc::EncryptedKey do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
describe 'encrypted_data' do
|
36
|
-
|
37
|
-
|
36
|
+
describe 'with reference list' do
|
37
|
+
it 'returns the encrypted data element' do
|
38
|
+
expect(subject.encrypted_data).to be_a(Xmlenc::EncryptedData)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe 'without reference list' do
|
43
|
+
it 'returns the encrypted data element' do
|
44
|
+
xml_no_ref = File.read('spec/fixtures/encrypted_document_no_ref_list.xml')
|
45
|
+
no_ref_doc = Nokogiri::XML::Document.parse(xml_no_ref)
|
46
|
+
encrypted_no_ref_key_node = no_ref_doc.at_xpath("//xenc:EncryptedKey[@ID='second_key']", Xmlenc::NAMESPACES)
|
47
|
+
no_ref_node = Xmlenc::EncryptedKey.new(encrypted_no_ref_key_node)
|
48
|
+
expect(no_ref_node.encrypted_data.node['ID']).to be == 'second_data'
|
49
|
+
end
|
38
50
|
end
|
39
51
|
end
|
40
52
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xmlenc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benoist
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -141,6 +141,7 @@ files:
|
|
141
141
|
- lib/xmlenc/encrypted_key.rb
|
142
142
|
- lib/xmlenc/version.rb
|
143
143
|
- spec/fixtures/encrypted_document.xml
|
144
|
+
- spec/fixtures/encrypted_document_no_ref_list.xml
|
144
145
|
- spec/fixtures/key.pem
|
145
146
|
- spec/fixtures/phaos/enc-content-aes256-kt-rsa1_5.xml
|
146
147
|
- spec/fixtures/phaos/enc-element-3des-kt-rsa_oaep_sha1.xml
|
@@ -198,6 +199,7 @@ specification_version: 4
|
|
198
199
|
summary: A (partial)implementation of the XMLENC specificiation
|
199
200
|
test_files:
|
200
201
|
- spec/fixtures/encrypted_document.xml
|
202
|
+
- spec/fixtures/encrypted_document_no_ref_list.xml
|
201
203
|
- spec/fixtures/key.pem
|
202
204
|
- spec/fixtures/phaos/enc-content-aes256-kt-rsa1_5.xml
|
203
205
|
- spec/fixtures/phaos/enc-element-3des-kt-rsa_oaep_sha1.xml
|