[xml] Help required, trying to EXEC_C14N sub-document




All I am trying to do is calculate the DigestValue over the XML (see part of
XML doc below) sub-document with Id=MsgOperation.  I know that the data from
this sub-document is converted into a hash with SHA-1 and then Base64.

The problem I am having is converting the sub-document using EXEC-C14N.  I
am trying to use the LibXML2 library (very good), to EXEC-C14N the
sub-document with:

[code]
CString CDigitalCerts::C14N( const char* pszXml, const bool bExclusive )
{
   CString sRet         = _T("");
   xmlChar* pOutput     = NULL;
   xmlDocPtr pXmlDoc    = xmlReadMemory( pszXml, (int)strlen( pszXml ),
_T("xml"), NULL, 0 );
   int result           = 0;
   void* pData          = NULL;

   xmlOutputBufferPtr buf = 0;

   if ( pXmlDoc )
   {
      result = xmlC14NDocDumpMemory( pXmlDoc,                                           
                                     NULL,                                              
                                     (int)bExclusive,                           
                                     NULL,                                              
                                     0,                                         
                                     &pOutput );
   }

   xmlFreeDoc( pXmlDoc );

   if ( result > 0 )
   {
      sRet = (LPCTSTR)pOutput;
   }

   xmlFree( pOutput );
   pOutput = NULL;

   return sRet;
}
[/code]

I would appreciate if someone could advise on what I need to add to argv[1]
(nodes) or argv[3] (inclusive_ns_prefixes) so that the resultant string of
the sub-document is correctly canonicalized.  Or what the canonicalized
sub-document should look like to correctly then calculate the DigestValue
which I know is: wJsL4RtLToFeHW/xt2ewbAAiNxk=

[code]
<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
 <soapenv:Header>
  <ns1:Operation Id="MsgOperation" soapenv:mustUnderstand="0"
xsi:type="xsd:string" xmlns:ns1="http://www.ros.ie/schemas/service/";
xmlns:xsi="http://w
ww.w3.org/2001/XMLSchema-instance">CT1/File</ns1:Operation>
<wsse:Security
xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/07/secext">

...

<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
      <ds:SignedInfo>
        <ds:CanonicalizationMethod
Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
        <ds:SignatureMethod
Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
        <ds:Reference URI="#MsgOperation">
          <ds:Transforms>
            <ds:Transform
Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
          </ds:Transforms>
          <ds:DigestMethod
Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
          <ds:DigestValue></ds:DigestValue>
        </ds:Reference>

...

      </ds:SignedInfo>
      <ds:SignatureValue>
      </ds:SignatureValue>
      <ds:KeyInfo>
        <wsse:SecurityTokenReference>
          <wsse:Reference URI="#X509Token"/>
        </wsse:SecurityTokenReference>
      </ds:KeyInfo>
    </ds:Signature></wsse:Security> </soapenv:Header>
[/code]
-- 
View this message in context: 
http://www.nabble.com/Help-required%2C-trying-to-EXEC_C14N-sub-document-tp18239229p18239229.html
Sent from the Gnome - Lib - Xml - General mailing list archive at Nabble.com.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]