Dear all,

Im writing an OpenSSL engine and I have some internal data to manage via
ex_data functions.

What I've been doing so far is using RSA_get_ex_new_index(0, NULL, NULL,
NULL, <my free function>), at the initialization of the engine to register
a free function for structures allocated when the method
ENGINE_load_private_key (or ENGINE_load_public_key) is called.
To do so, I use the method RSA_set_ex_data(<my_rsa>, <the index returned
by RSA_get_ex_new_index> , <my custom data>) and I do the proper cleanup
at  <my free function> accordingly.

Everything works fine, except for the fact that, when I finish the engine,
other keys that are not engine related still try to get cleaned up by <my
free function>,  which no longer exists, and my program crashes.

I realize, also, that if I call CRYPTO_cleanup_all_ex_data after finishing
the engine, no problems occur.

The problem with CRYPTO_cleanup_all_ex_data is that I'm planning to have
multiple engines at the same time, so I'd like to cleanup only the index
created with RSA_get_ex_new_index for an specific engine.

I tryed to debug the method RSA_get_ex_new_index to figure  something out,
but didn't understand it well =p.

Thank you.

-- 
Felipe Menegola Blauth

Reply via email to