use*_*494 5 openssl openssl-engine
我正在为我的应用程序开发一个示例 OpenSSL 引擎。
#include <openssl/engine.h>
static const char *engine_id = "sample";
static const char *engine_name = "developed by Devang";
static int engine_init(ENGINE *e);
static EVP_PKEY *load_key(ENGINE *e, const char *id, UI_METHOD *ui, void *cb);
int bind_helper(ENGINE*e, const char *id) {
if(!ENGINE_set_id(e, engine_id) ||
!ENGINE_set_init_function(e, engine_init) ||
!ENGINE_set_load_privkey_function(e, load_key))
return 0;
return 1;
}
IMPLEMENT_DYNAMIC_CHECK_FN(); IMPLEMENT_DYANMIC_BIND_FN(bind_helper);
static int engine_init(ENGINE *e)
{
printf("In engine_init \n");
}
static EVP_PKEY *load_key(ENGINE *e, const char *id, UI_METHOD *ui, void *cb) {
printf(" In load_key function\n");
}
Run Code Online (Sandbox Code Playgroud)
我构建了这个 openssl 引擎(sample.so)并将共享库放入 /usr/lib/x86_64-linu-gnu/openssl-1.0.0/engines/
我创建了一个示例应用程序sampleTest.c
#include <openssl/engine.h>
int main(void)
{
ENGINE_load_dynamic();
ENGINE *en = ENGINE_by_id("sample");
ENGINE_init(en);
ENGINE_load_private_key(en, NULL, UI_OpenSSL(), NULL);
}
Run Code Online (Sandbox Code Playgroud)
我运行这个示例应用程序,输出:
在engine_init中
为什么不调用load_key函数?任何人都可以帮助我从我的应用程序链接到 load_key 函数吗?
尝试从 engine_init() 函数返回 1。Openssl 会认为您的引擎未能初始化,否则不会使用进一步的函数引用。
即:它认为您的“硬件加速器”未插入或出现其他类型的故障。
static int engine_init(ENGINE *e)
{
printf("In engine_init \n");
return 1;
}
Run Code Online (Sandbox Code Playgroud)
我将其添加到您的示例中,并从您正在寻找的 load_key() 中获取了输出。
| 归档时间: |
|
| 查看次数: |
1745 次 |
| 最近记录: |