wolfssl/examples/async
David Garske 78a28d153a Fix async examples build for asn_orig.c
Add settings.h include before the compile guard in asn_orig.c so
WOLFSSL_IGNORE_FILE_WARN is available when compiled separately.
Add -Wno-pedantic for asn_orig.c in async examples Makefile to
suppress empty translation unit warning.
2026-03-23 15:27:47 -07:00
..
async_client.c Fixes for async and crypto callbacks 2026-02-27 14:35:03 -08:00
async_server.c Fixes for async and crypto callbacks 2026-02-27 14:35:03 -08:00
async_tls.c Fix code comment - peer review 2026-03-02 08:16:53 -08:00
async_tls.h update Copyright year 2026-02-18 09:52:21 -07:00
include.am Add X25519 non-blocking support for key gen and shared secret 2026-02-04 21:28:52 -08:00
Makefile Fix async examples build for asn_orig.c 2026-03-23 15:27:47 -07:00
README.md Add tests for async with crypto callbacks 2026-02-27 14:35:02 -08:00
user_settings.h Add tests for async with crypto callbacks 2026-02-27 14:35:02 -08:00

wolfSSL Asynchronous Cryptography support

Supported with:

  • Intel QuickAssist
  • Marvell (Cavium) Nitrox
  • Crypto Callbacks (--enable-cryptocb)
  • PK Callbacks (--enable-pkcallbacks)

Tested with:

  • ./configure --enable-asynccrypt --enable-rsa --disable-ecc
  • ./configure --enable-asynccrypt --disable-rsa --enable-ecc
  • ./configure --enable-asynccrypt --enable-cryptocb --enable-rsa --disable-ecc
  • ./configure --enable-asynccrypt --enable-cryptocb --disable-rsa --enable-ecc
  • ./configure --enable-asynccrypt --enable-pkcallbacks --enable-rsa --disable-ecc
  • ./configure --enable-asynccrypt --enable-pkcallbacks --disable-rsa --enable-ecc

Build Modes

The async examples support two mutually exclusive async modes controlled via the ASYNC_MODE Makefile variable:

Software Async Mode (default)

Uses WOLFSSL_ASYNC_CRYPT_SW with non-blocking ECC (WC_ECC_NONBLOCK):

make -C examples/async
# or explicitly:
make -C examples/async ASYNC_MODE=sw

Crypto Callback Mode

Uses WOLF_CRYPTO_CB with the AsyncTlsCryptoCb callback that simulates hardware crypto delays by returning WC_PENDING_E for a configurable number of iterations:

make -C examples/async ASYNC_MODE=cryptocb

To adjust the simulated pending count (default is 2), define TEST_PEND_COUNT:

make -C examples/async ASYNC_MODE=cryptocb EXTRA_CFLAGS="-DTEST_PEND_COUNT=5"

To enable crypto callback debug output:

make -C examples/async ASYNC_MODE=cryptocb EXTRA_CFLAGS="-DDEBUG_CRYPTOCB"

Note: WOLFSSL_ASYNC_CRYPT_SW and WOLF_CRYPTO_CB are mutually exclusive in the async polling code (async.c uses #elif).

Running the Examples

./examples/async/async_server --ecc
./examples/async/async_client --ecc 127.0.0.1 11111
./examples/async/async_client --x25519 ecc256.badssl.com 443

Optional ready-file sync (CI-friendly, avoids sleeps):

export WOLFSSL_ASYNC_READYFILE=/tmp/wolfssl_async_ready
./examples/async/async_server --ecc
WOLFSSL_ASYNC_READYFILE=/tmp/wolfssl_async_ready ./examples/async/async_client --ecc 127.0.0.1 11111

Porting the TCP/IP stack: Define NET_USER_HEADER to include your network shim and provide the NET_* macros plus NET_IO_SEND_CB / NET_IO_RECV_CB.

Asynchronous Cryptography Design

When a cryptographic call is handed off to hardware it return WC_PENDING_E up to caller. Then it can keep calling until the operation completes. For some platforms it is required to call wolfSSL_AsyncPoll. At the TLS layer a "devId" (Device ID) must be set using wolfSSL_CTX_SetDevId to indicate desire to offload cryptography.

For further design details please see: https://github.com/wolfSSL/wolfAsyncCrypt#design

Support

For questions please email support@wolfssl.com