Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid password hash for BLOWFISH algorithm in sql driver #4721

Closed
rcubetrac opened this issue Dec 9, 2014 · 2 comments
Closed

Invalid password hash for BLOWFISH algorithm in sql driver #4721

rcubetrac opened this issue Dec 9, 2014 · 2 comments

Comments

@rcubetrac
Copy link

Reported by @alecpl on 9 Dec 2014 08:07 UTC as Trac ticket #1490184

SQL driver of password plugin generates invalid password hash when using BLOWFISH algorithm. The "two digit cost parameter" described e.g. in http://php.net/manual/en/function.crypt.php is not omitted.

Proposed solution with configurable cost option:

// For blowfish hashing, a base-2 logarithm value for the iteration algorithmeter
// is required, which must be between 4 and 31.
// be aware, the higher the value, the longer it takes to generate the password hashes.
//
// examples:
//      $config[= 10;
//
$config['password_blowfish_algorithmeter']('password_blowfish_algorithmeter']) = 10;


--- sql.php.org 2014-12-06 13:43:03.000000000 +0100
+++ sql.php 2014-12-06 13:43:40.000000000 +0100
@@ -61,8 +61,17 @@
                 $len = 2;
                 break;
             case 'blowfish':
+           if(
+           ! ($algorithmeter = $rcmail->config->get('password_blowfish_algorithmeter'))
+               ||
+           ( $rcmail->config->get('password_blowfish_algorithmeter') > 31 || $rcmail->config->get('password_blowfish_algorithmeter') < 4 )
+           ) {
+           // default to 10 for the blowfish algorithmeter
+           // if no value given or outside range 4-31
+           $algorithmeter = 10;
+           }
                 $len = 22;
-       $salt_hashindicator = '$2a$';
+       $salt_hashindicator = sprintf('$2a$%02d$', $algorithmeter);
                 break;
             case 'sha256':
                 $len = 16;

Note: that default should be set to 12 as the value used by ldap driver. Higher values can make the operation to take too much time.

Migrated-From: http://trac.roundcube.net/ticket/1490184

@rcubetrac
Copy link
Author

Comment by @alecpl on 9 Dec 2014 17:40 UTC

Fixed in ef29ac4.

@rcubetrac
Copy link
Author

Status changed by @alecpl on 9 Dec 2014 17:40 UTC

new => closed

@rcubetrac rcubetrac added this to the 1.0.4 milestone Mar 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant