Take an engine reference in the key

Apparently openssl doesn't do this for engine keys meaning that the
openssl described way of obtaining and engine key

    if (ENGINE_init(e)) {
        pkey = ENGINE_load_private_key(e, file, ui_method, &cb_data);
        ENGINE_finish(e);
    }

results in a dynamic engine being torn down immediately after the key
is obtained. Fix this by taking a reference in the binding and
releasing it when the key app_data is freed.  This requires adding a
pointer to the engine to the app_data.

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
6 files changed