Doc #64688 [NEW]: crypt doesn't truncate salt correctly for EXT_DES
| From: | chaos-master at gmx dot de | Date: | Sun, 21 Apr 2013 16:47:33 +0000 |
| Subject: | Doc #64688 [NEW]: crypt doesn't truncate salt correctly for EXT_DES | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-9753@lists.php.net to get a copy of this message | ||
From: chaos-master at gmx dot de
Operating system: GNU/Linux
PHP version: 5.3.24
Package: *Encryption and hash functions
Bug Type: Documentation Problem
Bug description:crypt doesn't truncate salt correctly for EXT_DES
Description:
------------
---
From manual page:
http://www.php.net/function.crypt#refsect1-function.crypt-examples
---
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:
---------------
<?php
// 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:
----------------
$6$Rp.sVGo.zbHnQds.$I/mOIzdGE8g53MGbCe8gPcOdUMX.BiGz8Nx9HMa0UDKacGscGIAu.H75iG5U0d/niZk76y/LLHtHKZL9VdEZY0
$6$Rp.sVGo.zbHnQds.$I/mOIzdGE8g53MGbCe8gPcOdUMX.BiGz8Nx9HMa0UDKacGscGIAu.H75iG5U0d/niZk76y/LLHtHKZL9VdEZY0
_6C/.jjzcoAyXu0Z0XlM
_6C/.jjzcoAyXu0Z0XlM
_6C/.jjzcoAyXu0Z0XlM
Actual result:
--------------
$6$Rp.sVGo.zbHnQds.$I/mOIzdGE8g53MGbCe8gPcOdUMX.BiGz8Nx9HMa0UDKacGscGIAu.H75iG5U0d/niZk76y/LLHtHKZL9VdEZY0
$6$Rp.sVGo.zbHnQds.$I/mOIzdGE8g53MGbCe8gPcOdUMX.BiGz8Nx9HMa0UDKacGscGIAu.H75iG5U0d/niZk76y/LLHtHKZL9VdEZY0
_6C/.jjzcoAyXu0Z0XlM
_6T7pAW9oacXQ
_6C/.jjzcoAyXu0Z0XlM
--
Edit bug report at https://bugs.php.net/bug.php?id=64688&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=64688&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=64688&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=64688&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=64688&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=64688&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=64688&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=64688&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=64688&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=64688&r=support
Expected behavior: https://bugs.php.net/fix.php?id=64688&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=64688&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=64688&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=64688&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64688&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=64688&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=64688&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=64688&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64688&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=64688&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=64688&r=mysqlcfg