OSDN Git Service

Peter Kjellerstedt writes:
[uclinux-h8/uClibc.git] / libcrypt / crypt.c
index 13d8efc..57181dc 100644 (file)
@@ -2,8 +2,9 @@
 /*
  * crypt() for uClibc
  *
- * Copyright (C) 2001 by Lineo, inc.  Written by 
- *  Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
+ * Copyright (C) 2000 by Lineo, inc. and Erik Andersen
+ * Copyright (C) 2000,2001 by Erik Andersen <andersen@uclibc.org>
+ * Written by Erik Andersen <andersen@uclibc.org>
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Library General Public License as published by
  * You should have received a copy of the GNU Library General Public License
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
  */
 
+#define __FORCE_GLIBC
 #include <crypt.h>
 #include <unistd.h>
 
-/* For use by the old, non-reentrant routines (crypt/encrypt/setkey)  */
-static struct crypt_data __crypt_data;
-
-char * crypt(const char *key, const char *salt)
-{
-    return crypt_r (key, salt, &__crypt_data);
-}
-
-void setkey(const char *key)
-{
-    return setkey_r(key, &__crypt_data);
-}
+extern char * __md5_crypt( const char *pw, const char *salt);
+extern char * __des_crypt( const char *pw, const char *salt);
 
-void encrypt(char *block, int edflag)
+extern char * crypt(const char *key, const char *salt)
 {
-    return encrypt_r(block, edflag, &__crypt_data);
+       /* First, check if we are supposed to be using the MD5 replacement
+        * instead of DES...  */
+       if (salt[0]=='$' && salt[1]=='1' && salt[2]=='$')
+               return __md5_crypt(key, salt);
+       else
+               return __des_crypt(key, salt);
 }