mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-11-14 17:34:07 +00:00
Merge branch '3.0'
This commit is contained in:
commit
30eeb49583
@ -106,7 +106,7 @@ class PrivateKey extends EC implements Common\PrivateKey
|
|||||||
|
|
||||||
if ($this->curve instanceof TwistedEdwardsCurve) {
|
if ($this->curve instanceof TwistedEdwardsCurve) {
|
||||||
if ($this->curve instanceof Ed25519 && self::$engines['libsodium'] && !isset($this->context)) {
|
if ($this->curve instanceof Ed25519 && self::$engines['libsodium'] && !isset($this->context)) {
|
||||||
$result = sodium_crypto_sign_detached($message, $this->toString('libsodium'));
|
$result = sodium_crypto_sign_detached($message, $this->withPassword()->toString('libsodium'));
|
||||||
return $shortFormat == 'SSH2' ? Strings::packSSH2('ss', 'ssh-' . strtolower($this->getCurve()), $result) : $result;
|
return $shortFormat == 'SSH2' ? Strings::packSSH2('ss', 'ssh-' . strtolower($this->getCurve()), $result) : $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,6 +190,19 @@ class Unit_Crypt_EC_CurveTest extends PhpseclibTestCase
|
|||||||
$this->assertTrue($publickey->verify($plaintext, $sig));
|
$this->assertTrue($publickey->verify($plaintext, $sig));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testCanSignWithAnEncryptedPrivateKey()
|
||||||
|
{
|
||||||
|
EC::useBestEngine();
|
||||||
|
|
||||||
|
$plaintext = 'zzz';
|
||||||
|
|
||||||
|
$privatekey = EC::createKey('Ed25519')->withPassword('foo');
|
||||||
|
$publickey = $privatekey->getPublicKey();
|
||||||
|
$sig = $privatekey->sign($plaintext);
|
||||||
|
|
||||||
|
$this->assertTrue($publickey->verify($plaintext, $sig));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sign with best engine, verify with internal engine
|
* Sign with best engine, verify with internal engine
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user