aboutsummaryrefslogtreecommitdiff
path: root/crypt/crypt_util.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/crypt_util.c
parentd936d379eb1837c35e390b6293f15f75b634db6e (diff)
downloadglibc-8747cd034a460597a78c4ac616c13e3c981ff1d3.tar
glibc-8747cd034a460597a78c4ac616c13e3c981ff1d3.tar.gz
glibc-8747cd034a460597a78c4ac616c13e3c981ff1d3.tar.bz2
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/crypt_util.c')
-rw-r--r--crypt/crypt_util.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/crypt/crypt_util.c b/crypt/crypt_util.c
index 287593142b..9381d67194 100644
--- a/crypt/crypt_util.c
+++ b/crypt/crypt_util.c
@@ -253,6 +253,10 @@ static ufc_long eperm32tab[4][256][2];
*/
static ufc_long efp[16][64][2];
+/* Table with characters for base64 transformation. */
+static const char b64t[64] =
+"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+
/*
* For use by the old, non-reentrant routines
* (crypt/encrypt/setkey)
@@ -956,3 +960,17 @@ setkey(__key)
{
__setkey_r(__key, &_ufc_foobar);
}
+
+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;
+ }
+}