The CPVerifySignature function is used to verify a digital signature against a hash object.
BOOL CPVerifySignature(
HCRYPTPROV hProv, // in
HCRYPTHASH hHash, // in
CONST BYTE *pbSignature, // in
DWORD dwSigLen, // in
HCRYPTKEY hPubKey, // in
LPCWSTR sDescription, // in
DWORD dwFlags // in
);
If the function succeeds, TRUE should be returned; otherwise, return FALSE. When FALSE is returned, the appropriate error code (see the following table) must be set via 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 may also be returned if the hashing or signature algorithms don't 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:
The application should not be allowed to add more data to the hash object after the verification has been performed. However, the application is still responsible for calling the CPDestroyHash function.
CPCreateHash, CPHashData, CPSignHash, CryptVerifySignature