mirror of
https://github.com/danog/tgseclib.git
synced 2025-01-22 05:51:20 +01:00
use array type hint
This commit is contained in:
parent
8e03f5bfb2
commit
557676edd9
@ -182,7 +182,7 @@ abstract class PKCS1 extends PKCS
|
||||
* @param array $options optional
|
||||
* @return string
|
||||
*/
|
||||
protected static function wrapPrivateKey($key, $type, $password, $options = [])
|
||||
protected static function wrapPrivateKey($key, $type, $password, array $options = [])
|
||||
{
|
||||
if (empty($password) || !is_string($password)) {
|
||||
return "-----BEGIN $type PRIVATE KEY-----\r\n" .
|
||||
|
@ -529,7 +529,7 @@ abstract class PKCS8 extends PKCS
|
||||
* @param array $options optional
|
||||
* @return string
|
||||
*/
|
||||
protected static function wrapPrivateKey($key, $attr, $params, $password, $oid = null, $publicKey = '', $options = [])
|
||||
protected static function wrapPrivateKey($key, $attr, $params, $password, $oid = null, $publicKey = '', array $options = [])
|
||||
{
|
||||
self::initialize_static_variables();
|
||||
|
||||
|
@ -175,7 +175,7 @@ abstract class PuTTY
|
||||
* @param array $options optional
|
||||
* @return string
|
||||
*/
|
||||
protected static function wrapPrivateKey($public, $private, $type, $password, $options = [])
|
||||
protected static function wrapPrivateKey($public, $private, $type, $password, array $options = [])
|
||||
{
|
||||
$key = "PuTTY-User-Key-File-2: " . $type . "\r\nEncryption: ";
|
||||
$encryption = (!empty($password) || is_string($password)) ? 'aes256-cbc' : 'none';
|
||||
|
@ -25,6 +25,6 @@ interface PrivateKey
|
||||
public function sign($message);
|
||||
//public function decrypt($ciphertext);
|
||||
public function getPublicKey();
|
||||
public function toString($type);
|
||||
public function toString($type, array $options = []);
|
||||
public function withPassword($string);
|
||||
}
|
||||
|
@ -24,6 +24,6 @@ interface PublicKey
|
||||
{
|
||||
public function verify($message, $signature);
|
||||
//public function encrypt($plaintext);
|
||||
public function toString($type);
|
||||
public function toString($type, array $options = []);
|
||||
public function getFingerprint($algorithm);
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ abstract class OpenSSH extends Progenitor
|
||||
* @param array $options optional
|
||||
* @return string
|
||||
*/
|
||||
public static function savePublicKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y, $options = [])
|
||||
public static function savePublicKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y, array $options = [])
|
||||
{
|
||||
if ($q->getLength() != 160) {
|
||||
throw new \InvalidArgumentException('SSH only supports keys with an N (length of Group Order q) of 160');
|
||||
|
@ -116,7 +116,7 @@ abstract class PKCS1 extends Progenitor
|
||||
* @param array $options optional
|
||||
* @return string
|
||||
*/
|
||||
public static function savePrivateKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y, BigInteger $x, $password = '', $options = [])
|
||||
public static function savePrivateKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y, BigInteger $x, $password = '', array $options = [])
|
||||
{
|
||||
$key = [
|
||||
'version' => 0,
|
||||
|
@ -130,7 +130,7 @@ abstract class PKCS8 extends Progenitor
|
||||
* @param array $options optional
|
||||
* @return string
|
||||
*/
|
||||
public static function savePrivateKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y, BigInteger $x, $password = '', $options = [])
|
||||
public static function savePrivateKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y, BigInteger $x, $password = '', array $options = [])
|
||||
{
|
||||
$params = [
|
||||
'p' => $p,
|
||||
@ -154,7 +154,7 @@ abstract class PKCS8 extends Progenitor
|
||||
* @param array $options optional
|
||||
* @return string
|
||||
*/
|
||||
public static function savePublicKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y, $options = [])
|
||||
public static function savePublicKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y, array $options = [])
|
||||
{
|
||||
$params = [
|
||||
'p' => $p,
|
||||
|
@ -94,7 +94,7 @@ abstract class PuTTY extends Progenitor
|
||||
* @param array $options optional
|
||||
* @return string
|
||||
*/
|
||||
public static function savePrivateKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y, BigInteger $x, $password = false, $options = [])
|
||||
public static function savePrivateKey(BigInteger $p, BigInteger $q, BigInteger $g, BigInteger $y, BigInteger $x, $password = false, array $options = [])
|
||||
{
|
||||
if ($q->getLength() != 160) {
|
||||
throw new \InvalidArgumentException('SSH only supports keys with an N (length of Group Order q) of 160');
|
||||
|
@ -31,7 +31,7 @@ class Parameters extends DSA
|
||||
* @param array $options optional
|
||||
* @return string
|
||||
*/
|
||||
public function toString($type = 'PKCS1', $options = [])
|
||||
public function toString($type = 'PKCS1', array $options = [])
|
||||
{
|
||||
$type = self::validatePlugin('Keys', 'PKCS1', 'saveParameters');
|
||||
|
||||
|
@ -147,7 +147,7 @@ class PrivateKey extends DSA implements Common\PrivateKey
|
||||
* @param array $options optional
|
||||
* @return string
|
||||
*/
|
||||
public function toString($type, $options = [])
|
||||
public function toString($type, array $options = [])
|
||||
{
|
||||
$type = self::validatePlugin('Keys', $type, 'savePrivateKey');
|
||||
|
||||
|
@ -83,7 +83,7 @@ class PublicKey extends DSA implements Common\PublicKey
|
||||
* @param array $options optional
|
||||
* @return string
|
||||
*/
|
||||
public function toString($type, $options = [])
|
||||
public function toString($type, array $options = [])
|
||||
{
|
||||
$type = self::validatePlugin('Keys', $type, 'savePublicKey');
|
||||
|
||||
|
@ -189,7 +189,7 @@ abstract class OpenSSH extends Progenitor
|
||||
* @param array $options optional
|
||||
* @return string
|
||||
*/
|
||||
public static function savePublicKey(BaseCurve $curve, array $publicKey, $options = [])
|
||||
public static function savePublicKey(BaseCurve $curve, array $publicKey, array $options = [])
|
||||
{
|
||||
$comment = isset($options['comment']) ? $options['comment'] : self::$comment;
|
||||
|
||||
|
@ -118,7 +118,7 @@ abstract class PKCS1 extends Progenitor
|
||||
* @param array $options optional
|
||||
* @return string
|
||||
*/
|
||||
public static function savePrivateKey(Integer $privateKey, BaseCurve $curve, array $publicKey, $password = '', $options = [])
|
||||
public static function savePrivateKey(Integer $privateKey, BaseCurve $curve, array $publicKey, $password = '', array $options = [])
|
||||
{
|
||||
self::initialize_static_variables();
|
||||
|
||||
|
@ -201,7 +201,7 @@ abstract class PKCS8 extends Progenitor
|
||||
* @param array $options optional
|
||||
* @return string
|
||||
*/
|
||||
public static function savePrivateKey(Integer $privateKey, BaseCurve $curve, array $publicKey, $password = '', $options = [])
|
||||
public static function savePrivateKey(Integer $privateKey, BaseCurve $curve, array $publicKey, $password = '', array $options = [])
|
||||
{
|
||||
self::initialize_static_variables();
|
||||
|
||||
|
@ -99,7 +99,7 @@ abstract class PuTTY extends Progenitor
|
||||
* @param array $options optional
|
||||
* @return string
|
||||
*/
|
||||
public static function savePrivateKey(Integer $privateKey, BaseCurve $curve, array $publicKey, $password = false, $options = [])
|
||||
public static function savePrivateKey(Integer $privateKey, BaseCurve $curve, array $publicKey, $password = false, array $options = [])
|
||||
{
|
||||
self::initialize_static_variables();
|
||||
|
||||
|
@ -31,7 +31,7 @@ class Parameters extends ECDSA
|
||||
* @param array $options optional
|
||||
* @return string
|
||||
*/
|
||||
public function toString($type = 'PKCS1', $options = [])
|
||||
public function toString($type = 'PKCS1', array $options = [])
|
||||
{
|
||||
$type = self::validatePlugin('Keys', 'PKCS1', 'saveParameters');
|
||||
|
||||
|
@ -185,7 +185,7 @@ class PrivateKey extends ECDSA implements Common\PrivateKey
|
||||
* @param array $options optional
|
||||
* @return string
|
||||
*/
|
||||
public function toString($type, $options = [])
|
||||
public function toString($type, array $options = [])
|
||||
{
|
||||
$type = self::validatePlugin('Keys', $type, 'savePrivateKey');
|
||||
|
||||
|
@ -162,7 +162,7 @@ class PublicKey extends ECDSA implements Common\PublicKey
|
||||
* @param array $options optional
|
||||
* @return string
|
||||
*/
|
||||
public function toString($type, $options = [])
|
||||
public function toString($type, array $options = [])
|
||||
{
|
||||
$type = self::validatePlugin('Keys', $type, 'savePublicKey');
|
||||
|
||||
|
@ -185,7 +185,7 @@ abstract class MSBLOB
|
||||
* @param string $password optional
|
||||
* @return string
|
||||
*/
|
||||
public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, $primes, $exponents, $coefficients, $password = '')
|
||||
public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, $password = '')
|
||||
{
|
||||
if (count($primes) != 2) {
|
||||
throw new \InvalidArgumentException('MSBLOB does not support multi-prime RSA keys');
|
||||
|
@ -66,7 +66,7 @@ abstract class OpenSSH extends Progenitor
|
||||
* @param array $options optional
|
||||
* @return string
|
||||
*/
|
||||
public static function savePublicKey(BigInteger $n, BigInteger $e, $options = [])
|
||||
public static function savePublicKey(BigInteger $n, BigInteger $e, array $options = [])
|
||||
{
|
||||
$RSAPublicKey = Strings::packSSH2('sii', 'ssh-rsa', $e, $n);
|
||||
|
||||
|
@ -104,7 +104,7 @@ abstract class PKCS1 extends Progenitor
|
||||
* @param array $options optional
|
||||
* @return string
|
||||
*/
|
||||
public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, $primes, $exponents, $coefficients, $password = '', $options = [])
|
||||
public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, $password = '', array $options = [])
|
||||
{
|
||||
$num_primes = count($primes);
|
||||
$key = [
|
||||
|
@ -107,7 +107,7 @@ abstract class PKCS8 extends Progenitor
|
||||
* @param array $options optional
|
||||
* @return string
|
||||
*/
|
||||
public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, $primes, $exponents, $coefficients, $password = '', $options = [])
|
||||
public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, $password = '', array $options = [])
|
||||
{
|
||||
$key = PKCS1::savePrivateKey($n, $e, $d, $primes, $exponents, $coefficients);
|
||||
$key = ASN1::extractBER($key);
|
||||
@ -123,7 +123,7 @@ abstract class PKCS8 extends Progenitor
|
||||
* @param array $options optional
|
||||
* @return string
|
||||
*/
|
||||
public static function savePublicKey(BigInteger $n, BigInteger $e, $options = [])
|
||||
public static function savePublicKey(BigInteger $n, BigInteger $e, array $options = [])
|
||||
{
|
||||
$key = PKCS1::savePublicKey($n, $e);
|
||||
$key = ASN1::extractBER($key);
|
||||
|
@ -166,7 +166,7 @@ abstract class PSS extends Progenitor
|
||||
* @param array $options optional
|
||||
* @return string
|
||||
*/
|
||||
public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, $primes, $exponents, $coefficients, $password = '', $options = [])
|
||||
public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, $password = '', array $options = [])
|
||||
{
|
||||
self::initialize_static_variables();
|
||||
|
||||
@ -185,7 +185,7 @@ abstract class PSS extends Progenitor
|
||||
* @param array $options optional
|
||||
* @return string
|
||||
*/
|
||||
public static function savePublicKey(BigInteger $n, BigInteger $e, $options = [])
|
||||
public static function savePublicKey(BigInteger $n, BigInteger $e, array $options = [])
|
||||
{
|
||||
$key = PKCS1::savePublicKey($n, $e);
|
||||
$key = ASN1::extractBER($key);
|
||||
@ -200,7 +200,7 @@ abstract class PSS extends Progenitor
|
||||
* @param array $options
|
||||
* @return string
|
||||
*/
|
||||
private static function savePSSParams($options)
|
||||
private static function savePSSParams(array $options)
|
||||
{
|
||||
/*
|
||||
The trailerField field is an integer. It provides
|
||||
|
@ -103,7 +103,7 @@ abstract class PuTTY extends Progenitor
|
||||
* @param array $options optional
|
||||
* @return string
|
||||
*/
|
||||
public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, $primes, $exponents, $coefficients, $password = '', $options = [])
|
||||
public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, $password = '', array $options = [])
|
||||
{
|
||||
if (count($primes) != 2) {
|
||||
throw new \InvalidArgumentException('PuTTY does not support multi-prime RSA keys');
|
||||
|
@ -131,7 +131,7 @@ abstract class XML
|
||||
* @param string $password optional
|
||||
* @return string
|
||||
*/
|
||||
public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, $primes, $exponents, $coefficients, $password = '')
|
||||
public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, $password = '')
|
||||
{
|
||||
if (count($primes) != 2) {
|
||||
throw new \InvalidArgumentException('XML does not support multi-prime RSA keys');
|
||||
|
@ -518,7 +518,7 @@ class PrivateKey extends RSA implements Common\PrivateKey
|
||||
* @param array $options optional
|
||||
* @return string
|
||||
*/
|
||||
public function toString($type, $options = [])
|
||||
public function toString($type, array $options = [])
|
||||
{
|
||||
$type = self::validatePlugin(
|
||||
'Keys',
|
||||
|
@ -469,7 +469,7 @@ class PublicKey extends RSA implements Common\PublicKey
|
||||
* @param array $options optional
|
||||
* @return mixed
|
||||
*/
|
||||
public function toString($type, $options = [])
|
||||
public function toString($type, array $options = [])
|
||||
{
|
||||
$type = self::validatePlugin('Keys', $type, 'savePublicKey');
|
||||
|
||||
|
@ -320,9 +320,10 @@ class Identity implements PrivateKey
|
||||
* Returns the private key
|
||||
*
|
||||
* @param string $type
|
||||
* @param array $options optional
|
||||
* @return string
|
||||
*/
|
||||
public function toString($type)
|
||||
public function toString($type, array $options = [])
|
||||
{
|
||||
throw new \RuntimeException('ssh-agent does not provide a mechanism to get the private key');
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user