(CSP) 加密服务提供商使用 FuncVerifyImage 回调函数来验证 DLL 的签名。
CSP 在其中进行函数调用的所有辅助 DLL 都必须以与主 CSP DLL 相同的方式 (和相同的密钥) 进行签名。 为了确保此签名,必须使用 LoadLibrary 函数动态加载辅助 DLL。 但在加载 DLL 之前,必须验证 DLL 的签名。 CSP 通过调用 FuncVerifyImage 函数来执行此验证,如以下示例所示。
语法
typedef BOOL ( WINAPI *CRYPT_VERIFY_IMAGE)(
_In_ LPCTSTR lpszImage,
_In_ const BYTE *pbSigData
);
参数
-
lpszImage [in]
-
以 null 结尾的字符串的地址,该字符串包含要验证其签名的 DLL 的路径和文件名。
-
pbSigData [in]
-
包含签名的缓冲区的地址。
返回值
如果函数成功,则返回 TRUE ;如果失败,则返回 FALSE 。
示例
以下示例演示如何在云解决方案提供商加载 DLL 之前使用 FuncVerifyImage 回调函数验证 DLL 的签名。
BOOL (FARPROC *ProvVerifyImage)(LPCSTR lpszImage, BYTE *pSigData);
// "ProvVerifyImage" has been set to "pVTable->FuncVerifyImage"
// within the CPAcquireContext function.
// bSignature is a previously assigned BYTE array that contains the
// signature that is stored in the C:\Winnt40\System32\signature.sig
// file. During development, this file is created with the
// Sign.exe tool.
...
// Verify the signature in the
// C:\Winnt40\System32\Signature.dll file.
if(RCRYPT_FAILED(ProvVerifyImage
("c:\\winnt40\\system32\\signature.dll",
bSignature)) {
SetLastError(NTE_BAD_SIGNATURE);
return CRYPT_FAILED;
}
// Load the DLL with the LoadLibrary function, then acquire pointers
// to the functions with the GetProcAddress function.
//...
要求
| 要求 | 值 |
|---|---|
| 最低受支持的客户端 |
Windows XP [仅限桌面应用] |
| 最低受支持的服务器 |
Windows Server 2003 [仅限桌面应用] |
| 标头 |
|
另请参阅