crypt.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * crypt() for uClibc
  4. *
  5. * Copyright (C) 2000 by Lineo, inc. and Erik Andersen
  6. * Copyright (C) 2000,2001 by Erik Andersen <andersen@uclibc.org>
  7. * Written by Erik Andersen <andersen@uclibc.org>
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation; either
  12. * version 2.1 of the License, or (at your option) any later version.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; see the file COPYING.LIB. If not,
  21. * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  22. * Boston, MA 02111-1307, USA.
  23. */
  24. #define __FORCE_GLIBC
  25. #include <crypt.h>
  26. #include <unistd.h>
  27. extern char * __md5_crypt( const char *pw, const char *salt);
  28. extern char * __des_crypt( const char *pw, const char *salt);
  29. extern char * crypt(const char *key, const char *salt)
  30. {
  31. /* First, check if we are supposed to be using the MD5 replacement
  32. * instead of DES... */
  33. if (salt[0]=='$' && salt[1]=='1' && salt[2]=='$')
  34. return __md5_crypt(key, salt);
  35. else
  36. return __des_crypt(key, salt);
  37. }