From 5d7a4ac5c758c9020d94756b95ecdc5d8abc322c Mon Sep 17 00:00:00 2001 From: blainett Date: Sat, 26 Aug 2006 20:18:55 +0000 Subject: [PATCH] Change to genkey.php, according to php documentation of sha1, there aren't neccesity of pecl hash extension. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4520 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/heimdal/genkey.php | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/include/heimdal/genkey.php b/include/heimdal/genkey.php index fa9829c6d..0a6531d8a 100644 --- a/include/heimdal/genkey.php +++ b/include/heimdal/genkey.php @@ -81,7 +81,7 @@ class genkey{ for ($i=0;$iintg_dkey);$i++){ $data.=chr($this->intg_dkey[$i]); } - $sha1_hmac_raw=hash_hmac("sha1",$hash_key,$data,true); + $sha1_hmac_raw=$this->hmacsha1($data,$hash_key); $this->sha1hmac=array(); for ($i=0;$isha1hmac[$i]=ord(substr($sha1_hmac_raw,$i,1)); @@ -151,5 +151,26 @@ class genkey{ printf("key(base64):\n".$this->b64."\n"); } + function hmacsha1($key,$data){ + $blocksize=64; + $hashfunc='sha1'; + if (strlen($key)>$blocksize) + $key=pack('H*', $hashfunc($key)); + $key=str_pad($key,$blocksize,chr(0x00)); + $ipad=str_repeat(chr(0x36),$blocksize); + $opad=str_repeat(chr(0x5c),$blocksize); + $hmac = pack( + 'H*',$hashfunc( + ($key^$opad).pack( + 'H*',$hashfunc( + ($key^$ipad).$data + ) + ) + ) + ); + return($hmac); + //return bin2hex($hmac); + } + }; ?> \ No newline at end of file -- 2.30.2