tpm2-software / tpm2-tss-engine

OpenSSL Engine for TPM2 devices
https://tpm2-software.github.io
BSD 3-Clause "New" or "Revised" License
148 stars 97 forks source link

TPM engine couldn't load when loading the tpm engine more than once with 1.2.0 version of TPM2-TSS-ENGINE #270

Open shrikant1407 opened 1 year ago

shrikant1407 commented 1 year ago

we are trying to load the TPM engine using OpenSSL API as follows:

ENGINE_load_dynamic();
engine = ENGINE_by_id("dynamic");
if (engine == NULL) {
    LOG(LOG_ERROR, "Could not find external engine.\n");
    goto error;
}

if (!ENGINE_ctrl_cmd_string(engine, "SO_PATH", TPM2_TSS_ENGINE_SO_PATH,
                    0)) {
    LOG(LOG_ERROR, "Could not set TPM Engine path.\n");
    goto error;
}

if (!ENGINE_ctrl_cmd_string(engine, "LOAD", NULL, 0)) {
    LOG(LOG_ERROR, "Could not load TPM engine.\n");
    goto error;
}

The flow for loading such an engine is triggered by ENGINE_ctrl_cmd_string(engine, "SO_PATH", TPM2_TSS_ENGINE_SO_PATH, 0), and when using a dynamic path it will dynamically load the engine's .sofile. Our application needs to load the TPM engine more than once but it's not able to load at the second instance. The same configuration was working with 1.1.0 version of TPM2-TSS-ENGINE

AndreasFuchsTPM commented 1 year ago

Could you provide me with a complete snippet that we can add to the tests ?