summaryrefslogtreecommitdiff
path: root/libcrypt/crypt.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2002-04-25 01:39:08 +0000
committerEric Andersen <andersen@codepoet.org>2002-04-25 01:39:08 +0000
commit3e87ecb2f6d97f0a12ba76a32f46bd0f27b72c1b (patch)
tree62928a831a9385192bc7b6bf902f8b200dd649c4 /libcrypt/crypt.c
parent4844aa2aaca0e6d34c58ede6a8583f554c477feb (diff)
Rework libcrypt based on the openbsd crypt implementation so that it passes the
DES validation suite. setkey_r, encrypt_r, and __des_crypt_r are not really reentrant now, and that should be fixed (or we should drop crypt_r and friends which are not supported by SuSv3). -Erik
Diffstat (limited to 'libcrypt/crypt.c')
-rw-r--r--libcrypt/crypt.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/libcrypt/crypt.c b/libcrypt/crypt.c
index 84c7678c2..027aa5a4d 100644
--- a/libcrypt/crypt.c
+++ b/libcrypt/crypt.c
@@ -21,11 +21,14 @@
* 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;
+extern char * __md5_crypt_r( const char *pw, const char *salt, struct crypt_data * data);
+extern char * __des_crypt_r( const char *pw, const char *salt, struct crypt_data * data);
extern char * crypt(const char *key, const char *salt)
{
@@ -42,3 +45,12 @@ extern void encrypt(char *block, int edflag)
encrypt_r(block, edflag, &__crypt_data);
}
+extern char *crypt_r(const char *pw, const char *salt, struct crypt_data *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_r(pw, salt, data);
+ else
+ return __des_crypt_r(pw, salt, data);
+}