web/lib/Zend/Crypt/Hmac.php
changeset 1230 68c69c656a2c
parent 807 877f952ae2bd
equal deleted inserted replaced
1229:5a6b6e770365 1230:68c69c656a2c
    13  * to license@zend.com so we can send you a copy immediately.
    13  * to license@zend.com so we can send you a copy immediately.
    14  *
    14  *
    15  * @category   Zend
    15  * @category   Zend
    16  * @package    Zend_Crypt
    16  * @package    Zend_Crypt
    17  * @subpackage Hmac
    17  * @subpackage Hmac
    18  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    18  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    20  * @version    $Id: Hmac.php 24593 2012-01-05 20:35:02Z matthew $
    20  * @version    $Id$
    21  */
    21  */
    22 
    22 
    23 /**
    23 /**
    24  * @see Zend_Crypt
    24  * @see Zend_Crypt
    25  */
    25  */
    31  *
    31  *
    32  * @todo  Patch for refactoring failed tests (key block sizes >80 using internal algo)
    32  * @todo  Patch for refactoring failed tests (key block sizes >80 using internal algo)
    33  * @todo       Check if mhash() is a required alternative (will be PECL-only soon)
    33  * @todo       Check if mhash() is a required alternative (will be PECL-only soon)
    34  * @category   Zend
    34  * @category   Zend
    35  * @package    Zend_Crypt
    35  * @package    Zend_Crypt
    36  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    36  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
    37  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    37  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    38  */
    38  */
    39 class Zend_Crypt_Hmac extends Zend_Crypt
    39 class Zend_Crypt_Hmac extends Zend_Crypt
    40 {
    40 {
    41 
    41 
    83      *
    83      *
    84      * @param string $key
    84      * @param string $key
    85      * @param string $hash
    85      * @param string $hash
    86      * @param string $data
    86      * @param string $data
    87      * @param string $output
    87      * @param string $output
    88      * @param boolean $internal
    88      * @throws Zend_Crypt_Hmac_Exception
    89      * @return string
    89      * @return string
    90      */
    90      */
    91     public static function compute($key, $hash, $data, $output = self::STRING)
    91     public static function compute($key, $hash, $data, $output = self::STRING)
    92     {
    92     {
    93         // set the key
    93         // set the key
   106 
   106 
   107     /**
   107     /**
   108      * Setter for the hash method.
   108      * Setter for the hash method.
   109      *
   109      *
   110      * @param string $hash
   110      * @param string $hash
       
   111      * @throws Zend_Crypt_Hmac_Exception
   111      * @return Zend_Crypt_Hmac
   112      * @return Zend_Crypt_Hmac
   112      */
   113      */
   113     protected static function _setHashAlgorithm($hash)
   114     protected static function _setHashAlgorithm($hash)
   114     {
   115     {
   115         if (!isset($hash) || empty($hash)) {
   116         if (!isset($hash) || empty($hash)) {
   145      */
   146      */
   146     protected static function _hash($data, $output = self::STRING, $internal = false)
   147     protected static function _hash($data, $output = self::STRING, $internal = false)
   147     {
   148     {
   148         if (function_exists('hash_hmac')) {
   149         if (function_exists('hash_hmac')) {
   149             if ($output == self::BINARY) {
   150             if ($output == self::BINARY) {
   150                 return hash_hmac(self::$_hashAlgorithm, $data, self::$_key, 1);
   151                 return hash_hmac(self::$_hashAlgorithm, $data, self::$_key, true);
   151             }
   152             }
   152             return hash_hmac(self::$_hashAlgorithm, $data, self::$_key);
   153             return hash_hmac(self::$_hashAlgorithm, $data, self::$_key);
   153         }
   154         }
   154 
   155 
   155         if (function_exists('mhash')) {
   156         if (function_exists('mhash')) {