[phpldapadmin] SHA512 web interface support patch
Nathanael Anderson <[email protected]> Mon, 13 Dec 2010 16:51:41 -0600
| Newsgroups | gmane.comp.ldap.davedap |
|---|---|
| Message-ID | <[email protected]> |
At work we use sha512 for storing password hashes, so I added support as we plan to use phpldapadmin. Let me know if its is the wrong place to send the patch. Nathanael ------------------------------------------------------------------------------ Lotusphere 2011 Register now for Lotusphere 2011 and learn how to connect the dots, take your collaborative environment to the next level, and enter the era of Social Business. http://p.sf.net/sfu/lotusphere-d2d ______________________________________ phpLDAPadmin development mailing list. To unsbuscribe: https://lists.sourceforge.net/lists/listinfo/phpldapadmin-devel http://phpldapadmin.sourceforge.net/
phpldapadmin_sha512.patch
(text/x-patch, 1.6 KB)
--- lib/functions.php.orig 2010-12-13 16:27:51.573306808 -0600
+++ lib/functions.php 2010-12-13 16:42:49.314644754 -0600
@@ -2085,6 +2085,7 @@
debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs);
return array(
+ 'sha512'=>'sha512',
'blowfish'=>'blowfish',
''=>'clear',
'crypt'=>'crypt',
@@ -2102,7 +2103,7 @@
*
* @param string The password to hash in clear text.
* @param string Standard LDAP encryption type which must be one of
- * crypt, ext_des, md5crypt, blowfish, md5, sha, smd5, ssha, or clear.
+ * crypt, ext_des, md5crypt, blowfish, md5, sha, smd5, ssha, sha512, or clear.
* @return string The hashed password.
*/
function password_hash($password_clear,$enc_type) {
@@ -2161,6 +2162,12 @@
break;
+ case 'sha512' :
+ if (function_exists('openssl_digest') && function_exists('base64_encode')) {
+ $new_value = sprintf('{SHA512}%s', base64_encode(openssl_digest($password_clear, 'sha512')));
+ }else{
+ error(_('Your PHP install does not have the openssl_digest() or base64_encode() function. Cannot do SHA512 hashes.'),'error','index.php');
+ }
case 'ssha':
if (function_exists('mhash') && function_exists('mhash_keygen_s2k')) {
mt_srand((double)microtime()*1000000);
@@ -2263,6 +2270,16 @@
break;
+ # SHA512 crypted passwords
+ case 'sha':
+ if (strcasecmp(password_hash($plainpassword,'sha512'),'{SHA512}'.$cryptedpassword) == 0)
+ return true;
+ else
+ return false;
+
+ break;
+
+
# MD5 crypted passwords
case 'md5':
if( strcasecmp(password_hash($plainpassword,'md5'),'{MD5}'.$cryptedpassword) == 0)