[xmlsec] Different digest value between .NET implementation and XmlSec?
Chugh, Sanjay
schugh@filenet.com
Thu, 9 Oct 2003 13:53:21 -0600
This is a multi-part message in MIME format.
------_=_NextPart_001_01C38E9E.FE066A5B
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Hello, I am in the middle of learning all this business about XmlDigital
signatures and Encryption.
To try and understand things, I've been trying different libraries and
trying to verify results.
I have run into one issue that I was wondering if somebody could shed
some light into.
I have the XML file shown at the bottom of the e-mail.
When I calculate a signature using XmlSec, the digest value generated
is:
<DigestValue>UT4+z2LQyKSxNWWdS7VE8uTo+wE=3D</DigestValue>
However, when I calculate a signature on the same file using .NET, the
digest value is different:
<DigestValue>sUD7jzvAdt3liQEkrpGsJukqftU=3D</DigestValue>
I have tracked it down to the following. The XmlSec library is
calculating the digest on the canonicalized form without the procession
instruction=20
=20
<?xml-stylesheet type=3D"text/xsl" href=3D"myfile.xsl" ?>
at the top of the file. The .NET implementation includes the processing
instruction in it's calculation of the digest. According to what I have
read, I believe that .NET is correct to include the processing
instruction in it's calculation of the digest.
=20
Does anyone know why this should be the case?
=20
Thanks.
=20
-- Sanjay
=20
Here is the Xml file:
=20
<?xml version=3D"1.0"?>
<?xml-stylesheet type=3D"text/xsl" href=3D"myfile.xsl" ?>
<!DOCTYPE sales [
<!ELEMENT sales (region*)>
<!ATTLIST sales quarter CDATA #IMPLIED>
<!ELEMENT region (units, amount)>
<!ATTLIST region name ID #IMPLIED>
<!ELEMENT units (#PCDATA) >
<!ELEMENT amount (#PCDATA) >
]>
<sales quarter=3D"2001-01">
<region name=3D"Northeast">
<units>374</units>
<amount>12500.26</amount>
</region>
<region name=3D"Southeast">
<units>512</units>
<amount>17692</amount>
</region>
<region name=3D"Southwest">
<units>161</units>
<amount>8349.72</amount>
</region>
<region name=3D"Northwest">
<units>465</units>
<amount>15239.6</amount>
</region>
</sales>
------_=_NextPart_001_01C38E9E.FE066A5B
Content-Type: text/html;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Message</TITLE>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dus-ascii">
<META content=3D"MSHTML 6.00.2800.1264" name=3DGENERATOR></HEAD>
<BODY>
<DIV><SPAN class=3D937574019-09102003><FONT face=3DArial size=3D2>Hello, =
I am in the=20
middle of learning all this business about XmlDigital signatures and=20
Encryption.</FONT></SPAN></DIV>
<DIV><SPAN class=3D937574019-09102003><FONT face=3DArial size=3D2>To try =
and=20
understand things, I've been trying different libraries and trying to =
verify=20
results.</FONT></SPAN></DIV>
<DIV><SPAN class=3D937574019-09102003><FONT face=3DArial size=3D2>I have =
run into one=20
issue that I was wondering if somebody could shed some light=20
into.</FONT></SPAN></DIV>
<DIV><SPAN class=3D937574019-09102003><FONT face=3DArial size=3D2>I have =
the XML file=20
shown at the bottom of the e-mail.</FONT></SPAN></DIV>
<DIV><SPAN class=3D937574019-09102003><FONT face=3DArial size=3D2>When I =
calculate a=20
signature using XmlSec, the digest value generated =
is:</FONT></SPAN></DIV>
<DIV><SPAN class=3D937574019-09102003><FONT face=3DArial=20
size=3D2><DigestValue>UT4+z2LQyKSxNWWdS7VE8uTo+wE=3D</DigestValu=
e><BR></FONT></SPAN></DIV>
<DIV><SPAN class=3D937574019-09102003><FONT face=3DArial =
size=3D2>However, when I=20
calculate a signature on the same file using .NET, the digest value is=20
different:</FONT></SPAN></DIV>
<DIV><SPAN class=3D937574019-09102003><FONT face=3DArial=20
size=3D2><DigestValue>sUD7jzvAdt3liQEkrpGsJukqftU=3D</DigestValu=
e><BR></FONT></SPAN></DIV>
<DIV><SPAN class=3D937574019-09102003><FONT face=3DArial size=3D2>I have =
tracked it=20
down to the following. The XmlSec library is calculating the digest on =
the=20
canonicalized form without the procession instruction =
</FONT></SPAN></DIV>
<DIV><SPAN class=3D937574019-09102003><FONT face=3DArial=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D937574019-09102003><FONT face=3DArial =
size=3D2><?xml-stylesheet=20
type=3D"text/xsl" href=3D"myfile.xsl" ?><BR></DIV></FONT></SPAN>
<DIV><SPAN class=3D937574019-09102003><FONT face=3DArial size=3D2>at the =
top of the=20
file. The .NET implementation includes the processing instruction in =
it's=20
calculation of the digest. According to what I have read, I believe that =
.NET is=20
correct to include the processing instruction in it's calculation of the =
digest.</FONT></SPAN></DIV>
<DIV><SPAN class=3D937574019-09102003><FONT face=3DArial=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D937574019-09102003><FONT face=3DArial size=3D2>Does =
anyone know why=20
this should be the case?</FONT></SPAN></DIV>
<DIV><SPAN class=3D937574019-09102003><FONT face=3DArial=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D937574019-09102003><FONT face=3DArial=20
size=3D2>Thanks.</FONT></SPAN></DIV>
<DIV><SPAN class=3D937574019-09102003><FONT face=3DArial=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D937574019-09102003><FONT face=3DArial size=3D2>--=20
Sanjay</FONT></SPAN></DIV>
<DIV><SPAN class=3D937574019-09102003><FONT face=3DArial=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D937574019-09102003><FONT face=3DArial size=3D2>Here =
is the Xml=20
file:</FONT></SPAN></DIV>
<DIV><SPAN class=3D937574019-09102003><FONT face=3DArial=20
size=3D2></FONT></SPAN> </DIV>
<DIV><SPAN class=3D937574019-09102003><FONT face=3DArial =
size=3D2><?xml=20
version=3D"1.0"?><BR><?xml-stylesheet type=3D"text/xsl" =
href=3D"myfile.xsl"=20
?><BR><!DOCTYPE sales [<BR><!ELEMENT sales=20
(region*)><BR><!ATTLIST sales quarter CDATA =
#IMPLIED><BR><!ELEMENT=20
region (units, amount)><BR><!ATTLIST region name ID=20
#IMPLIED><BR><!ELEMENT units (#PCDATA) ><BR><!ELEMENT amount =
(#PCDATA) ><BR>]><BR><sales =
quarter=3D"2001-01"><BR> =20
<region name=3D"Northeast"><BR> =20
<units>374</units><BR> =20
<amount>12500.26</amount><BR> =20
</region><BR> <region=20
name=3D"Southeast"><BR> =20
<units>512</units><BR> =20
<amount>17692</amount><BR> =20
</region><BR> <region=20
name=3D"Southwest"><BR> =20
<units>161</units><BR> =20
<amount>8349.72</amount><BR> =20
</region><BR> <region=20
name=3D"Northwest"><BR> =20
<units>465</units><BR> =20
<amount>15239.6</amount><BR> =20
</region><BR></sales><BR></FONT></SPAN></DIV></BODY></HTML>
=00
------_=_NextPart_001_01C38E9E.FE066A5B--