phpseclib API Documentation
Class

phpseclib\System\SSH\Agent\Identity

class Identity

Pure-PHP ssh-agent client identity object

Instantiation should only be performed by \phpseclib\System\SSH\Agent class. This could be thought of as implementing an interface that phpseclib\Crypt\RSA implements. ie. maybe a NetSSHAuth_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.

Constants

SSH_AGENT_RSA2_256

SSH_AGENT_RSA2_512

Properties

RSA $key Key Object
string $key_blob Key Blob
resource $fsock Socket Resource
int $flags Signature flags

Methods

Identity __construct(resource $fsock)

Default Constructor.

setPublicKey(RSA $key)

Set Public Key

setPublicKeyBlob(string $key_blob)

Set Public Key

mixed getPublicKey(int $format = null)

Get Public Key

setSignatureMode(int $mode)

Set Signature Mode

setHash(string $hash)

Set Hash

string sign(string $message)

Create a signature

string _string_shift(string $string, int $index = 1)

String Shift

Details

at line 90
public Identity __construct(resource $fsock)

Default Constructor.

Parameters

resource $fsock

Return Value

Identity

at line 103
public setPublicKey(RSA $key)

Set Public Key

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

Parameters

RSA $key

at line 118
public setPublicKeyBlob(string $key_blob)

Set Public Key

Called by \phpseclib\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

at line 132
public mixed getPublicKey(int $format = null)

Get Public Key

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

Parameters

int $format optional

Return Value

mixed

at line 146
public setSignatureMode(int $mode)

Set Signature Mode

Doesn't do anything as ssh-agent doesn't let you pick and choose the signature mode. ie. ssh-agent's only supported mode is \phpseclib\Crypt\RSA::SIGNATURE_PKCS1

Parameters

int $mode

at line 158
public setHash(string $hash)

Set Hash

ssh-agent doesn't support using hashes for RSA other than SHA1

Parameters

string $hash

at line 184
public string sign(string $message)

Create a signature

See "2.6.2 Protocol 2 private key signature request"

Parameters

string $message

Return Value

string

at line 235
public string _string_shift(string $string, int $index = 1)

String Shift

Inspired by array_shift

Parameters

string $string
int $index

Return Value

string