gpt4 book ai didi

c - 在 Visual Studio 中使用 PKCS#11

转载 作者:行者123 更新时间:2023-11-30 17:48:24 25 4
gpt4 key购买 nike

我需要使用标准 PKCS#11 连接到 token 。在我用 Visual Studio 编写的 C 程序中,我包含了从 RSA 网站下载的 PKCS#11 header 和一些宏。

//define macros
#define CK_PTR *
#define CK_DEFINE_FUNCTION(returnType, name) returnType name
#define CK_DECLARE_FUNCTION(returnType, name) returnType name
#define CK_DECLARE_FUNCTION_POINTER(returnType, name) returnType (* name)
#define CK_CALLBACK_FUNCTION(returnType, name) returnType (* name)
#ifndef NULL_PTR
#define NULL_PTR 0
#endif

#include "pkcs11.h"

int main(int argc, char * argv[]) {
[..]
C_Initialize(NULL_PTR);
[..]

当我构建它时,我得到“对 C_Initialize 的 undefined reference ”。我使用的所有 pkcs11 函数都有同样的错误。在程序目录中还有其他 pkcs11 header 。这有什么问题吗?

最佳答案

对于静态链接,您需要有相应的 .lib 文件。将应用程序与特定硬件设备的SDK链接即可获得。

通用方法是动态加载最终用户给出的 DLL。为此,您的代码需要使用 LoadLibrary() 和 GetProcAddress() Windows API 函数来获取库中每个函数的地址(是的,如果没记错的话,其中有超过 50 个函数)。

关于c - 在 Visual Studio 中使用 PKCS#11,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18588506/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com