@@ -33,60 +33,38 @@ module.exports = {
33
33
34
34
35
35
36
- "empty URI reference should consider the whole document" : function ( test ) {
37
-
38
- var sampleXml = [ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" ,
39
- "<root>" ,
40
- " <a>" ,
41
- " <b/>" ,
42
- " </a>" ,
43
- " <Seal><Signature xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><SignedInfo><CanonicalizationMethod Algorithm=\"http://www.w3.org/2001/10/xml-exc-c14n#\"/><SignatureMethod Algorithm=\"http://www.w3.org/2001/04/xmldsig-more#rsa-sha256\"/><Reference URI=\"\"><Transforms><Transform Algorithm=\"http://www.w3.org/2000/09/xmldsig#enveloped-signature\"/></Transforms><DigestMethod Algorithm=\"http://www.w3.org/2001/04/xmlenc#sha256\"/><DigestValue>FOezc5yb1O+LfQaD4UBKEUphrGzFAq5DM9B9ll37JOA=</DigestValue></Reference></SignedInfo><SignatureValue>AjkQ5NF71bwJ2YHIs8jbqva9qaNv66BYZiZw0JJZ1cW6jf3mjWShIMQZWcw78QGpzzr+ZspzUbs4" ,
44
- "6VAnHApJElOTDylSf3rDSvzsklKcFpHJ9yCJV+PnipEsY8qWhzKHlKCdtEn1xH0BCP/2JfMYgLQl" ,
45
- "PCvaR8XrgdODeQ2Gn6g=</SignatureValue><KeyInfo><KeyValue><RSAKeyValue><Modulus>t+qknJd/Kdo09fvQrRThqh/3EyDQj8zT1ZT7uXmivni4Vaysf6zHv+oORIvAt9ntZE2ZCif9v6CC" ,
46
- "W+hmRFkdgRoVpmD2TErjykzowx6Ffyf5BkVnVB89+g/ZqNyyvXiBe8SmpBrRLOMifnbacyrJcsrH" ,
47
- "fwlCnuyGKXj1LfzDcR8=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue></KeyValue></KeyInfo></Signature></Seal>" ,
48
- " <c>" ,
49
- " <d e=\"f\"/>" ,
50
- " </c>" ,
51
- "</root>" ] . join ( "\n" ) ;
52
-
53
- var doc = new Dom ( ) . parseFromString ( sampleXml ) ;
36
+ "empty URI reference should consider the whole document" : function ( test ) {
37
+ var xml = "<library>" +
38
+ "<book>" +
39
+ "<name>Harry Potter</name>" +
40
+ "</book>" +
41
+ "</library>" ;
42
+
43
+ var signature = '<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">' +
44
+ '<SignedInfo>' +
45
+ '<CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>' +
46
+ '<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>' +
47
+ '<Reference URI="">' +
48
+ '<Transforms>' +
49
+ '<Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>' +
50
+ '</Transforms>' +
51
+ '<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>' +
52
+ '<DigestValue>1tjZsV007JgvE1YFe1C8sMQ+iEg=</DigestValue>' +
53
+ '</Reference>' +
54
+ '</SignedInfo>' +
55
+ '<SignatureValue>FONRc5/nnQE2GMuEV0wK5/ofUJMHH7dzZ6VVd+oHDLfjfWax/lCMzUahJxW1i/dtm9Pl0t2FbJONVd3wwDSZzy6u5uCnj++iWYkRpIEN19RAzEMD1ejfZET8j3db9NeBq2JjrPbw81Fm7qKvte6jGa9ThTTB+1MHFRkC8qjukRM=</SignatureValue>' +
56
+ '</Signature>' ;
57
+
58
+ var sig = new crypto . SignedXml ( )
59
+ sig . keyInfoProvider = new crypto . FileKeyInfo ( "./test/static/client_public.pem" )
60
+ sig . loadSignature ( signature ) ;
54
61
55
- var signature = crypto . xpath ( doc , "//*//*[local-name(.)='Signature' and namespace-uri(.)='http://www.w3.org/2000/09/xmldsig#']" ) [ 0 ] ;
56
- var sig = new crypto . SignedXml ( ) ;
57
- sig . keyInfoProvider = new crypto . FileKeyInfo ( "./test/static/empty_uri.pem" ) ;
58
- sig . loadSignature ( signature ) ;
59
- var result = sig . checkSignature ( sampleXml ) ;
60
- test . equal ( result , true ) ;
61
- test . done ( ) ;
62
- } ,
63
-
64
-
65
-
66
- "windows store signature" : function ( test ) {
67
-
68
- var xml = fs . readFileSync ( './test/static/windows_store_signature.xml' , 'utf-8' ) ;
69
-
70
- // Make sure that whitespace in the source document is removed -- see xml-crypto issue #23 and post at
71
- // http://webservices20.blogspot.co.il/2013/06/validating-windows-mobile-app-store.html
72
- // This regex is naive but works for this test case; for a more general solution consider
73
- // the xmldom-fork-fixed library which can pass {ignoreWhiteSpace: true} into the Dom constructor.
74
- xml = xml . replace ( / > \s * < / g, '><' ) ;
75
-
76
- var doc = new Dom ( ) . parseFromString ( xml ) ;
77
- xml = doc . firstChild . toString ( )
78
-
79
- var signature = crypto . xpath ( doc , "//*//*[local-name(.)='Signature' and namespace-uri(.)='http://www.w3.org/2000/09/xmldsig#']" ) [ 0 ] ;
80
- var sig = new crypto . SignedXml ( ) ;
81
- sig . keyInfoProvider = new crypto . FileKeyInfo ( "./test/static/windows_store_certificate.pem" ) ;
82
- sig . loadSignature ( signature ) ;
83
62
var result = sig . checkSignature ( xml ) ;
84
63
test . equal ( result , true ) ;
85
64
test . done ( ) ;
86
65
} ,
87
66
88
67
89
-
90
68
"signature with inclusive namespaces" : function ( test ) {
91
69
92
70
var xml = fs . readFileSync ( './test/static/signature_with_inclusivenamespaces.xml' , 'utf-8' ) ;
@@ -190,7 +168,7 @@ function verifySignature(test, xml, expected, xpath) {
190
168
191
169
var sig = new SignedXml ( )
192
170
sig . signingKey = fs . readFileSync ( "./test/static/client.pem" )
193
- sig . keyInfoCaluse = null
171
+ sig . keyInfo = null ;
194
172
195
173
xpath . map ( function ( n ) { sig . addReference ( n ) } )
196
174
0 commit comments