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: 6324631 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9CD189F374 for ; Mon, 4 May 2015 09:01:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C5DBA20138 for ; Mon, 4 May 2015 09:01:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E8E5A202B8 for ; Mon, 4 May 2015 09:01:52 +0000 (UTC) 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-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=gHlS9A5wrv+DZmT1GsP30+umWZVjx7fk5TolwwB1Wd0=; b=WIEp5RWxeH1GbF3doGeO5A9wpWi7NYCIXAyjBNmNUdCkkrbLl++IJFv1JFdbcwm/om /m2A1dJjhVKcjmYXACmHJHuC7vbavh2/BDlcfsI3z3XRZUmPQNm2zJwFMWQpNhhT+3xD DjvCv3fjw1e2bRNPAxn0GLlOWY718iibz1ZdieoncdUcbqCHen2AjntfiLEU5BTd3KLA 6YRWJpevEJj67eWW2b9hMRPtoN/BpWkAIFDpIz/Xqbq+8FKbI9i6bRwQ2qyKtx4UU/tD +6GVI75uwo72APhw6fXFSutnz9/yfFn0/0XzcL9J93I63rmeJ2Oyr7M9GYYnnxSl9ib9 sOlQ== X-Gm-Message-State: ALoCoQlCcd/eXvqIqckm1uRhNLK3vMC/8BWw9Qwb7kPk61kDGLNeKBu52FNaVy5HV28lzEqvDILk 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: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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, } };