From 224abbc1f9b8fc8df891f81102adcb112fdf56a5 Mon Sep 17 00:00:00 2001 From: Bastien Miclo Date: Wed, 23 Dec 2020 10:37:05 +0100 Subject: [PATCH] Show array-failure in load() method --- phpseclib/Crypt/PublicKeyLoader.php | 2 +- tests/Unit/Crypt/RSA/LoadKeyTest.php | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/phpseclib/Crypt/PublicKeyLoader.php b/phpseclib/Crypt/PublicKeyLoader.php index f718d1f5..db4abf7c 100644 --- a/phpseclib/Crypt/PublicKeyLoader.php +++ b/phpseclib/Crypt/PublicKeyLoader.php @@ -33,7 +33,7 @@ abstract class PublicKeyLoader * * @return AsymmetricKey * @access public - * @param string $key + * @param string|array $key * @param string $password optional */ public static function load($key, $password = false) diff --git a/tests/Unit/Crypt/RSA/LoadKeyTest.php b/tests/Unit/Crypt/RSA/LoadKeyTest.php index 9105e484..8b20ebe0 100644 --- a/tests/Unit/Crypt/RSA/LoadKeyTest.php +++ b/tests/Unit/Crypt/RSA/LoadKeyTest.php @@ -34,6 +34,17 @@ class Unit_Crypt_RSA_LoadKeyTest extends PhpseclibTestCase PublicKeyLoader::load($key); } + public function testLoadModulusAndExponent() + { + $rsa = PublicKeyLoader::load([ + 'e' => new BigInteger('123', 16), + 'n' => new BigInteger('123', 16) + ]); + + $this->assertInstanceOf(PublicKey::class, $rsa); + $this->assertIsString("$rsa"); + } + public function testPKCS1Key() { $key = '-----BEGIN RSA PRIVATE KEY-----