Platform SDK: Cryptography |
The CPVerifySignature function verifies the digital signature.
BOOL CPVerifySignature( HCRYPTPROV hProv, // in HCRYPTHASH hHash, // in CONST BYTE *pbSignature, // in DWORD dwSigLen, // in HCRYPTKEY hPubKey, // in LPCWSTR sDescription, // in DWORD dwFlags // in );
The use of this parameter is not recommended because of security vulnerabilities. It is recommended that it always be interpreted as set to NULL. Some CSPs might prefer to keep supporting it for backward compatibility with the Microsoft Cryptographic Service Providers.
The Microsoft cryptographic providers support this flag in Windows 2000. This support is not included with Windows 98 or Internet Explorer 5.0 or later.
If the function succeeds, the return value is TRUE.
If the function fails, the return value is FALSE, and the appropriate error code from the following table must be set using SetLastError.
Error | Description |
---|---|
NTE_BAD_FLAGS | The dwFlags parameter is non-zero. |
NTE_BAD_HASH | The hash object specified by the hHash parameter is invalid. |
NTE_BAD_KEY | The hPubKey parameter does not contain a handle to a valid public key. |
NTE_BAD_SIGNATURE | The signature failed to verify. This could be because the data itself has changed, the description string did not match, or the wrong public key was specified by hPubKey.
This error might also be returned if the hashing or signature algorithms do not match the ones used to create the signature. |
NTE_BAD_UID | The CSP context that was specified when the hash object was created cannot now be found. |
NTE_NO_MEMORY | The CSP ran out of memory during the operation. |
The CPVerifySignature function typically performs the following steps internally:
CPVerifySignature completes a hash. After CPVerifySignature has been called, no more data can be added to the hash. Additional calls to CPHashData or CPHashSessionKey fail. However, additional calls to CPDeriveKey, CPGetHashParam, CPSignHash, and CPVerifySignature succeed and use the finished hash object.
Windows NT/2000: Requires Windows NT 4.0 or later.
Windows 95/98: Requires Windows 95 OSR2 or later (or Windows 95 with Internet Explorer 3.02 or later).
Header: Declared in Wincrypt.h.