Skip to content

Commit

Permalink
Fixed bug #3531 regarding incorrect key padding
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.php.net/repository/pear/packages/Crypt_HMAC/trunk@180213 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information
Matthew Fonda committed Feb 20, 2005
1 parent 121da10 commit 09900b0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion HMAC.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,14 @@ function setKey($key)
* Pad the key as the RFC wishes
*/
$func = $this->_func;
$key = (strlen($key) > 64) ? pack($this->_pack, $func($key)) : str_pad($key, 64, chr(0));

if (strlen($key) > 64) {
$key = pack($this->_pack, $func($key));
}
if (strlen($key) < 64) {
$key = str_pad($key, 64, chr(0));
}


/* Calculate the padded keys and save them */
$this->_ipad = (substr($key, 0, 64) ^ str_repeat(chr(0x36), 64));
Expand Down

0 comments on commit 09900b0

Please sign in to comment.