From patchwork Sat May 26 07:08:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 10428861 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 76714601C7 for ; Sat, 26 May 2018 07:12:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 604D8297DD for ; Sat, 26 May 2018 07:12:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 521B929826; Sat, 26 May 2018 07:12:15 +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 E1868297DD for ; Sat, 26 May 2018 07:12:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031132AbeEZHMN (ORCPT ); Sat, 26 May 2018 03:12:13 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:38231 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031171AbeEZHMM (ORCPT ); Sat, 26 May 2018 03:12:12 -0400 Received: by mail-pg0-f68.google.com with SMTP id c9-v6so366232pgf.5 for ; Sat, 26 May 2018 00:12:12 -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=Z1lkwNa3IBamhlVNLqza8LSPS2yT5NTrRk4kgO9al8w=; b=jndi3sWlspYvy37vQTOCKPxr9Ny0Px+DeG70TsXniGxzLRHHL1pDecBhRM3tTK9wRJ iBkYbSxqO81vHET+gXv+kXIpQRbJoMdhu3Cj2imy60ezvB4B8hQFKSsxIc7sf27Ks9Ng 4iYwV12Slc/HiDEH+/zXiFpikFpg0JdE3Zl+xA2ijpPk9aCKQikF3ohEOw97nAlvCiZ2 KoCIB4UKw/WNBBOgWla3WRTBVbnN1o/UHcP1+D/aUfn8k0Ka4mlvBKX3pLkhpjreqq0e a6a1AOeNd7fGpCn1jDd2YoC/l4gXZEnrTyz3tgye/TlMt6MoQ2xm9ucL4jgWiirIH3DY AqeA== 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=Z1lkwNa3IBamhlVNLqza8LSPS2yT5NTrRk4kgO9al8w=; b=EbFAvczSUaxudQtLigxye0w9DYujURuvwhnzn918SeuoEkzUiTDxLRw5Ch0UMEVTVZ l8elM6WO+g5M8oRYqjURJnXhXEmCW995P8LzR86//Q2zUnLk0oEdiK84kaZzOwJhvIbi u2h7n3Y81sUoqdpJmaoZ2FsaZU0Jvo/OMERBSNSGt1euz6GsXX3nd5X1pbIDr3/bPUxU L4sgVZDIi0D/U9fWCJTco5DNP7yAV8a/Zg+bxbHNqW4LEiCvoLS6liSaQiwVKiU+4v1u RjHiiufzja+XXM6MfmSrgkI53HQxjHd6uEL9B0HGHOFi3MFsrpHplqvoNPZp2G7h0HAA xUOQ== X-Gm-Message-State: ALKqPwePq7EB/j7LZCExpFB1r+NWbcAyTC2izfFacAgpFHGGcsRJy7WQ zd4uWr/Ik6a13qkDyl69DHm1+AZo X-Google-Smtp-Source: AB8JxZrnMWDDsSgFfK4D0jj3fX0+igMoIb6hcn8Vj1JknOGHE2BEMXWmzgSoXAqW2zIjLtaYgGNLaQ== X-Received: by 2002:a65:65ce:: with SMTP id y14-v6mr4254342pgv.270.1527318731822; Sat, 26 May 2018 00:12:11 -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 e87-v6sm62557020pfl.65.2018.05.26.00.12.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 26 May 2018 00:12:11 -0700 (PDT) From: Eric Biggers To: linux-crypto@vger.kernel.org, Herbert Xu Cc: x86@kernel.org, Josh Poimboeuf , Tan Swee Heng , Eric Biggers Subject: [PATCH 2/2] crypto: salsa20 - Revert "crypto: salsa20 - export generic helpers" Date: Sat, 26 May 2018 00:08:59 -0700 Message-Id: <20180526070859.20513-3-ebiggers3@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180526070859.20513-1-ebiggers3@gmail.com> References: <20180526070859.20513-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 This reverts commit eb772f37ae8163a89e28a435f6a18742ae06653b, as now the x86 Salsa20 implementation has been removed and the generic helpers are no longer needed outside of salsa20_generic.c. We could keep this just in case someone else wants to add a new optimized Salsa20 implementation. But given that we have ChaCha20 now too, I think it's unlikely. And this can always be reverted back. Signed-off-by: Eric Biggers --- crypto/salsa20_generic.c | 20 +++++++++++++------- include/crypto/salsa20.h | 27 --------------------------- 2 files changed, 13 insertions(+), 34 deletions(-) delete mode 100644 include/crypto/salsa20.h diff --git a/crypto/salsa20_generic.c b/crypto/salsa20_generic.c index 5074006a56c3..8c77bc78a09f 100644 --- a/crypto/salsa20_generic.c +++ b/crypto/salsa20_generic.c @@ -21,9 +21,17 @@ #include #include -#include #include +#define SALSA20_IV_SIZE 8 +#define SALSA20_MIN_KEY_SIZE 16 +#define SALSA20_MAX_KEY_SIZE 32 +#define SALSA20_BLOCK_SIZE 64 + +struct salsa20_ctx { + u32 initial_state[16]; +}; + static void salsa20_block(u32 *state, __le32 *stream) { u32 x[16]; @@ -93,16 +101,15 @@ static void salsa20_docrypt(u32 *state, u8 *dst, const u8 *src, } } -void crypto_salsa20_init(u32 *state, const struct salsa20_ctx *ctx, +static void salsa20_init(u32 *state, const struct salsa20_ctx *ctx, const u8 *iv) { memcpy(state, ctx->initial_state, sizeof(ctx->initial_state)); state[6] = get_unaligned_le32(iv + 0); state[7] = get_unaligned_le32(iv + 4); } -EXPORT_SYMBOL_GPL(crypto_salsa20_init); -int crypto_salsa20_setkey(struct crypto_skcipher *tfm, const u8 *key, +static int salsa20_setkey(struct crypto_skcipher *tfm, const u8 *key, unsigned int keysize) { static const char sigma[16] = "expand 32-byte k"; @@ -143,7 +150,6 @@ int crypto_salsa20_setkey(struct crypto_skcipher *tfm, const u8 *key, return 0; } -EXPORT_SYMBOL_GPL(crypto_salsa20_setkey); static int salsa20_crypt(struct skcipher_request *req) { @@ -155,7 +161,7 @@ static int salsa20_crypt(struct skcipher_request *req) err = skcipher_walk_virt(&walk, req, true); - crypto_salsa20_init(state, ctx, walk.iv); + salsa20_init(state, ctx, walk.iv); while (walk.nbytes > 0) { unsigned int nbytes = walk.nbytes; @@ -183,7 +189,7 @@ static struct skcipher_alg alg = { .max_keysize = SALSA20_MAX_KEY_SIZE, .ivsize = SALSA20_IV_SIZE, .chunksize = SALSA20_BLOCK_SIZE, - .setkey = crypto_salsa20_setkey, + .setkey = salsa20_setkey, .encrypt = salsa20_crypt, .decrypt = salsa20_crypt, }; diff --git a/include/crypto/salsa20.h b/include/crypto/salsa20.h deleted file mode 100644 index 19ed48aefc86..000000000000 --- a/include/crypto/salsa20.h +++ /dev/null @@ -1,27 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Common values for the Salsa20 algorithm - */ - -#ifndef _CRYPTO_SALSA20_H -#define _CRYPTO_SALSA20_H - -#include - -#define SALSA20_IV_SIZE 8 -#define SALSA20_MIN_KEY_SIZE 16 -#define SALSA20_MAX_KEY_SIZE 32 -#define SALSA20_BLOCK_SIZE 64 - -struct crypto_skcipher; - -struct salsa20_ctx { - u32 initial_state[16]; -}; - -void crypto_salsa20_init(u32 *state, const struct salsa20_ctx *ctx, - const u8 *iv); -int crypto_salsa20_setkey(struct crypto_skcipher *tfm, const u8 *key, - unsigned int keysize); - -#endif /* _CRYPTO_SALSA20_H */