Code

Change to genkey.php, according to php documentation
authorblainett <blainett@594d385d-05f5-0310-b6e9-bd551577e9d8>
Sat, 26 Aug 2006 20:18:55 +0000 (20:18 +0000)
committerblainett <blainett@594d385d-05f5-0310-b6e9-bd551577e9d8>
Sat, 26 Aug 2006 20:18:55 +0000 (20:18 +0000)
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

index fa9829c6d5025a70c19f418d1c7bf1bb2d32809c..0a6531d8a8c47c4a0a100ca8c5a14e73e03eddbd 100644 (file)
@@ -81,7 +81,7 @@ class genkey{
                for ($i=0;$i<count($this->intg_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;$i<strlen($sha1_hmac_raw);$i++){
                        $this->sha1hmac[$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