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.
diff --git a/include/libbb.h b/include/libbb.h
index 97aae0b..bd2dbe5 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -1032,8 +1032,19 @@
extern void setup_environment(const char *shell, int clear_env, int change_env, const struct passwd *pw);
extern int correct_password(const struct passwd *pw);
/* Returns a ptr to static storage */
-extern char *pw_encrypt(const char *clear, const char *salt);
+extern char *pw_encrypt(const char *clear, const char *salt, int cleanup);
extern int obscure(const char *old, const char *newval, const struct passwd *pwdp);
+/* rnd is additional random input. New one is returned.
+ * Useful if you call crypt_make_salt many times in a row:
+ * rnd = crypt_make_salt(buf1, 4, 0);
+ * rnd = crypt_make_salt(buf2, 4, rnd);
+ * rnd = crypt_make_salt(buf3, 4, rnd);
+ * (otherwise we risk having same salt generated)
+ */
+extern int crypt_make_salt(char *p, int cnt, int rnd);
+/* Returns number of lines changed, or -1 on error */
+extern int update_passwd(const char *filename, const char *username,
+ const char *new_pw);
int index_in_str_array(const char *const string_array[], const char *key);
int index_in_strings(const char *strings, const char *key);
@@ -1044,19 +1055,6 @@
extern void print_login_issue(const char *issue_file, const char *tty);
extern void print_login_prompt(void);
-/* rnd is additional random input. New one is returned.
- * Useful if you call crypt_make_salt many times in a row:
- * rnd = crypt_make_salt(buf1, 4, 0);
- * rnd = crypt_make_salt(buf2, 4, rnd);
- * rnd = crypt_make_salt(buf3, 4, rnd);
- * (otherwise we risk having same salt generated)
- */
-extern int crypt_make_salt(char *p, int cnt, int rnd);
-
-/* Returns number of lines changed, or -1 on error */
-extern int update_passwd(const char *filename, const char *username,
- const char *new_pw);
-
/* NB: typically you want to pass fd 0, not 1. Think 'applet | grep something' */
int get_terminal_width_height(int fd, unsigned *width, unsigned *height);