1*b077aed3SPierre Pronchery=pod 2*b077aed3SPierre Pronchery 3*b077aed3SPierre Pronchery=head1 NAME 4*b077aed3SPierre Pronchery 5*b077aed3SPierre ProncherySSL_CTX_set_async_callback, 6*b077aed3SPierre ProncherySSL_CTX_set_async_callback_arg, 7*b077aed3SPierre ProncherySSL_set_async_callback, 8*b077aed3SPierre ProncherySSL_set_async_callback_arg, 9*b077aed3SPierre ProncherySSL_get_async_status, 10*b077aed3SPierre ProncherySSL_async_callback_fn 11*b077aed3SPierre Pronchery- manage asynchronous operations 12*b077aed3SPierre Pronchery 13*b077aed3SPierre Pronchery=head1 SYNOPSIS 14*b077aed3SPierre Pronchery 15*b077aed3SPierre Pronchery=for openssl multiple includes 16*b077aed3SPierre Pronchery 17*b077aed3SPierre Pronchery #include <openssl/ssl.h> 18*b077aed3SPierre Pronchery 19*b077aed3SPierre Pronchery typedef int (*SSL_async_callback_fn)(SSL *s, void *arg); 20*b077aed3SPierre Pronchery int SSL_CTX_set_async_callback(SSL_CTX *ctx, SSL_async_callback_fn callback); 21*b077aed3SPierre Pronchery int SSL_CTX_set_async_callback_arg(SSL_CTX *ctx, void *arg); 22*b077aed3SPierre Pronchery int SSL_set_async_callback(SSL *s, SSL_async_callback_fn callback); 23*b077aed3SPierre Pronchery int SSL_set_async_callback_arg(SSL *s, void *arg); 24*b077aed3SPierre Pronchery int SSL_get_async_status(SSL *s, int *status); 25*b077aed3SPierre Pronchery 26*b077aed3SPierre Pronchery=head1 DESCRIPTION 27*b077aed3SPierre Pronchery 28*b077aed3SPierre ProncherySSL_CTX_set_async_callback() sets an asynchronous callback function. All B<SSL> 29*b077aed3SPierre Proncheryobjects generated based on this B<SSL_CTX> will get this callback. If an engine 30*b077aed3SPierre Proncherysupports the callback mechanism, it will be automatically called if 31*b077aed3SPierre ProncheryB<SSL_MODE_ASYNC> has been set and an asynchronous capable engine completes a 32*b077aed3SPierre Proncherycryptography operation to notify the application to resume the paused work flow. 33*b077aed3SPierre Pronchery 34*b077aed3SPierre ProncherySSL_CTX_set_async_callback_arg() sets the callback argument. 35*b077aed3SPierre Pronchery 36*b077aed3SPierre ProncherySSL_set_async_callback() allows an application to set a callback in an 37*b077aed3SPierre Proncheryasynchronous B<SSL> object, so that when an engine completes a cryptography 38*b077aed3SPierre Proncheryoperation, the callback will be called to notify the application to resume the 39*b077aed3SPierre Proncherypaused work flow. 40*b077aed3SPierre Pronchery 41*b077aed3SPierre ProncherySSL_set_async_callback_arg() sets an argument for the B<SSL> object when the 42*b077aed3SPierre Proncheryabove callback is called. 43*b077aed3SPierre Pronchery 44*b077aed3SPierre ProncherySSL_get_async_status() returns the engine status. This function facilitates the 45*b077aed3SPierre Proncherycommunication from the engine to the application. During an SSL session, 46*b077aed3SPierre Proncherycryptographic operations are dispatched to an engine. The engine status is very 47*b077aed3SPierre Proncheryuseful for an application to know if the operation has been successfully 48*b077aed3SPierre Proncherydispatched. If the engine does not support this additional callback method, 49*b077aed3SPierre ProncheryB<ASYNC_STATUS_UNSUPPORTED> will be returned. See ASYNC_WAIT_CTX_set_status() 50*b077aed3SPierre Proncheryfor a description of all of the status values. 51*b077aed3SPierre Pronchery 52*b077aed3SPierre ProncheryAn example of the above functions would be the following: 53*b077aed3SPierre Pronchery 54*b077aed3SPierre Pronchery=over 4 55*b077aed3SPierre Pronchery 56*b077aed3SPierre Pronchery=item 1. 57*b077aed3SPierre Pronchery 58*b077aed3SPierre ProncheryApplication sets the async callback and callback data on an SSL connection 59*b077aed3SPierre Proncheryby calling SSL_set_async_callback(). 60*b077aed3SPierre Pronchery 61*b077aed3SPierre Pronchery=item 2. 62*b077aed3SPierre Pronchery 63*b077aed3SPierre ProncheryApplication sets B<SSL_MODE_ASYNC> and makes an asynchronous SSL call 64*b077aed3SPierre Pronchery 65*b077aed3SPierre Pronchery=item 3. 66*b077aed3SPierre Pronchery 67*b077aed3SPierre ProncheryOpenSSL submits the asynchronous request to the engine. If a retry occurs at 68*b077aed3SPierre Proncherythis point then the status within the B<ASYNC_WAIT_CTX> would be set and the 69*b077aed3SPierre Proncheryasync callback function would be called (goto Step 7). 70*b077aed3SPierre Pronchery 71*b077aed3SPierre Pronchery=item 4. 72*b077aed3SPierre Pronchery 73*b077aed3SPierre ProncheryThe OpenSSL engine pauses the current job and returns, so that the 74*b077aed3SPierre Proncheryapplication can continue processing other connections. 75*b077aed3SPierre Pronchery 76*b077aed3SPierre Pronchery=item 5. 77*b077aed3SPierre Pronchery 78*b077aed3SPierre ProncheryAt a future point in time (probably via a polling mechanism or via an 79*b077aed3SPierre Proncheryinterrupt) the engine will become aware that the asynchronous request has 80*b077aed3SPierre Proncheryfinished processing. 81*b077aed3SPierre Pronchery 82*b077aed3SPierre Pronchery=item 6. 83*b077aed3SPierre Pronchery 84*b077aed3SPierre ProncheryThe engine will call the application's callback passing the callback data as 85*b077aed3SPierre Proncherya parameter. 86*b077aed3SPierre Pronchery 87*b077aed3SPierre Pronchery=item 7. 88*b077aed3SPierre Pronchery 89*b077aed3SPierre ProncheryThe callback function should then run. Note: it is a requirement that the 90*b077aed3SPierre Proncherycallback function is small and nonblocking as it will be run in the context of 91*b077aed3SPierre Proncherya polling mechanism or an interrupt. 92*b077aed3SPierre Pronchery 93*b077aed3SPierre Pronchery=item 8. 94*b077aed3SPierre Pronchery 95*b077aed3SPierre ProncheryIt is the application's responsibility via the callback function to schedule 96*b077aed3SPierre Proncheryrecalling the OpenSSL asynchronous function and to continue processing. 97*b077aed3SPierre Pronchery 98*b077aed3SPierre Pronchery=item 9. 99*b077aed3SPierre Pronchery 100*b077aed3SPierre ProncheryThe callback function has the option to check the status returned via 101*b077aed3SPierre ProncherySSL_get_async_status() to determine whether a retry happened instead of the 102*b077aed3SPierre Proncheryrequest being submitted, allowing different processing if required. 103*b077aed3SPierre Pronchery 104*b077aed3SPierre Pronchery=back 105*b077aed3SPierre Pronchery 106*b077aed3SPierre Pronchery=head1 RETURN VALUES 107*b077aed3SPierre Pronchery 108*b077aed3SPierre ProncherySSL_CTX_set_async_callback(), SSL_set_async_callback(), 109*b077aed3SPierre ProncherySSL_CTX_set_async_callback_arg(), SSL_CTX_set_async_callback_arg() and 110*b077aed3SPierre ProncherySSL_get_async_status() return 1 on success or 0 on error. 111*b077aed3SPierre Pronchery 112*b077aed3SPierre Pronchery=head1 SEE ALSO 113*b077aed3SPierre Pronchery 114*b077aed3SPierre ProncheryL<ssl(7)> 115*b077aed3SPierre Pronchery 116*b077aed3SPierre Pronchery=head1 HISTORY 117*b077aed3SPierre Pronchery 118*b077aed3SPierre ProncherySSL_CTX_set_async_callback(), SSL_CTX_set_async_callback_arg(), 119*b077aed3SPierre ProncherySSL_set_async_callback(), SSL_set_async_callback_arg() and 120*b077aed3SPierre ProncherySSL_get_async_status() were first added to OpenSSL 3.0. 121*b077aed3SPierre Pronchery 122*b077aed3SPierre Pronchery=head1 COPYRIGHT 123*b077aed3SPierre Pronchery 124*b077aed3SPierre ProncheryCopyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved. 125*b077aed3SPierre Pronchery 126*b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License"). You may not use 127*b077aed3SPierre Proncherythis file except in compliance with the License. You can obtain a copy 128*b077aed3SPierre Proncheryin the file LICENSE in the source distribution or at 129*b077aed3SPierre ProncheryL<https://www.openssl.org/source/license.html>. 130*b077aed3SPierre Pronchery 131*b077aed3SPierre Pronchery=cut 132