[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    [PATCH 2/5] crypt_make_salt: cleanup leftover comments
From:       Rasmus Villemoes <rasmus.villemoes () prevas ! dk>
Date:       2024-04-15 12:56:25
Message-ID: 20240415125628.780178-3-rasmus.villemoes () prevas ! dk
[Download RAW message or body]

Way back in commit 12a432715f06, crypt_make_salt() was changed to use
monotonic_us() instead of time(NULL) as a poor man's random source,
and, since that then at least made it much less likely that
consecutive calls would return the same result, at the same time lost
the "rnd" parameter. Remnants of that were left in comments, but 13
years later that really serves no purpose.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
---
 include/libbb.h    | 11 ++---------
 libbb/pw_encrypt.c |  3 +--
 2 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/include/libbb.h b/include/libbb.h
index ef5d04713..db61e62ab 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -1783,15 +1783,8 @@ int ask_and_check_password(const struct passwd *pw) FAST_FUNC;
 #endif
 extern char *pw_encrypt(const char *clear, const char *salt, int cleanup) FAST_FUNC;
 extern int obscure(const char *old, const char *newval, const struct passwd *pwdp) FAST_FUNC;
-/*
- * rnd is additional random input. New one is returned.
- * Useful if you call crypt_make_salt many times in a row:
- * rnd = crypt_make_salt(buf1, 4, 0);
- * rnd = crypt_make_salt(buf2, 4, rnd);
- * rnd = crypt_make_salt(buf3, 4, rnd);
- * (otherwise we risk having same salt generated)
- */
-extern int crypt_make_salt(char *p, int cnt /*, int rnd*/) FAST_FUNC;
+
+extern int crypt_make_salt(char *p, int cnt) FAST_FUNC;
 /* "$N$" + sha_salt_16_bytes + NUL */
 #define MAX_PW_SALT_LEN (3 + 16 + 1)
 extern char* crypt_make_pw_salt(char p[MAX_PW_SALT_LEN], const char *algo) FAST_FUNC;
diff --git a/libbb/pw_encrypt.c b/libbb/pw_encrypt.c
index adbdc1d1e..458792faa 100644
--- a/libbb/pw_encrypt.c
+++ b/libbb/pw_encrypt.c
@@ -34,9 +34,8 @@ static int i64c(int i)
 	return ('a' - 38 + i);
 }
 
-int FAST_FUNC crypt_make_salt(char *p, int cnt /*, int x */)
+int FAST_FUNC crypt_make_salt(char *p, int cnt)
 {
-	/* was: x += ... */
 	unsigned x = getpid() + monotonic_us();
 	do {
 		/* x = (x*1664525 + 1013904223) % 2^32 generator is lame
-- 
2.40.1.1.g1c60b9335d

_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic