12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- #ifndef _RVC_CODESIGN_VERIFY_H_
- #define _RVC_CODESIGN_VERIFY_H_
- #pragma once
- #include "SpBase.h"
- #include "SimpleString.h"
- #if defined(_MSC_VER)
- #include <WinCrypt.h>
- #endif //_MSC_VER
- struct CVersionInfo
- {
- CVersion FileVersion;
- CVersion ProductVersion;
- CSimpleStringA strProductName;
- CSimpleStringA strAuthorName;
- CSimpleStringA strCompanyName;
- CSimpleStringA strDescription;
- CVersionInfo() :strProductName(""), strAuthorName(""), strCompanyName(""), strDescription(""){}
- };
- struct CSignInfo
- {
- CSimpleStringA strProgramName;
- CSimpleStringA strSignCertSerialNo;
- CSimpleStringA strSignCertIssuer;
- CSimpleStringA strSignCertSubject;
- CSmallDateTime dtSignTime;
- CSimpleStringA strSignCertHash;
- CSignInfo() :strProgramName(""), strSignCertIssuer(""), strSignCertSubject(""), strSignCertHash(""){}
- };
- #ifdef RVC_OS_WIN
- // verify code signature & get file version
- class CCodeSignVerify
- {
- public:
- CCodeSignVerify(DWORD dwCodePage = 0x04b0, DWORD dwLangID = 0x0804);
- ~CCodeSignVerify();
- bool GetVersionInfo(const char *pszFileName, CVersionInfo &versionInfo);
- bool VerifySignature(const char *pszFileName, CSignInfo &signInfo);
- CSimpleStringA GetErrorMsg();
- private:
- bool IsSignFromTrust(const char *pszFileName);
- bool GetSignInfo(const char *pszFileName, CSignInfo &signInfo);
- void SetLastErrMsg(const char *pErrMsg = NULL);
- bool GetStringFileInfo(void *pVersionInfo, const char *pszKeyName, CSimpleStringA &strValue);
-
- bool GetTimeOfTimeStamp(HCERTSTORE hStore, PCMSG_SIGNER_INFO pSignerInfo, SYSTEMTIME *st);
- bool GetProgramName(PCMSG_SIGNER_INFO pSignerInfo, CSimpleStringA &strProgramName);
- bool GetSignCertInfo(HCERTSTORE hStore, PCMSG_SIGNER_INFO pSignerInfo, CSimpleStringA &strSerialNum,
- CSimpleStringA &strIssuer, CSimpleStringA &strSubject, CSimpleStringA &strCertHash);
-
- bool Sha1Hash(BYTE *pData, int nDataLen, BYTE hash[20]);
- private:
- CSimpleStringA m_strLastErrMsg;
- DWORD m_dwCodePage;
- DWORD m_dwLangID;
- };
- #endif //_WIN32
- #endif //_RVC_CODESIGN_VERIFY_H_
|