<?xml version="1.0" ?><html>
<head>
<title></title>
</head>
<body>
<div align="left"><font face="Arial"><span style="font-size:10pt">Hi</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">I successfully signed xml according to rules http://www.w3.org/TR/xmldsig-core/.</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">I did it using xmlsec. Signature is correct because I checked it using external tool.</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">But I've got an unsolved problem at verifing my signature myself.</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">I used code published in verify3.c file doing little changes matching to my task</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">and context (CryptoApi, X509, C++Builder6)</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">I read xml file to char* buffer and call my VerifyCert function. It successfully read</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">all certs from "CA" CryptoApi store and put them to xmlsec keys manager using</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">xmlSecMSCryptoAppKeysMngrCertLoadMemory (see LoadCerts() function).</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">But VerifyCert fails during call of xmlSecDSigCtxVerify(). This function returns</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">a few error context via error callback function. They look like:</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">1.</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt"> file:        ..\src\keys.c</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt"> func:        xmlSecKeysMngrGetKey</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt"> errorObject:   </span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt"> errorSubject:    xmlSecKeysMngrFindKey</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt"> reason:        1</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt"> msg:        </span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">2.</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt"> file:        ..\src\xmldsig.c</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt"> func:        xmlSecDSigCtxProcessKeyInfoNode</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt"> errorObject:    </span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt"> errorSubject:    </span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt"> reason:        45</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt"> msg:    </span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">3.</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt"> file:        ..\src\xmldsig.c</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt"> func:        xmlSecDSigCtxProcessSignatureNode</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt"> errorObject:   </span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt"> errorSubject:    xmlSecDSigCtxProcessKeyInfoNode</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt"> reason:        1</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt"> msg:</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">4.</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt"> file:        ..\src\xmldsig.c</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt"> func:        xmlSecDSigCtxVerify</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt"> errorObject:    </span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt"> errorSubject:    xmlSecDSigCtxSigantureProcessNode</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt"> reason:        1</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt"> msg:      </span></font></div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">What should I change to make this code to work?</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">Where did I mistakes?</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">Should I load all certs from CA store, or only proper one?</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">Thanx in advance</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">Peter</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">My code looks like:</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">//------------------------------------------------------------</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">// loads certs from MsStore</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">//</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">xmlSecKeysMngrPtr LoadCerts(AnsiString StoreName) {</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   xmlSecKeysMngrPtr mngr = NULL;</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   // przygotowanie menagera xmlsec</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   mngr = xmlSecKeysMngrCreate();</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   if(mngr == NULL) {</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      return (NULL);</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   }</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   if(xmlSecCryptoAppDefaultKeysMngrInit(mngr) < 0) {</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      xmlSecKeysMngrDestroy(mngr);</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      return (NULL);</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   }</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   //xmlSecKeyDataFormat secKeyDataFormat = X509_ASN_ENCODING;</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   // pobranie listy certyfikatow  - retrieving cert list</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   wchar_t wcharStoreName[256];</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   StoreName.WideChar(wcharStoreName, 256);</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   HCERTSTORE hStoreHandle;</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   PCCERT_CONTEXT pSignerCert = NULL;</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   CRYPT_SIGN_MESSAGE_PARA  SigParams;</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   DWORD cbSignedMessageBlob;</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   BYTE  *pbSignedMessageBlob;</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   DWORD cbDecodedMessageBlob;</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   BYTE  *pbDecodedMessageBlob;</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   CRYPT_VERIFY_MESSAGE_PARA VerifyParams;</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   //--------------------------------------------------------------------</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   // opening CryptoApi cert store</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   if(!( hStoreHandle = CertOpenStore(</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      CERT_STORE_PROV_SYSTEM,</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      0,</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      NULL,</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      CERT_SYSTEM_STORE_CURRENT_USER,</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      wcharStoreName))){</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">        return NULL;</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   }</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   PCCERT_CONTEXT  pCertContext = NULL;</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   int loadResult = 0;</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   // enumerating certs from CryptoApi store and loading to xmlsec keys menager</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   while(loadResult == 0){</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      pCertContext = CertEnumCertificatesInStore(hStoreHandle, pCertContext);</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      if(!pCertContext)</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">         break;</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      //char pszNameString[256];</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      //CertGetNameString(pCertContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, NULL,</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      //   pszNameString, 128);</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      //if(strcmp(pszNameString, "Izba Celna w Krakowie") == 0)</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      loadResult = xmlSecMSCryptoAppKeysMngrCertLoadMemory(mngr,</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">                              
pCertContext->pbCertEncoded,</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">                              
pCertContext->cbCertEncoded,</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">                              
xmlSecKeyDataFormatDer,</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">                              
xmlSecKeyDataTypeTrusted);</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   }</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   if(loadResult < 0){</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      // cleaning</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      xmlSecKeysMngrDestroy(mngr);</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      return NULL;</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   }</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   return mngr;</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">}</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">// --------------------------------------------------------------</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">/* verifing certs</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">/*</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">some explanation: storeName = "CA"</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">inBuffer - contains previously loaded xml data</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">inSize   - size of inBuffer</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">txt - holds error messages</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">*/</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">bool VerifyCert(char *inBuffer, int inSize, char *storeName, int storeNameSize, AnsiString&
txt){</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   txt = "";</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   bool result = true;</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   xmlSecKeysMngrPtr mngr = NULL;</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   if(!InitParser(storeName)){</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      txt = "Nie można zainicjalizować parsera";</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      return false;</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   }</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   // setting up error callback</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   xmlSecErrorsDefaultCallbackEnableOutput (1);</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   xmlSecErrorsSetCallback(myXmlSecErrorsCallback);</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   // loading certs from CryptoApi</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   mngr = LoadCerts(storeName);</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   if(!mngr){</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      txt = "TXMLDocumentSign::VerifyCert() - błąd ładowania certyfikatów";</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      StopParser();</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      return false;</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   }</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   xmlDocPtr doc = NULL;</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   xmlSecDSigCtxPtr dsigCtx = NULL;</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   xmlNodePtr node = NULL;</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   int res = -1;</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   // loading data from buffer and parsing</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   doc = xmlParseMemory(inBuffer, inSize);</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   xmlNodePtr rootNode = xmlDocGetRootElement(doc);</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   if ((doc == NULL) || (rootNode == NULL)){</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      result = false;</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      txt = "TXMLDocumentSign::VerifyCert() - brak elemementu głównego w dokumencie
XML.";</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      goto done;</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   }</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   // test code</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   {</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      xmlChar *mem  = NULL;</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      int size = 0;</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      xmlDocDumpMemory(doc, &mem, &size);</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      std::auto_ptr<TFileStream> fs (new TFileStream("dump.xml", fmCreate));</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      fs->Write(mem, size);</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      fs.release();</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   }</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   // find start node</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   node = xmlSecFindNode(rootNode, BAD_CAST "Signature", BAD_CAST
"http://www.w3.org/2000/09/xmldsig#"/*xmlSecDSigNs*/ );</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   if(node == NULL) {</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      result = false;</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      txt = "TXMLDocumentSign::VerifyCert() - nie można odnaleŁć elementu \"Signature\".";</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      goto done;</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   }</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   // create signature context</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   dsigCtx = xmlSecDSigCtxCreate(mngr);</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   if(dsigCtx == NULL) {</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      result = false;</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      txt = "TXMLDocumentSign::VerifyCert() - błąd pozyskiwania kontekstu.";</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      goto done;</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   }</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   // Verify signature</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   if(xmlSecDSigCtxVerify(dsigCtx, node) < 0) {</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      txt = "TXMLDocumentSign::VerifyCert() - nieudana weryfikacja podpisu.";</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      result = false;</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      goto done;</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   }</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   if(!dsigCtx->status == xmlSecDSigStatusSucceeded){</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      result = false;</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   }</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">done:</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   // cleanup</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   if(dsigCtx != NULL) {</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      xmlSecDSigCtxDestroy(dsigCtx);</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   }</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   if(doc != NULL) {</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      xmlFreeDoc(doc);</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   }</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   StopParser();</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   return result;</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">}</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">// --------------- initialization of xmlsec</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">int InitParser(char *storeName){</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   xmlInitParser();</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   LIBXML_TEST_VERSION xmlLoadExtDtdDefaultValue = XML_DETECT_IDS |
XML_COMPLETE_ATTRS;</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   xmlSubstituteEntitiesDefault(1);</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">#ifndef XMLSEC_NO_XSLT</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   xmlIndentTreeOutput = 1;</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">#endif // XMLSEC_NO_XSLT</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   // Init xmlsec library</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   if(xmlSecInit() < 0) {</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      return(0);</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   }</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   // Check loaded library version</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   if(xmlSecCheckVersion() != 1) {</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      return(0);</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   }</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   // Load default crypto engine if we are supporting dynamic</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   // * loading for xmlsec-crypto libraries. Use the crypto library</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   // * name ("openssl", "nss", etc.) to load corresponding</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   // * xmlsec-crypto library.</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   //</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">#ifdef XMLSEC_CRYPTO_DYNAMIC_LOADING</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   if(xmlSecCryptoDLLoadLibrary(BAD_CAST XMLSEC_CRYPTO) < 0) {</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      return(0);</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   }</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">#endif // XMLSEC_CRYPTO_DYNAMIC_LOADING</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   // Init crypto library</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   if(xmlSecCryptoAppInit(storeName) < 0) {</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      return(0);</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   }</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   // Init xmlsec-crypto library</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   if(xmlSecCryptoInit() < 0) {</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">      return(0);</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   }</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   return 1;</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">}</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">// shutting down xmlsec</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">int StopParser(){</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   // Shutdown xmlsec-crypto library</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   xmlSecCryptoShutdown();</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   // Shutdown crypto library</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   xmlSecCryptoAppShutdown();</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   // Shutdown xmlsec library</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   xmlSecShutdown();</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   // Shutdown libxslt/libxml</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">//#ifndef XMLSEC_NO_XSLT</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">//   xsltCleanupGlobals();</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">//#endif // XMLSEC_NO_XSLT</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   xmlCleanupParser();</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">   return(0);</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">}</span></font></div>
<div align="left"><br/>
</div>
<div align="left"></div>
</body>
</html>