mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-10-24 04:09:07 +03:00
A crypto callback that returns WC_PENDING_E for a TLS record cipher silently corrupted records: Encrypt()/Decrypt() advance the cipher state to CIPHER_STATE_END before the pending check, so on resume the record is shipped without re-running the cipher. WOLF_CRYPTO_CB_ASYNC_POLL gives crypto callback devices the QAT/Nitrox "poll to fill output" completion model. On WC_PENDING_E the async event stays queued; wolfSSL_AsyncPoll() re-enters the device with the new WC_ALGO_TYPE_ASYNC_POLL (wc_CryptoCb_Poll) to finish the job and fill the output buffer. The re-entry only polls while the event is still pending, and a device that cannot complete the job (no poll support, or it reports nothing pending) hard-fails with WC_HW_E rather than reporting the op done with an unfilled buffer. Only the two async record ciphers (AES and 3DES markers) are routed to poll completion, and only when crypto callbacks are the async backend (not QAT/Cavium/SW); handshake PK keeps the re-invoke model. The wolfSSL_AsyncPop eviction is gated for poll-capable devices so the existing resume-at-CIPHER_STATE_END path becomes correct with no record state-machine changes. Without the feature (and without a software/QAT/Cavium backend) a pending bulk cipher op now errors out with ASYNC_OP_E instead of corrupting the record, and configure/cryptocb.c warn about the unsupported combination. Tests in tests/api/test_async.c cover direct AES-GCM/CBC/CCM and 3DES poll completion in both directions at multiple pend depths, negative cases for cipher types defined but not dispatched (ChaCha, single DES), and full TLS 1.3 handshake+echo: an encrypt-offload run, a both- directions run that offloads encrypt and decrypt on both peers using a per-peer device, and the no-poll failure path.
54 lines
2.4 KiB
C
54 lines
2.4 KiB
C
/* test_async.h
|
|
*
|
|
* Copyright (C) 2006-2026 wolfSSL Inc.
|
|
*
|
|
* This file is part of wolfSSL.
|
|
*
|
|
* wolfSSL is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* wolfSSL is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
|
*/
|
|
|
|
#ifndef WOLFCRYPT_TEST_ASYNC_H
|
|
#define WOLFCRYPT_TEST_ASYNC_H
|
|
|
|
#include <tests/api/api_decl.h>
|
|
|
|
int test_wc_CryptoCb_AsyncPollAesGcm(void);
|
|
int test_wc_CryptoCb_AsyncPollAesCbc(void);
|
|
int test_wc_CryptoCb_AsyncPollAesCcm(void);
|
|
int test_wc_CryptoCb_AsyncPollDes3(void);
|
|
int test_wc_CryptoCb_AsyncPollUnsupported(void);
|
|
int test_wc_CryptoCb_AsyncPollChachaUnimpl(void);
|
|
int test_wc_CryptoCb_AsyncPollDesUnimpl(void);
|
|
int test_wc_CryptoCb_AsyncPollTlsAesGcm(void);
|
|
int test_wc_CryptoCb_AsyncPollTlsChachaNotOffloaded(void);
|
|
int test_wc_CryptoCb_AsyncPollTlsNoPollFails(void);
|
|
int test_wc_CryptoCb_AsyncPollTlsBothDirections(void);
|
|
|
|
#define TEST_ASYNC_DECLS \
|
|
TEST_DECL_GROUP("async", test_wc_CryptoCb_AsyncPollAesGcm), \
|
|
TEST_DECL_GROUP("async", test_wc_CryptoCb_AsyncPollAesCbc), \
|
|
TEST_DECL_GROUP("async", test_wc_CryptoCb_AsyncPollAesCcm), \
|
|
TEST_DECL_GROUP("async", test_wc_CryptoCb_AsyncPollDes3), \
|
|
TEST_DECL_GROUP("async", test_wc_CryptoCb_AsyncPollUnsupported), \
|
|
TEST_DECL_GROUP("async", test_wc_CryptoCb_AsyncPollChachaUnimpl), \
|
|
TEST_DECL_GROUP("async", test_wc_CryptoCb_AsyncPollDesUnimpl), \
|
|
TEST_DECL_GROUP("async", test_wc_CryptoCb_AsyncPollTlsAesGcm), \
|
|
TEST_DECL_GROUP("async", \
|
|
test_wc_CryptoCb_AsyncPollTlsChachaNotOffloaded), \
|
|
TEST_DECL_GROUP("async", test_wc_CryptoCb_AsyncPollTlsNoPollFails), \
|
|
TEST_DECL_GROUP("async", test_wc_CryptoCb_AsyncPollTlsBothDirections)
|
|
|
|
#endif /* WOLFCRYPT_TEST_ASYNC_H */
|