ENGINE_init fails on TPM engine

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

ENGINE_init fails on TPM engine

Yichun Ding
openssl version: 1.0.1e

During reboot, the following code is used to set up the tpm engine:

    e = ENGINE_by_id("tpm");
    if(!e) {
        /* the engine isn't available */
        ERR("ENGINE_by_id failed.");
        return CU_ERROR;

    if (!ENGINE_init(e)) {
        int err_num = ERR_get_error();
        char buf[128] = {0};
        ERR("ENGINE_init failed.");
        printf("ENGINE_init error: %s\n", ERR_error_string(err_num, buf));
        return CU_ERROR;

What happens is that ENGINE_init(e) fails sometimes (not always) with the following error:

ENGINE_init error: error:00000000:lib(0):func(0):reason(0)

There is no race condition in this case as far as I can tell.

Is this a bug in this version of openSSL?