aboutsummaryrefslogtreecommitdiff
path: root/loginutils/passwd.c
diff options
context:
space:
mode:
authorvda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2007-05-08 17:52:17 +0000
committervda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2007-05-08 17:52:17 +0000
commit722cfbe0032c15b1bc9cf13a94197564b0860b09 (patch)
treec03518f2059504a513119cf4d499ccf5c7233f83 /loginutils/passwd.c
parent92ce299856803ce2a2e59c4bfd2cc9edce90d3f7 (diff)
downloadbusybox-w32-722cfbe0032c15b1bc9cf13a94197564b0860b09.tar.gz
busybox-w32-722cfbe0032c15b1bc9cf13a94197564b0860b09.tar.bz2
busybox-w32-722cfbe0032c15b1bc9cf13a94197564b0860b09.zip
cryptpw: new applet (a bit less than 3k added)
(by Thomas Lundquist <lists@zelow.no>) git-svn-id: svn://busybox.net/trunk/busybox@18586 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to '')
-rw-r--r--loginutils/passwd.c50
1 files changed, 0 insertions, 50 deletions
diff --git a/loginutils/passwd.c b/loginutils/passwd.c
index b937ce45e..a323c0a40 100644
--- a/loginutils/passwd.c
+++ b/loginutils/passwd.c
@@ -12,44 +12,6 @@ static void nuke_str(char *str)
12 if (str) memset(str, 0, strlen(str)); 12 if (str) memset(str, 0, strlen(str));
13} 13}
14 14
15
16static int i64c(int i)
17{
18 i &= 0x3f;
19 if (i == 0)
20 return '.';
21 if (i == 1)
22 return '/';
23 if (i < 12)
24 return ('0' - 2 + i);
25 if (i < 38)
26 return ('A' - 12 + i);
27 return ('a' - 38 + i);
28}
29
30
31static void crypt_make_salt(char *p, int cnt)
32{
33 unsigned x = x; /* it's pointless to initialize it anyway :) */
34
35 x += getpid() + time(NULL) + clock();
36 do {
37 /* x = (x*1664525 + 1013904223) % 2^32 generator is lame
38 * (low-order bit is not "random", etc...),
39 * but for our purposes it is good enough */
40 x = x*1664525 + 1013904223;
41 /* BTW, Park and Miller's "minimal standard generator" is
42 * x = x*16807 % ((2^31)-1)
43 * It has no problem with visibly alternating lowest bit
44 * but is also weak in cryptographic sense + needs div,
45 * which needs more code (and slower) on many CPUs */
46 *p++ = i64c(x >> 16);
47 *p++ = i64c(x >> 22);
48 } while (--cnt);
49 *p = '\0';
50}
51
52
53static char* new_password(const struct passwd *pw, uid_t myuid, int algo) 15static char* new_password(const struct passwd *pw, uid_t myuid, int algo)
54{ 16{
55 char salt[sizeof("$N$XXXXXXXX")]; /* "$N$XXXXXXXX" or "XX" */ 17 char salt[sizeof("$N$XXXXXXXX")]; /* "$N$XXXXXXXX" or "XX" */
@@ -109,18 +71,6 @@ static char* new_password(const struct passwd *pw, uid_t myuid, int algo)
109} 71}
110 72
111 73
112#if 0
113static int get_algo(char *a)
114{
115 /* standard: MD5 */
116 int x = 1;
117 if (strcasecmp(a, "des") == 0)
118 x = 0;
119 return x;
120}
121#endif
122
123
124static int update_passwd(const char *filename, const char *username, 74static int update_passwd(const char *filename, const char *username,
125 const char *new_pw) 75 const char *new_pw)
126{ 76{