Commit b36c2dba authored by Oleg Korshul's avatar Oleg Korshul

verify ooxml file. first worked version

parent 10b9e9e5
......@@ -99,7 +99,7 @@ private:
for (int i = 0; i < nCount; i++)
{
oNodes.GetAt(i, ret.m_node);
CXmlStackNamespaces _retRecursion = ret.GetByIdRec(ret, id);
CXmlStackNamespaces _retRecursion = ret.GetByIdRec(ret, id, isNameUse);
if (_retRecursion.m_node.IsValid())
return _retRecursion;
}
......@@ -117,7 +117,15 @@ private:
std::wstring sXmlFind = L"<" + sName + L" ";
if (0 == sXml.find(sXmlFind))
{
sXml.replace(0, sXmlFind.length(), L"<" + sName + L" " + m_namespaces + L" ");
}
else
{
sXmlFind = L"<" + sName + L">";
if (0 == sXml.find(sXmlFind))
sXml.replace(0, sXmlFind.length(), L"<" + sName + L" " + m_namespaces + L">");
}
}
return U_TO_UTF8(sXml);
......@@ -223,7 +231,7 @@ public:
std::string sXml = stackRes.GetXml();
std::string sCanonicalizationMethod = m_node.ReadNode(L"SignedInfo").ReadNode(L"CanonicalizationMethod").GetAttributeA("Algorithm");
std::string sSignatureMethod = m_node.ReadNode(L"SignedInfo").ReadNode(L"CanonicalizationMethod").GetAttributeA("Algorithm");
std::string sSignatureMethod = m_node.ReadNode(L"SignedInfo").ReadNode(L"SignatureMethod").GetAttributeA("Algorithm");
int nSignatureMethod = ICertificate::GetOOXMLHashAlg(sSignatureMethod);
if (OOXML_HASH_ALG_INVALID == nSignatureMethod)
......@@ -244,7 +252,7 @@ public:
std::string sSignatureValue = U_TO_UTF8((m_node.ReadValueString(L"SignatureValue")));
if (sSignatureCalcValue != sSignatureValue)
if (!m_cert->Verify(sSignatureCalcValue, sSignatureValue, nSignatureMethod))
m_valid = OOXML_SIGNATURE_INVALID;
}
......
......@@ -181,6 +181,9 @@ public:
bResult = CryptAcquireCertificatePrivateKey(m_context, 0, NULL, &hCryptProv, &dwKeySpec, NULL);
if (!bResult)
bResult = CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
if (!bResult)
return "";
......@@ -264,14 +267,17 @@ public:
BOOL bResult = CryptAcquireCertificatePrivateKey(m_context, 0, NULL, &hCryptProv, &dwKeySpec, NULL);
if (!bResult)
return FALSE;
bResult = CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
if (!bResult)
return false;
bResult = CryptCreateHash(hCryptProv, GetHashId(nAlg), 0, 0, &hHash);
if (!bResult)
{
CryptReleaseContext(hCryptProv, 0);
return FALSE;
return false;
}
BYTE* pDataHash = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment