mirror of
https://github.com/phpseclib/phpseclib.git
synced 2025-01-28 09:38:33 +00:00
SSH2: get binary output from OpenSSH key handler
This commit is contained in:
parent
e06f733528
commit
85e2bd4811
@ -192,6 +192,11 @@ abstract class OpenSSH extends Progenitor
|
|||||||
{
|
{
|
||||||
if ($curve instanceof Ed25519) {
|
if ($curve instanceof Ed25519) {
|
||||||
$key = Strings::packSSH2('ss', 'ssh-ed25519', $curve->encodePoint($publicKey));
|
$key = Strings::packSSH2('ss', 'ssh-ed25519', $curve->encodePoint($publicKey));
|
||||||
|
|
||||||
|
if (self::$binary) {
|
||||||
|
return $key;
|
||||||
|
}
|
||||||
|
|
||||||
$key = 'ssh-ed25519 ' . Base64::encode($key) . ' ' . self::$comment;
|
$key = 'ssh-ed25519 ' . Base64::encode($key) . ' ' . self::$comment;
|
||||||
return $key;
|
return $key;
|
||||||
}
|
}
|
||||||
|
@ -68,6 +68,7 @@ use phpseclib\Exception\NoSupportedAlgorithmsException;
|
|||||||
use phpseclib\Exception\UnsupportedAlgorithmException;
|
use phpseclib\Exception\UnsupportedAlgorithmException;
|
||||||
use phpseclib\Exception\UnsupportedCurveException;
|
use phpseclib\Exception\UnsupportedCurveException;
|
||||||
use phpseclib\Common\Functions\Strings;
|
use phpseclib\Common\Functions\Strings;
|
||||||
|
use phpseclib\Crypt\Common\Keys\OpenSSH;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pure-PHP implementation of SSHv2.
|
* Pure-PHP implementation of SSHv2.
|
||||||
@ -2446,8 +2447,10 @@ class SSH2
|
|||||||
throw new UnsupportedAlgorithmException('Please use either an RSA key, an ECDSA one or a DSA key');
|
throw new UnsupportedAlgorithmException('Please use either an RSA key, an ECDSA one or a DSA key');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$status = OpenSSH::getBinaryOutput();
|
||||||
|
OpenSSH::setBinaryOutput(true);
|
||||||
$publickeyStr = $publickey->toString('OpenSSH');
|
$publickeyStr = $publickey->toString('OpenSSH');
|
||||||
$publickeyStr = base64_decode(preg_replace('#(^.*? )|( .*?)$#', '', $publickeyStr));
|
OpenSSH::setBinaryOutput($status);
|
||||||
|
|
||||||
$part1 = Strings::packSSH2(
|
$part1 = Strings::packSSH2(
|
||||||
'Csss',
|
'Csss',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user