From f7fb93276a4bd8a8abe288676b0eab3a629472c8 Mon Sep 17 00:00:00 2001 From: Clint Nelissen Date: Wed, 3 Dec 2014 18:44:30 -0800 Subject: [PATCH] Moved global constants to class constants --- phpseclib/System/SSH/Agent.php | 35 ++++++++++++------------- phpseclib/System/SSH/Agent/Identity.php | 4 +-- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/phpseclib/System/SSH/Agent.php b/phpseclib/System/SSH/Agent.php index 59cb881a..8ad83ab9 100644 --- a/phpseclib/System/SSH/Agent.php +++ b/phpseclib/System/SSH/Agent.php @@ -31,22 +31,6 @@ * @internal See http://api.libssh.org/rfc/PROTOCOL.agent */ -/**#@+ - * Message numbers - * - * @access private - */ -// to request SSH1 keys you have to use SSH_AGENTC_REQUEST_RSA_IDENTITIES (1) -define('SYSTEM_SSH_AGENTC_REQUEST_IDENTITIES', 11); -// this is the SSH2 response; the SSH1 response is SSH_AGENT_RSA_IDENTITIES_ANSWER (2). -define('SYSTEM_SSH_AGENT_IDENTITIES_ANSWER', 12); -define('SYSTEM_SSH_AGENT_FAILURE', 5); -// the SSH1 request is SSH_AGENTC_RSA_CHALLENGE (3) -define('SYSTEM_SSH_AGENTC_SIGN_REQUEST', 13); -// the SSH1 response is SSH_AGENT_RSA_RESPONSE (4) -define('SYSTEM_SSH_AGENT_SIGN_RESPONSE', 14); -/**#@-*/ - if (!class_exists('System_SSH_Agent_Identity')) { include_once 'Agent/Identity.php'; } @@ -62,6 +46,21 @@ if (!class_exists('System_SSH_Agent_Identity')) { */ class System_SSH_Agent { + /**#@+ + * Message numbers + * + * @access private + */ + // to request SSH1 keys you have to use SSH_AGENTC_REQUEST_RSA_IDENTITIES (1) + const SSH_AGENTC_REQUEST_IDENTITIES = 11; + // this is the SSH2 response; the SSH1 response is SSH_AGENT_RSA_IDENTITIES_ANSWER (2). + const SSH_AGENT_IDENTITIES_ANSWER = 12; + // the SSH1 request is SSH_AGENTC_RSA_CHALLENGE (3) + const SSH_AGENTC_SIGN_REQUEST = 13; + // the SSH1 response is SSH_AGENT_RSA_RESPONSE (4) + const SSH_AGENT_SIGN_RESPONSE = 14; + /**#@-*/ + /** * Socket Resource * @@ -111,14 +110,14 @@ class System_SSH_Agent return array(); } - $packet = pack('NC', 1, SYSTEM_SSH_AGENTC_REQUEST_IDENTITIES); + $packet = pack('NC', 1, self::SSH_AGENTC_REQUEST_IDENTITIES); if (strlen($packet) != fputs($this->fsock, $packet)) { user_error('Connection closed while requesting identities'); } $length = current(unpack('N', fread($this->fsock, 4))); $type = ord(fread($this->fsock, 1)); - if ($type != SYSTEM_SSH_AGENT_IDENTITIES_ANSWER) { + if ($type != self::SSH_AGENT_IDENTITIES_ANSWER) { user_error('Unable to request identities'); } diff --git a/phpseclib/System/SSH/Agent/Identity.php b/phpseclib/System/SSH/Agent/Identity.php index 962d7a71..0dc06827 100644 --- a/phpseclib/System/SSH/Agent/Identity.php +++ b/phpseclib/System/SSH/Agent/Identity.php @@ -135,7 +135,7 @@ class System_SSH_Agent_Identity function sign($message) { // the last parameter (currently 0) is for flags and ssh-agent only defines one flag (for ssh-dss): SSH_AGENT_OLD_SIGNATURE - $packet = pack('CNa*Na*N', SYSTEM_SSH_AGENTC_SIGN_REQUEST, strlen($this->key_blob), $this->key_blob, strlen($message), $message, 0); + $packet = pack('CNa*Na*N', System_SSH_Agent::SYSTEM_SSH_AGENTC_SIGN_REQUEST, strlen($this->key_blob), $this->key_blob, strlen($message), $message, 0); $packet = pack('Na*', strlen($packet), $packet); if (strlen($packet) != fputs($this->fsock, $packet)) { user_error('Connection closed during signing'); @@ -143,7 +143,7 @@ class System_SSH_Agent_Identity $length = current(unpack('N', fread($this->fsock, 4))); $type = ord(fread($this->fsock, 1)); - if ($type != SYSTEM_SSH_AGENT_SIGN_RESPONSE) { + if ($type != System_SSH_Agent::SYSTEM_SSH_AGENT_SIGN_RESPONSE) { user_error('Unable to retreive signature'); }