nptl: remove asm from sysdep-cancel.h
[uclibc-ng.git] / libcrypt / crypt.c
blob8399205ca2995f157300810f5ff8b7fe3efe2b28
1 /*
2 * crypt() for uClibc
3 * Copyright (C) 2000-2006 by Erik Andersen <andersen@uclibc.org>
4 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
5 */
7 #include <unistd.h>
8 #include <crypt.h>
9 #include "libcrypt.h"
11 char *crypt(const char *key, const char *salt)
13 const unsigned char *ukey = (const unsigned char *)key;
14 const unsigned char *usalt = (const unsigned char *)salt;
16 if (salt[0] == '$') {
17 if (salt[1] && salt[2] == '$') { /* no blowfish '2X' here ATM */
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 /* __set_errno(EINVAL);*/ /* ENOSYS might be misleading */
30 return NULL;
32 return __des_crypt(ukey, usalt);