ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Identity.php
Go to the documentation of this file.
1<?php
17
19
35{
43 var $key;
44
53
61 var $fsock;
62
71 {
72 $this->fsock = $fsock;
73 }
74
84 {
85 $this->key = $key;
86 $this->key->setPublicKey();
87 }
88
99 {
100 $this->key_blob = $key_blob;
101 }
102
112 function getPublicKey($format = null)
113 {
114 return !isset($format) ? $this->key->getPublicKey() : $this->key->getPublicKey($format);
115 }
116
126 function setSignatureMode($mode)
127 {
128 }
129
139 function sign($message)
140 {
141 // the last parameter (currently 0) is for flags and ssh-agent only defines one flag (for ssh-dss): SSH_AGENT_OLD_SIGNATURE
142 $packet = pack('CNa*Na*N', Agent::SSH_AGENTC_SIGN_REQUEST, strlen($this->key_blob), $this->key_blob, strlen($message), $message, 0);
143 $packet = pack('Na*', strlen($packet), $packet);
144 if (strlen($packet) != fputs($this->fsock, $packet)) {
145 user_error('Connection closed during signing');
146 }
147
148 $length = current(unpack('N', fread($this->fsock, 4)));
149 $type = ord(fread($this->fsock, 1));
151 user_error('Unable to retreive signature');
152 }
153
154 $signature_blob = fread($this->fsock, $length - 1);
155 // the only other signature format defined - ssh-dss - is the same length as ssh-rsa
156 // the + 12 is for the other various SSH added length fields
157 return substr($signature_blob, strlen('ssh-rsa') + 12);
158 }
159}
An exception for terminatinating execution or to throw for unit testing.
setPublicKey($key)
Set Public Key.
Definition: Identity.php:83
getPublicKey($format=null)
Get Public Key.
Definition: Identity.php:112
setPublicKeyBlob($key_blob)
Set Public Key.
Definition: Identity.php:98
__construct($fsock)
Default Constructor.
Definition: Identity.php:70
sign($message)
Create a signature.
Definition: Identity.php:139
setSignatureMode($mode)
Set Signature Mode.
Definition: Identity.php:126
$format
Definition: metadata.php:141
catch(Exception $e) $message
$type