Make WordPress Core


Ignore:
Timestamp:
09/12/2009 10:03:14 PM (14 years ago)
Author:
westi
Message:

Correct key padding and add support for raw_output in hash_hmac. Fixes #10284 props mdawaffe.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/compat.php

    r11920 r11921  
    7373    if (strlen($key) > 64)
    7474        $key = pack($pack, $algo($key));
    75     else if (strlen($key) < 64)
    76         $key = str_pad($key, 64, chr(0));
     75
     76    $key = str_pad($key, 64, chr(0));
    7777
    7878    $ipad = (substr($key, 0, 64) ^ str_repeat(chr(0x36), 64));
    7979    $opad = (substr($key, 0, 64) ^ str_repeat(chr(0x5C), 64));
    8080
    81     return $algo($opad . pack($pack, $algo($ipad . $data)));
     81    $hmac = $algo($opad . pack($pack, $algo($ipad . $data)));
     82
     83    if ( $raw_output )
     84        return pack( $pack, $hmac );
     85    return $hmac;
    8286}
    8387
Note: See TracChangeset for help on using the changeset viewer.