summaryrefslogtreecommitdiff
path: root/src/misc/crypt_r.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-08-29 12:41:29 -0400
committerRich Felker <dalias@aerifal.cx>2012-08-29 12:41:29 -0400
commit88bf5a8a8d7d796f63cca8589f4de67aa8345f1a (patch)
tree93ef111566aae52afa23a5c5201d9d46615f92ba /src/misc/crypt_r.c
parentb439c051c7eee4eb4b93fc382f993aa6305ce530 (diff)
downloadmusl-88bf5a8a8d7d796f63cca8589f4de67aa8345f1a.tar.gz
add sha256/sha512 crypt
based on versions sent to the list by nsz, with some simplification and debloating. i'd still like to get them a bit smaller, or ideally merge them into a single file with most of the code being shared, but that can be done later.
Diffstat (limited to 'src/misc/crypt_r.c')
-rw-r--r--src/misc/crypt_r.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/misc/crypt_r.c b/src/misc/crypt_r.c
index f4716d6f..1c7f9cf0 100644
--- a/src/misc/crypt_r.c
+++ b/src/misc/crypt_r.c
@@ -6,6 +6,8 @@ struct crypt_data;
char *__crypt_des(const char *, const char *, char *);
char *__crypt_md5(const char *, const char *, char *);
char *__crypt_blowfish(const char *, const char *, char *);
+char *__crypt_sha256(const char *, const char *, char *);
+char *__crypt_sha512(const char *, const char *, char *);
char *__crypt_r(const char *key, const char *salt, struct crypt_data *data)
{
@@ -17,6 +19,10 @@ char *__crypt_r(const char *key, const char *salt, struct crypt_data *data)
#endif
if (salt[1] == '2' && salt[3] == '$')
return __crypt_blowfish(key, salt, output);
+ if (salt[1] == '5' && salt[2] == '$')
+ return __crypt_sha256(key, salt, output);
+ if (salt[1] == '6' && salt[2] == '$')
+ return __crypt_sha512(key, salt, output);
}
return __crypt_des(key, salt, output);
}