mirror of
https://github.com/danog/tgseclib.git
synced 2024-11-27 12:44:38 +01:00
_mgf1() shouldn't be using $this->hLen
git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@69 21d32557-59b3-4da0-833f-c5933fad653e
This commit is contained in:
parent
315dec9dc5
commit
8379f46a77
@ -62,7 +62,7 @@
|
|||||||
* @author Jim Wigginton <terrafrost@php.net>
|
* @author Jim Wigginton <terrafrost@php.net>
|
||||||
* @copyright MMIX Jim Wigginton
|
* @copyright MMIX Jim Wigginton
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt
|
* @license http://www.gnu.org/licenses/lgpl.txt
|
||||||
* @version $Id: RSA.php,v 1.5 2009-12-07 23:22:05 terrafrost Exp $
|
* @version $Id: RSA.php,v 1.6 2009-12-08 14:18:59 terrafrost Exp $
|
||||||
* @link http://phpseclib.sourceforge.net
|
* @link http://phpseclib.sourceforge.net
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -332,6 +332,14 @@ class Crypt_RSA {
|
|||||||
*/
|
*/
|
||||||
var $mgfHash;
|
var $mgfHash;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Length of MGF hash function output
|
||||||
|
*
|
||||||
|
* @var Integer
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
var $mgfHLen;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encryption mode
|
* Encryption mode
|
||||||
*
|
*
|
||||||
@ -1075,14 +1083,13 @@ class Crypt_RSA {
|
|||||||
case 'sha384':
|
case 'sha384':
|
||||||
case 'sha512':
|
case 'sha512':
|
||||||
$this->hash = new Crypt_Hash($hash);
|
$this->hash = new Crypt_Hash($hash);
|
||||||
$this->hLen = $this->hash->getLength();
|
|
||||||
$this->hashName = $hash;
|
$this->hashName = $hash;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->hash = new Crypt_Hash('sha1');
|
$this->hash = new Crypt_Hash('sha1');
|
||||||
$this->hLen = $this->hash->getLength();
|
|
||||||
$this->hashName = 'sha1';
|
$this->hashName = 'sha1';
|
||||||
}
|
}
|
||||||
|
$this->hLen = $this->hash->getLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1109,6 +1116,7 @@ class Crypt_RSA {
|
|||||||
default:
|
default:
|
||||||
$this->mgfHash = new Crypt_Hash('sha1');
|
$this->mgfHash = new Crypt_Hash('sha1');
|
||||||
}
|
}
|
||||||
|
$this->mgfHLen = $this->mgfHash->getLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1302,7 +1310,7 @@ class Crypt_RSA {
|
|||||||
/**
|
/**
|
||||||
* MGF1
|
* MGF1
|
||||||
*
|
*
|
||||||
* See {@link http://tools.ietf.org/html/rfc3447#section-B.2.1 RFC3447#section-B.2.1}.
|
* See {@link http://tools.ietf.org/html/rfc3447#appendix-B.2.1 RFC3447#appendix-B.2.1}.
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param String $mgfSeed
|
* @param String $mgfSeed
|
||||||
@ -1314,7 +1322,7 @@ class Crypt_RSA {
|
|||||||
// if $maskLen would yield strings larger than 4GB, PKCS#1 suggests a "Mask too long" error be output.
|
// if $maskLen would yield strings larger than 4GB, PKCS#1 suggests a "Mask too long" error be output.
|
||||||
|
|
||||||
$t = '';
|
$t = '';
|
||||||
$count = ceil($maskLen / $this->hLen);
|
$count = ceil($maskLen / $this->mgfHLen);
|
||||||
for ($i = 0; $i < $count; $i++) {
|
for ($i = 0; $i < $count; $i++) {
|
||||||
$c = pack('N', $i);
|
$c = pack('N', $i);
|
||||||
$t.= $this->mgfHash->hash($mgfSeed . $c);
|
$t.= $this->mgfHash->hash($mgfSeed . $c);
|
||||||
|
Loading…
Reference in New Issue
Block a user