[xmlsec] Microsoft .NET compatibility

Aleksey Sanin aleksey at aleksey.com
Fri May 9 09:30:27 PDT 2003


Hi, Rob!

Seems that there is a problem in xmlsec (to be precise, in libxml2
canonicalization code) which does not remove #D as it is required
by the spec. The only problem is that I could not understand how
you got same digests in this case? Digests verification should also fail
because of this problem.

Not sure that there is a trivial fix. If you want to play with it your 
self,
look at c14n.c file in the LibXML2. I'll take a look at this later today
and send you status update as soon as I find something.

Thanks for investigating this problem!

Aleksey

Rob Cronin wrote:

>Hi Aleksey,
>
>Okay, I've figured it all out, or at least I think so, and I was hoping you
>could help me in making the next step.  Here's what Microsoft does.  They
>take the data, remove all of the line feeds (which I thought was part of the
>canonicalization), and create a digest from that using ENC-C14N, but then
>put the data with the line feeds back into the soap request, and add the
>digest into the <SignedInfo> tag.  Then they take the <SignedInfo> tag and
>again, remove all of the line feeds in there, sign it, and then put the
>original <SignedInfo> back with the line feeds, and they add the new
>signature.  So if I remove all the line feeds from the data and from the
><SignedInfo> tag, xmlsec can verify the signature just fine.  Hence this
>document is verified fine by xmlsec
>
>  
>
>
> <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/2000/09/xmldsig#rsa-sha1"/><Reference
>URI="#Id-3ec382bd-2a43-4978-b70c-c3431f96fe35"><Transforms><Transform
>Algorithm
>="http://www.w3.org/2001/10/xml-exc-c14n#"/></Transforms><DigestMethod
>Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><Digest
>Value>Rv0EK/wMWw/octwR+XkoRlHm1g0=</DigestValue></Reference></SignedInfo>
>
><SignatureValue>BQishbkGvcJAYToL2oqdMCAVJH+5p/CmZCOoQ3yVAJCmqa3Pfaec+It3MHy1
>VlWWfIo7hTlWOjTBn3mLWgb/PIc4Kn3CmAYt6G0dvWV6T2
>73CtFgosNgZF8P1ZSOQuh2nLEpTo2JaYMC/JcCsYNOshwsu280ZQUeTiwG31P7zGk=</Signatur
>eValue>
>        <KeyInfo>
>          <wsse:SecurityTokenReference>
>            <wsse:Reference
>URI="#SecurityToken-590bfd6c-6c75-40bf-8b02-dfff9aa86eb7"/>
>          </wsse:SecurityTokenReference>
>        </KeyInfo>
>      </Signature>
>    </wsse:Security>
>  </soap:Header>
>  <soap:Body xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility"
>wsu:Id="Id-3ec382bd-2a43-4978-b70c-c3431f96fe35"><Call xmln
>s="http://asp.asp.cornell.edu/cgi-bin/rmc24/arithmeticsecure.cgi"><sleep_for
>  
>
>>1</sleep_for><y>2</y><x>1</x></Call></soap:Body>
>>    
>>
></soap:Envelope>
>
>  
>
>
>I know email will insert line feeds in there, but Signed Info and soap:Body
>are both supposed to be 1 line
>and this document will not be verified by xmlsec
>
>  
>
>
><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/2000/09/xmldsig#rsa-sha1"/>
>          <Reference URI="#Id-3ec382bd-2a43-4978-b70c-c3431f96fe35">
>            <Transforms>
>              <Transform
>Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
>            </Transforms>
>            <DigestMethod
>Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
>            <DigestValue>Rv0EK/wMWw/octwR+XkoRlHm1g0=</DigestValue>
>          </Reference>
>        </SignedInfo>
>
><SignatureValue>BQishbkGvcJAYToL2oqdMCAVJH+5p/CmZCOoQ3yVAJCmqa3Pfaec+It3MHy1
>VlWWfIo7hTlWOjTBn3mLWgb/PIc4Kn3CmAYt6G0dvWV6T2
>73CtFgosNgZF8P1ZSOQuh2nLEpTo2JaYMC/JcCsYNOshwsu280ZQUeTiwG31P7zGk=</Signatur
>eValue>
>        <KeyInfo>
>          <wsse:SecurityTokenReference>
>            <wsse:Reference
>URI="#SecurityToken-590bfd6c-6c75-40bf-8b02-dfff9aa86eb7"/>
>          </wsse:SecurityTokenReference>
>        </KeyInfo>
>      </Signature>
>    </wsse:Security>
>  </soap:Header>
>  <soap:Body xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility"
>wsu:Id="Id-3ec382bd-2a43-4978-b70c-c3431f96fe35">
>    <Call
>xmlns="http://asp.asp.cornell.edu/cgi-bin/rmc24/arithmeticsecure.cgi">
>      <sleep_for>1</sleep_for>
>      <y>2</y>
>      <x>1</x>
>    </Call>
>  </soap:Body>
></soap:Envelope>
>
>  
>
>
>Now I'm not 100% sure who's implementation is more correct, or if they are
>both right based on the interpretation of the docuiments out there.  But
>here's what I wonder, is there a quick fix you can throw in there to make it
>work, or, where should I go in the code to try and change it, so that these
>line feeds will be used in the verification and signing process, but will
>not appear in the final document.  Meaning, take the data, remove the line
>feeds (keeping the original in the SOAP document), do the digest stuff, put
>the original data and the new <SignedInfo> into the document, take the
><SignedInfo>, remove the line feeds (keeping the original in the SOAP
>document), sign it, and put in the signature now.
>
>Thanks so much for your help Aleksey, I think we're close now.
>
>Rob Cronin
>  
>




More information about the xmlsec mailing list