|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64688 crypt doesn't truncate salt correctly for EXT_DES
Submitted: 2013-04-21 16:47 UTC Modified: 2015-09-20 04:22 UTC
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: chaos-master at gmx dot de Assigned:
Status: No Feedback Package: *Encryption and hash functions
PHP Version: 5.3.24 OS: GNU/Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: chaos-master at gmx dot de
New email:
PHP Version: OS:


 [2013-04-21 16:47 UTC] chaos-master at gmx dot de
From manual page:

The documentation for the crypt()-function asks to provide the complete hash as salt in order to verify a given hash.

However if the given hash is an EXT_DES Hash this doesn't work correctly

Test script:
// Correct behavior (here using SHA512)
$hash = crypt('foobar', '$6$Rp.sVGo.zbHnQds.');
echo $hash."\n";                                                // $6$Rp.sVGo.zbHnQds.$I/mOIzdGE8g53MGbCe8gPcOdUMX.BiGz8Nx9HMa0UDKacGscGIAu.H75iG5U0d/niZk76y/LLHtHKZL9VdEZY0
echo crypt('foobar', $hash)."\n";                               // $6$Rp.sVGo.zbHnQds.$I/mOIzdGE8g53MGbCe8gPcOdUMX.BiGz8Nx9HMa0UDKacGscGIAu.H75iG5U0d/niZk76y/LLHtHKZL9VdEZY0

// Inorrect behavior (EXT_DES)
$hash = crypt('foobar', '_6C/.jjzc');
echo $hash."\n";                                                // _6C/.jjzcoAyXu0Z0XlM
echo crypt('foobar', $hash)."\n";                               // _6T7pAW9oacXQ

// Workaround
echo crypt('foobar', substr($hash,0,9))."\n";                   // _6C/.jjzcoAyXu0Z0XlM

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-04-21 16:51 UTC] chaos-master at gmx dot de
-Type: Documentation Problem +Type: Bug
 [2013-04-21 16:51 UTC] chaos-master at gmx dot de
changed bug type: doc -> bug
 [2015-09-07 23:48 UTC]
-Status: Open +Status: Feedback
 [2015-09-07 23:48 UTC]
I can't reproduce the described behavior:
<>. Could you please provide further details
where it occurs?
 [2015-09-20 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jul 25 07:01:31 2024 UTC