Skip to content

Commit 598f003

Browse files
committed
RSA: raw keys didn't load correctly
1 parent f8d3f14 commit 598f003

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/Crypt/RSA.php

+9
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@
6161
use phpseclib3\Exception\NoKeyLoadedException;
6262
use phpseclib3\Crypt\Common\Formats\Keys\PuTTY;
6363
use phpseclib3\Crypt\Common\Formats\Keys\OpenSSH;
64+
use phpseclib3\Math\BigInteger;
65+
use phpseclib\Math\BigInteger as BigInteger2;
6466

6567
/**
6668
* Pure-PHP PKCS#1 compliant implementation of RSA.
@@ -385,6 +387,13 @@ public function loadKey($key)
385387
$this->key = $key->key;
386388
} else {
387389
try {
390+
if (is_array($key)) {
391+
foreach ($key as &$value) {
392+
if ($value instanceof BigInteger2) {
393+
$value = new BigInteger($value->toBytes(true), -256);
394+
}
395+
}
396+
}
388397
$this->key = PublicKeyLoader::load($key, $this->password);
389398
} catch (NoKeyLoadedException $e) {
390399
$this->key = $this->origKey = null;

0 commit comments

Comments
 (0)