From abd1775ebd4ce7ac7e38839b0855020a45eb5ecf Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Wed, 8 Sep 2021 12:29:51 +0530 Subject: [PATCH] common/dpaax/caamflib: fix IV for short MAC-I in SNOW3G [ upstream commit c0182d6b752e3fe320f8f8e3db6256cd21234d9a ] The logic was incorrectly doing conditional swap. It need to be bit swap always. Fixes: 73a24060cd70 ("crypto/dpaa2_sec: add sample PDCP descriptor APIs") Signed-off-by: Gagandeep Singh Acked-by: Akhil Goyal --- drivers/common/dpaax/caamflib/desc/pdcp.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/common/dpaax/caamflib/desc/pdcp.h b/drivers/common/dpaax/caamflib/desc/pdcp.h index 476115323c..bf82bd53c8 100644 --- a/drivers/common/dpaax/caamflib/desc/pdcp.h +++ b/drivers/common/dpaax/caamflib/desc/pdcp.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-3-Clause or GPL-2.0+ * Copyright 2008-2013 Freescale Semiconductor, Inc. - * Copyright 2019-2020 NXP + * Copyright 2019-2021 NXP */ #ifndef __DESC_PDCP_H__ @@ -3691,9 +3691,10 @@ cnstr_shdsc_pdcp_short_mac(uint32_t *descbuf, break; case PDCP_AUTH_TYPE_SNOW: + /* IV calculation based on 3GPP specs. 36331, section:5.3.7.4 */ iv[0] = 0xFFFFFFFF; - iv[1] = swap ? swab32(0x04000000) : 0x04000000; - iv[2] = swap ? swab32(0xF8000000) : 0xF8000000; + iv[1] = swab32(0x04000000); + iv[2] = swab32(0xF8000000); KEY(p, KEY2, authdata->key_enc_flags, authdata->key, authdata->keylen, INLINE_KEY(authdata));