]> Git Repo - uclibc-ng.git/blame - libcrypt/crypt.c
hasmntopt: better option matching
[uclibc-ng.git] / libcrypt / crypt.c
CommitLineData
08012e24
EA
1/*
2 * crypt() for uClibc
f79ff084 3 * Copyright (C) 2000-2006 by Erik Andersen <[email protected]>
3f87a95d 4 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
08012e24
EA
5 */
6
08012e24 7#include <unistd.h>
de596417 8#include <crypt.h>
8d9ff89b 9#include "libcrypt.h"
08012e24 10
8d9ff89b 11char *crypt(const char *key, const char *salt)
3e87ecb2 12{
4a2b0641
MF
13 const unsigned char *ukey = (const unsigned char *)key;
14 const unsigned char *usalt = (const unsigned char *)salt;
40c426ae 15
78b154a9
BRF
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);
de596417 20#ifdef __UCLIBC_HAS_SHA256_CRYPT_IMPL__
78b154a9
BRF
21 else if (*salt == '5')
22 return __sha256_crypt(ukey, usalt);
de596417
BRF
23#endif
24#ifdef __UCLIBC_HAS_SHA512_CRYPT_IMPL__
78b154a9
BRF
25 else if (*salt == '6')
26 return __sha512_crypt(ukey, usalt);
de596417 27#endif
78b154a9
BRF
28 }
29 /* __set_errno(EINVAL);*/ /* ENOSYS might be misleading */
30 return NULL;
40c426ae 31 }
de596417 32 return __des_crypt(ukey, usalt);
3e87ecb2 33}
This page took 0.208959 seconds and 4 git commands to generate.