Commit d0591483 authored by ElenaSubbotina's avatar ElenaSubbotina

Merge branches 'develop' and 'develop' of https://github.com/ONLYOFFICE/core into develop

parents 729f9f24 17a6ba73
......@@ -27,11 +27,11 @@ public:
virtual std::string GetCertificateHash() = 0;
public:
virtual std::string Sign(std::string sXml) = 0;
virtual std::string Sign(const std::string& sXml) = 0;
virtual std::string GetHash(unsigned char* pData, unsigned int nSize, int nAlg) = 0;
virtual std::string GetHash(std::string& sXml, int nAlg) = 0;
virtual std::string GetHash(std::wstring& sXmlFile, int nAlg) = 0;
virtual bool Verify(std::string& sXml, std::string& sXmlSignature, int nAlg) = 0;
virtual std::string GetHash(const std::string& sXml, int nAlg) = 0;
virtual std::string GetHash(const std::wstring& sXmlFile, int nAlg) = 0;
virtual bool Verify(const std::string& sXml, std::string& sXmlSignature, int nAlg) = 0;
virtual bool LoadFromBase64Data(const std::string& data) = 0;
......
......@@ -40,7 +40,8 @@ public:
std::wstring sXml = L"<Reference URI=\"" + file + L"?ContentType=" + content_type + L"\">";
sXml += L"<DigestMethod Algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\"/>";
sXml += L"<DigestValue>";
sXml += UTF8_TO_U(m_certificate->GetHash(m_sFolder + file, OOXML_HASH_ALG_SHA1));
std::string sTmp = m_certificate->GetHash(m_sFolder + file, OOXML_HASH_ALG_SHA1);
sXml += UTF8_TO_U(sTmp);
sXml += L"</DigestValue>";
sXml += L"</Reference>";
return sXml;
......
......@@ -4,11 +4,13 @@
#endif
#if defined(_LINUX) && !defined(_MAC)
#include "./XmlSigner_openssl.h"
#define CCertificate CCertificate_openssl
#endif
#ifdef _MAC
#include "./XmlSigner_openssl.h"
#define CCertificate CCertificate_openssl
#endif
int ICertificate::GetOOXMLHashAlg(const std::string& sAlg)
......
......@@ -154,7 +154,7 @@ public:
return builder.GetData();
}
void CheckOriginSigs(std::wstring& file)
void CheckOriginSigs(const std::wstring& file)
{
int rId = 0;
std::vector<COOXMLRelationship>::iterator i = rels.begin();
......
......@@ -100,7 +100,7 @@ public:
}
public:
virtual std::string Sign(std::string sXml)
virtual std::string Sign(const std::string& sXml)
{
BOOL bResult = TRUE;
DWORD dwKeySpec = 0;
......@@ -240,12 +240,12 @@ public:
return sReturn;
}
virtual std::string GetHash(std::string& sXml, int nAlg)
virtual std::string GetHash(const std::string& sXml, int nAlg)
{
return GetHash((BYTE*)sXml.c_str(), (DWORD)sXml.length(), nAlg);
}
virtual std::string GetHash(std::wstring& sXmlFile, int nAlg)
virtual std::string GetHash(const std::wstring& sXmlFile, int nAlg)
{
BYTE* pFileData = NULL;
DWORD dwFileDataLen = 0;
......@@ -260,7 +260,7 @@ public:
return sReturn;
}
virtual bool Verify(std::string& sXml, std::string& sXmlSignature, int nAlg)
virtual bool Verify(const std::string& sXml, std::string& sXmlSignature, int nAlg)
{
DWORD dwKeySpec = 0;
HCRYPTHASH hHash = NULL;
......
#ifndef _XMLSIGNER_OPENSSL_H_
#define _XMLSIGNER_OPENSSL_H_
#include "./include/XmlCertificate.h"
#include "../../../common/File.h"
#include "../../../common/BigInteger.h"
class CCertificate_openssl : public ICertificate
{
public:
protected:
BYTE* m_rawData;
int m_rawDataLen;
public:
CCertificate_openssl() : ICertificate()
{
m_rawData = NULL;
m_rawDataLen = 0;
}
virtual ~CCertificate_openssl()
{
}
public:
virtual std::string GetNumber()
{
return "";
}
virtual std::wstring GetSignerName()
{
return L"";
}
virtual std::string GetCertificateBase64()
{
return "";
}
virtual std::string GetCertificateHash()
{
return "";
}
public:
virtual std::string Sign(const std::string& sXml)
{
return "";
}
virtual std::string GetHash(unsigned char* pData, unsigned int nSize, int nAlg)
{
return "";
}
virtual std::string GetHash(const std::string& sXml, int nAlg)
{
return GetHash((BYTE*)sXml.c_str(), (DWORD)sXml.length(), nAlg);
}
virtual std::string GetHash(const std::wstring& sXmlFile, int nAlg)
{
BYTE* pFileData = NULL;
DWORD dwFileDataLen = 0;
NSFile::CFileBinary::ReadAllBytes(sXmlFile, &pFileData, dwFileDataLen);
if (0 == dwFileDataLen)
return "";
std::string sReturn = GetHash(pFileData, dwFileDataLen, nAlg);
RELEASEARRAYOBJECTS(pFileData);
return sReturn;
}
virtual bool Verify(const std::string& sXml, std::string& sXmlSignature, int nAlg)
{
return false;
}
virtual bool LoadFromBase64Data(const std::string& data)
{
return false;
}
virtual int ShowCertificate()
{
return 1;
}
public:
virtual bool ShowSelectDialog()
{
return false;
}
};
#endif // _XMLSIGNER_OPENSSL_H_
......@@ -4,7 +4,7 @@
#include "../../../common/File.h"
void main(void)
int main(void)
{
//std::wstring sFolderOOOXML = NSFile::GetProcessDirectory() + L"/ImageStamp";
//std::wstring sSignId = L"{39B6B9C7-60AD-45A2-9F61-40C74A24042E}";
......@@ -19,7 +19,7 @@ void main(void)
if (!pCertificate->ShowSelectDialog())
{
RELEASEOBJECT(pCertificate);
return;
return 0;
}
COOXMLSigner oOOXMLSigner(sFolderOOXML, pCertificate);
......@@ -45,4 +45,5 @@ void main(void)
nRes = nRes;
}
}
return 0;
}
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