diff options
author | Ping Yu <ping.yu@intel.com> | 2018-11-05 15:41:01 -0500 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2019-01-27 12:27:17 +0000 |
commit | 9f5a87fd665cb597fa1c1f4eef882d2d2f833e61 (patch) | |
tree | 3bad8287fe464c81267aa7cf43a41344fd6db414 /ssl | |
parent | 61e033308b1c004bd808352fb1d786547dcdf62b (diff) | |
download | openssl-9f5a87fd665cb597fa1c1f4eef882d2d2f833e61.zip openssl-9f5a87fd665cb597fa1c1f4eef882d2d2f833e61.tar.gz openssl-9f5a87fd665cb597fa1c1f4eef882d2d2f833e61.tar.bz2 |
add an additional async notification communication method based on callback
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Yang <yang.yang@baishancloud.com>
Signed-off-by: Ping Yu <ping.yu@intel.com>
Signed-off-by: Steven Linsell <stevenx.linsell@intel.com>
(Merged from https://github.com/openssl/openssl/pull/7573)
Diffstat (limited to 'ssl')
-rw-r--r-- | ssl/ssl_lib.c | 48 | ||||
-rw-r--r-- | ssl/ssl_locl.h | 8 |
2 files changed, 56 insertions, 0 deletions
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index ba606e3..6d6060a 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -831,6 +831,9 @@ SSL *SSL_new(SSL_CTX *ctx) s->psk_find_session_cb = ctx->psk_find_session_cb; s->psk_use_session_cb = ctx->psk_use_session_cb; + s->async_cb = ctx->async_cb; + s->async_cb_arg = ctx->async_cb_arg; + s->job = NULL; #ifndef OPENSSL_NO_CT @@ -1652,6 +1655,40 @@ int SSL_get_changed_async_fds(SSL *s, OSSL_ASYNC_FD *addfd, size_t *numaddfds, numdelfds); } +int SSL_CTX_set_async_callback(SSL_CTX *ctx, SSL_async_callback_fn callback) +{ + ctx->async_cb = callback; + return 1; +} + +int SSL_CTX_set_async_callback_arg(SSL_CTX *ctx, void *arg) +{ + ctx->async_cb_arg = arg; + return 1; +} + +int SSL_set_async_callback(SSL *s, SSL_async_callback_fn callback) +{ + s->async_cb = callback; + return 1; +} + +int SSL_set_async_callback_arg(SSL *s, void *arg) +{ + s->async_cb_arg = arg; + return 1; +} + +int SSL_get_async_status(SSL *s, int *status) +{ + ASYNC_WAIT_CTX *ctx = s->waitctx; + + if (ctx == NULL) + return 0; + *status = ASYNC_WAIT_CTX_get_status(ctx); + return 1; +} + int SSL_accept(SSL *s) { if (s->handshake_func == NULL) { @@ -1677,6 +1714,13 @@ long SSL_get_default_timeout(const SSL *s) return s->method->get_timeout(); } +static int ssl_async_wait_ctx_cb(void *arg) +{ + SSL *s = (SSL *)arg; + + return s->async_cb(s, s->async_cb_arg); +} + static int ssl_start_async_job(SSL *s, struct ssl_async_args *args, int (*func) (void *)) { @@ -1685,6 +1729,10 @@ static int ssl_start_async_job(SSL *s, struct ssl_async_args *args, s->waitctx = ASYNC_WAIT_CTX_new(); if (s->waitctx == NULL) return -1; + if (s->async_cb != NULL + && !ASYNC_WAIT_CTX_set_callback + (s->waitctx, ssl_async_wait_ctx_cb, s)) + return -1; } switch (ASYNC_start_job(&s->job, s->waitctx, &ret, func, args, sizeof(struct ssl_async_args))) { diff --git a/ssl/ssl_locl.h b/ssl/ssl_locl.h index 2d68691..bd0d421 100644 --- a/ssl/ssl_locl.h +++ b/ssl/ssl_locl.h @@ -1076,6 +1076,10 @@ struct ssl_ctx_st { /* Do we advertise Post-handshake auth support? */ int pha_enabled; + + /* Callback for SSL async handling */ + SSL_async_callback_fn async_cb; + void *async_cb_arg; }; struct ssl_st { @@ -1471,6 +1475,10 @@ struct ssl_st { /* Callback to determine if early_data is acceptable or not */ SSL_allow_early_data_cb_fn allow_early_data_cb; void *allow_early_data_cb_data; + + /* Callback for SSL async handling */ + SSL_async_callback_fn async_cb; + void *async_cb_arg; }; /* |