[PATCH v2 13/30] crypto: sa2ul - preserve full authentication key lengths

From: Manorit Chawdhry

Date: Wed Nov 04 2026 - 00:51:31 EST


Authentication keys come from the Crypto API with an unsigned-int length,
but narrowing that length to u16 before HMAC preparation silently changes
keys longer than 65535 bytes. Carry the full length through security
context setup and ipad/opad preparation so long keys are hashed intact.

Fixes: d2c8ac187fc9 ("crypto: sa2ul - Add AEAD algorithm support")
Signed-off-by: Manorit Chawdhry <m-chawdhry@xxxxxx>
---
drivers/crypto/sa2ul.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/crypto/sa2ul.c b/drivers/crypto/sa2ul.c
index 23a821de46cd..3c25c98e3e92 100644
--- a/drivers/crypto/sa2ul.c
+++ b/drivers/crypto/sa2ul.c
@@ -356,8 +356,8 @@ static void sa_swiz_128(u8 *in, u16 len)
}
}

-static void sa_prepare_iopads(struct algo_data *data, const u8 *key, u16 key_sz,
- __be32 *ipad, __be32 *opad)
+static void sa_prepare_iopads(struct algo_data *data, const u8 *key,
+ unsigned int key_sz, __be32 *ipad, __be32 *opad)
{
union {
struct hmac_sha1_key sha1;
@@ -455,8 +455,8 @@ static int sa_set_sc_enc(struct algo_data *ad, const u8 *key, u16 key_sz,
}

/* Set Security context for the authentication engine */
-static void sa_set_sc_auth(struct algo_data *ad, const u8 *key, u16 key_sz,
- u8 *sc_buf)
+static void sa_set_sc_auth(struct algo_data *ad, const u8 *key,
+ unsigned int key_sz, u8 *sc_buf)
{
__be32 *ipad = (void *)(sc_buf + 32);
__be32 *opad = (void *)(sc_buf + 64);
@@ -619,7 +619,7 @@ static void sa_dump_sc(u8 *buf, dma_addr_t dma_addr)
static
int sa_init_sc(struct sa_ctx_info *ctx, const struct sa_match_data *match_data,
const u8 *enc_key, u16 enc_key_sz,
- const u8 *auth_key, u16 auth_key_sz,
+ const u8 *auth_key, unsigned int auth_key_sz,
struct algo_data *ad, u8 enc, u32 *swinfo)
{
int enc_sc_offset = 0;

--
2.43.0