×
您的位置: 首页 > 编程笔记

数字签名与CryptVerifySignature(Digital signature with CryptVerifySignature)

C# 时间:2020-06-15  查看:1125   收藏

I want to implement digital signature app using CryptVerifySignature. I've written this code(with help of MSDN example):

#define Check(condition, message) if (!(condition)) { fprintf(stderr, "%sn", message); goto Exit; };
void DigSign(const char* inputFileName, const char* signFileName)
{

    HCRYPTPROV hProv;
    BYTE *pbBuffer= NULL;
    DWORD dwBufferLen = 0;
    HCRYPTHASH hHash;
    HCRYPTKEY hKey;
    HCRYPTKEY hPubKey;
    BYTE *pbKeyBlob;        
    BYTE *pbSignature;
    DWORD dwSigLen;
    DWORD dwBlobLen;

    FILE* inputFile = NULL;

    Check((inputFile = fopen(inputFileName, "r")) != NULL, "File does not exists");
    dwBufferLen = GetFileSize(inputFile);
    Check(pbBuffer = (BYTE*)malloc(dwBufferLen + 1), "cannot allocate memory");

    fread(pbBuffer, 1, dwBufferLen, inputFile);
    pbBuffer[dwBufferLen] = '

 

0% (0)
0% (0)