summaryrefslogtreecommitdiffhomepage
path: root/loginutils/cryptpw.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-06-12 16:55:59 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-06-12 16:55:59 +0000
commit4ea83bf562c44a6792e7c77e7d87cba91f86f763 (patch)
tree64dba9163b29724e282c1e94027001a11978e74b /loginutils/cryptpw.c
parent9de462205542547694299e9fe2bc321088ab79aa (diff)
uclibc insists on having 70k static buffer for crypt.
For bbox it's not acceptable. Roll our own des and md5 crypt implementation. Against older uclibc: text data bss dec hex filename 759945 604 6684 767233 bb501 busybox_old 759766 604 6684 767054 bb44e busybox_unstripped so, we still save on code size.
Diffstat (limited to 'loginutils/cryptpw.c')
-rw-r--r--loginutils/cryptpw.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/loginutils/cryptpw.c b/loginutils/cryptpw.c
index 68f5e8074..1acbc6db0 100644
--- a/loginutils/cryptpw.c
+++ b/loginutils/cryptpw.c
@@ -7,6 +7,30 @@
#include "libbb.h"
+#define TESTING 0
+
+/*
+set TESTING to 1 and pipe some file through this script
+if you played with bbox's crypt implementation.
+
+while read line; do
+ n=`./busybox cryptpw -a des -- "$line"`
+ o=`./busybox_old cryptpw -a des -- "$line"`
+ test "$n" != "$o" && {
+ echo n="$n"
+ echo o="$o"
+ exit
+ }
+ n=`./busybox cryptpw -- "$line"`
+ o=`./busybox_old cryptpw -- "$line"`
+ test "$n" != "$o" && {
+ echo n="$n"
+ echo o="$o"
+ exit
+ }
+done
+ */
+
int cryptpw_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int cryptpw_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
@@ -18,11 +42,17 @@ int cryptpw_main(int argc ATTRIBUTE_UNUSED, char **argv)
//((uint32_t*)&salt)[0] = '$' + '1'*0x100 + '$'*0x10000;
/* Hope one day gcc will do it itself (inlining strcpy) */
crypt_make_salt(salt + 3, 4, 0); /* md5 */
+#if TESTING
+ strcpy(salt + 3, "ajg./bcf");
+#endif
} else {
crypt_make_salt(salt, 1, 0); /* des */
+#if TESTING
+ strcpy(salt, "a.");
+#endif
}
- puts(pw_encrypt(argv[optind] ? argv[optind] : xmalloc_fgetline(stdin), salt));
+ puts(pw_encrypt(argv[optind] ? argv[optind] : xmalloc_fgetline(stdin), salt, 1));
return 0;
}