|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36937 key length too long distroys the hash
Submitted: 2006-03-31 20:35 UTC Modified: 2006-04-09 01:00 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: dragos at codersnest dot com Assigned:
Status: No Feedback Package: mhash related
PHP Version: 4.4.2 OS: Suse 9.3 + Windoze XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
33 + 3 = ?
Subscribe to this entry?

 [2006-03-31 20:35 UTC] dragos at codersnest dot com
I tried to do a gateway script which required me to send a hash(SHA1) of some given data, with a given key. In the beginning it worked, then after we switched to production, the key changed length from 32 to 194 (hex chars). The key was calculated as pack() binary value from the original key. At this point, the value returned by mhash() got wrong. So, basically, I am assuming that there is somewhere a constraint on the key length, either on pack() there might be a problem, though i've used that one before.

Reproduce code:
example 1 (working):
$data = 'some string data';
$mkey = '00112233445566778899AABBCCDDEEFF';
$mac = bin2hex(mhash(MHASH_SHA1,$mac,pack('h*',$mkey)));
This was working!

example 2:
This was not workign anymore!

Expected result:
a correct hash value which to be checked at the gateway again by calculating the same hash from fields of a form..

Actual result:
bad hash value


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-03-31 20:41 UTC] dragos at codersnest dot com
same thing hapenned on windowsXP+php 5.1.2 and on Fedora3+php 4.3.11, even with iconCube and ZendOptimizer disabled
 [2006-04-01 19:57 UTC]
I'm afraid "doesn't work" is not enough.
This is what I get:
string(40) "dd1b15a9ea9b697388beedb3a5283754b4a7807d"
string(40) "700877a1dc9bb89d5c1f86a4efc71ed457de8add"

Which one is correct and how do you detect it?
 [2006-04-09 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jun 19 05:01:30 2024 UTC