mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-11-16 02:07:09 +00:00
Merge branch '3.0'
This commit is contained in:
commit
abb4fc8bc8
@ -202,7 +202,7 @@ abstract class OpenSSH
|
|||||||
*/
|
*/
|
||||||
protected static function wrapPrivateKey($publicKey, $privateKey, $password, $options)
|
protected static function wrapPrivateKey($publicKey, $privateKey, $password, $options)
|
||||||
{
|
{
|
||||||
if (!empty($password) || is_string($password)) {
|
if (!empty($password) && is_string($password)) {
|
||||||
throw new UnsupportedFormatException('Encrypted OpenSSH private keys are not supported');
|
throw new UnsupportedFormatException('Encrypted OpenSSH private keys are not supported');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ use phpseclib3\Crypt\EC\Curves\Curve448;
|
|||||||
use phpseclib3\Crypt\EC\BaseCurves\Montgomery as MontgomeryCurve;
|
use phpseclib3\Crypt\EC\BaseCurves\Montgomery as MontgomeryCurve;
|
||||||
use phpseclib3\Math\Common\FiniteField\Integer;
|
use phpseclib3\Math\Common\FiniteField\Integer;
|
||||||
use phpseclib3\Math\BigInteger;
|
use phpseclib3\Math\BigInteger;
|
||||||
|
use phpseclib3\Exception\UnsupportedFormatException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Montgomery Curve Private Key Handler
|
* Montgomery Curve Private Key Handler
|
||||||
@ -98,6 +99,10 @@ abstract class MontgomeryPrivate
|
|||||||
*/
|
*/
|
||||||
public static function savePrivateKey(Integer $privateKey, MontgomeryCurve $curve, array $publicKey, $password = '')
|
public static function savePrivateKey(Integer $privateKey, MontgomeryCurve $curve, array $publicKey, $password = '')
|
||||||
{
|
{
|
||||||
|
if (!empty($password) && is_string($password)) {
|
||||||
|
throw new UnsupportedFormatException('MontgomeryPrivate private keys do not support encryption');
|
||||||
|
}
|
||||||
|
|
||||||
return $privateKey->toBytes();
|
return $privateKey->toBytes();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ namespace phpseclib3\Crypt\EC\Formats\Keys;
|
|||||||
|
|
||||||
use phpseclib3\Crypt\EC\Curves\Ed25519;
|
use phpseclib3\Crypt\EC\Curves\Ed25519;
|
||||||
use phpseclib3\Math\Common\FiniteField\Integer;
|
use phpseclib3\Math\Common\FiniteField\Integer;
|
||||||
|
use phpseclib3\Exception\UnsupportedFormatException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* libsodium Key Handler
|
* libsodium Key Handler
|
||||||
@ -113,6 +114,9 @@ abstract class libsodium
|
|||||||
if (strlen($privateKey->secret) != 32) {
|
if (strlen($privateKey->secret) != 32) {
|
||||||
throw new \RuntimeException('Private Key secret is not of the correct length');
|
throw new \RuntimeException('Private Key secret is not of the correct length');
|
||||||
}
|
}
|
||||||
|
if (!empty($password) && is_string($password)) {
|
||||||
|
throw new UnsupportedFormatException('libsodium private keys do not support encryption');
|
||||||
|
}
|
||||||
return $privateKey->secret . $curve->encodePoint($publicKey);
|
return $privateKey->secret . $curve->encodePoint($publicKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ namespace phpseclib3\Crypt\RSA\Formats\Keys;
|
|||||||
use ParagonIE\ConstantTime\Base64;
|
use ParagonIE\ConstantTime\Base64;
|
||||||
use phpseclib3\Math\BigInteger;
|
use phpseclib3\Math\BigInteger;
|
||||||
use phpseclib3\Common\Functions\Strings;
|
use phpseclib3\Common\Functions\Strings;
|
||||||
|
use phpseclib3\Exception\UnsupportedFormatException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Microsoft BLOB Formatted RSA Key Handler
|
* Microsoft BLOB Formatted RSA Key Handler
|
||||||
@ -191,6 +192,10 @@ abstract class MSBLOB
|
|||||||
throw new \InvalidArgumentException('MSBLOB does not support multi-prime RSA keys');
|
throw new \InvalidArgumentException('MSBLOB does not support multi-prime RSA keys');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($password) && is_string($password)) {
|
||||||
|
throw new UnsupportedFormatException('MSBLOB private keys do not support encryption');
|
||||||
|
}
|
||||||
|
|
||||||
$n = strrev($n->toBytes());
|
$n = strrev($n->toBytes());
|
||||||
$e = str_pad(strrev($e->toBytes()), 4, "\0");
|
$e = str_pad(strrev($e->toBytes()), 4, "\0");
|
||||||
$key = pack('aavV', chr(self::PRIVATEKEYBLOB), chr(2), 0, self::CALG_RSA_KEYX);
|
$key = pack('aavV', chr(self::PRIVATEKEYBLOB), chr(2), 0, self::CALG_RSA_KEYX);
|
||||||
|
@ -24,6 +24,7 @@ namespace phpseclib3\Crypt\RSA\Formats\Keys;
|
|||||||
|
|
||||||
use ParagonIE\ConstantTime\Base64;
|
use ParagonIE\ConstantTime\Base64;
|
||||||
use phpseclib3\Math\BigInteger;
|
use phpseclib3\Math\BigInteger;
|
||||||
|
use phpseclib3\Exception\UnsupportedFormatException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* XML Formatted RSA Key Handler
|
* XML Formatted RSA Key Handler
|
||||||
@ -136,6 +137,11 @@ abstract class XML
|
|||||||
if (count($primes) != 2) {
|
if (count($primes) != 2) {
|
||||||
throw new \InvalidArgumentException('XML does not support multi-prime RSA keys');
|
throw new \InvalidArgumentException('XML does not support multi-prime RSA keys');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($password) && is_string($password)) {
|
||||||
|
throw new UnsupportedFormatException('XML private keys do not support encryption');
|
||||||
|
}
|
||||||
|
|
||||||
return "<RSAKeyPair>\r\n" .
|
return "<RSAKeyPair>\r\n" .
|
||||||
' <Modulus>' . Base64::encode($n->toBytes()) . "</Modulus>\r\n" .
|
' <Modulus>' . Base64::encode($n->toBytes()) . "</Modulus>\r\n" .
|
||||||
' <Exponent>' . Base64::encode($e->toBytes()) . "</Exponent>\r\n" .
|
' <Exponent>' . Base64::encode($e->toBytes()) . "</Exponent>\r\n" .
|
||||||
|
Loading…
Reference in New Issue
Block a user