From e03bc94742a77ae5a2921e64aa40da59b5ce8050 Mon Sep 17 00:00:00 2001 From: rizlik Date: Tue, 12 May 2026 19:21:42 +0200 Subject: [PATCH] swdev: add AES-ECB only testing option --- .github/workflows/cryptocb-only.yml | 7 +++++++ tests/swdev/swdev.c | 11 ++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cryptocb-only.yml b/.github/workflows/cryptocb-only.yml index d71a8b0947..101c74dffc 100644 --- a/.github/workflows/cryptocb-only.yml +++ b/.github/workflows/cryptocb-only.yml @@ -37,6 +37,13 @@ jobs: # software path via cryptocb. - name: AES cppflags: -DWOLF_CRYPTO_CB_ONLY_AES + # Same as AES but tells swdev to refuse AES-GCM (SWDEV_AES_ONLYECB). + # That forces the parent's CB_ONLY_AES host-side GCM software path: + # GHASH runs on the host while AES-CTR blocks dispatch back through + # cryptocb ECB. The AES entry above instead has swdev handle GCM + # end-to-end, so the host-side GCM path is otherwise uncovered. + - name: AES_GCM_via_ECB + cppflags: -DWOLF_CRYPTO_CB_ONLY_AES -DSWDEV_AES_ONLYECB # All four ONLY_* macros at once: every supported software primitive # is stripped and dispatched through cryptocb. Catches any cross- # algorithm call that a single-strip entry would still resolve via diff --git a/tests/swdev/swdev.c b/tests/swdev/swdev.c index 981e55ec14..18bcfaed1b 100644 --- a/tests/swdev/swdev.c +++ b/tests/swdev/swdev.c @@ -357,7 +357,12 @@ static int swdev_aes_ecb(wc_CryptoInfo* info) } #endif /* HAVE_AES_ECB || WOLFSSL_AES_DIRECT */ -#ifdef HAVE_AESGCM +/* SWDEV_AES_ONLYECB: when defined, swdev's AES backend returns + * CRYPTOCB_UNAVAILABLE for AES-GCM so the parent's CB_ONLY_AES host-side + * GCM software path runs (GHASH on the host; AES-CTR blocks dispatch back + * through cryptocb ECB). Without this macro, swdev handles GCM end-to-end + * and the host-side software path is never exercised. */ +#if defined(HAVE_AESGCM) && !defined(SWDEV_AES_ONLYECB) static int swdev_aes_gcm(wc_CryptoInfo* info) { Aes* aes = info->cipher.enc ? info->cipher.aesgcm_enc.aes : @@ -401,7 +406,7 @@ static int swdev_aes_gcm(wc_CryptoInfo* info) wc_AesFree(&shadow); return ret; } -#endif /* HAVE_AESGCM */ +#endif /* HAVE_AESGCM && !SWDEV_AES_ONLYECB */ #ifdef HAVE_AESCCM static int swdev_aes_ccm(wc_CryptoInfo* info) @@ -527,7 +532,7 @@ WC_SWDEV_EXPORT int wc_SwDev_Callback(int devId, wc_CryptoInfo* info, case WC_CIPHER_AES_ECB: return swdev_aes_ecb(info); #endif - #ifdef HAVE_AESGCM + #if defined(HAVE_AESGCM) && !defined(SWDEV_AES_ONLYECB) case WC_CIPHER_AES_GCM: return swdev_aes_gcm(info); #endif