From patchwork Fri Dec 29 16:10:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 10137207 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 B72FB6020A for ; Fri, 29 Dec 2017 16:13:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4E5C2B743 for ; Fri, 29 Dec 2017 16:13:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A39B22D1A0; Fri, 29 Dec 2017 16:13:10 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, 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 AFAAA2D153 for ; Fri, 29 Dec 2017 16:13:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751315AbdL2QM7 (ORCPT ); Fri, 29 Dec 2017 11:12:59 -0500 Received: from mail-it0-f66.google.com ([209.85.214.66]:45995 "EHLO mail-it0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751246AbdL2QM7 (ORCPT ); Fri, 29 Dec 2017 11:12:59 -0500 Received: by mail-it0-f66.google.com with SMTP id z6so31440614iti.4 for ; Fri, 29 Dec 2017 08:12:58 -0800 (PST) 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=BJjlRO48ay8eLmk0NBH6AbDcVSFQ3ZZNMOAZLsXZ4U8=; b=rTAdkbYgbJus6t4rfNXoQ6+qSUZikjHK1OlCjRl3mCKoK03OT9dsbEHAoLnB2Z+dUU BvvjtldfUk8VpWIPt3Pkt3T9547OdJM8zwe4m0rCaW6AZ5NEjHGGmPJpSEqAukbwXnrx 2D3ZDXXBUXImatwao6yWqCpNmvo5WQpSyl+d+KcgBvyK8ZGK/uDYMUTaD4lVE3Ccnlcb HeaNEtgQ+GXg51A6U2AcF/bjGD4Z3JD269XscaTFnYUQV5V4VNVShPGPzlQg4H1X8vid 12EJ3wB3jMiJcSIIF9jVXUhxEPl7VZAVHSuRYUlRcGlwP5bMWUkyvcXINz3WPD4BL36O XnsQ== 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=BJjlRO48ay8eLmk0NBH6AbDcVSFQ3ZZNMOAZLsXZ4U8=; b=RIoObm8sHeK8/Kg/Omn6ZrLgHs6zPDRV31o4ZajR0Xtkake9YnCqJXn1p91njdDYNP ShlNvxfIw7fC8usBVWaMqZsWuyh4MjVmNyWHvPz48MheI7I88oVhKPkSUDIxB/HGKXgx xHaap3cesigTfaA8esb8kdV+fuBKZennQyLIfkUDo/e9CjK77Z9JELklHXWIpJXJmNhE PNZNjmq68iKvJcC76k+Dp1D5mnNLuBGAyXwi8pqLpNWS+SUS88QxT+uHXuVTpfbq15MF hdkWxMFjd1+10Mfs+qC74Cu2U3YKWh2XsnXye9+a/K0Q8XYuQzR5euaHeqKWmteIJes4 UivQ== X-Gm-Message-State: AKGB3mJBd0/BY7oKm01Joim60s0L8/8nWr1XaLWak9U8vMjMNKdSGG2i Oo5zaJLI1cnMC9WViF6MTLGo08rj X-Google-Smtp-Source: ACJfBotn0VABYgpHJrYUPyHdtJxTzrhkNZwUK65I0H43m3zkTyHNNnynN1KSxF7Ebz9w1XZ2SAa4Fw== X-Received: by 10.36.124.15 with SMTP id a15mr48477725itd.135.1514563978410; Fri, 29 Dec 2017 08:12:58 -0800 (PST) Received: from zzz.Home (h184-60-19-231.mdsnwi.dsl.dynamic.tds.net. [184.60.19.231]) by smtp.gmail.com with ESMTPSA id 72sm1743830itg.0.2017.12.29.08.12.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Dec 2017 08:12:57 -0800 (PST) From: Eric Biggers To: linux-crypto@vger.kernel.org, Herbert Xu Cc: "David S . Miller" , "Jason A . Donenfeld" , Martin Willi , Eric Biggers Subject: [PATCH 1/3] crypto: poly1305 - use unaligned access macros to output digest Date: Fri, 29 Dec 2017 10:10:24 -0600 Message-Id: <20171229161026.28102-2-ebiggers3@gmail.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20171229161026.28102-1-ebiggers3@gmail.com> References: <20171229161026.28102-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 Currently the only part of poly1305-generic which is assuming special alignment is the part where the final digest is written. Switch this over to the unaligned access macros so that we'll be able to remove the cra_alignmask. Signed-off-by: Eric Biggers --- crypto/poly1305_generic.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/crypto/poly1305_generic.c b/crypto/poly1305_generic.c index b1c2d57dc734..d752901ba0bc 100644 --- a/crypto/poly1305_generic.c +++ b/crypto/poly1305_generic.c @@ -210,7 +210,6 @@ EXPORT_SYMBOL_GPL(crypto_poly1305_update); int crypto_poly1305_final(struct shash_desc *desc, u8 *dst) { struct poly1305_desc_ctx *dctx = shash_desc_ctx(desc); - __le32 *mac = (__le32 *)dst; u32 h0, h1, h2, h3, h4; u32 g0, g1, g2, g3, g4; u32 mask; @@ -267,10 +266,10 @@ int crypto_poly1305_final(struct shash_desc *desc, u8 *dst) h3 = (h3 >> 18) | (h4 << 8); /* mac = (h + s) % (2^128) */ - f = (f >> 32) + h0 + dctx->s[0]; mac[0] = cpu_to_le32(f); - f = (f >> 32) + h1 + dctx->s[1]; mac[1] = cpu_to_le32(f); - f = (f >> 32) + h2 + dctx->s[2]; mac[2] = cpu_to_le32(f); - f = (f >> 32) + h3 + dctx->s[3]; mac[3] = cpu_to_le32(f); + f = (f >> 32) + h0 + dctx->s[0]; put_unaligned_le32(f, dst + 0); + f = (f >> 32) + h1 + dctx->s[1]; put_unaligned_le32(f, dst + 4); + f = (f >> 32) + h2 + dctx->s[2]; put_unaligned_le32(f, dst + 8); + f = (f >> 32) + h3 + dctx->s[3]; put_unaligned_le32(f, dst + 12); return 0; }