Skip to content

Commit d1cdd43

Browse files
authored
adding failing test case for dotnet#95390
1 parent f66c1c1 commit d1cdd43

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/libraries/System.Security.Cryptography.Xml/tests/SignedXmlTest.cs

+13
Original file line numberDiff line numberDiff line change
@@ -1993,5 +1993,18 @@ public void CheckSignatureHandlesIncorrectOrTamperedReferenceWithMultipleEnvelop
19931993

19941994
Assert.False(subject.CheckSignature());
19951995
}
1996+
1997+
[Fact]
1998+
[ActiveIssue("https://github.com/dotnet/runtime/issues/95390")]
1999+
public void CheckSignatureHandlesEnvelopedSignatureWithRootXpointerReference()
2000+
{
2001+
const string EnvelopedSignatureWithRootXpointerReference = """<?xml version="1.0" encoding="UTF-8"?><hello><world>Hi</world><Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#WithComments" /><SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" /><Reference URI="#xpointer(/)"><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" /><Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#WithComments" /></Transforms><DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" /><DigestValue>SVaCE5w9iLXTVYTKP1t/yjjmPXvWovMYpgljGgpgz2Y=</DigestValue></Reference></SignedInfo><SignatureValue>dqcBmS1ZvDJNhmCEgobpAb+A2XaiuB69dfGIhisZvqoxaWqAqv/0w49jp38+usJ5t3wcq3aMC631QE8iln+lHWrarojDMDWLa00isv3oE3q9UgOIV9e6MUSoRTTvQkmlK/LSYV9T/SKx6h03vLLcIkUMXaTkC/n2kthlJTGkLbU=</SignatureValue><KeyInfo><KeyValue><RSAKeyValue><Modulus>t6qV1iTlkCPoaIeOTvnDczQv5pytUxMoyNXws5vaMQYxfJMKos47dvmiLtfWUDLYXFX3Yf/JMC14plJw2JA5jLrlHLnZj/vCjRtXckmWW/wGYewXUqrgR1CytStUeQKj9mNsi76erukua10UhzIrWG+H6YQ/qS4AMMJZU6jBvO0=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue></KeyValue></KeyInfo></Signature></hello>""";
2002+
XmlDocument xmlDoc = new ();
2003+
xmlDoc.LoadXml(EnvelopedSignatureWithRootXpointerReference);
2004+
SignedXml signedXml = new (xmlDoc);
2005+
signedXml.LoadXml(xmlDoc.GetElementsByTagName("Signature", SignedXml.XmlDsigNamespaceUrl)[0] as XmlElement);
2006+
2007+
Assert.True(signedXml.CheckSignature());
2008+
}
19962009
}
19972010
}

0 commit comments

Comments
 (0)