Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp6023494ybn; Sun, 29 Sep 2019 10:39:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqwrd1is2BnzHVMuQH+6CBA9CpvsGoFWbQdvfCRH2itqd0tDxPSYmd7uf1O9zMK95+sh2y4v X-Received: by 2002:a17:906:7798:: with SMTP id s24mr16279716ejm.211.1569778790560; Sun, 29 Sep 2019 10:39:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569778790; cv=none; d=google.com; s=arc-20160816; b=KI3ZhifX1d6IkEl8Ctjh2XCeTlhNrC/eb4ZuRLzoVHdr11+wb6g4FOFpcJIn3OYyt9 DaFIMHswHnULW305YstldBX1R4nJuGf5HQAimU1GbPmebEAqrEOfKLCk7Rnc9zCu0hdw FirOz+NAI1+k0ezYlFANki2zslj65D+A35sFQ47f1gWaOc0KzoH9iNzZt+2wyC0uJ0eK hNMEX3JWDTuUlNH3CTSt8MrWIF1eWt3HdkePpB7kOqFIjqS02Ya2MpIIaJxuueaAQHcW MHF0YHA+Ya5PJuWB9wIJpHBcgUuo87ajJyHrKZ/cZ6IudRtk3zPnzMILA7hyDV9uk60n 4RLA== 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 y13si5612721ejw.2.2019.09.29.10.39.25; Sun, 29 Sep 2019 10:39:50 -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 + 99 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(+) 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) { -- 2.17.1