我有一个应用程序,它与 OpenSSL 1.0.2 和 TPM 硬件与 RSA 的 OpenSSL ENGINE 实现动态链接。
我使用 OpenSSL 的动态ENGINE 来注册 TPM ENGINE。这是(简化的)代码的样子:
ENGINE_load_dynamic();
ENGINE *e = ENGINE_by_id("dynamic");
ENGINE_ctrl_cmd_string(e, "SO_PATH", path_to_libtpm, 0);
ENGINE_ctrl_cmd_string(e, "ID", "tpm2tss", 0);
ENGINE_ctrl_cmd_string(e, "LOAD", NULL, 0);
ENGINE_init(e);
ENGINE_ctrl_cmd(e, ...);
ENGINE_ctrl_cmd(e, ...);
ENGINE_register_all_complete();
ENGINE_finish(e);
ENGINE_free(e);
根据手册页,由于我调用ENGINE_register_all_complete()
而不是ENGINE_set_default_RSA
,我让 OpenSSL 决定使用哪个 RSA 实现。
下次 OpenSSL 尝试设置 RSA 密钥时,任何实现 RSA_METHOD 的捆绑 ENGINE 都将被传递给 ENGINE_init(),如果其中任何一个成功,则该 ENGINE 将被设置为从那时起使用 RSA 的默认值
OpenSSL 是否会将已注册 ENGINE 中的 RSA 实现优先于其自己的实现?
当注册了多个为同一算法提供实现的 ENGINE 时会发生什么?OpenSSL 会使用它能够初始化的第一个 ENGINE 吗?
如果ENGINE_set_default_XXX
不调用,是否可以保证使用已注册的 ENGINE?