Skip to content

Commit 95e7b5b

Browse files
committed
Add AES key wrap with padding (RFC 5649) and crypto callback support
Adds wc_AesKeyWrap_Pad/wc_AesKeyUnWrap_Pad and their _ex variants plus crypto callback dispatch, routing blocks through wc_AesEcb* so an ECB only callback works.
1 parent 5012d1d commit 95e7b5b

13 files changed

Lines changed: 2051 additions & 42 deletions

File tree

.github/workflows/cryptocb-only.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
"--enable-swdev", "--enable-cryptocb", "--enable-ecc",
7070
"--enable-rsa", "--enable-dh", "--enable-aesgcm",
7171
"--enable-aesccm", "--enable-aesctr", "--enable-aescfb",
72-
"--enable-aeskeywrap", "--enable-aessiv", "--enable-aesofb",
72+
"--enable-aeskeywrap=padding", "--enable-aessiv", "--enable-aesofb",
7373
"--enable-aesxts", "--enable-camellia", "--enable-chacha",
7474
"--enable-poly1305", "--enable-sha", "--enable-sha3",
7575
"--enable-shake128", "--enable-shake256", "--enable-blake2",
@@ -100,7 +100,7 @@ jobs:
100100
"comment": "Same as sha512 but tells swdev to refuse the SHA-384 / SHA-512/224 / SHA-512/256 variant callbacks (WOLFSSL_SWDEV_SHA512_GENERAL_ONLY). That forces the cryptocb dispatcher's fallback-to-plain-SHA-512-with-truncation path. The sha512 entry above instead has swdev handle every variant end-to-end, so the dispatcher fallback is otherwise uncovered.",
101101
"configure": ["CPPFLAGS=-DWOLF_CRYPTO_CB_ONLY_SHA512 -DWOLFSSL_SWDEV_SHA512_GENERAL_ONLY"]},
102102
{"name": "aes",
103-
"comment": "WOLF_CRYPTO_CB_ONLY_AES: strips software AES; swdev provides the software path via cryptocb.",
103+
"comment": "WOLF_CRYPTO_CB_ONLY_AES: strips software AES; swdev provides the software path via cryptocb. aeskeywrap=padding covers RFC 3394 + RFC 5649 key wrap via swdev_aes_keywrap.",
104104
"configure": ["CPPFLAGS=-DWOLF_CRYPTO_CB_ONLY_AES"]},
105105
{"name": "aes-gcm-via-ecb",
106106
"comment": "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 instead has swdev handle GCM end-to-end, so the host-side GCM path is otherwise uncovered.",

.github/workflows/os-check.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,15 @@ jobs:
299299
"configure": ["--disable-sni", "--disable-ecc", "--disable-tls13",
300300
"--disable-secure-renegotiation-info"]},
301301
{"name": "default", "minutes": 1.6},
302+
{"name": "aeskeywrap-padding", "minutes": 1.6,
303+
"comment": "RFC 5649 AES key wrap with padding; exercises the =padding sub-option (not pulled in by --enable-all).",
304+
"configure": ["--enable-aeskeywrap=padding"]},
305+
{"name": "aeskeywrap-padding-cryptocb", "minutes": 1.6,
306+
"comment": "Key wrap (RFC 3394 + RFC 5649) over WOLF_CRYPTO_CB device offload; runs test_wc_CryptoCb_AesKeyWrap.",
307+
"configure": ["--enable-cryptocb", "--enable-aeskeywrap=padding"]},
308+
{"name": "aeskeywrap-padding-cryptocb-ecb", "minutes": 1.6,
309+
"comment": "Key wrap with HAVE_AES_ECB so the RFC 3394 loops route each block through wc_AesEcb*; runs test_wc_CryptoCb_AesKeyWrapEcbCompose (key wrap composed from an ECB-only crypto callback).",
310+
"configure": ["--enable-cryptocb", "--enable-aeskeywrap=padding", "--enable-aesecb"]},
302311
{"name": "no-client-no-client-auth", "minutes": 1.6,
303312
"configure": ["CPPFLAGS=-DNO_WOLFSSL_CLIENT -DWOLFSSL_NO_CLIENT_AUTH"]},
304313
{"name": "ascon-experimental", "minutes": 1.6,

configure.ac

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6715,12 +6715,31 @@ AC_ARG_ENABLE([entropy-memuse],
67156715
)
67166716

67176717
# AES key wrap
6718+
# Accepts a comma-separated value list; "padding" adds RFC 5649 key wrap with
6719+
# padding on top of the base RFC 3394 key wrap.
67186720
AC_ARG_ENABLE([aeskeywrap],
6719-
[AS_HELP_STRING([--enable-aeskeywrap],[Enable AES key wrap support (default: disabled)])],
6721+
[AS_HELP_STRING([--enable-aeskeywrap],[Enable AES key wrap support, optionally with RFC 5649 padding via "=padding" (default: disabled)])],
67206722
[ ENABLED_AESKEYWRAP=$enableval ],
67216723
[ ENABLED_AESKEYWRAP=no ]
67226724
)
67236725

6726+
ENABLED_AESKEYWRAP_PADDING=no
6727+
for v in `echo $ENABLED_AESKEYWRAP | tr "," " "`
6728+
do
6729+
case $v in
6730+
yes | no)
6731+
;;
6732+
padding)
6733+
# padding (RFC 5649) builds on the base key wrap support
6734+
ENABLED_AESKEYWRAP_PADDING=yes
6735+
ENABLED_AESKEYWRAP=yes
6736+
;;
6737+
*)
6738+
AC_MSG_ERROR([Invalid aeskeywrap option. Valid are: yes, no, padding. Seen: $ENABLED_AESKEYWRAP.])
6739+
;;
6740+
esac
6741+
done
6742+
67246743
# FIPS feature and macro setup
67256744

