diff options
Diffstat (limited to 'crypt/crypt-entry.c')
-rw-r--r-- | crypt/crypt-entry.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/crypt/crypt-entry.c b/crypt/crypt-entry.c index ca219bb69c..fdddad2c55 100644 --- a/crypt/crypt-entry.c +++ b/crypt/crypt-entry.c @@ -1,7 +1,7 @@ /* * UFC-crypt: ultra fast crypt(3) implementation * - * Copyright (C) 1991, 1992, 1993, 1996, 1997 Free Software Foundation, Inc. + * Copyright (C) 1991,1992,1993,1996,1997,2007 Free Software Foundation, Inc. * * The GNU C Library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -55,6 +55,12 @@ void _ufc_clearmem (char *start, int cnt); extern char *__md5_crypt_r (const char *key, const char *salt, char *buffer, int buflen); extern char *__md5_crypt (const char *key, const char *salt); +extern char *__sha256_crypt_r (const char *key, const char *salt, + char *buffer, int buflen); +extern char *__sha256_crypt (const char *key, const char *salt); +extern char *__sha512_crypt_r (const char *key, const char *salt, + char *buffer, int buflen); +extern char *__sha512_crypt (const char *key, const char *salt); #endif /* Define our magic string to mark salt for MD5 encryption @@ -62,6 +68,12 @@ extern char *__md5_crypt (const char *key, const char *salt); encryption implementations. */ static const char md5_salt_prefix[] = "$1$"; +/* Magic string for SHA256 encryption. */ +static const char sha256_salt_prefix[] = "$5$"; + +/* Magic string for SHA512 encryption. */ +static const char sha512_salt_prefix[] = "$6$"; + /* For use by the old, non-reentrant routines (crypt/encrypt/setkey) */ extern struct crypt_data _ufc_foobar; @@ -84,6 +96,16 @@ __crypt_r (key, salt, data) if (strncmp (md5_salt_prefix, salt, sizeof (md5_salt_prefix) - 1) == 0) return __md5_crypt_r (key, salt, (char *) data, sizeof (struct crypt_data)); + + /* Try to find out whether we have to use SHA256 encryption replacement. */ + if (strncmp (sha256_salt_prefix, salt, sizeof (sha256_salt_prefix) - 1) == 0) + return __sha256_crypt_r (key, salt, (char *) data, + sizeof (struct crypt_data)); + + /* Try to find out whether we have to use SHA512 encryption replacement. */ + if (strncmp (sha512_salt_prefix, salt, sizeof (sha512_salt_prefix) - 1) == 0) + return __sha512_crypt_r (key, salt, (char *) data, + sizeof (struct crypt_data)); #endif /* @@ -126,6 +148,14 @@ crypt (key, salt) /* Try to find out whether we have to use MD5 encryption replacement. */ if (strncmp (md5_salt_prefix, salt, sizeof (md5_salt_prefix) - 1) == 0) return __md5_crypt (key, salt); + + /* Try to find out whether we have to use SHA256 encryption replacement. */ + if (strncmp (sha256_salt_prefix, salt, sizeof (sha256_salt_prefix) - 1) == 0) + return __sha256_crypt (key, salt); + + /* Try to find out whether we have to use SHA512 encryption replacement. */ + if (strncmp (sha512_salt_prefix, salt, sizeof (sha512_salt_prefix) - 1) == 0) + return __sha512_crypt (key, salt); #endif return __crypt_r (key, salt, &_ufc_foobar); |