mirror of
https://github.com/danog/phpseclib.git
synced 2024-12-15 02:17:04 +01:00
Merge branch '3.0'
This commit is contained in:
commit
d8dabdf7bc
@ -20,6 +20,7 @@ namespace phpseclib3\Crypt\Common\Formats\Keys;
|
||||
use ParagonIE\ConstantTime\Base64;
|
||||
use phpseclib3\Common\Functions\Strings;
|
||||
use phpseclib3\Crypt\Random;
|
||||
use phpseclib3\Exception\UnsupportedFormatException;
|
||||
|
||||
/**
|
||||
* OpenSSH Formatted RSA Key Handler
|
||||
@ -195,10 +196,16 @@ abstract class OpenSSH
|
||||
* @access public
|
||||
* @param string $publicKey
|
||||
* @param string $privateKey
|
||||
* @param string $password
|
||||
* @param array $options
|
||||
* @return string
|
||||
*/
|
||||
protected static function wrapPrivateKey($publicKey, $privateKey, $options)
|
||||
protected static function wrapPrivateKey($publicKey, $privateKey, $password, $options)
|
||||
{
|
||||
if (!empty($password) || is_string($password)) {
|
||||
throw new UnsupportedFormatException('Encrypted OpenSSH private keys are not supported');
|
||||
}
|
||||
|
||||
list(, $checkint) = unpack('N', Random::string(4));
|
||||
|
||||
$comment = isset($options['comment']) ? $options['comment'] : self::$comment;
|
||||
|
@ -121,6 +121,6 @@ abstract class OpenSSH extends Progenitor
|
||||
$publicKey = self::savePublicKey($p, $q, $g, $y, ['binary' => true]);
|
||||
$privateKey = Strings::packSSH2('si5', 'ssh-dss', $p, $q, $g, $y, $x);
|
||||
|
||||
return self::wrapPrivateKey($publicKey, $privateKey, $options);
|
||||
return self::wrapPrivateKey($publicKey, $privateKey, $password, $options);
|
||||
}
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ abstract class OpenSSH extends Progenitor
|
||||
$publicKey = Strings::packSSH2('ss', 'ssh-ed25519', $pubKey);
|
||||
$privateKey = Strings::packSSH2('sss', 'ssh-ed25519', $pubKey, $privateKey->secret . $pubKey);
|
||||
|
||||
return self::wrapPrivateKey($publicKey, $privateKey, $options);
|
||||
return self::wrapPrivateKey($publicKey, $privateKey, $password, $options);
|
||||
}
|
||||
|
||||
$alias = self::getAlias($curve);
|
||||
@ -211,6 +211,6 @@ abstract class OpenSSH extends Progenitor
|
||||
|
||||
$privateKey = Strings::packSSH2('sssi', 'ecdsa-sha2-' . $alias, $alias, $points, $privateKey);
|
||||
|
||||
return self::wrapPrivateKey($publicKey, $privateKey, $options);
|
||||
return self::wrapPrivateKey($publicKey, $privateKey, $password, $options);
|
||||
}
|
||||
}
|
||||
|
@ -135,6 +135,6 @@ abstract class OpenSSH extends Progenitor
|
||||
$publicKey = self::savePublicKey($n, $e, ['binary' => true]);
|
||||
$privateKey = Strings::packSSH2('si6', 'ssh-rsa', $n, $e, $d, $coefficients[2], $primes[1], $primes[2]);
|
||||
|
||||
return self::wrapPrivateKey($publicKey, $privateKey, $options);
|
||||
return self::wrapPrivateKey($publicKey, $privateKey, $password, $options);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user