67266745
AS_CASE([$FIPS_VERSION],
@@ -11363,6 +11382,11 @@ then
1136311382
AM_CFLAGS="$AM_CFLAGS -DHAVE_AES_KEYWRAP -DWOLFSSL_AES_DIRECT"
1136411383
fi
1136511384
11385+
if test "$ENABLED_AESKEYWRAP_PADDING" = "yes"
11386+
then
11387+
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_AES_KEYWRAP_PADDING"
11388+
fi
11389+
1136611390
1136711391
# Old name support for backwards compatibility
1136811392
AC_ARG_ENABLE([oldnames],
@@ -13343,6 +13367,7 @@ echo " * AES-GCM-SIV: $ENABLED_AESGCMSIV"
1334313367
echo " * AES-EAX: $ENABLED_AESEAX"
1334413368
echo " * AES Bitspliced: $ENABLED_AESBS"
1334513369
echo " * AES Key Wrap: $ENABLED_AESKEYWRAP"
13370+
echo " * AES Key Wrap Padding: $ENABLED_AESKEYWRAP_PADDING"
1334613371
echo " * ARIA: $ENABLED_ARIA"
1334713372
echo " * ASCON: $ENABLED_ASCON"
1334813373
echo " * DES3: $ENABLED_DES3"

tests/api.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37045,6 +37045,9 @@ TEST_CASE testCases[] = {
3704537045
#if defined(WOLFSSL_AES_SIV) && defined(WOLFSSL_AES_128)
3704637046
TEST_AES_SIV_DECLS,
3704737047
#endif /* WOLFSSL_AES_SIV && WOLFSSL_AES_128 */
37048+
#if defined(HAVE_AES_KEYWRAP) && defined(WOLFSSL_AES_KEYWRAP_PADDING)
37049+
TEST_AES_KEYWRAP_DECLS,
37050+
#endif /* HAVE_AES_KEYWRAP && WOLFSSL_AES_KEYWRAP_PADDING */
3704837051
TEST_GMAC_DECLS,
3704937052
/* Ascon */
3705037053
TEST_ASCON_DECLS,

0 commit comments

Comments
 (0)