xmldsig 0.6.4 → 0.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 64e2371ac44ab8d5d30b2e1dfa83349a9ca0bb29
4
- data.tar.gz: cbcf177d17808d6491cc86de1543bfee644a9759
3
+ metadata.gz: a9796692edf2edbf8dc5b0b3e034e72c110b9632
4
+ data.tar.gz: 987fa5579e92b79490237b25eb01bdea3fb9e7db
5
5
  SHA512:
6
- metadata.gz: 30da1a037016e8414285ce55a4feeaa6279aab87f32343fab4004d02ce445f661349e1d4d5fb44ee397435f2d1f3b97a45abb0c902977cc2caa171129aed124a
7
- data.tar.gz: 9f193467662531c2ff8a21bf22d16fea14801fc52527ece095c54a47690a34a7262f91b2f36b4f6461b1f23a132c47ca688ddc89c9eb2edf5cf4b47c3881fa3e
6
+ metadata.gz: 36cc6186cf9d51dbd483c2d64d31bd81f3c7411e53fa43be74463ca7613dd107efc679893fa9510f985230ad40289bc0fb50b73ae83d389d13e5e40482452f1e
7
+ data.tar.gz: aafbdeb71da7b102eb054f6ae9db0e590ddda376cca8a85056279511d03b85a4b426a83fd1511c2cc6451a68b5d817c2665a9c89cd7c972edf1800009327dc6f
@@ -1,4 +1,7 @@
1
1
  # Changelog
2
+ v0.6.5
3
+ - Added inclusive namespace prefix list for canonicalization method (jmhooper)
4
+
2
5
  v0.6.4
3
6
  - Allow a custom XSD file for schema verifiation
4
7
 
@@ -54,7 +54,20 @@ module Xmldsig
54
54
  end
55
55
 
56
56
  def canonicalized_signed_info
57
- Canonicalizer.new(signed_info, canonicalization_method).canonicalize
57
+ Canonicalizer.new(
58
+ signed_info,
59
+ canonicalization_method,
60
+ inclusive_namespaces_for_canonicalization
61
+ ).canonicalize
62
+ end
63
+
64
+ def inclusive_namespaces_for_canonicalization
65
+ namespaces_node = signed_info.at_xpath(
66
+ 'descendant::ds:CanonicalizationMethod/ec:InclusiveNamespaces',
67
+ NAMESPACES
68
+ )
69
+ return unless namespaces_node && namespaces_node.get_attribute('PrefixList')
70
+ namespaces_node.get_attribute('PrefixList').split(/\W+/)
58
71
  end
59
72
 
60
73
  def calculate_signature_value(private_key, &block)
@@ -1,3 +1,3 @@
1
1
  module Xmldsig
2
- VERSION = '0.6.4'
2
+ VERSION = '0.6.5'
3
3
  end
@@ -0,0 +1,23 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <foo:Foo xmlns:foo="http://example.com/foo#" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#" ID="foo">
3
+ <foo:Bar>bar</foo:Bar>
4
+ <ds:Signature>
5
+ <ds:SignedInfo>
6
+ <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
7
+ <ec:InclusiveNamespaces xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList="foo"/>
8
+ </ds:CanonicalizationMethod>
9
+ <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
10
+ <ds:Reference URI="#foo">
11
+ <ds:Transforms>
12
+ <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
13
+ <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
14
+ <ec:InclusiveNamespaces PrefixList="foo"/>
15
+ </ds:Transform>
16
+ </ds:Transforms>
17
+ <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
18
+ <ds:DigestValue>ftoSYFdze1AWgGHF5N9i9SFKThXkqH2AdyzA3/epbJw=</ds:DigestValue>
19
+ </ds:Reference>
20
+ </ds:SignedInfo>
21
+ <ds:SignatureValue>s3yYvk1UCZkIpljdy6GZTdbOi/FvhuvCnBSYmdPb3yQmtEpww5Q2tCKgqu/9ixxf1tmyUulRrIZk0mVarQUsykrJhOKBHo8ht487c/XT+fmv+zF4JeO4fV6VsAx1cFd/qMXdDyE6nOxgW+qppeRwkdfX2N5I8COzn0fHOLp9QTo=</ds:SignatureValue>
22
+ </ds:Signature>
23
+ </foo:Foo>
@@ -0,0 +1,23 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <foo:Foo ID="foo" xmlns:foo="http://example.com/foo#" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#">
3
+ <foo:Bar>bar</foo:Bar>
4
+ <ds:Signature>
5
+ <ds:SignedInfo>
6
+ <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
7
+ <ec:InclusiveNamespaces xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList="foo"/>
8
+ </ds:CanonicalizationMethod>
9
+ <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
10
+ <ds:Reference URI="#foo">
11
+ <ds:Transforms>
12
+ <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
13
+ <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
14
+ <ec:InclusiveNamespaces PrefixList="foo"/>
15
+ </ds:Transform>
16
+ </ds:Transforms>
17
+ <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
18
+ <ds:DigestValue></ds:DigestValue>
19
+ </ds:Reference>
20
+ </ds:SignedInfo>
21
+ <ds:SignatureValue></ds:SignatureValue>
22
+ </ds:Signature>
23
+ </foo:Foo>
@@ -106,6 +106,7 @@ describe Xmldsig::Signature do
106
106
 
