CryptVerifySignatureA function (wincrypt.h)
After CryptVerifySignature completes, only CryptDestroyHash can be called by using the hHash handle.
BOOL CryptVerifySignatureA( [in] HCRYPTHASH hHash, [in] const BYTE *pbSignature, [in] DWORD dwSigLen, [in] HCRYPTKEY hPubKey, [in] LPCSTR szDescription, [in] DWORD dwFlags );
A handle to the hash object to verify.
The address of the signature data to be verified.
The number of bytes in the pbSignature signature data.
This parameter should no longer be used and must be set to NULL to prevent security vulnerabilities. However, it is still supported for backward compatibility in the Microsoft Base Cryptographic Provider.
The following flag values are defined.
||This flag is used with RSA providers. When verifying the signature, the hash object identifier (OID) is not expected to be present or checked. If this flag is not set, the hash OID in the default signature is verified as specified in the definition of DigestInfo in PKCS #7.|
||This flag is not used.|
||Use X.931 support for the FIPS 186-2–compliant version of RSA (rDSA).|
If the function succeeds, the return value is TRUE.
If the function fails, the return value is FALSE. For extended error information, call GetLastError.
The error codes prefaced by "NTE" are generated by the particular CSP you are using. Some possible error codes follow.
||One of the parameters specifies a handle that is not valid.|
||One of the parameters contains a value that is not valid. This is most often a pointer that is not valid.|
||The dwFlags parameter is nonzero.|
||The hash object specified by the hHash parameter is not valid.|
||The hPubKey parameter does not contain a handle to a valid public key.|
The signature was not valid. This might be because the data itself has changed, the description string did not match, or the wrong public key was specified by hPubKey.
This error can also be returned if the hashing or signature algorithms do not match the ones used to create the signature.
||The cryptographic service provider (CSP) context that was specified when the hash object was created cannot be found.|
||The CSP ran out of memory during the operation.|
The CryptVerifySignature function completes the hash. After this call, no more data can be added to the hash. Additional calls to CryptHashData or CryptHashSessionKey fail. After the application is done with the hash, CryptDestroyHash should be called to destroy the hash object.
If you generate a signature by using the .NET Framework APIs and try to verify it by using the CryptVerifySignature function, the function will fail and GetLastError will return NTE_BAD_SIGNATURE. This is due to the different byte orders between the native Win32 API and the .NET Framework API.
The native cryptography API uses little-endian byte order while the .NET Framework API uses big-endian byte order. If you are verifying a signature generated by using a .NET Framework API, you must swap the order of signature bytes before calling the CryptVerifySignature function to verify the signature.
For an example that uses the CryptVerifySignature function, see Example C Program: Signing a Hash and Verifying the Hash Signature.
The wincrypt.h header defines CryptVerifySignature as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.
|Minimum supported client||Windows XP [desktop apps only]|
|Minimum supported server||Windows Server 2003 [desktop apps only]|