reduce some unneeded warnings.
[uclibc-ng.git] / libcrypt / crypt.c
blobf79c9fe8bf644ab35b06a29774d3c505af767119
1 /* vi: set sw=4 ts=4: */
2 /*
3 * crypt() for uClibc
4 * Copyright (C) 2000-2006 by Erik Andersen <andersen@uclibc.org>
5 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
6 */
8 #include <unistd.h>
9 #include <crypt.h>
10 #include "libcrypt.h"
12 char *crypt(const char *key, const char *salt)
14 const unsigned char *ukey = (const unsigned char *)key;
15 const unsigned char *usalt = (const unsigned char *)salt;
17 if (salt[0] == '$' && salt[2] == '$') {
18 if (*++salt == '1')
19 return __md5_crypt(ukey, usalt);
20 #ifdef __UCLIBC_HAS_SHA256_CRYPT_IMPL__
21 else if (*salt == '5')
22 return __sha256_crypt(ukey, usalt);
23 #endif
24 #ifdef __UCLIBC_HAS_SHA512_CRYPT_IMPL__
25 else if (*salt == '6')
26 return __sha512_crypt(ukey, usalt);
27 #endif
29 return __des_crypt(ukey, usalt);