openssl version: 1.0.1e
During reboot, the following code is used to set up the tpm engine:
ENGINE_load_builtin_engines();
e = ENGINE_by_id("tpm");
if(!e) {
/* the engine isn't available */
ERR("ENGINE_by_id failed.");
ERR_print_errors_fp(stderr);
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;
}
e = ENGINE_by_id("tpm");
if(!e) {
/* the engine isn't available */
ERR("ENGINE_by_id failed.");
ERR_print_errors_fp(stderr);
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?
Thanks,
Joe