]>
Commit | Line | Data |
---|---|---|
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> |
6993d937 | 9 | #include <errno.h> |
8d9ff89b | 10 | #include "libcrypt.h" |
08012e24 | 11 | |
8d9ff89b | 12 | char *crypt(const char *key, const char *salt) |
3e87ecb2 | 13 | { |
4a2b0641 MF |
14 | const unsigned char *ukey = (const unsigned char *)key; |
15 | const unsigned char *usalt = (const unsigned char *)salt; | |
40c426ae | 16 | |
78b154a9 BRF |
17 | if (salt[0] == '$') { |
18 | if (salt[1] && salt[2] == '$') { /* no blowfish '2X' here ATM */ | |
19 | if (*++salt == '1') | |
20 | return __md5_crypt(ukey, usalt); | |
de596417 | 21 | #ifdef __UCLIBC_HAS_SHA256_CRYPT_IMPL__ |
78b154a9 BRF |
22 | else if (*salt == '5') |
23 | return __sha256_crypt(ukey, usalt); | |
de596417 BRF |
24 | #endif |
25 | #ifdef __UCLIBC_HAS_SHA512_CRYPT_IMPL__ | |
78b154a9 BRF |
26 | else if (*salt == '6') |
27 | return __sha512_crypt(ukey, usalt); | |
de596417 | 28 | #endif |
78b154a9 | 29 | } |
2f6076cd | 30 | __set_errno(EINVAL); |
78b154a9 | 31 | return NULL; |
40c426ae | 32 | } |
de596417 | 33 | return __des_crypt(ukey, usalt); |
3e87ecb2 | 34 | } |