summaryrefslogtreecommitdiffstats
path: root/lib/libcrypt/misc.c
diff options
context:
space:
mode:
authormarkm <markm@FreeBSD.org>2011-04-09 14:02:04 +0000
committermarkm <markm@FreeBSD.org>2011-04-09 14:02:04 +0000
commit007c1b95e1cf5a923c2f9c02e31c5076fd19b33c (patch)
tree77707a3cb29b813530fe64df7c6a723558bd5ddc /lib/libcrypt/misc.c
parent4f5a8eb04f8d12eec8824c3bc241d96ffdc42985 (diff)
downloadFreeBSD-src-007c1b95e1cf5a923c2f9c02e31c5076fd19b33c.zip
FreeBSD-src-007c1b95e1cf5a923c2f9c02e31c5076fd19b33c.tar.gz
Add SHA256/512 ($5$ and $6$) to crypt(3). Used in linux-world, doesn't
hurt us. PR: misc/124164 Submitted by: KIMURA Yasuhiro < yasu utahime org > MFC after: 1 month
Diffstat (limited to 'lib/libcrypt/misc.c')
-rw-r--r--lib/libcrypt/misc.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/libcrypt/misc.c b/lib/libcrypt/misc.c
index 594c580..0f63ce0 100644
--- a/lib/libcrypt/misc.c
+++ b/lib/libcrypt/misc.c
@@ -45,3 +45,19 @@ _crypt_to64(char *s, u_long v, int n)
v >>= 6;
}
}
+
+void
+b64_from_24bit(uint8_t B2, uint8_t B1, uint8_t B0, int n, int *buflen, char **cp)
+{
+ uint32_t w;
+ int i;
+
+ w = (B2 << 16) | (B1 << 8) | B0;
+ for (i = 0; i < n; i++) {
+ **cp = itoa64[w&0x3f];
+ (*cp)++;
+ if ((*buflen)-- < 0)
+ break;
+ w >>= 6;
+ }
+}
OpenPOWER on IntegriCloud