class Identity implements PrivateKey (View source)

Pure-PHP ssh-agent client identity object

Instantiation should only be performed by \phpseclib3\System\SSH\Agent class. This could be thought of as implementing an interface that phpseclib3\Crypt\RSA implements. ie. maybe a Net_SSH_Auth_PublicKey interface or something. The methods in this interface would be getPublicKey and sign since those are the methods phpseclib looks for to perform public key authentication.

Traits

ReadBytes trait

Constants

SSH_AGENT_RSA2_256

SSH_AGENT_RSA2_512

Methods

readBytes(int $length)

Read data

__construct(resource $fsock)

Default Constructor.

withPublicKey(PublicKey $key)

Set Public Key

withPublicKeyBlob(string $key_blob)

Set Public Key

getPublicKey(string $type = 'PKCS8')

Get Public Key

withHash(string $hash)

Sets the hash

withPadding(string $padding)

Sets the padding

withSignatureFormat(string $format)

Determines the signature padding mode

string|array
getCurve()

Returns the curve

sign($message)

Create a signature

toString($type, array $options = [])

Returns the private key

withPassword(string|bool $password = false)

Sets the password

Details

readBytes(int $length)

Read data

Parameters

int $length

Exceptions

RuntimeException on connection errors

Identity __construct(resource $fsock)

Default Constructor.

Parameters

resource $fsock

Return Value

Identity

withPublicKey(PublicKey $key)

Set Public Key

Called by \phpseclib3\System\SSH\Agent::requestIdentities()

Parameters

PublicKey $key

withPublicKeyBlob(string $key_blob)

Set Public Key

Called by \phpseclib3\System\SSH\Agent::requestIdentities(). The key blob could be extracted from $this->key but this saves a small amount of computation.

Parameters

string $key_blob

getPublicKey(string $type = 'PKCS8')

Get Public Key

Wrapper for $this->key->getPublicKey()

Parameters

string $type optional

withHash(string $hash)

Sets the hash

Parameters

string $hash

withPadding(string $padding)

Sets the padding

Only PKCS1 padding is supported

Parameters

string $padding

withSignatureFormat(string $format)

Determines the signature padding mode

Valid values are: ASN1, SSH2, Raw

Parameters

string $format

string|array getCurve()

Returns the curve

Returns a string if it's a named curve, an array if not

Return Value

string|array

sign($message)

Create a signature

See "2.6.2 Protocol 2 private key signature request"

Parameters

$message

Exceptions

RuntimeException on connection errors
UnsupportedAlgorithmException if the algorithm is unsupported

toString($type, array $options = [])

Returns the private key

Parameters

$type
array $options

withPassword(string|bool $password = false)

Sets the password

Parameters

string|bool $password