软件数字签名 c语言,数字签名,该怎么解决

当前位置:我的异常 ? C语言 ? 数字签名,该怎么解决

数字签名,该怎么解决

www.myexceptions.net   友分享于:2013-05-23  浏览:74次

数字签名

请问大神们,关于数字签名有没有什么比较新颖的算法,谢谢!

——解决方案——————–

#include

#include

#include

#include

#include

#pragma comment(lib, “crypt32.lib”)

#define ENCODING (X509_ASN_ENCODING | PKCS_7_ASN_ENCODING)

typedef struct {

LPWSTR lpszProgramName;

LPWSTR lpszPublisherLink;

LPWSTR lpszMoreInfoLink;

} SPROG_PUBLISHERINFO, *PSPROG_PUBLISHERINFO;

BOOL GetProgAndPublisherInfo(PCMSG_SIGNER_INFO pSignerInfo,

PSPROG_PUBLISHERINFO Info);

BOOL GetDateOfTimeStamp(PCMSG_SIGNER_INFO pSignerInfo, SYSTEMTIME *st);

BOOL PrintCertificateInfo(PCCERT_CONTEXT pCertContext);

BOOL GetTimeStampSignerInfo(PCMSG_SIGNER_INFO pSignerInfo,

PCMSG_SIGNER_INFO *pCounterSignerInfo);

int _tmain(int argc, TCHAR *argv[])

{

WCHAR szFileName[MAX_PATH];

HCERTSTORE hStore = NULL;

HCRYPTMSG hMsg = NULL;

PCCERT_CONTEXT pCertContext = NULL;

BOOL fResult;

DWORD dwEncoding, dwContentType, dwFormatType;

PCMSG_SIGNER_INFO pSignerInfo = NULL;

PCMSG_SIGNER_INFO pCounterSignerInfo = NULL;

DWORD dwSignerInfo;

CERT_INFO CertInfo;

SPROG_PUBLISHERINFO ProgPubInfo;

SYSTEMTIME st;

ZeroMemory(&ProgPubInfo, sizeof(ProgPubInfo));

__try

{

if (argc != 2)

{

_tprintf(_T(“Usage: SignedFileInfo n”));

return 0;

}

#ifdef UNICODE

lstrcpynW(szFileName, argv[1], MAX_PATH);

#else

if (mbstowcs(szFileName, argv[1], MAX_PATH) == -1)

{

printf(“Unable to convert to unicode.n”);

__leave;

}

#endif

// Get message handle and store handle from the signed file.

fResult = CryptQueryObject(CERT_QUERY_OBJECT_FILE,

szFileName,

CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED_EMBED,

CERT_QUERY_FORMAT_FLAG_BINARY,

0,

&dwEncoding,

&dwContentType,

&dwFormatType,

&hStore,

&hMsg,

NULL);

if (!fResult)

{

_tprintf(_T(“CryptQueryObject failed with %xn”), GetLastError());

__leave;

}

// Get signer information size.

fResult = CryptMsgGetParam(hMsg,

CMSG_SIGNER_INFO_PARAM,

0,

NULL,

&dwSignerInfo);

if (!fResult)

{

_tprintf(_T(“CryptMsgGetParam failed with %xn”), GetLastError());

__leave;

}

// Allocate memory for signer information.

pSignerInfo = (PCMSG_SIGNER_INFO)LocalAlloc(LPTR, dwSignerInfo);

if (!pSignerInfo)

{

_tprintf(_T(“Unable to allocate memory for Signer Info.n”));

__leave;

}

// Get Signer Information.

fResult = CryptMsgGetParam(hMsg,

CMSG_SIGNER_INFO_PARAM,

0,

(PVOID)pSignerInfo,

&dwSignerInfo);

文章评论

文章知识点与官方知识档案匹配,可进一步学习相关知识C技能树首页概览115003 人正在系统学习中 相关资源:ios签名软件-iOS工具类资源

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2021年4月15日
下一篇 2021年4月15日

相关推荐