Re: [PATCH] crypto: hisilicon/sec2: fix CCM algorithm long packet failure

From: Herbert Xu

Date: Fri Aug 14 2026 - 21:28:16 EST


On Tue, Aug 04, 2026 at 10:22:07AM +0800, Chenghai Huang wrote:
> From: Zhushuai Yin <yinzhushuai@xxxxxxxxxx>
>
> In the CCM B0 block the message-length field Q spans L bytes, where
> L (cl in the driver) is derived from the cipher IV flags byte as
> c_ivin[0] + 1. set_aead_auth_iv() hardcoded writing only the last 2
> bytes of a_ivin with cryptlen, implicitly assuming cl = 2.
>
> When cl = 3 (a shorter nonce yielding a 3-byte length field) and the
> packet is longer than 65535 bytes, cryptlen no longer fits in 2 bytes.
> The dropped high byte made the auth IV built by the driver differ from
> the one consumed by the hardware, so the software/hardware comparison
> failed and the CCM request errored out.
>
> Write the last cl bytes of a_ivin in a loop driven by the IV's CL
> value, so the length-field width always matches the algorithm
> configuration instead of assuming a fixed 2-byte field.
>
> Fixes: c16a70c1f253 ("crypto: hisilicon/sec - add new algorithm mode for AEAD")
> Signed-off-by: Zhushuai Yin <yinzhushuai@xxxxxxxxxx>
> Signed-off-by: Chenghai Huang <huangchenghai2@xxxxxxxxxx>
> ---
> drivers/crypto/hisilicon/sec2/sec_crypto.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)

Patch applied. Thanks.
--
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt