[git commit] libbb/yescrypt: make some functions static

Denys Vlasenko vda.linux at googlemail.com
Sun Jul 6 00:39:07 UTC 2025


commit: https://git.busybox.net/busybox/commit/?id=e189464fa7dac7c6b6ae5ee80d55ab05dc67b6d7
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

function                                             old     new   delta
static.yescrypt_kdf_body                               -    1166   +1166
yescrypt_r                                           692    1342    +650
atoi64                                                 -      25     +25
decode64_uint32                                      201     166     -35
encode64                                             153       -    -153
decode64                                             174       -    -174
yescrypt_kdf                                         442       -    -442
yescrypt_kdf_body                                   1239       -   -1239
------------------------------------------------------------------------------
(add/remove: 2/4 grow/shrink: 1/1 up/down: 1841/-2043)       Total: -202 bytes

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 libbb/yescrypt/alg-yescrypt-common.c | 27 ++++++++++++++++++---------
 libbb/yescrypt/alg-yescrypt-kdf.c    |  1 +
 libbb/yescrypt/alg-yescrypt.h        |  9 +++------
 3 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/libbb/yescrypt/alg-yescrypt-common.c b/libbb/yescrypt/alg-yescrypt-common.c
index bf2934bc9..c04e074bd 100644
--- a/libbb/yescrypt/alg-yescrypt-common.c
+++ b/libbb/yescrypt/alg-yescrypt-common.c
@@ -18,7 +18,12 @@
  * SUCH DAMAGE.
  */
 
-static inline uint32_t atoi64(uint8_t src)
+/* Not inlining:
+ * decode64 fuinctions are only used to read
+ * yescrypt_params_t field, and convert salt ti binary -
+ * both of these are negligible compared to main hashing operation
+ */
+static NOINLINE uint32_t atoi64(uint8_t src)
 {
 	static const uint8_t atoi64_partial[77] = {
 		0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
@@ -34,8 +39,9 @@ static inline uint32_t atoi64(uint8_t src)
 	return 64;
 }
 
-static const uint8_t *decode64_uint32(uint32_t *dst,
-    const uint8_t *src, uint32_t min)
+static NOINLINE const uint8_t *decode64_uint32(
+		uint32_t *dst,
+		const uint8_t *src, uint32_t min)
 {
 	uint32_t start = 0, end = 47, chars = 1, bits = 0;
 	uint32_t c;
@@ -70,8 +76,9 @@ fail:
 	return NULL;
 }
 
-static uint8_t *encode64_uint32_fixed(uint8_t *dst, size_t dstlen,
-    uint32_t src, uint32_t srcbits)
+static uint8_t *encode64_uint32_fixed(
+		uint8_t *dst, size_t dstlen,
+		uint32_t src, uint32_t srcbits)
 {
 	uint32_t bits;
 
@@ -91,8 +98,9 @@ static uint8_t *encode64_uint32_fixed(uint8_t *dst, size_t dstlen,
 	return dst;
 }
 
-uint8_t *encode64(uint8_t *dst, size_t dstlen,
-    const uint8_t *src, size_t srclen)
+static uint8_t *encode64(
+		uint8_t *dst, size_t dstlen,
+		const uint8_t *src, size_t srclen)
 {
 	size_t i;
 
@@ -118,8 +126,9 @@ uint8_t *encode64(uint8_t *dst, size_t dstlen,
 	return dst;
 }
 
-const uint8_t *decode64(uint8_t *dst, size_t *dstlen,
-    const uint8_t *src, size_t srclen)
+static const uint8_t *decode64(
+		uint8_t *dst, size_t *dstlen,
+		const uint8_t *src, size_t srclen)
 {
 	size_t dstpos = 0;
 
diff --git a/libbb/yescrypt/alg-yescrypt-kdf.c b/libbb/yescrypt/alg-yescrypt-kdf.c
index 6c1108514..93938e69c 100644
--- a/libbb/yescrypt/alg-yescrypt-kdf.c
+++ b/libbb/yescrypt/alg-yescrypt-kdf.c
@@ -976,6 +976,7 @@ out_EINVAL:
  * to this function are the same as those for yescrypt_kdf_body() above, with
  * the addition of g, which controls hash upgrades (0 for no upgrades so far).
  */
+static
 int yescrypt_kdf(
 		yescrypt_local_t *local,
 		const uint8_t *passwd, size_t passwdlen,
diff --git a/libbb/yescrypt/alg-yescrypt.h b/libbb/yescrypt/alg-yescrypt.h
index bb30da8a8..7f2b7f471 100644
--- a/libbb/yescrypt/alg-yescrypt.h
+++ b/libbb/yescrypt/alg-yescrypt.h
@@ -184,12 +184,14 @@ extern int yescrypt_free_local(yescrypt_local_t *local);
  *
  * MT-safe as long as local and buf are local to the thread.
  */
-extern int yescrypt_kdf(
+#ifdef YESCRYPT_INTERNAL
+static int yescrypt_kdf(
     yescrypt_local_t *local,
     const uint8_t *passwd, size_t passwdlen,
     const uint8_t *salt, size_t saltlen,
     const yescrypt_params_t *params,
     uint8_t *buf, size_t buflen);
+#endif
 
 /**
  * yescrypt_r(shared, local, passwd, passwdlen, setting, key, buf, buflen):
@@ -211,8 +213,3 @@ extern uint8_t *yescrypt_r(
     const uint8_t *passwd, size_t passwdlen,
     const uint8_t *setting,
     uint8_t *buf, size_t buflen);
-
-extern const uint8_t *decode64(uint8_t *dst, size_t *dstlen,
-    const uint8_t *src, size_t srclen);
-extern uint8_t *encode64(uint8_t *dst, size_t dstlen,
-    const uint8_t *src, size_t srclen);


More information about the busybox-cvs mailing list