Skip to content

Commit

Permalink
RSA: raw keys didn't load correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
terrafrost committed Feb 2, 2021
1 parent f8d3f14 commit 598f003
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Crypt/RSA.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
use phpseclib3\Exception\NoKeyLoadedException;
use phpseclib3\Crypt\Common\Formats\Keys\PuTTY;
use phpseclib3\Crypt\Common\Formats\Keys\OpenSSH;
use phpseclib3\Math\BigInteger;
use phpseclib\Math\BigInteger as BigInteger2;

/**
* Pure-PHP PKCS#1 compliant implementation of RSA.
Expand Down Expand Up @@ -385,6 +387,13 @@ public function loadKey($key)
$this->key = $key->key;
} else {
try {
if (is_array($key)) {
foreach ($key as &$value) {
if ($value instanceof BigInteger2) {
$value = new BigInteger($value->toBytes(true), -256);
}
}
}
$this->key = PublicKeyLoader::load($key, $this->password);
} catch (NoKeyLoadedException $e) {
$this->key = $this->origKey = null;
Expand Down

1 comment on commit 598f003

@terrafrost
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #3

Please sign in to comment.