107
107
  it "returns false with the default validation scheme and true with the X509 serial fix scheme" do
108
108
  aggregate_failures do
109
+ break expect(signature.valid?(certificate)).to eq(true) if RUBY_ENGINE == 'jruby'
109
110
  expect { signature.valid?(certificate) }.to raise_error Xmldsig::SchemaError, /is not a valid value of the atomic type 'xs:integer'/
110
111
  expect(signature.valid?(certificate, Xmldsig::XSD_X509_SERIAL_FIX_FILE)).to eq(true)
111
112
  expect(signature.errors).to eql []
@@ -125,6 +125,15 @@ describe Xmldsig::SignedDocument do
125
125
  expect(signed_document.signatures.last.signature_value).to_not be(unsigned_document.signatures.last.signature_value)
126
126
  end
127
127
  end
128
+
129
+ context 'with inclusive namespaces for the signature' do
130
+ let(:unsigned_xml) { File.read("spec/fixtures/unsigned_signature_namespace.xml") }
131
+ let(:signed_xml) { File.read("spec/fixtures/signed_signature_namespace.xml") }
132
+
133
+ it 'canonicalizes and signs correctly' do
134
+ expect(unsigned_document.sign(private_key)).to eq(signed_xml)
135
+ end
136
+ end
128
137
  end
129
138
 
130
139
  describe "Nested Signatures" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xmldsig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - benoist
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-07 00:00:00.000000000 Z
11
+ date: 2017-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -69,6 +69,7 @@ files:
69
69
  - spec/fixtures/signed/shib.cert
70
70
  - spec/fixtures/signed/shib.xml
71
71
  - spec/fixtures/signed_custom_attribute_id.xml
72
+ - spec/fixtures/signed_signature_namespace.xml
72
73
  - spec/fixtures/signed_xml-exc-c14n#with_comments.xml
73
74
  - spec/fixtures/unsigned-invalid.xml
74
75
  - spec/fixtures/unsigned-malicious.xml
@@ -93,6 +94,7 @@ files:
93
94
  - spec/fixtures/unsigned_multiple_references.xml
94
95
  - spec/fixtures/unsigned_nested_signature.xml
95
96
  - spec/fixtures/unsigned_nested_signed_signature.xml
97
+ - spec/fixtures/unsigned_signature_namespace.xml
96
98
  - spec/lib/xmldsig/reference_spec.rb
97
99
  - spec/lib/xmldsig/signature_spec.rb
98
100
  - spec/lib/xmldsig/signed_document_spec.rb
@@ -136,6 +138,7 @@ test_files:
136
138
  - spec/fixtures/signed/shib.cert
137
139
  - spec/fixtures/signed/shib.xml
138
140
  - spec/fixtures/signed_custom_attribute_id.xml
141
+ - spec/fixtures/signed_signature_namespace.xml
139
142
  - spec/fixtures/signed_xml-exc-c14n#with_comments.xml
140
143
  - spec/fixtures/unsigned-invalid.xml
141
144
  - spec/fixtures/unsigned-malicious.xml
@@ -160,6 +163,7 @@ test_files:
160
163
  - spec/fixtures/unsigned_multiple_references.xml
161
164
  - spec/fixtures/unsigned_nested_signature.xml
162
165
  - spec/fixtures/unsigned_nested_signed_signature.xml
166
+ - spec/fixtures/unsigned_signature_namespace.xml
163
167
  - spec/lib/xmldsig/reference_spec.rb
164
168
  - spec/lib/xmldsig/signature_spec.rb
165
169
  - spec/lib/xmldsig/signed_document_spec.rb