From patchwork Sun Sep 29 17:38:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 174677 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp6171629ill; Sun, 29 Sep 2019 10:39:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqxqFJ0I0mFLoTBA9ORmpptKEOIMH8vHH0gA71aIB8wEFgDOnqdkspKK65NM2hccwoXfBD9w X-Received: by 2002:a05:6402:1a45:: with SMTP id bf5mr15202224edb.275.1569778747050; Sun, 29 Sep 2019 10:39:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569778747; cv=none; d=google.com; s=arc-20160816; b=NEOZQ5zvFGl3+Iugx+HBpoarYZzfQjrh+tWKgVr4uG9ReIW8IbpRwF64iG/TVIR2+G sWlt64dk8nmSSxI9P4f8E/unBO7RLht9pZQkeLSCxQg6qF7S+5RTKkTdB/zKuux2iORo 3pqRR4/OlLnIzjdoxREFBgfqEHyO3VmK2raYvTYEQ7StEXG8KQdl26pU3GpK3+BOwrgp RMY2Cz7aixqsIQOSD/gp1gbYb6mXk2I/i6ydE2+CzP92WXUvK9zm61f9OshXZfShLzMv G/iuXCPOgRNrs+MTOcH+AWXIxE1c6EDoiTKJSjmfv1M2H4AzyU+SRTIdl1UOGMAwJUhg LsNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=p4KKhW/ILVWczJ+i+Rd5vVeZAxxdEodk6kG2Ndh76c8=; b=Uhq0YGamxSxVl02Gn5h3B0qvdqyEkfJC1/M6drBrs3xweN90IdYGWk67UcIlrzPQzu l5Wtq6UoviK+VUh4/lDzLjdb/vt1JGv7o9wOu9bHbbCTUtbAo/oUuGXyFax8YlOqoXKF imwCZ+AH+/abrvBa7czCh9BuY8D8OP+WmvTDmbkYB1AW22d+80brJ8llAXfycP9Yz0vB z1cbJO9bjHqspAsuOMB3/lHcWkArVg8ELtac0woqEddBiFn7ZfHf7LD2z0sRcL06m01J VUXqIV924rq953hKWK9UntCgqc9NDCCoZMHhYwLBWXv4tfippvMIe7FpBwFTP+nwrC8j EOnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ZEyCF1H/"; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a54si5497520edc.333.2019.09.29.10.39.06; Sun, 29 Sep 2019 10:39:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ZEyCF1H/"; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730284AbfI2RjF (ORCPT + 3 others); Sun, 29 Sep 2019 13:39:05 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:35920 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730169AbfI2RjD (ORCPT ); Sun, 29 Sep 2019 13:39:03 -0400 Received: by mail-wm1-f66.google.com with SMTP id m18so10215486wmc.1 for ; Sun, 29 Sep 2019 10:39:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=p4KKhW/ILVWczJ+i+Rd5vVeZAxxdEodk6kG2Ndh76c8=; b=ZEyCF1H/kwGHAmCX7wDAnQK5bIXTg6qZpWC74qnqY63TcIy3pIPkbxc2sTcCg8luZz q6N80FqXhB6heMzg+6M6s1ZbjhQiwAwKiwJl5kzEEEf1cYK4WUbFQw0Y8Uj+g2yzNTFv 9fIVOzRuCjBrBFS7wUp7S242oOoi/7zLsDBJXmprJa01APm+Y1j9gH7WuPc3Sv9tpTmn gp/wOHtBOLF70hK4Ck/P8+gHxV0M45lPFCwc8RZ69k6RaE5dcvL+kHTgC1pnah7DR9qV 1R25ncK0DlZangay+d/xk81n4/XgAm9mJJk2QNmAn+QVgPO/Snle8BXiIFez++yRTcwv i5DQ== 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=p4KKhW/ILVWczJ+i+Rd5vVeZAxxdEodk6kG2Ndh76c8=; b=dnybO73yMN+jiQZC1B9vjlloqd0+t5tgJIbrFVbLoSECOUcueggOw/igcnt4CV8dbV OqHnugZ9RdIdwhAKu9kiSy0b7Qz3Ua3jXBUOZ7JSknrQhopTdWLeZIHwCTR62gMTKCq7 kRxUcJLe0a33iD7mQ7nTRwZbaOFAI44+lh8vnAhT6vDRNq7g9hJl8NOomdDV3mIkfOCJ roXEqO17m5l72uTfkQvCtmGQuNdLDPq8DU+VOa/dtKaoJdHLWN0umQDzVKjuXmxfi/cQ SgJiceE2KgMsOKZZ029eH2VAsMs5h/gbARlVyC47AdgqFhbGkJwhMo3g6zTtAfxIjvOl BMlA== X-Gm-Message-State: APjAAAXEP+FjXMxFdIpHttf183YtkOHXvDmrL90LFa8lEWkHugfc9i2r PI2NwDo0QgYHL+RUiJnbkgYSnTZiLoQk6BYJ X-Received: by 2002:a05:600c:290c:: with SMTP id i12mr14943151wmd.77.1569778742225; Sun, 29 Sep 2019 10:39:02 -0700 (PDT) Received: from e123331-lin.nice.arm.com (bar06-5-82-246-156-241.fbx.proxad.net. [82.246.156.241]) by smtp.gmail.com with ESMTPSA id q192sm17339779wme.23.2019.09.29.10.39.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Sep 2019 10:39:01 -0700 (PDT) From: Ard Biesheuvel To: linux-crypto@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Herbert Xu , David Miller , Greg KH , Linus Torvalds , "Jason A . Donenfeld" , Samuel Neves , Dan Carpenter , Arnd Bergmann , Eric Biggers , Andy Lutomirski , Will Deacon , Marc Zyngier , Catalin Marinas , Martin Willi Subject: [RFC PATCH 03/20] crypto: arm64/chacha - expose arm64 ChaCha routine as library function Date: Sun, 29 Sep 2019 19:38:33 +0200 Message-Id: <20190929173850.26055-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190929173850.26055-1-ard.biesheuvel@linaro.org> References: <20190929173850.26055-1-ard.biesheuvel@linaro.org> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Expose the accelerated NEON ChaCha routine directly as a symbol export so that users of the ChaCha library can use it directly. Signed-off-by: Ard Biesheuvel --- arch/arm64/crypto/Kconfig | 1 + arch/arm64/crypto/chacha-neon-glue.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) -- 2.17.1 diff --git a/arch/arm64/crypto/Kconfig b/arch/arm64/crypto/Kconfig index 4922c4451e7c..09aa69ccc792 100644 --- a/arch/arm64/crypto/Kconfig +++ b/arch/arm64/crypto/Kconfig @@ -104,6 +104,7 @@ config CRYPTO_CHACHA20_NEON depends on KERNEL_MODE_NEON select CRYPTO_BLKCIPHER select CRYPTO_CHACHA20 + select CRYPTO_ARCH_HAVE_LIB_CHACHA config CRYPTO_NHPOLY1305_NEON tristate "NHPoly1305 hash function using NEON instructions (for Adiantum)" diff --git a/arch/arm64/crypto/chacha-neon-glue.c b/arch/arm64/crypto/chacha-neon-glue.c index d4cc61bfe79d..26c12b19a4ad 100644 --- a/arch/arm64/crypto/chacha-neon-glue.c +++ b/arch/arm64/crypto/chacha-neon-glue.c @@ -59,6 +59,18 @@ static void chacha_doneon(u32 *state, u8 *dst, const u8 *src, } } +void chacha_crypt(u32 *state, u8 *dst, const u8 *src, unsigned int bytes, + int nrounds) +{ + if (bytes <= CHACHA_BLOCK_SIZE || !crypto_simd_usable()) + return chacha_crypt_generic(state, dst, src, bytes, nrounds); + + kernel_neon_begin(); + chacha_doneon(state, dst, src, bytes, nrounds); + kernel_neon_end(); +} +EXPORT_SYMBOL(chacha_crypt); + static int chacha_neon_stream_xor(struct skcipher_request *req, const struct chacha_ctx *ctx, const u8 *iv) {