about summary refs log tree commit diff
path: root/crypt/md5-crypt.c
diff options
context:
space:
mode:
authorKonstantin Serebryany <konstantin.s.serebryany@gmail.com>2014-06-03 16:39:08 +0530
committerSiddhesh Poyarekar <siddhesh@redhat.com>2014-06-03 16:39:08 +0530
commit8747cd034a460597a78c4ac616c13e3c981ff1d3 (patch)
treee7afbbf3198b6e56c3560b2b8805d029af24605c /crypt/md5-crypt.c
parentd936d379eb1837c35e390b6293f15f75b634db6e (diff)
downloadglibc-8747cd034a460597a78c4ac616c13e3c981ff1d3.tar.gz
glibc-8747cd034a460597a78c4ac616c13e3c981ff1d3.tar.xz
glibc-8747cd034a460597a78c4ac616c13e3c981ff1d3.zip
Remove redundant nested function b64_from_24bit
Move multiple definitions of the nested function b64_from_24bit into a
single function __b64_from_24bit.
Diffstat (limited to 'crypt/md5-crypt.c')
-rw-r--r--crypt/md5-crypt.c43
1 files changed, 13 insertions, 30 deletions
diff --git a/crypt/md5-crypt.c b/crypt/md5-crypt.c
index f6739d3f92..0aa4f7ec72 100644
--- a/crypt/md5-crypt.c
+++ b/crypt/md5-crypt.c
@@ -25,6 +25,7 @@
 #include <sys/param.h>
 
 #include "md5.h"
+#include "crypt-private.h"
 
 
 #ifdef USE_NSS
@@ -78,30 +79,12 @@ typedef int PRBool;
    encryption implementations.  */
 static const char md5_salt_prefix[] = "$1$";
 
-/* Table with characters for base64 transformation.  */
-static const char b64t[64] =
-"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
-
 
 /* Prototypes for local functions.  */
 extern char *__md5_crypt_r (const char *key, const char *salt,
 			    char *buffer, int buflen);
 extern char *__md5_crypt (const char *key, const char *salt);
 
-static void
-b64_from_24bit (char **cp, int *buflen,
-		unsigned int b2, unsigned int b1, unsigned int b0,
-		int n)
-{
-  unsigned int w = (b2 << 16) | (b1 << 8) | b0;
-  while (n-- > 0 && *buflen > 0)
-    {
-      *(*cp)++ = b64t[w & 0x3f];
-      --*buflen;
-      w >>= 6;
-    }
-}
-
 
 /* This entry point is equivalent to the `crypt' function in Unix
    libcs.  */
@@ -282,18 +265,18 @@ __md5_crypt_r (key, salt, buffer, buflen)
       --buflen;
     }
 
-  b64_from_24bit (&cp, &buflen,
-		  alt_result[0], alt_result[6], alt_result[12], 4);
-  b64_from_24bit (&cp, &buflen,
-		  alt_result[1], alt_result[7], alt_result[13], 4);
-  b64_from_24bit (&cp, &buflen,
-		  alt_result[2], alt_result[8], alt_result[14], 4);
-  b64_from_24bit (&cp, &buflen,
-		  alt_result[3], alt_result[9], alt_result[15], 4);
-  b64_from_24bit (&cp, &buflen,
-		  alt_result[4], alt_result[10], alt_result[5], 4);
-  b64_from_24bit (&cp, &buflen,
-		  0, 0, alt_result[11], 2);
+  __b64_from_24bit (&cp, &buflen,
+		    alt_result[0], alt_result[6], alt_result[12], 4);
+  __b64_from_24bit (&cp, &buflen,
+		    alt_result[1], alt_result[7], alt_result[13], 4);
+  __b64_from_24bit (&cp, &buflen,
+		    alt_result[2], alt_result[8], alt_result[14], 4);
+  __b64_from_24bit (&cp, &buflen,
+		    alt_result[3], alt_result[9], alt_result[15], 4);
+  __b64_from_24bit (&cp, &buflen,
+		    alt_result[4], alt_result[10], alt_result[5], 4);
+  __b64_from_24bit (&cp, &buflen,
+		    0, 0, alt_result[11], 2);
   if (buflen <= 0)
     {
       __set_errno (ERANGE);