From d1a84a2880073f6cc5e2f9f4e5f236cd110f01a0 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Sun, 7 Dec 2008 01:16:34 +0000 Subject: libbb: move crypt_make_salt() to pw_encrypt.c, reuse bin-to-ascii64 conversion which does not require an array. function old new delta to64 29 33 +4 to64_msb_first 63 62 -1 ascii64 65 - -65 --- libbb/crypt_make_salt.c | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) delete mode 100644 libbb/crypt_make_salt.c (limited to 'libbb/crypt_make_salt.c') diff --git a/libbb/crypt_make_salt.c b/libbb/crypt_make_salt.c deleted file mode 100644 index 14bb0ddc9..000000000 --- a/libbb/crypt_make_salt.c +++ /dev/null @@ -1,46 +0,0 @@ -/* vi: set sw=4 ts=4: */ -/* - * crypt_make_salt - * - * i64c was also put here, this is the only function that uses it. - * - * Lifted from loginutils/passwd.c by Thomas Lundquist - * - * Licensed under GPLv2, see file LICENSE in this tarball for details. - */ - -#include "libbb.h" - -static int i64c(int i) -{ - i &= 0x3f; - if (i == 0) - return '.'; - if (i == 1) - return '/'; - if (i < 12) - return ('0' - 2 + i); - if (i < 38) - return ('A' - 12 + i); - return ('a' - 38 + i); -} - -int FAST_FUNC crypt_make_salt(char *p, int cnt, int x) -{ - x += getpid() + time(NULL); - do { - /* x = (x*1664525 + 1013904223) % 2^32 generator is lame - * (low-order bit is not "random", etc...), - * but for our purposes it is good enough */ - x = x*1664525 + 1013904223; - /* BTW, Park and Miller's "minimal standard generator" is - * x = x*16807 % ((2^31)-1) - * It has no problem with visibly alternating lowest bit - * but is also weak in cryptographic sense + needs div, - * which needs more code (and slower) on many CPUs */ - *p++ = i64c(x >> 16); - *p++ = i64c(x >> 22); - } while (--cnt); - *p = '\0'; - return x; -} -- cgit v1.2.3