Hi all, I having a problem with the openssl engine manipulation. At my program I need crypt a text using the private key inside the engine and decrypt the crypted text using the public key at the disc. To do it first I need setup the engine, crypt the text and then free all engine instances to decrypt the text using the public key stored at the hard disc. The program need runs continuously, but at the second iteration the following error occur: 1886:error:8806D064:eracom engine:PKC11_FINISH:already loaded:hw_eracom.c:1507: 1886:error:2607E074:engine routines:func(126):reason(116):eng_table.c:182: The code is below. Someone already have this problem or one similar that? Any idea why it happens?
Fabrício int main(int argc, char* argv[]) { int i =0; while(1){ runTest(); } } void runTest() { BIO *bio_err = BIO_new_fp(stderr, BIO_NOCLOSE); const char *engine_id = "ERACOM"; const char *name = "PKCS_SLOT_0_PIN"; const char *password = "password"; ENGINE *e = NULL; OpenSSL_add_all_algorithms(); ENGINE_load_builtin_engines(); ERR_load_crypto_strings(); e = _util.setupEngine(engine_id,name,password); /****** code to crypt the text using the private key inside the hsm ******/ ENGINE_free(e); ENGINE_cleanup(); /****** code to decrypt the crypted text using the public key stored at the hard disc ******/ EVP_cleanup(); CRYPTO_cleanup_all_ex_data(); ERR_remove_state(0); ERR_free_strings(); BIO_free(bio_err); } ENGINE *XMLCAUtils::setupEngine(const char *__engine_id, const char *__name, const char *__password, BIO *bio_err) { ENGINE *e = NULL; int engine = 0; setenv(__name, __password, 0); if(((e = ENGINE_by_id(__engine_id)) == NULL)&&((e = loadEngine(__engine_id)) == NULL)){ BIO_free(bio_err); ERR_print_errors(bio_err); return(NULL); } if(!ENGINE_set_default(e,ENGINE_METHOD_RSA)){ /****** here happens the error at the second iteration ******/ ERR_print_errors(bio_err); ENGINE_free(e); BIO_free(bio_err); return(NULL); } ENGINE_free(e); return(e); } ENGINE *XMLCAUtils::loadEngine(char const *__pcc_engine) { ENGINE *e = ENGINE_by_id("dynamic"); if(e){ if((!ENGINE_ctrl_cmd_string(e, "SO_PATH", __pcc_engine, 0))||(!ENGINE_ctrl_cmd_string(e, "LOAD", NULL, 0))){ ENGINE_free(e); e = NULL; } } return(e); } ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List [EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]