From patchwork Sun May 20 05:07:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 10413083 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B550A600F6 for ; Sun, 20 May 2018 05:07:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A5E322847A for ; Sun, 20 May 2018 05:07:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A775286FB; Sun, 20 May 2018 05:07:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C2C5A286FD for ; Sun, 20 May 2018 05:07:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750912AbeETFG6 (ORCPT ); Sun, 20 May 2018 01:06:58 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:47035 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750873AbeETFG5 (ORCPT ); Sun, 20 May 2018 01:06:57 -0400 Received: by mail-pl0-f65.google.com with SMTP id 30-v6so6840804pld.13 for ; Sat, 19 May 2018 22:06:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2earDPO/na+UrwqkPsGT9M/Ti5zCSLUlTnDUHo5bBg8=; b=dTjEFN5fQ38CP//UuSeqNbDC/ZhqMKLuFaHYasACVW/5LW2J2pdg4qimOmQssV9yXQ Y2Pw4e91VJVUEwG7ucmU/lGWbIkrxg/MrXc8ByidE0XSTg0OwsaN7MieINmJChkCNIhe pFz9fqvdVaE2KTgJbAu+PYLGnKf3BOpwZOtyvBv7+tNTTc0YVQKVLKNo2o4760QP2HHI KwzNyDiwSqiuic+C843WIKU0bIHLIBofbWyAAhDfYUKkiPWrHhZAC3ObImTDe5RHXRng BzhVUlQ/IG74NccHvdZQs/ro3b+IvwJjSaZThKyudYqyd6XudWZU+8ZoEIRllWkyAPJe ciqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2earDPO/na+UrwqkPsGT9M/Ti5zCSLUlTnDUHo5bBg8=; b=DAqU24/wd/LV+EajudTIhfhcaodxJNYKNCe6IKzSX71tcRf1GdqP7GzfI0Ol9jyfx7 iNYu2uCiX+SMNueJCnRboRnna0xgoEPrEVhbaLtsEWX6YNBHEOmUMBAG03cPDy9DJ+tM EpU5PQJkv1J+OSo0t+OthupuMZ23M4vU/Iqj62RMecidokgQzjxbql9JgH27LqUk9mJM oH0ptQRT0XIRCNGKZ2NreQOcbsZMA88ymWdjLSPd5MIrR07+9ltBkkijhmpvaQvvwOpW mBASpN8U6hFR5c8EWI8srXB6eAv84TcJCheH8EMrOFz5wKuu97eDHkj+1TVNnOyzARii 7u5Q== X-Gm-Message-State: ALKqPwft9F8aAiiSD0pTOHkU9u/1v9jXptVu39Vrc3UBx6q1xXwzBe33 ukHFQKOL1QgrxduW6R6ClQuQBFiJ X-Google-Smtp-Source: AB8JxZofGr3uLJtWr1sUID+/e6Ytkoeo6ja42s5cxmi4rPe4lAkSV/wAIHkRUGo3/yfqziOk6N8sJQ== X-Received: by 2002:a17:902:a582:: with SMTP id az2-v6mr15385836plb.98.1526792816714; Sat, 19 May 2018 22:06:56 -0700 (PDT) Received: from sol.localdomain (c-67-185-97-198.hsd1.wa.comcast.net. [67.185.97.198]) by smtp.gmail.com with ESMTPSA id m9-v6sm19488322pff.41.2018.05.19.22.06.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 19 May 2018 22:06:56 -0700 (PDT) From: Eric Biggers To: linux-crypto@vger.kernel.org, Herbert Xu Cc: Eric Biggers Subject: [PATCH 2/6] crypto: crc32c-generic - remove cra_alignmask Date: Sat, 19 May 2018 22:07:38 -0700 Message-Id: <20180520050742.5008-3-ebiggers3@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180520050742.5008-1-ebiggers3@gmail.com> References: <20180520050742.5008-1-ebiggers3@gmail.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Biggers crc32c-generic sets an alignmask, but actually its ->update() works with any alignment; only its ->setkey() and outputting the final digest assume an alignment. To prevent the buffer from having to be aligned by the crypto API for just these cases, switch these cases over to the unaligned access macros and remove the cra_alignmask. Note that this also makes crc32c-generic more consistent with crc32-generic. Signed-off-by: Eric Biggers --- crypto/crc32c_generic.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crypto/crc32c_generic.c b/crypto/crc32c_generic.c index 372320399622..7283066ecc98 100644 --- a/crypto/crc32c_generic.c +++ b/crypto/crc32c_generic.c @@ -35,6 +35,7 @@ * */ +#include #include #include #include @@ -82,7 +83,7 @@ static int chksum_setkey(struct crypto_shash *tfm, const u8 *key, crypto_shash_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN); return -EINVAL; } - mctx->key = le32_to_cpu(*(__le32 *)key); + mctx->key = get_unaligned_le32(key); return 0; } @@ -99,13 +100,13 @@ static int chksum_final(struct shash_desc *desc, u8 *out) { struct chksum_desc_ctx *ctx = shash_desc_ctx(desc); - *(__le32 *)out = ~cpu_to_le32p(&ctx->crc); + put_unaligned_le32(~ctx->crc, out); return 0; } static int __chksum_finup(u32 *crcp, const u8 *data, unsigned int len, u8 *out) { - *(__le32 *)out = ~cpu_to_le32(__crc32c_le(*crcp, data, len)); + put_unaligned_le32(~__crc32c_le(*crcp, data, len), out); return 0; } @@ -148,7 +149,6 @@ static struct shash_alg alg = { .cra_priority = 100, .cra_flags = CRYPTO_ALG_OPTIONAL_KEY, .cra_blocksize = CHKSUM_BLOCK_SIZE, - .cra_alignmask = 3, .cra_ctxsize = sizeof(struct chksum_ctx), .cra_module = THIS_MODULE, .cra_init = crc32c_cra_init,