From patchwork Sun Jul 9 15:42:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Heiko_St=C3=BCbner?= X-Patchwork-Id: 11774 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp4511199vqx; Sun, 9 Jul 2023 08:53:36 -0700 (PDT) X-Google-Smtp-Source: APBJJlH1reXaW7r5oNJPrxh0Ubx4fVBYvb/V4jwTlycTXM3asQ+QtA2lh2+QnrcvFiadrWZa5RUo X-Received: by 2002:a17:90a:f182:b0:263:312:611f with SMTP id bv2-20020a17090af18200b002630312611fmr10557714pjb.3.1688918015887; Sun, 09 Jul 2023 08:53:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688918015; cv=none; d=google.com; s=arc-20160816; b=bdz2dsnW/8kpTtABFQjJ6eDiOD/FTs3AaWZ0/n9DTPYDRW4ZLpZd0G/MyfpeoZYWuN tHzUkiioSKJSFRX2a1ZtuRDynDuQxLAyMipQqZpXmpPXW3qPVWNjqz5pcx5qI6tuwm4a LAizKbusbnieuZa00P3iRkeQQ/PvtgbJA8wRbgyMMlXIi+IOeg+7iZA/Hi+YQm4BIFHt nt67GL8JuvsXxgp65FgXnq9DxLaNGOR+o2muqZQjLco1FxagmCPK9Ek2O3JCX85qpCqh YICRo0RKgesYp+O9LnCxXAV/qwnK3k6qwHl8RSweZ2UeMYxw1/IuGoYRx/wWOEiH3hzK +OtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=lCnm5HaEGa5IUYAN5P/doak2SUYkVrKq7iy5M8O8OLU=; fh=kdZoYQ7OxiOlgk8JV6AaRDhZ3ti3Lsh9kEAaaefSh4Y=; b=DNbyY7QWrE9Ch4Kyp67lcG9oU+4F8x+kqPSWMsu8Yh6BxUPNszxvtLifK1XDOTGS15 lMnZYXtwRnrdqFBu59MMMmD9I72xUjTrwHOG1UqsDbrL7bwL50oHQM7QYGvPVAWzKx3z A7h6qABvSqINgbYQtCmW/rdcLdMO8rPMRZ6VB1djL4ixRJTavTeR9Ac112MjO9yZmmW1 edhMuwnZDRZXOX1CFs9QoTvzI6HoC+836uXyRt8g7T5jpoSEFC1jMW0xCmjvEwf+zhjt tKdDNQQe/KT0cDOoxSCIa4pi9x8T2CWz9z2yCVAnsBWGxcivHeYfqEQotjizHUKi7CFJ nxmQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=sntech.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id md10-20020a17090b23ca00b00260a7aee610si2036650pjb.152.2023.07.09.08.53.23; Sun, 09 Jul 2023 08:53:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=sntech.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233007AbjGIPnI (ORCPT + 99 others); Sun, 9 Jul 2023 11:43:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229579AbjGIPnC (ORCPT ); Sun, 9 Jul 2023 11:43:02 -0400 Received: from gloria.sntech.de (gloria.sntech.de [185.11.138.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C720D9; Sun, 9 Jul 2023 08:42:55 -0700 (PDT) Received: from i53875a50.versanet.de ([83.135.90.80] helo=phil.fritz.box) by gloria.sntech.de with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qIWYf-0002yG-Td; Sun, 09 Jul 2023 17:42:45 +0200 From: Heiko Stuebner To: palmer@dabbelt.com, paul.walmsley@sifive.com Cc: aou@eecs.berkeley.edu, heiko@sntech.de, herbert@gondor.apana.org.au, davem@davemloft.net, conor.dooley@microchip.com, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, christoph.muellner@vrull.eu, ebiggers@kernel.org, Heiko Stuebner Subject: [PATCH v6 0/3] Implement GCM ghash using Zbc and Zbkb extensions Date: Sun, 9 Jul 2023 17:42:40 +0200 Message-Id: <20230709154243.1582671-1-heiko@sntech.de> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_PASS,T_SCC_BODY_TEXT_LINE, T_SPF_HELO_TEMPERROR autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1770958897331356582 X-GMAIL-MSGID: 1770958897331356582 From: Heiko Stuebner This was originally part of my vector crypto series, but was part of a separate openssl merge request implementing GCM ghash as using non-vector extensions. As that pull-request https://github.com/openssl/openssl/pull/20078 got merged recently into openssl, we could also check if this could go into the kernel as well and provide a base for further accelerated cryptographic support. changes in v6: - rebase on top of riscv/for-next - rebase on top of Samuel Ortiz Arch-random series https://lore.kernel.org/r/20230709115549.2666557-1-sameo@rivosinc.com as it has the nicer Zbc + Zbkb integration for extensions and hwprobe - update perl code with better licensing text (Eric) This was also merged into the original openSSL sources - add SPDX license identifier (Eric) - drop unneeded fallback element in the private struct (Herbert) Changes in v5: - rebased on top of 6.4-based riscv/next - code from openssl is now dual-licensed under Apache + BSD see https://github.com/openssl/openssl/pull/20649 - separate init functions instead of creating them with macros (Nathan) Changes in v4: - rebase on top of riscv/for-next - split out the scalar crypto implementation from the vector series - refresh code from openSSL to match exactly - Remove RFC label, as Zbc and Zbkb are ratified and the cryptographic code was merged into openSSL changes in v3: - rebase on top of 6.3-rc2 - rebase on top of vector-v14 patchset - add the missing Co-developed-by mentions to showcase the people that did the actual openSSL crypto code changes in v2: - rebased on 6.2 + zbb series, so don't include already applied changes anymore - refresh code picked from openssl as that side matures - more algorithms (SHA512, AES, SM3, SM4) Heiko Stuebner (3): RISC-V: expose Zbc as Kconfig option RISC-V: hook new crypto subdir into build-system RISC-V: crypto: add accelerated GCM GHASH implementation arch/riscv/Kbuild | 1 + arch/riscv/Kconfig | 23 ++ arch/riscv/crypto/Kconfig | 18 ++ arch/riscv/crypto/Makefile | 18 ++ arch/riscv/crypto/ghash-riscv64-glue.c | 291 +++++++++++++++++ arch/riscv/crypto/ghash-riscv64-zbc.pl | 430 +++++++++++++++++++++++++ arch/riscv/crypto/riscv.pm | 261 +++++++++++++++ crypto/Kconfig | 3 + 8 files changed, 1045 insertions(+) create mode 100644 arch/riscv/crypto/Kconfig create mode 100644 arch/riscv/crypto/Makefile create mode 100644 arch/riscv/crypto/ghash-riscv64-glue.c create mode 100644 arch/riscv/crypto/ghash-riscv64-zbc.pl create mode 100644 arch/riscv/crypto/riscv.pm