Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp3760530rwe; Mon, 29 Aug 2022 20:06:24 -0700 (PDT) X-Google-Smtp-Source: AA6agR7V6WR/X5Kqu/cowGadWwco4FEobd9Rm8I400Gyl80kKHzlb8bXlqrKk9u09Z7RhppcY5qZ X-Received: by 2002:a05:6402:43c6:b0:43d:79a6:4e32 with SMTP id p6-20020a05640243c600b0043d79a64e32mr18171062edc.281.1661828783907; Mon, 29 Aug 2022 20:06:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661828783; cv=none; d=google.com; s=arc-20160816; b=RRywJx6IE9ySTyL2P8oNO7HG85X/yDkzastr2I3MXws5pppxHQd5OZWk87UYVv924b I1jQnxzsxjUV7uBJyH/Mo0I+/sn5jdnSVIiaPL8r5xnI7+i7m8fULRX8ETsFRQQHUpGG 2uU2fmfOEOUEIkdmVz4bORct1m/ELQBMD/KVs4NBhr4IYv4X6fl1MhEinsY70cEoO1oC KMZpiSdBJB07jzFGzm3WsWykk3elJmkCULew+rp1FcuVBOq1YvqrbSu1pROGlsmkl3x/ 1z3oP02gruttKdAwkclRMBQV0SF71XeuiZxD6IDCSYuX9gBfn/p3wd1h8dxOrINJPjaA jhTw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=tEUS5NVpeNkT2ib0ytK7390ZoM/5mi9plOGbSeDW1RI=; b=Rj3QyVfZFIcQNokvzmoe7WqXxR1aqwRl6qhi02AIoreR0gqAPWOFVpcV8fh3R1rtqt mjS5wkW13IMfH5LZLFFrbI2wirUbygMYlk4KfkktxIyGHj0mTqAjHpvLrR1Mt2c7YgTd POrbye8TuffXjAHQ9kDWQLfT/wtdjb+/eZ1Rxix9fKIpY/ubCmSa1z4HZT+3x271vKB3 H9vTY/1VRIRWH710HxUAbKKMZe6rXyIiF9VJrEsPo5jyuH8tQZ0D14aUBIgxsMk1sQo0 OGDo0H5whnj+FJQRjTNJphLCRr5sk1Bt3sC89HGo6tLFGXAdmoMNCe6Kw8D6IwGFWqxt NRpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@maxlinear.com header.s=selector header.b=XDpDRnab; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=maxlinear.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hr8-20020a1709073f8800b0073d9af9347bsi674453ejc.673.2022.08.29.20.05.47; Mon, 29 Aug 2022 20:06:23 -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=@maxlinear.com header.s=selector header.b=XDpDRnab; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=maxlinear.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229556AbiH3DFQ (ORCPT + 99 others); Mon, 29 Aug 2022 23:05:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229453AbiH3DFN (ORCPT ); Mon, 29 Aug 2022 23:05:13 -0400 X-Greylist: delayed 305 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 29 Aug 2022 20:05:11 PDT Received: from us-smtp-delivery-115.mimecast.com (us-smtp-delivery-115.mimecast.com [170.10.133.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0778312AC4 for ; Mon, 29 Aug 2022 20:05:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=maxlinear.com; s=selector; t=1661828706; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tEUS5NVpeNkT2ib0ytK7390ZoM/5mi9plOGbSeDW1RI=; b=XDpDRnab5wgfkvK2nlj2XVkE5mcQvHd2dBprAlLEw36xNLsUnmRvUKfP7nYXOV7XM7YA7q Gd2YlEgKC8QcdiCwADxgbGfjZ539l1ARFSp1xRJuaIR4EVKNk/JfnLaOiZ+1H9Hm2kPpmO QnlhbwbmyWlFmqd8vJEHA1LNB23toObNKLJwBiLfi1S2Tmw2/b6NQuVzERK6yTX9bx8bwN 5IXwaIuv1xfQ+XQkC9RG2JMCIBBhyM3OA9AnOkQs4BJpsPjboXoHHDylIG3rURfghsXQ08 imVwIC3o6KDtJBFoQ28BbgojjbKviYVwAkLcf5BgCvwTluQHcp/R+axoQyTUsg== Received: from mail.maxlinear.com (174-47-1-83.static.ctl.one [174.47.1.83]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id us-mta-127-dIipq-oxOviO5zmhMB-W3A-1; Mon, 29 Aug 2022 22:58:54 -0400 X-MC-Unique: dIipq-oxOviO5zmhMB-W3A-1 Received: from sgsxdev002.isng.phoenix.local (10.226.81.112) by mail.maxlinear.com (10.23.38.120) with Microsoft SMTP Server id 15.1.2375.24; Mon, 29 Aug 2022 19:58:51 -0700 From: Peter Harliman Liem To: , CC: , , "Peter Harliman Liem" Subject: [PATCH] crypto: inside_secure - Change swab to swab32 Date: Tue, 30 Aug 2022 10:58:45 +0800 Message-ID: <8e639ef525eab18a0628df948459bbef11553ba1.1661827923.git.pliem@maxlinear.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: maxlinear.com Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 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. Signed-off-by: Peter Harliman Liem --- 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, =09=09=09=09=09u32 x; =20 =09=09=09=09=09x =3D ipad[i] ^ ipad[i + 4]; -=09=09=09=09=09cache[i] ^=3D swab(x); +=09=09=09=09=09cache[i] ^=3D swab32(x); =09=09=09=09} =09=09=09} =09=09=09cache_len =3D AES_BLOCK_SIZE; @@ -821,7 +821,7 @@ static int safexcel_ahash_final(struct ahash_request *a= req) =09=09=09u32 *result =3D (void *)areq->result; =20 =09=09=09/* K3 */ -=09=09=09result[i] =3D swab(ctx->base.ipad.word[i + 4]); +=09=09=09result[i] =3D swab32(ctx->base.ipad.word[i + 4]); =09=09} =09=09areq->result[0] ^=3D 0x80;=09=09=09// 10- padding =09=09crypto_cipher_encrypt_one(ctx->kaes, areq->result, areq->result); @@ -2106,7 +2106,7 @@ static int safexcel_xcbcmac_setkey(struct crypto_ahas= h *tfm, const u8 *key, =09crypto_cipher_encrypt_one(ctx->kaes, (u8 *)key_tmp + AES_BLOCK_SIZE, =09=09"\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3"); =09for (i =3D 0; i < 3 * AES_BLOCK_SIZE / sizeof(u32); i++) -=09=09ctx->base.ipad.word[i] =3D swab(key_tmp[i]); +=09=09ctx->base.ipad.word[i] =3D swab32(key_tmp[i]); =20 =09crypto_cipher_clear_flags(ctx->kaes, CRYPTO_TFM_REQ_MASK); =09crypto_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, =09=09return ret; =20 =09for (i =3D 0; i < len / sizeof(u32); i++) -=09=09ctx->base.ipad.word[i + 8] =3D swab(aes.key_enc[i]); +=09=09ctx->base.ipad.word[i + 8] =3D swab32(aes.key_enc[i]); =20 =09/* precompute the CMAC key material */ =09crypto_cipher_clear_flags(ctx->kaes, CRYPTO_TFM_REQ_MASK); --=20 2.17.1