EC / DSA: useBestEngine() needs to be called in getEngine()

This commit is contained in:
terrafrost 2022-03-20 13:52:00 -05:00
parent 301aad4764
commit 9a1e1caa90
2 changed files with 6 additions and 0 deletions

View File

@ -292,6 +292,9 @@ abstract class DSA extends AsymmetricKey
*/
public function getEngine()
{
if (!isset(self::$engines['PHP'])) {
self::useBestEngine();
}
return self::$engines['OpenSSL'] && in_array($this->hash->getHash(), openssl_get_md_methods()) ?
'OpenSSL' : 'PHP';
}

View File

@ -323,6 +323,9 @@ abstract class EC extends AsymmetricKey
*/
public function getEngine()
{
if (!isset(self::$engines['PHP'])) {
self::useBestEngine();
}
if ($this->curve instanceof TwistedEdwardsCurve) {
return $this->curve instanceof Ed25519 && self::$engines['libsodium'] && !isset($this->context) ?
'libsodium' : 'PHP';