From 596c443112d09506c3bf13ac98046a84b912e56c Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Mon, 9 Jun 2025 13:23:49 +0100 Subject: Use Windows library for cryptographic checksums Add a new feature to libbb, FEATURE_USE_CNG_API, which enables the use of the Cryptography API: Next Generation library to calculate checksums. It is disabled by default except in the mingw64u default config, as the API requires Windows 10+ to function. Usage of this API provides a size benefit and delegates hardware optimizations to the operating system cryptography library. Based on GitHub PR #498 by rfl890. Saves 4064 bytes in the mingw64u case. --- libbb/Config.src | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'libbb/Config.src') diff --git a/libbb/Config.src b/libbb/Config.src index 61b4601d6..ed6521c33 100644 --- a/libbb/Config.src +++ b/libbb/Config.src @@ -37,6 +37,14 @@ config PASSWORD_MINLEN help Minimum allowable password length. +config FEATURE_USE_CNG_API + bool "Use the Windows CNG API for checksums (Windows 10+ only)" + default n + depends on PLATFORM_MINGW32 + help + Use the in-built Windows CNG API for checksums. + This reduces code size, but is only supported on Windows 10+. + config MD5_SMALL int "MD5: Trade bytes for speed (0:fast, 3:slow)" default 1 # all "fast or small" options default to small @@ -67,6 +75,7 @@ config SHA1_SMALL config SHA1_HWACCEL bool "SHA1: Use hardware accelerated instructions if possible" default y + depends on !FEATURE_USE_CNG_API help On x86, this adds ~590 bytes of code. Throughput is about twice as fast as fully-unrolled generic code. @@ -74,6 +83,7 @@ config SHA1_HWACCEL config SHA256_HWACCEL bool "SHA256: Use hardware accelerated instructions if possible" default y + depends on !FEATURE_USE_CNG_API help On x86, this adds ~1k bytes of code. -- cgit v1.2.3-55-g6feb