mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-12-27 11:52:48 +00:00
Merge branch '3.0'
This commit is contained in:
commit
5babbd028c
@ -294,8 +294,11 @@ class Integer extends Base
|
||||
*/
|
||||
public function toBytes(): string
|
||||
{
|
||||
$length = static::$modulo[$this->instanceID]->getLengthInBytes();
|
||||
return str_pad($this->value->toBytes(), $length, "\0", STR_PAD_LEFT);
|
||||
if (isset(static::$modulo[$this->instanceID])) {
|
||||
$length = static::$modulo[$this->instanceID]->getLengthInBytes();
|
||||
return str_pad($this->value->toBytes(), $length, "\0", STR_PAD_LEFT);
|
||||
}
|
||||
return $this->value->toBytes();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -22,4 +22,21 @@ class PrimeFieldTest extends PhpseclibTestCase
|
||||
|
||||
echo $num2->squareRoot();
|
||||
}
|
||||
|
||||
/**
|
||||
* @group github1929
|
||||
*/
|
||||
public function testGarbageCollectedToBytes()
|
||||
{
|
||||
$blob = base64_decode('BFgsTFQeqKr0toyURbtT43INMDS7FTHjz3yn3MR1/Yv/pb2b9ZCYNQ/Tafe5hQpEJ4TpZOKfikP/hWZvFL8QCPgqbIGqw/KTfA==');
|
||||
$public = "\0" . substr($blob, 0, 49);
|
||||
$private = substr($blob, -24);
|
||||
|
||||
$point = \phpseclib3\Crypt\EC\Formats\Keys\PKCS1::extractPoint(
|
||||
$public,
|
||||
new \phpseclib3\Crypt\EC\Curves\secp192r1()
|
||||
);
|
||||
|
||||
$this->assertIsString($point[0]->toBytes());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user