From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 01745C77B7C for ; Wed, 25 Jun 2025 07:15:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=THHkjXjEOqvapB514CaFbXrbuImezgeDGuGgUZi1xU0=; b=MLpFqtzYQZ+wZmoo0bNpslXREY hHc6F5yu4CQ43ZLMh3THdYtLqizl94XLhTd8uimk2X3yT1fl23ppBQLQU9mwKf+HBuQvyC25ggl9+ hEBEIqPXbQDMu6XG+ykyMqj7gvzyvqAGHG7J7LGpur25+ikjTGkIe0TWHMQsfseuFxyPo2z9GQ1+h n2j7cNgwekFRro1Ea2sE2qzijkbKzp4f44tTQvj2mP51Lk6vRccgtYAVMcX90uyoPJx8IvBlvk51T i/sAUC9u4ZJBwacFZws14M2Weg+fapcDm4jezW9nXAOSVcLBbadLmP0U22WuDX1BjTNzKVxSOzEOW UU/JMRjA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uUKLi-00000007maD-2oaC; Wed, 25 Jun 2025 07:15:14 +0000 Received: from nyc.source.kernel.org ([2604:1380:45d1:ec00::3]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1uUKH6-00000007lJ5-1JYF; Wed, 25 Jun 2025 07:10:29 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 6DB4AA511D6; Wed, 25 Jun 2025 07:10:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BCD40C4CEEA; Wed, 25 Jun 2025 07:10:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750835427; bh=dNjTP1K/kwMastCEsJrXq3spz7hep3Wcru9OBJvpwJA=; h=From:To:Cc:Subject:Date:From; b=f8mx/QGaAe/zXMItJZ0F55QwX91jS97FGsefAFIby9DnkyFtMYmePw0hWX0k2Vjz0 BNtUus02OG1FPiTEiuTLnKq4XdAPibOkbVuuWIwqr6Teh6x7q+npmu7RYtGSs3TgKh yHlR3Z3sFMiJF1JmEr21Vz4XeDobauDmgAKuguO0wLRUkdQZo1+uNogSSTox5pjMRA Q9S3L7aW2Ha3BEGdVnUoHxi0bZrXRDXM98wQvtA8KqOd6w32WkvBpZ7zvQj5cG+WOI oDpEQEOqm7HuwDrOxoiqqiywB1kYtRddglKdLZktyv2YJSKY5cUtjgQmHokaeRDEJb SXMChrbYairMQ== From: Eric Biggers To: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Ard Biesheuvel , "Jason A . Donenfeld" , linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org, x86@kernel.org Subject: [PATCH 00/18] SHA-256 library improvements Date: Wed, 25 Jun 2025 00:08:01 -0700 Message-ID: <20250625070819.1496119-1-ebiggers@kernel.org> X-Mailer: git-send-email 2.50.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250625_001028_479813_D646C044 X-CRM114-Status: GOOD ( 15.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This series is targeting libcrypto-next and can also be retrieved from: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git sha256-lib-cleanup-v1 This series improves the SHA-224 and SHA-256 library code to be consistent with what I did for SHA-384 and SHA-512. This includes: - Use stronger typing in the SHA-224 and SHA-256 functions. - Add support for HMAC-SHA224 and HMAC-SHA256. (I'll send a separate patch with KUnit test cases for this.) - Make the old-school crypto API's support for sha224 and sha256 just use the actual library API, instead of unsafe low-level functions. - Consolidate the CPU-based SHA-224 and SHA-256 code into a single module, with better inlining and dead code elimination. - Properly document the SHA-224 and SHA-256 functions. - Other changes to synchronize the code with SHA-384 and SHA-512. Patches 3-6 are a few fixes/cleanups for the SHA-384 and SHA-512 code that I noticed while doing this. Eric Biggers (18): libceph: Rename hmac_sha256() to ceph_hmac_sha256() cxl/test: Simplify fw_buf_checksum_show() crypto: sha512 - Use the correct legacy export format lib/crypto: sha512: Reorder some code in sha512.c lib/crypto: sha512: Do not include lib/crypto: sha512: Fix a grammatical error in kerneldoc comments lib/crypto: sha256: Reorder some code lib/crypto: sha256: Remove sha256_blocks_simd() lib/crypto: sha256: Add sha224() and sha224_update() lib/crypto: sha256: Make library API use strongly-typed contexts lib/crypto: sha256: Propagate sha256_block_state type to implementations lib/crypto: sha256: Add HMAC-SHA224 and HMAC-SHA256 support crypto: sha256 - Wrap library and add HMAC support crypto: sha256 - Use same state format as legacy drivers lib/crypto: sha512: Remove sha256_is_arch_optimized() lib/crypto: sha256: Consolidate into single module lib/crypto: sha256: Sync sha256_update() with sha512_update() lib/crypto: sha256: Document the SHA-224 and SHA-256 API arch/mips/cavium-octeon/Kconfig | 6 - arch/mips/cavium-octeon/crypto/Makefile | 1 - arch/riscv/purgatory/purgatory.c | 8 +- arch/s390/purgatory/purgatory.c | 2 +- arch/x86/purgatory/purgatory.c | 2 +- crypto/Kconfig | 4 +- crypto/sha256.c | 371 +++++++++------- crypto/sha512.c | 22 +- crypto/testmgr.c | 12 + drivers/char/tpm/tpm2-sessions.c | 12 +- drivers/crypto/img-hash.c | 4 +- drivers/crypto/starfive/jh7110-hash.c | 8 +- include/crypto/internal/sha2.h | 66 --- include/crypto/sha2.h | 402 +++++++++++++++-- kernel/kexec_file.c | 10 +- lib/crypto/Kconfig | 34 +- lib/crypto/Makefile | 39 +- lib/crypto/arm/Kconfig | 7 - lib/crypto/arm/Makefile | 8 +- lib/crypto/arm/sha256-armv4.pl | 20 +- lib/crypto/arm/sha256-ce.S | 2 +- lib/crypto/arm/sha256.c | 64 --- lib/crypto/arm/sha256.h | 46 ++ lib/crypto/arm64/Kconfig | 6 - lib/crypto/arm64/Makefile | 9 +- lib/crypto/arm64/sha2-armv8.pl | 2 +- lib/crypto/arm64/sha256-ce.S | 2 +- lib/crypto/arm64/sha256.c | 75 ---- lib/crypto/arm64/sha256.h | 58 +++ lib/crypto/arm64/sha512.h | 6 +- .../crypto/mips/sha256.h | 20 +- lib/crypto/powerpc/Kconfig | 6 - lib/crypto/powerpc/Makefile | 3 - lib/crypto/powerpc/{sha256.c => sha256.h} | 19 +- lib/crypto/riscv/Kconfig | 8 - lib/crypto/riscv/Makefile | 3 - .../sha256-riscv64-zvknha_or_zvknhb-zvkb.S | 2 +- lib/crypto/riscv/sha256.c | 67 --- lib/crypto/riscv/sha256.h | 42 ++ lib/crypto/s390/Kconfig | 6 - lib/crypto/s390/Makefile | 3 - lib/crypto/s390/sha256.c | 47 -- lib/crypto/s390/sha256.h | 28 ++ lib/crypto/sha256-generic.c | 138 ------ lib/crypto/sha256.c | 411 ++++++++++++++++-- lib/crypto/sha512.c | 75 ++-- lib/crypto/sparc/Kconfig | 8 - lib/crypto/sparc/Makefile | 4 - lib/crypto/sparc/{sha256.c => sha256.h} | 37 +- lib/crypto/tests/sha224_kunit.c | 15 +- lib/crypto/tests/sha256_kunit.c | 2 +- lib/crypto/x86/Kconfig | 8 - lib/crypto/x86/Makefile | 3 - lib/crypto/x86/sha256-avx-asm.S | 2 +- lib/crypto/x86/sha256-avx2-asm.S | 2 +- lib/crypto/x86/sha256-ni-asm.S | 2 +- lib/crypto/x86/sha256-ssse3-asm.S | 2 +- lib/crypto/x86/sha256.c | 80 ---- lib/crypto/x86/sha256.h | 55 +++ net/ceph/messenger_v2.c | 12 +- tools/testing/cxl/test/mem.c | 21 +- 61 files changed, 1369 insertions(+), 1070 deletions(-) delete mode 100644 include/crypto/internal/sha2.h delete mode 100644 lib/crypto/arm/sha256.c create mode 100644 lib/crypto/arm/sha256.h delete mode 100644 lib/crypto/arm64/sha256.c create mode 100644 lib/crypto/arm64/sha256.h rename arch/mips/cavium-octeon/crypto/octeon-sha256.c => lib/crypto/mips/sha256.h (76%) rename lib/crypto/powerpc/{sha256.c => sha256.h} (76%) delete mode 100644 lib/crypto/riscv/sha256.c create mode 100644 lib/crypto/riscv/sha256.h delete mode 100644 lib/crypto/s390/sha256.c create mode 100644 lib/crypto/s390/sha256.h delete mode 100644 lib/crypto/sha256-generic.c delete mode 100644 lib/crypto/sparc/Kconfig delete mode 100644 lib/crypto/sparc/Makefile rename lib/crypto/sparc/{sha256.c => sha256.h} (53%) delete mode 100644 lib/crypto/x86/sha256.c create mode 100644 lib/crypto/x86/sha256.h base-commit: d74152ec2b5106263c2a502380acfaf5954f9898 -- 2.50.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 70CC9C7EE30 for ; Wed, 25 Jun 2025 07:15:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=KdJ2P3yTdDTFMu0TvyiyBNcEDobQkqcZfg1uBu0TpYg=; b=g+LkpYKNk9LYoY TWoqcJjKhZJCUeC3lk1E/6jJv5GJRJdRXYsFAtR5ATPSPfvBIXKcdGSr+F8j+ZmJsgYPCMcwf8Hrc k+qXkxPumzD5/FO90FWvb7HVEOX4SN3XcRNODzqbZjtYntTIF5pohglZt4jDZoP1untCA4IBAejqt jiZVrfGjzTEfDQ6/eVXTeKVjObuuCi43xsWiKJxn7lRTEusgjlimw6faMMB+RIr7YSPFEY9OJFkBn 27HZnYs0JrrhRvycqSR7tJApIlQkPGTCNNnf8Ian8Q8dwTbXoVNKaN5WtDmEq8iGua4xX/SnnkKfi 4uNW00L3lkkBS8nWCkiw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uUKLj-00000007maY-3HQF; Wed, 25 Jun 2025 07:15:15 +0000 Received: from nyc.source.kernel.org ([2604:1380:45d1:ec00::3]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1uUKH6-00000007lJ5-1JYF; Wed, 25 Jun 2025 07:10:29 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 6DB4AA511D6; Wed, 25 Jun 2025 07:10:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BCD40C4CEEA; Wed, 25 Jun 2025 07:10:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750835427; bh=dNjTP1K/kwMastCEsJrXq3spz7hep3Wcru9OBJvpwJA=; h=From:To:Cc:Subject:Date:From; b=f8mx/QGaAe/zXMItJZ0F55QwX91jS97FGsefAFIby9DnkyFtMYmePw0hWX0k2Vjz0 BNtUus02OG1FPiTEiuTLnKq4XdAPibOkbVuuWIwqr6Teh6x7q+npmu7RYtGSs3TgKh yHlR3Z3sFMiJF1JmEr21Vz4XeDobauDmgAKuguO0wLRUkdQZo1+uNogSSTox5pjMRA Q9S3L7aW2Ha3BEGdVnUoHxi0bZrXRDXM98wQvtA8KqOd6w32WkvBpZ7zvQj5cG+WOI oDpEQEOqm7HuwDrOxoiqqiywB1kYtRddglKdLZktyv2YJSKY5cUtjgQmHokaeRDEJb SXMChrbYairMQ== From: Eric Biggers To: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Ard Biesheuvel , "Jason A . Donenfeld" , linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org, x86@kernel.org Subject: [PATCH 00/18] SHA-256 library improvements Date: Wed, 25 Jun 2025 00:08:01 -0700 Message-ID: <20250625070819.1496119-1-ebiggers@kernel.org> X-Mailer: git-send-email 2.50.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250625_001028_479813_D646C044 X-CRM114-Status: GOOD ( 15.40 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org This series is targeting libcrypto-next and can also be retrieved from: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git sha256-lib-cleanup-v1 This series improves the SHA-224 and SHA-256 library code to be consistent with what I did for SHA-384 and SHA-512. This includes: - Use stronger typing in the SHA-224 and SHA-256 functions. - Add support for HMAC-SHA224 and HMAC-SHA256. (I'll send a separate patch with KUnit test cases for this.) - Make the old-school crypto API's support for sha224 and sha256 just use the actual library API, instead of unsafe low-level functions. - Consolidate the CPU-based SHA-224 and SHA-256 code into a single module, with better inlining and dead code elimination. - Properly document the SHA-224 and SHA-256 functions. - Other changes to synchronize the code with SHA-384 and SHA-512. Patches 3-6 are a few fixes/cleanups for the SHA-384 and SHA-512 code that I noticed while doing this. Eric Biggers (18): libceph: Rename hmac_sha256() to ceph_hmac_sha256() cxl/test: Simplify fw_buf_checksum_show() crypto: sha512 - Use the correct legacy export format lib/crypto: sha512: Reorder some code in sha512.c lib/crypto: sha512: Do not include lib/crypto: sha512: Fix a grammatical error in kerneldoc comments lib/crypto: sha256: Reorder some code lib/crypto: sha256: Remove sha256_blocks_simd() lib/crypto: sha256: Add sha224() and sha224_update() lib/crypto: sha256: Make library API use strongly-typed contexts lib/crypto: sha256: Propagate sha256_block_state type to implementations lib/crypto: sha256: Add HMAC-SHA224 and HMAC-SHA256 support crypto: sha256 - Wrap library and add HMAC support crypto: sha256 - Use same state format as legacy drivers lib/crypto: sha512: Remove sha256_is_arch_optimized() lib/crypto: sha256: Consolidate into single module lib/crypto: sha256: Sync sha256_update() with sha512_update() lib/crypto: sha256: Document the SHA-224 and SHA-256 API arch/mips/cavium-octeon/Kconfig | 6 - arch/mips/cavium-octeon/crypto/Makefile | 1 - arch/riscv/purgatory/purgatory.c | 8 +- arch/s390/purgatory/purgatory.c | 2 +- arch/x86/purgatory/purgatory.c | 2 +- crypto/Kconfig | 4 +- crypto/sha256.c | 371 +++++++++------- crypto/sha512.c | 22 +- crypto/testmgr.c | 12 + drivers/char/tpm/tpm2-sessions.c | 12 +- drivers/crypto/img-hash.c | 4 +- drivers/crypto/starfive/jh7110-hash.c | 8 +- include/crypto/internal/sha2.h | 66 --- include/crypto/sha2.h | 402 +++++++++++++++-- kernel/kexec_file.c | 10 +- lib/crypto/Kconfig | 34 +- lib/crypto/Makefile | 39 +- lib/crypto/arm/Kconfig | 7 - lib/crypto/arm/Makefile | 8 +- lib/crypto/arm/sha256-armv4.pl | 20 +- lib/crypto/arm/sha256-ce.S | 2 +- lib/crypto/arm/sha256.c | 64 --- lib/crypto/arm/sha256.h | 46 ++ lib/crypto/arm64/Kconfig | 6 - lib/crypto/arm64/Makefile | 9 +- lib/crypto/arm64/sha2-armv8.pl | 2 +- lib/crypto/arm64/sha256-ce.S | 2 +- lib/crypto/arm64/sha256.c | 75 ---- lib/crypto/arm64/sha256.h | 58 +++ lib/crypto/arm64/sha512.h | 6 +- .../crypto/mips/sha256.h | 20 +- lib/crypto/powerpc/Kconfig | 6 - lib/crypto/powerpc/Makefile | 3 - lib/crypto/powerpc/{sha256.c => sha256.h} | 19 +- lib/crypto/riscv/Kconfig | 8 - lib/crypto/riscv/Makefile | 3 - .../sha256-riscv64-zvknha_or_zvknhb-zvkb.S | 2 +- lib/crypto/riscv/sha256.c | 67 --- lib/crypto/riscv/sha256.h | 42 ++ lib/crypto/s390/Kconfig | 6 - lib/crypto/s390/Makefile | 3 - lib/crypto/s390/sha256.c | 47 -- lib/crypto/s390/sha256.h | 28 ++ lib/crypto/sha256-generic.c | 138 ------ lib/crypto/sha256.c | 411 ++++++++++++++++-- lib/crypto/sha512.c | 75 ++-- lib/crypto/sparc/Kconfig | 8 - lib/crypto/sparc/Makefile | 4 - lib/crypto/sparc/{sha256.c => sha256.h} | 37 +- lib/crypto/tests/sha224_kunit.c | 15 +- lib/crypto/tests/sha256_kunit.c | 2 +- lib/crypto/x86/Kconfig | 8 - lib/crypto/x86/Makefile | 3 - lib/crypto/x86/sha256-avx-asm.S | 2 +- lib/crypto/x86/sha256-avx2-asm.S | 2 +- lib/crypto/x86/sha256-ni-asm.S | 2 +- lib/crypto/x86/sha256-ssse3-asm.S | 2 +- lib/crypto/x86/sha256.c | 80 ---- lib/crypto/x86/sha256.h | 55 +++ net/ceph/messenger_v2.c | 12 +- tools/testing/cxl/test/mem.c | 21 +- 61 files changed, 1369 insertions(+), 1070 deletions(-) delete mode 100644 include/crypto/internal/sha2.h delete mode 100644 lib/crypto/arm/sha256.c create mode 100644 lib/crypto/arm/sha256.h delete mode 100644 lib/crypto/arm64/sha256.c create mode 100644 lib/crypto/arm64/sha256.h rename arch/mips/cavium-octeon/crypto/octeon-sha256.c => lib/crypto/mips/sha256.h (76%) rename lib/crypto/powerpc/{sha256.c => sha256.h} (76%) delete mode 100644 lib/crypto/riscv/sha256.c create mode 100644 lib/crypto/riscv/sha256.h delete mode 100644 lib/crypto/s390/sha256.c create mode 100644 lib/crypto/s390/sha256.h delete mode 100644 lib/crypto/sha256-generic.c delete mode 100644 lib/crypto/sparc/Kconfig delete mode 100644 lib/crypto/sparc/Makefile rename lib/crypto/sparc/{sha256.c => sha256.h} (53%) delete mode 100644 lib/crypto/x86/sha256.c create mode 100644 lib/crypto/x86/sha256.h base-commit: d74152ec2b5106263c2a502380acfaf5954f9898 -- 2.50.0 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv