Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1189169rwi; Wed, 19 Oct 2022 07:42:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM63EkKfUuN8P+1gdqip/vQ3Sc6IllNaj0Oes47yVs1HU+fetMccN2ykoF4LJ18cUq9I0qV2 X-Received: by 2002:a05:6402:1587:b0:458:fbea:436c with SMTP id c7-20020a056402158700b00458fbea436cmr7824256edv.407.1666190528390; Wed, 19 Oct 2022 07:42:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666190528; cv=none; d=google.com; s=arc-20160816; b=zhfoCLgD0yvyePJU22freXrJBzB4aR/HnKfX6FEC70OSXJphhb2om9NLfSy6v/dVM3 L6SJR4WImX96YDHpWOLszSASOk9un1S5g6Q+mvgIfjDcslDsHbJeuia7amzvQCZOz2cq 5S6fmp2DRtRLcLOI1K802EhSD2U4zLtjHZlSigwUUCazIIUBBwqVRFw9j8yb3xVPOD0B k6VWFDwkZvVXx8tYpF5PWa9QMslOIEuRb/CBK3ZfjH+kPA72P4sOWIJOYQQreEAPI9nt e0vkLuucyaMoKnaO7fjczFg+Yb7fzl1buudLqGs/CnE+rznqQWf5PJvRA4haf1QD8sgz 3RUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7x2n/RkekdGOKth6jNyMxgSl4XjLQSVzhxcKcZ4+GV8=; b=gEZhgu12hJhE+QIZ/2T/GiIL2JJdpi8GA8nrMJmyJRSGcFnP20AbG8+A3XNaH0H4Rd QCJzFeEZQnO/UWjI6d5pA9evOqS9cjtRofhNAlHDg/KfMqlSgfk/OgL7NyD6A4XSqAtu rfirORkH53zt5/OWGkFWX6XuZGfDfHZMhJHkAFvSdY8kRHVgGZOl1inmbLwfjVMn1E+C aqmMrxWI1pbExDg1Bxo0pp2Qah7l0U0sUSWrZf7aTUq2uQrmjofR7OqWmG3qVU05QmWZ dGT4dasRl12rZwusCWv3iTFNhIhS5PHusMEhefBPsSbvpc3AWiHWluWtUZR/iE0eZQHp D+1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Cs2s97br; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cn4-20020a0564020ca400b0045c4b1f4315si13046665edb.485.2022.10.19.07.41.42; Wed, 19 Oct 2022 07:42:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@linuxfoundation.org header.s=korg header.b=Cs2s97br; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233049AbiJSNqZ (ORCPT + 99 others); Wed, 19 Oct 2022 09:46:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233045AbiJSNp2 (ORCPT ); Wed, 19 Oct 2022 09:45:28 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 531DA3A154; Wed, 19 Oct 2022 06:31:53 -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 sin.source.kernel.org (Postfix) with ESMTPS id 070DACE2182; Wed, 19 Oct 2022 09:06:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0DB1DC433D6; Wed, 19 Oct 2022 09:06:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170409; bh=V158gqfaGOuKvv7mls5uKxEIcANh4s5FzQov9SkR/sc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cs2s97brTX4g9/pdKdnupz9nPUvDqEXXS6R/XjtDnA36nTNNr48/R51zBymsegKGK VoWFLnOKQgy0HaOByK0UbRCPoDjDnwo6BWloNFPPBnocrkkytBObbrQTdTnrkOjE/p +lXpA7ATUAZzgZzrufoBwFDgL8YD0DhMN9pAQzaA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Harliman Liem , Antoine Tenart , Herbert Xu , Sasha Levin Subject: [PATCH 6.0 637/862] crypto: inside-secure - Change swab to swab32 Date: Wed, 19 Oct 2022 10:32:04 +0200 Message-Id: <20221019083318.078529484@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 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 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-kernel@vger.kernel.org From: Peter Harliman Liem [ Upstream commit 664593407e936b6438fbfaaf98876910fd31cf9a ] 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. Fixes: 78cf1c8bfcb8 ("crypto: inside-secure - Move ipad/opad into safexcel_context") Signed-off-by: Peter Harliman Liem Acked-by: Antoine Tenart Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- drivers/crypto/inside-secure/safexcel_hash.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/inside-secure/safexcel_hash.c b/drivers/crypto/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_async_request *async, int ring, u32 x; x = ipad[i] ^ ipad[i + 4]; - cache[i] ^= swab(x); + cache[i] ^= swab32(x); } } cache_len = AES_BLOCK_SIZE; @@ -821,7 +821,7 @@ static int safexcel_ahash_final(struct ahash_request *areq) u32 *result = (void *)areq->result; /* K3 */ - result[i] = swab(ctx->base.ipad.word[i + 4]); + result[i] = swab32(ctx->base.ipad.word[i + 4]); } areq->result[0] ^= 0x80; // 10- padding crypto_cipher_encrypt_one(ctx->kaes, areq->result, areq->result); @@ -2106,7 +2106,7 @@ static int safexcel_xcbcmac_setkey(struct crypto_ahash *tfm, const u8 *key, crypto_cipher_encrypt_one(ctx->kaes, (u8 *)key_tmp + AES_BLOCK_SIZE, "\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3"); for (i = 0; i < 3 * AES_BLOCK_SIZE / sizeof(u32); i++) - ctx->base.ipad.word[i] = swab(key_tmp[i]); + ctx->base.ipad.word[i] = swab32(key_tmp[i]); 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; for (i = 0; i < len / sizeof(u32); i++) - ctx->base.ipad.word[i + 8] = swab(aes.key_enc[i]); + ctx->base.ipad.word[i + 8] = swab32(aes.key_enc[i]); /* precompute the CMAC key material */ crypto_cipher_clear_flags(ctx->kaes, CRYPTO_TFM_REQ_MASK); -- 2.35.1