Re: Xmldsig Countersignature DigestValue



On Mar 27, 12:31 pm, "Valery Pryamikov" <val...@xxxxxxxxx> wrote:
On Mar 22, 2:32 pm, "Iguana" <szewcz...@xxxxxxxxxxxxxxx> wrote:





Hi!
How can i calculate DigestValue for Reference to signature ( ...
uri="#signatureId" ...)?
I try this code:

xmlElement - signature from xml file;
SignedXml signature = new SignedXml();
signature.LoadXml((XmlElement)xmlElement);
Transform t = new
System.Security.Cryptography.Xml.XmlDsigC14NTransform();
XmlDocument doc = new XmlDocument();
doc.PreserveWhitespace = true;
doc.LoadXml(signature.GetXml().OuterXml);
System.IO.Stream s = null;
t.LoadInput(doc);
SHA1 sha1 = SHA1.Create();
byte[] digestValue = t.GetDigestedOutput(sha1);
MessageBox.Show(Convert.ToBase64String(digestValue));

Calculated digestValue is not the same, which is in reference
digestValue in countersignature after signing.
Can anyone help me calculate this digestValue?
Iguana


Another problem with your code could be the use of OuterXml in case if
it also returns xml header (ie. <?xml version...).
In that case you'll have problems verifying signature created anywhere
- you are trying to verify hash of child node and that can never
contain xml header which is only alllowed to be placed before
rootElement.

-Valery.

.



Relevant Pages

  • Re: Xmldsig Countersignature DigestValue
    ... How can i calculate DigestValue for Reference to signature (... ... all whitespaces, significant or not, must be ... All open source or Java implementations of XML signatures follows this ...
    (microsoft.public.dotnet.security)
  • Re: Xmldsig Countersignature DigestValue
    ... fine (with my code I verify signature have generated in java - ... // get signature to countersign ... Transform t1 = new ... DigestValue is wrong (in code with two transformation - I have ...
    (microsoft.public.dotnet.security)
  • Re: Xmldsig Countersignature DigestValue
    ... fine (with my code I verify signature have generated in java - ... // get signature to countersign ... Transform t1 = new ... DigestValue is wrong (in code with two transformation - I have ...
    (microsoft.public.dotnet.security)
  • Xmldsig Countersignature DigestValue
    ... How can i calculate DigestValue for Reference to signature (... ... SignedXml signature = new SignedXml; ...
    (microsoft.public.dotnet.security)