Bug #52409 [NEW]: Wrong hash_hmac result
| From: | blackakula at gmail dot com | Date: | Thu, 22 Jul 2010 17:48:31 +0000 |
| Subject: | Bug #52409 [NEW]: Wrong hash_hmac result | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-152626@lists.php.net to get a copy of this message | ||
From:
Operating system: Ubuntu 10.04
PHP version: 5.3.3
Package: OpenSSL related
Bug Type: Bug
Bug description:Wrong hash_hmac result
Description:
------------
I've tried many other ways to calculate this SHA-256. All sources gave me
expected result (string(64)
"88e0d97d68acf161407af5965ae1e33b1743dbc400af1cc8a2020d47f45ca83e"), except
PHP.
Source 1: http://hash.online-convert.com/sha256-generator
(online
sha256-generator)
Source 2: ruby code:
OpenSSL::HMAC.hexdigest('sha256','49a40e1d5c24be8a6e7d566a05d346d0','eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImV4cGlyZXMiOjEyNzk4MTgwMDAsIm9hdXRoX3Rva2VuIjoiMTIxMTc2NDk3OTEwMTg5fDIuNlBKWkFNTFozOGcxaUZYMXdraUZwZ19fLjM2MDAuMTI3OTgxODAwMC02MjAzMDc1NDJ8UXd5MHVuZEJ2YVlSYnJWcDBFSkN4eGdVRjQ4LiIsInVzZXJfaWQiOiI2MjAzMDc1NDIifQ')
PHP code example (gave me string(64)
"61c9a97bd820052765e1291708352acadb397ea15489bf8be18bd34f775cda1a"):
<?php
var_dump(hash_hmac('sha256','eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImV4cGlyZXMiOjEyNzk4MTA4MDAsIm9hdXRoX3Rva2VuIjoiMTIxMTc2NDk3OTEwMTg5fDIuNENNcl9UWV9OVnNKTmpSQlNzOGQ1QV9fLjM2MDAuMTI3OTgxMDgwMC02MjAzMDc1NDJ8eFg5QTBLRzRKbnNHNXZmQ2VaSGJpQmNJeE9vLiIsInVzZXJfaWQiOiI2MjAzMDc1NDIifQ','49a40e1d5c24be8a6e7d566a05d346d0',false));
?>
Test script:
---------------
<?php
var_dump(hash_hmac('sha256','eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImV4cGlyZXMiOjEyNzk4MTA4MDAsIm9hdXRoX3Rva2VuIjoiMTIxMTc2NDk3OTEwMTg5fDIuNENNcl9UWV9OVnNKTmpSQlNzOGQ1QV9fLjM2MDAuMTI3OTgxMDgwMC02MjAzMDc1NDJ8eFg5QTBLRzRKbnNHNXZmQ2VaSGJpQmNJeE9vLiIsInVzZXJfaWQiOiI2MjAzMDc1NDIifQ','49a40e1d5c24be8a6e7d566a05d346d0',false));
?>
Expected result:
----------------
string(64)
"88e0d97d68acf161407af5965ae1e33b1743dbc400af1cc8a2020d47f45ca83e"
Actual result:
--------------
string(64)
"61c9a97bd820052765e1291708352acadb397ea15489bf8be18bd34f775cda1a"
--
Edit bug report at http://bugs.php.net/bug.php?id=52409&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=52409&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=52409&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=52409&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=52409&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52409&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=52409&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=52409&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=52409&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=52409&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=52409&r=support
Expected behavior: http://bugs.php.net/fix.php?id=52409&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=52409&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=52409&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=52409&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52409&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=52409&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=52409&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=52409&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=52409&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=52409&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=52409&r=mysqlcfg