diff options
Diffstat (limited to 'libbb/crypt_make_salt.c')
-rw-r--r-- | libbb/crypt_make_salt.c | 46 |
1 files changed, 0 insertions, 46 deletions
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 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | ||
3 | * crypt_make_salt | ||
4 | * | ||
5 | * i64c was also put here, this is the only function that uses it. | ||
6 | * | ||
7 | * Lifted from loginutils/passwd.c by Thomas Lundquist <thomasez@zelow.no> | ||
8 | * | ||
9 | * Licensed under GPLv2, see file LICENSE in this tarball for details. | ||
10 | */ | ||
11 | |||
12 | #include "libbb.h" | ||
13 | |||
14 | static int i64c(int i) | ||
15 | { | ||
16 | i &= 0x3f; | ||
17 | if (i == 0) | ||
18 | return '.'; | ||
19 | if (i == 1) | ||
20 | return '/'; | ||
21 | if (i < 12) | ||
22 | return ('0' - 2 + i); | ||
23 | if (i < 38) | ||
24 | return ('A' - 12 + i); | ||
25 | return ('a' - 38 + i); | ||
26 | } | ||
27 | |||
28 | int FAST_FUNC crypt_make_salt(char *p, int cnt, int x) | ||
29 | { | ||
30 | x += getpid() + time(NULL); | ||
31 | do { | ||
32 | /* x = (x*1664525 + 1013904223) % 2^32 generator is lame | ||
33 | * (low-order bit is not "random", etc...), | ||
34 | * but for our purposes it is good enough */ | ||
35 | x = x*1664525 + 1013904223; | ||
36 | /* BTW, Park and Miller's "minimal standard generator" is | ||
37 | * x = x*16807 % ((2^31)-1) | ||
38 | * It has no problem with visibly alternating lowest bit | ||
39 | * but is also weak in cryptographic sense + needs div, | ||
40 | * which needs more code (and slower) on many CPUs */ | ||
41 | *p++ = i64c(x >> 16); | ||
42 | *p++ = i64c(x >> 22); | ||
43 | } while (--cnt); | ||
44 | *p = '\0'; | ||
45 | return x; | ||
46 | } | ||