xmlenc 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e401bd2ee8c45b6fa16fb1fd964339576196184
|
4
|
+
data.tar.gz: 8a662156741e2be202bb749a384d285e31315ede
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ccce2142048e50481634b71b3b3a5824bdfa7ce53708eb0078e56b432ed8bb7d2d71506579c97565d866eed39c6be03a63e74745ba3aed2a326dbc30cebe074
|
7
|
+
data.tar.gz: 3941eff179a841a04850503593746c8387e08cd83efdb858e628443d258318a0c5bef62256a95da75651c4ecf7acb04739265b09d79d4723d94d95d8ee21a0e4
|
data/lib/xmlenc.rb
CHANGED
@@ -11,11 +11,10 @@ module Xmlenc
|
|
11
11
|
:ds => 'http://www.w3.org/2000/09/xmldsig#'
|
12
12
|
}
|
13
13
|
|
14
|
-
class
|
15
|
-
end
|
16
|
-
|
17
|
-
class
|
18
|
-
end
|
14
|
+
class Error < StandardError; end
|
15
|
+
class UnsupportedError < Error; end
|
16
|
+
class UnparseableMessage < Error; end
|
17
|
+
class EncryptedDataNotFound < Error; end
|
19
18
|
|
20
19
|
module Builder
|
21
20
|
autoload :Base, 'xmlenc/builder/base'
|
data/lib/xmlenc/encrypted_key.rb
CHANGED
@@ -44,10 +44,11 @@ module Xmlenc
|
|
44
44
|
|
45
45
|
def referenced_node
|
46
46
|
if reference_uri
|
47
|
-
document.at_xpath("//xenc:EncryptedData[@Id='#{reference_uri}']", NAMESPACES)
|
47
|
+
document.at_xpath("//xenc:EncryptedData[@Id='#{reference_uri}']", NAMESPACES) ||
|
48
|
+
raise(Xmlenc::EncryptedDataNotFound.new("Encrypted data not found for: #{reference_uri}"))
|
48
49
|
else
|
49
|
-
|
50
|
-
|
50
|
+
@node.at_xpath('ancestor::xenc:EncryptedData', Xmlenc::NAMESPACES) ||
|
51
|
+
raise(Xmlenc::EncryptedDataNotFound.new('Encrypted data not in ancestore element'))
|
51
52
|
end
|
52
53
|
end
|
53
54
|
|
data/lib/xmlenc/version.rb
CHANGED
@@ -0,0 +1,48 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<PaymentInfo xmlns="http://example.org/paymentv2">
|
3
|
+
<Name>John Smith</Name>
|
4
|
+
<EncryptedKey Id="EK" xmlns="http://www.w3.org/2001/04/xmlenc#">
|
5
|
+
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5"/>
|
6
|
+
<ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
|
7
|
+
<ds:KeyName>my-rsa-key</ds:KeyName>
|
8
|
+
<ds:X509Data>
|
9
|
+
<ds:X509Certificate>
|
10
|
+
MIIDzTCCArWgAwIBAgIBATANBgkqhkiG9w0BAQQFADCBljELMAkGA1UEBhMCVVMx
|
11
|
+
CzAJBgNVBAgTAk5ZMRIwEAYDVQQHEwlNYW5oYXR0YW4xFTATBgNVBAoTDExhdmEg
|
12
|
+
U3VwcmVtZTEUMBIGA1UECxMLSGVhZCBPZmZpY2UxFDASBgNVBAMTC1JTQSBUZXN0
|
13
|
+
IENBMSMwIQYJKoZIhvcNAQkBFhR0ZWNoQGxhdmFzdXByZW1lLm9yZzAeFw0wMjAx
|
14
|
+
MzExNjI5NDNaFw00MzAyMjUxNjI5NDNaMIGWMQswCQYDVQQGEwJVUzELMAkGA1UE
|
15
|
+
CBMCTlkxEjAQBgNVBAcTCU1hbmhhdHRhbjEVMBMGA1UEChMMTGF2YSBTdXByZW1l
|
16
|
+
MRQwEgYDVQQLEwtIZWFkIE9mZmljZTEUMBIGA1UEAxMLUlNBIFRlc3QgQ0ExIzAh
|
17
|
+
BgkqhkiG9w0BCQEWFHRlY2hAbGF2YXN1cHJlbWUub3JnMIIBI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y2csj1BoQ7cqBjEhqEy
|
37
|
+
Eot4WNRYsY7P44mWBKurj2mdWQWgoxHvtITP9AR3JTMxUo3TF5ltW76DLDsEvWlE
|
38
|
+
uZKam0PYj6lYPKd4npUULeZyR/rDRrth/wFIBD8vbQlUsBHapNT9MbQfSKZemOuT
|
39
|
+
UJL9PNgsosySpKrX564oQw398XsxfTFxi4hqbdqzA/CLL418X01hUjIHdyv6XnA2
|
40
|
+
98Bmfv9WMPpX05udR4raDv5X8NWxjH00hAhasM3qumxoyCT6mAGfqvE23I+OXtrN
|
41
|
+
lUvE9mMjANw4zweCHsOcfw==
|
42
|
+
</CipherValue>
|
43
|
+
</CipherData>
|
44
|
+
<ReferenceList>
|
45
|
+
<DataReference URI="#ED"/>
|
46
|
+
</ReferenceList>
|
47
|
+
</EncryptedKey>
|
48
|
+
</PaymentInfo>
|
@@ -39,5 +39,13 @@ describe Xmlenc::EncryptedDocument do
|
|
39
39
|
it 'replaces the encrypted data with the unencrypted elements' do
|
40
40
|
expect(subject.decrypt(private_key).chomp).to be == plain_xml
|
41
41
|
end
|
42
|
+
|
43
|
+
context 'when encryption key is missing encryption data' do
|
44
|
+
let(:encrypted_xml) { File.read('spec/fixtures/encrypted_document_without_data.xml') }
|
45
|
+
|
46
|
+
it 'raises an error if the encrypted data cannot be found' do
|
47
|
+
expect { subject.decrypt(private_key).chomp }.to raise_error(Xmlenc::EncryptedDataNotFound)
|
48
|
+
end
|
49
|
+
end
|
42
50
|
end
|
43
51
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xmlenc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benoist
|
@@ -160,6 +160,7 @@ files:
|
|
160
160
|
- spec/fixtures/encrypted/java_to_ruby.txt
|
161
161
|
- spec/fixtures/encrypted_document.xml
|
162
162
|
- spec/fixtures/encrypted_document_no_ref_list.xml
|
163
|
+
- spec/fixtures/encrypted_document_without_data.xml
|
163
164
|
- spec/fixtures/key.pem
|
164
165
|
- spec/fixtures/phaos/enc-content-aes256-kt-rsa1_5.xml
|
165
166
|
- spec/fixtures/phaos/enc-element-3des-kt-rsa_oaep_sha1.xml
|
@@ -222,6 +223,7 @@ test_files:
|
|
222
223
|
- spec/fixtures/encrypted/java_to_ruby.txt
|
223
224
|
- spec/fixtures/encrypted_document.xml
|
224
225
|
- spec/fixtures/encrypted_document_no_ref_list.xml
|
226
|
+
- spec/fixtures/encrypted_document_without_data.xml
|
225
227
|
- spec/fixtures/key.pem
|
226
228
|
- spec/fixtures/phaos/enc-content-aes256-kt-rsa1_5.xml
|
227
229
|
- spec/fixtures/phaos/enc-element-3des-kt-rsa_oaep_sha1.xml
|