diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-05-08 17:52:17 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-05-08 17:52:17 +0000 |
commit | 7e84e539de530b2060f0e570fc8f063ed0aaad2f (patch) | |
tree | c03518f2059504a513119cf4d499ccf5c7233f83 /loginutils | |
parent | 92c0b8222eb50dd35c06e2f1265706b388762234 (diff) | |
download | busybox-7e84e539de530b2060f0e570fc8f063ed0aaad2f.tar.gz |
cryptpw: new applet (a bit less than 3k added)
(by Thomas Lundquist <lists@zelow.no>)
Diffstat (limited to 'loginutils')
-rw-r--r-- | loginutils/Config.in | 6 | ||||
-rw-r--r-- | loginutils/Kbuild | 1 | ||||
-rw-r--r-- | loginutils/passwd.c | 50 |
3 files changed, 7 insertions, 50 deletions
diff --git a/loginutils/Config.in b/loginutils/Config.in index e8ab9ec3c..919091ec6 100644 --- a/loginutils/Config.in +++ b/loginutils/Config.in @@ -166,6 +166,12 @@ config FEATURE_PASSWD_WEAK_CHECK help With this option passwd will refuse new passwords which are "weak". +config CRYPTPW + bool "cryptpw" + default n + help + Applet for crypting a string. + config SU bool "su" default n diff --git a/loginutils/Kbuild b/loginutils/Kbuild index 6c9d193e1..1b1165a6e 100644 --- a/loginutils/Kbuild +++ b/loginutils/Kbuild @@ -7,6 +7,7 @@ lib-y:= lib-$(CONFIG_ADDGROUP) += addgroup.o lib-$(CONFIG_ADDUSER) += adduser.o +lib-$(CONFIG_CRYPTPW) += cryptpw.o lib-$(CONFIG_GETTY) += getty.o lib-$(CONFIG_LOGIN) += login.o lib-$(CONFIG_PASSWD) += passwd.o 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) if (str) memset(str, 0, strlen(str)); } - -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); -} - - -static void crypt_make_salt(char *p, int cnt) -{ - unsigned x = x; /* it's pointless to initialize it anyway :) */ - - x += getpid() + time(NULL) + clock(); - 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'; -} - - static char* new_password(const struct passwd *pw, uid_t myuid, int algo) { 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) } -#if 0 -static int get_algo(char *a) -{ - /* standard: MD5 */ - int x = 1; - if (strcasecmp(a, "des") == 0) - x = 0; - return x; -} -#endif - - static int update_passwd(const char *filename, const char *username, const char *new_pw) { |