ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
HMAC.php File Reference

Go to the source code of this file.

Namespaces

namespace  OpenID
 This module contains code for dealing with associations between consumers and servers.

Functions

 Auth_OpenID_SHA1 ($text)
 Auth_OpenID_HMACSHA1 ($key, $text)
 Compute an HMAC/SHA1 hash.

Variables

const Auth_OpenID_SHA1_BLOCKSIZE = 64
 SHA1_BLOCKSIZE is this module's SHA1 blocksize used by the fallback implementation.

Function Documentation

Auth_OpenID_HMACSHA1 (   $key,
  $text 
)

Compute an HMAC/SHA1 hash.

private

Parameters
string$keyThe HMAC key
string$textThe message text to hash
Returns
string $mac The MAC

Definition at line 57 of file HMAC.php.

References Auth_OpenID_SHA1(), Auth_OpenID_SHA1_BLOCKSIZE, and Auth_OpenID\bytes().

{
$key = Auth_OpenID_SHA1($key, true);
}
$key = str_pad($key, Auth_OpenID_SHA1_BLOCKSIZE, chr(0x00));
$ipad = str_repeat(chr(0x36), Auth_OpenID_SHA1_BLOCKSIZE);
$opad = str_repeat(chr(0x5c), Auth_OpenID_SHA1_BLOCKSIZE);
$hash1 = Auth_OpenID_SHA1(($key ^ $ipad) . $text, true);
$hmac = Auth_OpenID_SHA1(($key ^ $opad) . $hash1, true);
return $hmac;
}
if (function_exists('hash') &&
function_exists('hash_algos') &&
(in_array('sha256', hash_algos()))) {
function Auth_OpenID_SHA256($text)
{
// PHP 5 case: 'hash' available and 'sha256' algo supported.
return hash('sha256', $text, true);
}
define('Auth_OpenID_SHA256_SUPPORTED', true);
} else {

+ Here is the call graph for this function:

Auth_OpenID_SHA1 (   $text)

Definition at line 25 of file HMAC.php.

Referenced by Auth_OpenID_FileStore\_safe64(), Auth_OpenID_DumbStore\Auth_OpenID_DumbStore(), and Auth_OpenID_HMACSHA1().

{
if (function_exists('hash') &&
function_exists('hash_algos') &&
(in_array('sha1', hash_algos()))) {
// PHP 5 case (sometimes): 'hash' available and 'sha1' algo
// supported.
return hash('sha1', $text, true);
} else if (function_exists('sha1')) {
// PHP 4 case: 'sha1' available.
$hex = sha1($text);
$raw = '';
for ($i = 0; $i < 40; $i += 2) {
$hexcode = substr($hex, $i, 2);
$charcode = (int)base_convert($hexcode, 16, 10);
$raw .= chr($charcode);
}
return $raw;
} else {
// Explode.
trigger_error('No SHA1 function found', E_USER_ERROR);
}
}

+ Here is the caller graph for this function:

Variable Documentation

const Auth_OpenID_SHA1_BLOCKSIZE = 64

SHA1_BLOCKSIZE is this module's SHA1 blocksize used by the fallback implementation.

Definition at line 23 of file HMAC.php.

Referenced by Auth_OpenID_HMACSHA1().