runsvd: shrink by Vladimir
[oweals/busybox.git] / libbb / pw_encrypt.c
index 762cbab27ab001ea498b8d5792242beebe31ecac..469e71f6ccdc9606a8f895d9db2d07127a17419f 100644 (file)
@@ -9,13 +9,11 @@
 
 #include "libbb.h"
 
+#if ENABLE_USE_BB_CRYPT
+
 /*
  * DES and MD5 crypt implementations are taken from uclibc.
  * They were modified to not use static buffers.
- * Comparison with uclibc (before uclibc had 70k staic buffers reinstated):
- *   text    data     bss     dec     hex filename
- * 759909     604    6684  767197   bb4dd busybox_old
- * 759579     604    6684  766867   bb393 busybox_unstripped
  */
 /* Common for them */
 static const uint8_t ascii64[] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
@@ -52,7 +50,7 @@ static void my_crypt_cleanup(void)
        des_ctx = NULL;
 }
 
-char *pw_encrypt(const char *clear, const char *salt, int cleanup)
+char* FAST_FUNC pw_encrypt(const char *clear, const char *salt, int cleanup)
 {
        char *encrypted;
 
@@ -69,3 +67,18 @@ char *pw_encrypt(const char *clear, const char *salt, int cleanup)
 
        return encrypted;
 }
+
+#else /* if !ENABLE_USE_BB_CRYPT */
+
+char* FAST_FUNC pw_encrypt(const char *clear, const char *salt, int cleanup)
+{
+#if 0 /* was CONFIG_FEATURE_SHA1_PASSWORDS, but there is no such thing??? */
+       if (strncmp(salt, "$2$", 3) == 0) {
+               return xstrdup(sha1_crypt(clear));
+       }
+#endif
+
+       return xstrdup(crypt(clear, salt));
+}
+
+#endif