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.

Properties

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

Methods

Identity __construct(resource $fsock)

Default Constructor.

setPublicKey(RSA $key)

Set Public Key

setPublicKeyBlob(string $key_blob)

Set Public Key

mixed getPublicKey(int $type = 'PKCS8')

Get Public Key

setHash(string $hash = 'sha1')

Sets the hash

string sign(string $message, int $padding = RSA::PADDING_PKCS1)

Create a signature

Details

at line 71
public Identity __construct(resource $fsock)

Default Constructor.

Parameters

resource $fsock

Return Value

Identity

at line 84
public setPublicKey(RSA $key)

Set Public Key

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

Parameters

RSA $key

at line 99
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 113
public mixed getPublicKey(int $type = 'PKCS8')

Get Public Key

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

Parameters

int $type optional

Return Value

mixed

at line 127
public setHash(string $hash = 'sha1')

Sets the hash

ssh-agent only supports signatures with sha1 hashes but to maintain BC with RSA.php this function exists

Parameters

string $hash optional

Exceptions

UnsupportedAlgorithmException if the algorithm is unsupported

at line 146
public string sign(string $message, int $padding = RSA::PADDING_PKCS1)

Create a signature

See "2.6.2 Protocol 2 private key signature request"

Parameters

string $message
int $padding optional

Return Value

string

Exceptions

RuntimeException on connection errors
UnsupportedAlgorithmException if the algorithm is unsupported