1
0
mirror of https://github.com/danog/tgseclib.git synced 2024-11-30 04:39:02 +01:00

Merge branch '1.0' into 2.0

This commit is contained in:
terrafrost 2016-06-04 22:56:49 -05:00
commit 87040bc518
2 changed files with 29 additions and 2 deletions

View File

@ -2085,8 +2085,14 @@ class RSA
*/
function _exponentiate($x)
{
if (empty($this->primes) || empty($this->coefficients) || empty($this->exponents)) {
return $x->modPow($this->exponent, $this->modulus);
switch (true) {
case empty($this->primes):
case $this->primes[1]->equals($this->zero):
case empty($this->coefficients):
case $this->coefficients[2]->equals($this->zero):
case empty($this->exponents):
case $this->exponents[1]->equals($this->zero):
return $x->modPow($this->exponent, $this->modulus);
}
$num_primes = count($this->primes);

View File

@ -380,4 +380,25 @@ Private-MAC: 35134b7434bf828b21404099861d455e660e8740';
$rsa->setPrivateKey();
$rsa->loadKey($rsa);
}
/**
* @group github980
*/
public function testZeroComponents()
{
$key = '-----BEGIN RSA PRIVATE KEY-----
MIGaAgEAAkEAt5yrcHAAjhglnCEn6yecMWPeUXcMyo0+itXrLlkpcKIIyqPw546b
GThhlb1ppX1ySX/OUA4jSakHekNP5eWPawIBAAJAW6/aVD05qbsZHMvZuS2Aa5Fp
NNj0BDlf38hOtkhDzz/hkYb+EBYLLvldhgsD0OvRNy8yhz7EjaUqLCB0juIN4QIB
AAIBAAIBAAIBAAIBAA==
-----END RSA PRIVATE KEY-----';
$rsa = new Crypt_RSA();
$rsa->loadKey($key);
$rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);
$rsa->setHash('md5');
$rsa->setMGFHash('md5');
$rsa->sign('zzzz');
}
}