SSH2: get binary output from OpenSSH key handler

This commit is contained in:
terrafrost 2019-05-21 09:10:18 -05:00
parent e06f733528
commit 85e2bd4811
2 changed files with 9 additions and 1 deletions

View File

@ -192,6 +192,11 @@ abstract class OpenSSH extends Progenitor
{
if ($curve instanceof Ed25519) {
$key = Strings::packSSH2('ss', 'ssh-ed25519', $curve->encodePoint($publicKey));
if (self::$binary) {
return $key;
}
$key = 'ssh-ed25519 ' . Base64::encode($key) . ' ' . self::$comment;
return $key;
}

View File

@ -68,6 +68,7 @@ use phpseclib\Exception\NoSupportedAlgorithmsException;
use phpseclib\Exception\UnsupportedAlgorithmException;
use phpseclib\Exception\UnsupportedCurveException;
use phpseclib\Common\Functions\Strings;
use phpseclib\Crypt\Common\Keys\OpenSSH;
/**
* 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');
}
$status = OpenSSH::getBinaryOutput();
OpenSSH::setBinaryOutput(true);
$publickeyStr = $publickey->toString('OpenSSH');
$publickeyStr = base64_decode(preg_replace('#(^.*? )|( .*?)$#', '', $publickeyStr));
OpenSSH::setBinaryOutput($status);
$part1 = Strings::packSSH2(
'Csss',