Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp2847220rwb; Mon, 5 Sep 2022 02:26:27 -0700 (PDT) X-Google-Smtp-Source: AA6agR4M0rKXXtKU0kIASkVuE/3oKh51o8n0sHEmNK81qKN1+OBg9yvU4H4NZVCV1iHGV6jlv0mE X-Received: by 2002:a63:485:0:b0:42b:1d81:8619 with SMTP id 127-20020a630485000000b0042b1d818619mr39696794pge.343.1662369987270; Mon, 05 Sep 2022 02:26:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662369987; cv=none; d=google.com; s=arc-20160816; b=quO8jZ8fVdrxMP1T9y/SPX5ecO9Wv4xH1ja1jNRm2RhzuSijHXnS+/gMn7+AN2fBFF lc8OR1JVu3p2LnxCG7yJlGf53+YC9I1RyqSR/gHKfuMGOi4F6ZNQkjvleEObv9d+81TH BFnp9Vf4YNhXCybwnbyVuj170PE1S1JSQLtIQ/SM5VnHZOLGiHhsjGruZIbKEO8CmxX0 BIvl2dsxFdGjX0sigLs0dDbvj4MiLVKtubYxFCw0dGtuhRV4BmGCtbQ3eFjl3FUKqUjZ EfgBym9HEbOc/uw69PSUd8wPzVZZmPVhXgZSm2NltCeytOQz9NsEdJYi6nzbGMMlzjuN b2Zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:message-id:from:cc:subject:to:references :in-reply-to:content-transfer-encoding:mime-version:dkim-signature; bh=IaDjNKhZ3mFi1ys1E3gnnIQty/lk13RMitLJfO7pAGA=; b=d6h8MAnXL4L4MqjTBw2kCcB73hOvb0umO/4Fvg9ui/eWK+OGF6jIFU6kOlWuukolDh VWEEWD13/Oj1YzqegxsGHpGwIybaTbObKndL2r9GCgcNMZDxqpLXMCPi1xMVHDHBUY5t Sb+TFtw/Pnh5xFy31Fpt4RoPrJueMuAO/ioUZWBwx5mv+7nAu7iODlMUunK3gbrAoEyo gwV3plb6Q5iE2V44oLYZH46h1xzCDPFN1reo9NL621sdtW0F0rDuHBq+oXK0LIorNjWo WkpIcg4b6qpsPbL+LqXJU/+zIc6jp+qPudM9irwJPQvn54S9i8zXSQu48VSGykLQ4DCj 3SDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FHeqU8vi; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m11-20020a170902db0b00b00172b87d9775si6646852plx.383.2022.09.05.02.26.12; Mon, 05 Sep 2022 02:26:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FHeqU8vi; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236418AbiIEJPE (ORCPT + 99 others); Mon, 5 Sep 2022 05:15:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235874AbiIEJPA (ORCPT ); Mon, 5 Sep 2022 05:15:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E39215FC7 for ; Mon, 5 Sep 2022 02:14:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CFC2E6118A for ; Mon, 5 Sep 2022 09:14:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5593C433C1; Mon, 5 Sep 2022 09:14:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662369297; bh=b3mKhOIaMNyWH7rYsB9hRh1xqCDTCyuaqTQJXi3+WOU=; h=In-Reply-To:References:To:Subject:Cc:From:Date:From; b=FHeqU8vi+N06NzVwUF0a8rDEuttc0b4y7hUQlYWG+uBscH0Fx81ETl7NexSmZcwEc wBLEsvxdRssuMhFZyXXHPkys/0CzHDNRj2v4JOapyw4FxnRU18J02NRRigBcF9m7fB ur1Rl3e/waxYJiWxZhO9J3A4Rq8kZd3T2nTFz0cTacP1WkiFUwrIeFFSFTA0eWiTTe qc6RcR1zwuz3GljG47Z2VUvV4ex9adMSYOL+K+Ca+YjZNt6l1ZhzxqwibVEO7jniYq 8oTx1SiXiBzg8BI0CIBXCmB/bllk41xwADTdMNv3W4Fdb2bNcAdMheZSmrBxAPLtDD b7f8s6VwJ6hkQ== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <8e639ef525eab18a0628df948459bbef11553ba1.1661827923.git.pliem@maxlinear.com> References: <8e639ef525eab18a0628df948459bbef11553ba1.1661827923.git.pliem@maxlinear.com> To: Peter Harliman Liem , herbert@gondor.apana.org.au Subject: Re: [PATCH] crypto: inside_secure - Change swab to swab32 Cc: linux-crypto@vger.kernel.org, linux-lgm-soc@maxlinear.com, Peter Harliman Liem From: Antoine Tenart Message-ID: <166236929443.3222.6763048576511318677@kwain> Date: Mon, 05 Sep 2022 11:14:54 +0200 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Hello, Quoting Peter Harliman Liem (2022-08-30 04:58:45) > The use of swab() is causing failures in 64-bit arch, as it > translates to __swab64() instead of the intended __swab32(). > It eventually causes wrong results in xcbcmac & cmac algo. >=20 > Signed-off-by: Peter Harliman Liem This is a fix, can you add a Fixes: tag? Thanks! > --- > drivers/crypto/inside-secure/safexcel_hash.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) >=20 > diff --git a/drivers/crypto/inside-secure/safexcel_hash.c b/drivers/crypt= o/inside-secure/safexcel_hash.c > index bc60b5802256..2124416742f8 100644 > --- a/drivers/crypto/inside-secure/safexcel_hash.c > +++ b/drivers/crypto/inside-secure/safexcel_hash.c > @@ -383,7 +383,7 @@ static int safexcel_ahash_send_req(struct crypto_asyn= c_request *async, int ring, > u32 x; > =20 > x =3D ipad[i] ^ ipad[i + 4]; > - cache[i] ^=3D swab(x); > + cache[i] ^=3D swab32(x); > } > } > cache_len =3D AES_BLOCK_SIZE; > @@ -821,7 +821,7 @@ static int safexcel_ahash_final(struct ahash_request = *areq) > u32 *result =3D (void *)areq->result; > =20 > /* K3 */ > - result[i] =3D swab(ctx->base.ipad.word[i + 4]); > + result[i] =3D swab32(ctx->base.ipad.word[i + 4]); > } > areq->result[0] ^=3D 0x80; // 10- = padding > crypto_cipher_encrypt_one(ctx->kaes, areq->result, areq->= result); > @@ -2106,7 +2106,7 @@ static int safexcel_xcbcmac_setkey(struct crypto_ah= ash *tfm, const u8 *key, > crypto_cipher_encrypt_one(ctx->kaes, (u8 *)key_tmp + AES_BLOCK_SI= ZE, > "\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3"); > for (i =3D 0; i < 3 * AES_BLOCK_SIZE / sizeof(u32); i++) > - ctx->base.ipad.word[i] =3D swab(key_tmp[i]); > + ctx->base.ipad.word[i] =3D swab32(key_tmp[i]); > =20 > crypto_cipher_clear_flags(ctx->kaes, CRYPTO_TFM_REQ_MASK); > crypto_cipher_set_flags(ctx->kaes, crypto_ahash_get_flags(tfm) & > @@ -2189,7 +2189,7 @@ static int safexcel_cmac_setkey(struct crypto_ahash= *tfm, const u8 *key, > return ret; > =20 > for (i =3D 0; i < len / sizeof(u32); i++) > - ctx->base.ipad.word[i + 8] =3D swab(aes.key_enc[i]); > + ctx->base.ipad.word[i + 8] =3D swab32(aes.key_enc[i]); > =20 > /* precompute the CMAC key material */ > crypto_cipher_clear_flags(ctx->kaes, CRYPTO_TFM_REQ_MASK); > --=20 > 2.17.1 >=20