From patchwork Mon May 4 09:00:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 47992 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 025AF2121F for ; Mon, 4 May 2015 09:01:56 +0000 (UTC) Received: by lamp14 with SMTP id p14sf44161953lam.3 for ; Mon, 04 May 2015 02:01:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=VASlbncJhzpyuthW4zWXftxC8/vYF3aRp/SzMYTQCds=; b=VU35701xVrOoaMd7FtAXq63nJREZ0pf5NLrdgL6V52wl5tMcwKteAejhKK0D5asqjj 1xYK5DwF0MF3h07vufHdAL9wuBYVHA42OFOQlUIznQ41bcgsI+y7O4xmXD4lrNndwp4y PyWIltxkeyuUIV6XW6UxL9i/eL/RDCtxmunw2++NRKLL3VkOPF/uniKB4YsirN+ac8D6 7aU+Vuk0mZ5JILqQVfI9S2KxTAN+B0nMCSNx4kNo+8NnGErQX36QsRPeRIO8Ai3+wsXq +TYEoArPDXOzwDbf1f/wAu/rLwembsvFr3K+48w3mQT86egpo3VsHshR506qzItJ6N39 su/w== X-Gm-Message-State: ALoCoQkzBwY9FhQYF18UKXZzCOju3PEilA+XBK8UjhBikU8optQ8LseeJ1j96Amx7EH2RtGEL/W3 X-Received: by 10.180.10.136 with SMTP id i8mr7808496wib.7.1430730114913; Mon, 04 May 2015 02:01:54 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.205.70 with SMTP id le6ls737029lac.50.gmail; Mon, 04 May 2015 02:01:54 -0700 (PDT) X-Received: by 10.152.29.67 with SMTP id i3mr18821776lah.64.1430730114753; Mon, 04 May 2015 02:01:54 -0700 (PDT) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id j2si9658315lbd.98.2015.05.04.02.01.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 May 2015 02:01:54 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by lagv1 with SMTP id v1so99555332lag.3 for ; Mon, 04 May 2015 02:01:54 -0700 (PDT) X-Received: by 10.112.13.6 with SMTP id d6mr17209756lbc.117.1430730114622; Mon, 04 May 2015 02:01:54 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.67.65 with SMTP id l1csp1543152lbt; Mon, 4 May 2015 02:01:54 -0700 (PDT) X-Received: by 10.68.205.197 with SMTP id li5mr40328824pbc.4.1430730112257; Mon, 04 May 2015 02:01:52 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id uw10si19028520pac.163.2015.05.04.02.01.51 for ; Mon, 04 May 2015 02:01:52 -0700 (PDT) Received-SPF: none (google.com: linux-crypto-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752477AbbEDJBt (ORCPT ); Mon, 4 May 2015 05:01:49 -0400 Received: from mail-wi0-f181.google.com ([209.85.212.181]:33344 "EHLO mail-wi0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752678AbbEDJAq (ORCPT ); Mon, 4 May 2015 05:00:46 -0400 Received: by wief7 with SMTP id f7so72723218wie.0 for ; Mon, 04 May 2015 02:00:45 -0700 (PDT) X-Received: by 10.194.240.6 with SMTP id vw6mr40003221wjc.137.1430730044971; Mon, 04 May 2015 02:00:44 -0700 (PDT) Received: from localhost.localdomain (cag06-7-83-153-85-71.fbx.proxad.net. [83.153.85.71]) by mx.google.com with ESMTPSA id j12sm2477017wjn.48.2015.05.04.02.00.43 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 May 2015 02:00:44 -0700 (PDT) From: Ard Biesheuvel To: herbert@gondor.apana.org.au, linux-crypto@vger.kernel.org Cc: yazen.ghannam@linaro.org, steve.capper@linaro.org, Ard Biesheuvel Subject: [PATCH 1/2] crypto: arm64/crc32: bring in line with generic CRC32 Date: Mon, 4 May 2015 11:00:16 +0200 Message-Id: <1430730017-3712-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: linux-crypto-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The arm64 CRC32 (not CRC32c) implementation was not quite doing the same thing as the generic one. Fix that. Signed-off-by: Ard Biesheuvel Acked-by: Steve Capper --- arch/arm64/crypto/crc32-arm64.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/arch/arm64/crypto/crc32-arm64.c b/arch/arm64/crypto/crc32-arm64.c index 9499199924ae..6a37c3c6b11d 100644 --- a/arch/arm64/crypto/crc32-arm64.c +++ b/arch/arm64/crypto/crc32-arm64.c @@ -147,13 +147,21 @@ static int chksum_final(struct shash_desc *desc, u8 *out) { struct chksum_desc_ctx *ctx = shash_desc_ctx(desc); + put_unaligned_le32(ctx->crc, out); + return 0; +} + +static int chksumc_final(struct shash_desc *desc, u8 *out) +{ + struct chksum_desc_ctx *ctx = shash_desc_ctx(desc); + put_unaligned_le32(~ctx->crc, out); return 0; } static int __chksum_finup(u32 crc, const u8 *data, unsigned int len, u8 *out) { - put_unaligned_le32(~crc32_arm64_le_hw(crc, data, len), out); + put_unaligned_le32(crc32_arm64_le_hw(crc, data, len), out); return 0; } @@ -199,6 +207,14 @@ static int crc32_cra_init(struct crypto_tfm *tfm) { struct chksum_ctx *mctx = crypto_tfm_ctx(tfm); + mctx->key = 0; + return 0; +} + +static int crc32c_cra_init(struct crypto_tfm *tfm) +{ + struct chksum_ctx *mctx = crypto_tfm_ctx(tfm); + mctx->key = ~0; return 0; } @@ -229,7 +245,7 @@ static struct shash_alg crc32c_alg = { .setkey = chksum_setkey, .init = chksum_init, .update = chksumc_update, - .final = chksum_final, + .final = chksumc_final, .finup = chksumc_finup, .digest = chksumc_digest, .descsize = sizeof(struct chksum_desc_ctx), @@ -241,7 +257,7 @@ static struct shash_alg crc32c_alg = { .cra_alignmask = 0, .cra_ctxsize = sizeof(struct chksum_ctx), .cra_module = THIS_MODULE, - .cra_init = crc32_cra_init, + .cra_init = crc32c_cra_init, } };