From 9a1e1caa90b4d11ce40e773343ecd3fc5f475d01 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sun, 20 Mar 2022 13:52:00 -0500 Subject: [PATCH] EC / DSA: useBestEngine() needs to be called in getEngine() --- phpseclib/Crypt/DSA.php | 3 +++ phpseclib/Crypt/EC.php | 3 +++ 2 files changed, 6 insertions(+) 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';