diff options
author | Richard Levitte <levitte@openssl.org> | 2000-02-20 23:43:02 +0000 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2000-02-20 23:43:02 +0000 |
commit | d3442bc780473f0cd4f378bc31130d4579da640b (patch) | |
tree | a9e0e2f1ba5080829e22783c739a9cacaa95ebd5 /ssl/ssl_lib.c | |
parent | dab6f09573742df94c4767663565aca3863f8173 (diff) | |
download | openssl-d3442bc780473f0cd4f378bc31130d4579da640b.tar.gz |
Move the registration of callback functions to special functions
designed for that. This removes the potential error to mix data and
function pointers.
Please note that I'm a little unsure how incorrect calls to the old
ctrl functions should be handled, in som cases. I currently return 0
and that's it, but it may be more correct to generate a genuine error
in those cases.
Diffstat (limited to 'ssl/ssl_lib.c')
-rw-r--r-- | ssl/ssl_lib.c | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index 3c71d5b367..8a9d2894f1 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -794,6 +794,15 @@ long SSL_ctrl(SSL *s,int cmd,long larg,char *parg) } } +long SSL_callback_ctrl(SSL *s, int cmd, void (*fp)()) + { + switch(cmd) + { + default: + return(s->method->ssl_callback_ctrl(s,cmd,fp)); + } + } + long SSL_CTX_ctrl(SSL_CTX *ctx,int cmd,long larg,char *parg) { long l; @@ -853,6 +862,15 @@ long SSL_CTX_ctrl(SSL_CTX *ctx,int cmd,long larg,char *parg) } } +long SSL_CTX_callback_ctrl(SSL_CTX *ctx, int cmd, void (*fp)()) + { + switch(cmd) + { + default: + return(ctx->method->ssl_ctx_callback_ctrl(ctx,cmd,fp)); + } + } + int ssl_cipher_id_cmp(SSL_CIPHER *a,SSL_CIPHER *b) { long l; @@ -1988,21 +2006,14 @@ void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx,RSA *(*cb)(SSL *ssl, int is_export, int keylength)) { - union rsa_fn_to_char_u rsa_tmp_cb; - - rsa_tmp_cb.fn_p = cb; - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_RSA_CB,0,rsa_tmp_cb.char_p); + SSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TMP_RSA_CB,(void (*)())cb); } -#endif -#ifndef NO_RSA -void SSL_set_tmp_rsa_callback(SSL *ssl,RSA *(*cb)(SSL *ssl,int is_export, - int keylength)) +void SSL_set_tmp_rsa_callback(SSL *ssl,RSA *(*cb)(SSL *ssl, + int is_export, + int keylength)) { - union rsa_fn_to_char_u rsa_tmp_cb; - - rsa_tmp_cb.fn_p = cb; - SSL_ctrl(ssl,SSL_CTRL_SET_TMP_RSA_CB,0,rsa_tmp_cb.char_p); + SSL_callback_ctrl(ssl,SSL_CTRL_SET_TMP_RSA_CB,(void (*)())cb); } #endif @@ -2031,19 +2042,13 @@ RSA *cb(SSL *ssl,int is_export,int keylength) void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx,DH *(*dh)(SSL *ssl,int is_export, int keylength)) { - union dh_fn_to_char_u dh_tmp_cb; - - dh_tmp_cb.fn_p = dh; - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_DH_CB,0,dh_tmp_cb.char_p); + SSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TMP_DH_CB,(void (*)())dh); } void SSL_set_tmp_dh_callback(SSL *ssl,DH *(*dh)(SSL *ssl,int is_export, - int keylength)) + int keylength)) { - union dh_fn_to_char_u dh_tmp_cb; - - dh_tmp_cb.fn_p = dh; - SSL_ctrl(ssl,SSL_CTRL_SET_TMP_DH_CB,0,dh_tmp_cb.char_p); + SSL_callback_ctrl(ssl,SSL_CTRL_SET_TMP_DH_CB,(void (*)())dh); } #endif |