Commit 9f2324d2 authored by Oleg Korshul's avatar Oleg Korshul

verify ooxml file. developing...

parent 6e258b85
...@@ -33,6 +33,9 @@ public: ...@@ -33,6 +33,9 @@ public:
virtual std::string GetHash(std::wstring& sXmlFile) = 0; virtual std::string GetHash(std::wstring& sXmlFile) = 0;
virtual bool Verify(std::string& sXml, std::string& sXmlSignature) = 0; virtual bool Verify(std::string& sXml, std::string& sXmlSignature) = 0;
virtual bool LoadFromBase64Data(const std::string& data) = 0;
virtual int ShowCertificate() = 0;
public: public:
virtual bool ShowSelectDialog() = 0; virtual bool ShowSelectDialog() = 0;
}; };
......
...@@ -14,27 +14,40 @@ public: ...@@ -14,27 +14,40 @@ public:
HCERTSTORE m_store; HCERTSTORE m_store;
PCCERT_CONTEXT m_context; PCCERT_CONTEXT m_context;
protected:
BYTE* m_rawData;
int m_rawDataLen;
public: public:
CCertificate_mscrypto() : ICertificate() CCertificate_mscrypto() : ICertificate()
{ {
m_store = NULL; m_store = NULL;
m_context = NULL; m_context = NULL;
m_rawData = NULL;
m_rawDataLen = 0;
} }
CCertificate_mscrypto(PCCERT_CONTEXT ctx) : ICertificate() CCertificate_mscrypto(PCCERT_CONTEXT ctx) : ICertificate()
{ {
m_store = NULL; m_store = NULL;
m_context = ctx; m_context = ctx;
m_rawData = NULL;
m_rawDataLen = 0;
} }
virtual ~CCertificate_mscrypto() virtual ~CCertificate_mscrypto()
{ {
if (m_store != NULL) if (m_store != NULL || m_rawData != NULL)
{ {
if (NULL != m_context) if (NULL != m_context)
CertFreeCertificateContext(m_context); CertFreeCertificateContext(m_context);
CertCloseStore(m_store, 0); RELEASEARRAYOBJECTS(m_rawData);
} }
if (m_store != NULL)
CertCloseStore(m_store, 0);
} }
public: public:
...@@ -286,6 +299,28 @@ public: ...@@ -286,6 +299,28 @@ public:
return bResultRet && bResult; return bResultRet && bResult;
} }
virtual bool LoadFromBase64Data(const std::string& data)
{
RELEASEARRAYOBJECTS(m_rawData);
if (!NSFile::CBase64Converter::Decode(data.c_str(), (int)data.length(), m_rawData, m_rawDataLen))
return false;
m_context = CertCreateCertificateContext(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, m_rawData, m_rawDataLen);
if (!m_context)
{
RELEASEARRAYOBJECTS(m_rawData);
m_rawDataLen = 0;
return false;
}
return true;
}
virtual int ShowCertificate()
{
return (int)CryptUIDlgViewContext(CERT_STORE_CERTIFICATE_CONTEXT, m_context, NULL, NULL, 0, NULL);
}
public: public:
virtual bool ShowSelectDialog() virtual bool ShowSelectDialog()
{ {
......
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