diff options
author | Richard Levitte <levitte@openssl.org> | 2016-04-02 18:46:17 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2016-04-06 16:19:20 +0200 |
commit | b72c9121379a5de0c8be0d4e1a4a6b9495042621 (patch) | |
tree | 5dfb1b8175489c5fef1d8111a45633ef7e85b997 /engines/e_dasync.c | |
parent | Document RSA accessors/writers (diff) | |
download | openssl-b72c9121379a5de0c8be0d4e1a4a6b9495042621.tar.xz openssl-b72c9121379a5de0c8be0d4e1a4a6b9495042621.zip |
Make the RSA_METHOD structure opaque
Move rsa_meth_st away from public headers.
Add RSA_METHOD creator/destructor functions.
Add RSA_METHOD accessor/writer functions.
Adapt all other source to use the creator, destructor, accessors and writers.
Reviewed-by: Matt Caswell <matt@openssl.org>
Diffstat (limited to 'engines/e_dasync.c')
-rw-r--r-- | engines/e_dasync.c | 53 |
1 files changed, 28 insertions, 25 deletions
diff --git a/engines/e_dasync.c b/engines/e_dasync.c index 0e10f6dfdd..2ee7d6363d 100644 --- a/engines/e_dasync.c +++ b/engines/e_dasync.c @@ -149,23 +149,7 @@ static int dasync_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, static int dasync_rsa_init(RSA *rsa); static int dasync_rsa_finish(RSA *rsa); -static RSA_METHOD dasync_rsa_method = { - "Dummy Async RSA method", - dasync_pub_enc, /* pub_enc */ - dasync_pub_dec, /* pub_dec */ - dasync_rsa_priv_enc, /* priv_enc */ - dasync_rsa_priv_dec, /* priv_dec */ - dasync_rsa_mod_exp, /* rsa_mod_exp */ - BN_mod_exp_mont, /* bn_mod_exp */ - dasync_rsa_init, /* init */ - dasync_rsa_finish, /* finish */ - 0, /* flags */ - NULL, /* app_data */ - 0, /* rsa_sign */ - 0, /* rsa_verify */ - NULL /* rsa_keygen */ -}; - +static RSA_METHOD *dasync_rsa_method = NULL; /* AES */ @@ -239,12 +223,26 @@ static int dasync_cipher_nids[] = { static int bind_dasync(ENGINE *e) { + /* Setup RSA_METHOD */ + if ((dasync_rsa_method = RSA_meth_new("Dummy Async RSA method", 0)) == NULL + || RSA_meth_set_pub_enc(dasync_rsa_method, dasync_pub_enc) == 0 + || RSA_meth_set_pub_dec(dasync_rsa_method, dasync_pub_dec) == 0 + || RSA_meth_set_priv_enc(dasync_rsa_method, dasync_rsa_priv_enc) == 0 + || RSA_meth_set_priv_enc(dasync_rsa_method, dasync_rsa_priv_dec) == 0 + || RSA_meth_set_mod_exp(dasync_rsa_method, dasync_rsa_mod_exp) == 0 + || RSA_meth_set_bn_mod_exp(dasync_rsa_method, BN_mod_exp_mont) == 0 + || RSA_meth_set_init(dasync_rsa_method, dasync_rsa_init) == 0 + || RSA_meth_set_finish(dasync_rsa_method, dasync_rsa_finish) == 0) { + DASYNCerr(DASYNC_F_BIND_DASYNC, DASYNC_R_INIT_FAILED); + return 0; + } + /* Ensure the dasync error handling is set up */ ERR_load_DASYNC_strings(); if (!ENGINE_set_id(e, engine_dasync_id) || !ENGINE_set_name(e, engine_dasync_name) - || !ENGINE_set_RSA(e, &dasync_rsa_method) + || !ENGINE_set_RSA(e, dasync_rsa_method) || !ENGINE_set_digests(e, dasync_digests) || !ENGINE_set_ciphers(e, dasync_ciphers) || !ENGINE_set_destroy_function(e, dasync_destroy) @@ -375,6 +373,7 @@ static int dasync_destroy(ENGINE *e) { destroy_digests(); destroy_ciphers(); + RSA_meth_free(dasync_rsa_method); ERR_unload_DASYNC_strings(); return 1; } @@ -545,14 +544,16 @@ static int dasync_pub_enc(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding) { /* Ignore errors - we carry on anyway */ dummy_pause_job(); - return RSA_PKCS1_OpenSSL()->rsa_pub_enc(flen, from, to, rsa, padding); + return RSA_meth_get_pub_enc(RSA_PKCS1_OpenSSL()) + (flen, from, to, rsa, padding); } static int dasync_pub_dec(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, int padding) { /* Ignore errors - we carry on anyway */ dummy_pause_job(); - return RSA_PKCS1_OpenSSL()->rsa_pub_dec(flen, from, to, rsa, padding); + return RSA_meth_get_pub_dec(RSA_PKCS1_OpenSSL()) + (flen, from, to, rsa, padding); } static int dasync_rsa_priv_enc(int flen, const unsigned char *from, @@ -560,7 +561,8 @@ static int dasync_rsa_priv_enc(int flen, const unsigned char *from, { /* Ignore errors - we carry on anyway */ dummy_pause_job(); - return RSA_PKCS1_OpenSSL()->rsa_priv_enc(flen, from, to, rsa, padding); + return RSA_meth_get_priv_enc(RSA_PKCS1_OpenSSL()) + (flen, from, to, rsa, padding); } static int dasync_rsa_priv_dec(int flen, const unsigned char *from, @@ -568,23 +570,24 @@ static int dasync_rsa_priv_dec(int flen, const unsigned char *from, { /* Ignore errors - we carry on anyway */ dummy_pause_job(); - return RSA_PKCS1_OpenSSL()->rsa_priv_dec(flen, from, to, rsa, padding); + return RSA_meth_get_priv_dec(RSA_PKCS1_OpenSSL()) + (flen, from, to, rsa, padding); } static int dasync_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx) { /* Ignore errors - we carry on anyway */ dummy_pause_job(); - return RSA_PKCS1_OpenSSL()->rsa_mod_exp(r0, I, rsa, ctx); + return RSA_meth_get_mod_exp(RSA_PKCS1_OpenSSL())(r0, I, rsa, ctx); } static int dasync_rsa_init(RSA *rsa) { - return RSA_PKCS1_OpenSSL()->init(rsa); + return RSA_meth_get_init(RSA_PKCS1_OpenSSL())(rsa); } static int dasync_rsa_finish(RSA *rsa) { - return RSA_PKCS1_OpenSSL()->finish(rsa); + return RSA_meth_get_finish(RSA_PKCS1_OpenSSL())(rsa); } /* Cipher helper functions */ |