diff --git a/phpseclib/Crypt/DSA.php b/phpseclib/Crypt/DSA.php index 1d38ed27..ac52bc47 100644 --- a/phpseclib/Crypt/DSA.php +++ b/phpseclib/Crypt/DSA.php @@ -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'; } diff --git a/phpseclib/Crypt/EC.php b/phpseclib/Crypt/EC.php index 6709d54c..736c6148 100644 --- a/phpseclib/Crypt/EC.php +++ b/phpseclib/Crypt/EC.php @@ -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';