Browse Source

Prevent null bytes causing bcrypt to bail early

Note that this password hashing change will cause an incompatibility
with a fraction of hashes made before this change. A migration is
necessary.
spaghetti 8 years ago
parent
commit
aa1f8ba839
1 changed files with 2 additions and 2 deletions
  1. 2
    2
      classes/users.class.php

+ 2
- 2
classes/users.class.php View File

319
    */
319
    */
320
   public static function check_password($Password, $Hash) {
320
   public static function check_password($Password, $Hash) {
321
     if (!$Password || !$Hash) { return false; }
321
     if (!$Password || !$Hash) { return false; }
322
-    return password_verify(hash("sha512", $Password, true), $Hash);
322
+    return password_verify(str_replace("\0","",hash("sha512", $Password, true)), $Hash);
323
   }
323
   }
324
 
324
 
325
   /**
325
   /**
329
    * @return salted hash
329
    * @return salted hash
330
    */
330
    */
331
   public static function make_sec_hash($Str) {
331
   public static function make_sec_hash($Str) {
332
-    return password_hash(hash("sha512", $Str, true), PASSWORD_DEFAULT);
332
+    return password_hash(str_replace("\0","",hash("sha512", $Str, true)), PASSWORD_DEFAULT);
333
   }
333
   }
334
 
334
 
335
   /**
335
   /**

Loading…
Cancel
Save