Subversion Repositories oidplus

Rev

Rev 846 | Rev 1042 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 846 Rev 874
Line 5... Line 5...
5
 *
5
 *
6
 * PHP version 5
6
 * PHP version 5
7
 *
7
 *
8
 * Place in $HOME/.ssh/authorized_keys
8
 * Place in $HOME/.ssh/authorized_keys
9
 *
9
 *
-
 
10
 * @category  Crypt
-
 
11
 * @package   Common
10
 * @author    Jim Wigginton <terrafrost@php.net>
12
 * @author    Jim Wigginton <terrafrost@php.net>
11
 * @copyright 2015 Jim Wigginton
13
 * @copyright 2015 Jim Wigginton
12
 * @license   http://www.opensource.org/licenses/mit-license.html  MIT License
14
 * @license   http://www.opensource.org/licenses/mit-license.html  MIT License
13
 * @link      http://phpseclib.sourceforge.net
15
 * @link      http://phpseclib.sourceforge.net
14
 */
16
 */
Line 21... Line 23...
21
use phpseclib3\Exception\UnsupportedFormatException;
23
use phpseclib3\Exception\UnsupportedFormatException;
22
 
24
 
23
/**
25
/**
24
 * OpenSSH Formatted RSA Key Handler
26
 * OpenSSH Formatted RSA Key Handler
25
 *
27
 *
-
 
28
 * @package Common
26
 * @author  Jim Wigginton <terrafrost@php.net>
29
 * @author  Jim Wigginton <terrafrost@php.net>
-
 
30
 * @access  public
27
 */
31
 */
28
abstract class OpenSSH
32
abstract class OpenSSH
29
{
33
{
30
    /**
34
    /**
31
     * Default comment
35
     * Default comment
32
     *
36
     *
33
     * @var string
37
     * @var string
-
 
38
     * @access private
34
     */
39
     */
35
    protected static $comment = 'phpseclib-generated-key';
40
    protected static $comment = 'phpseclib-generated-key';
36
 
41
 
37
    /**
42
    /**
38
     * Binary key flag
43
     * Binary key flag
39
     *
44
     *
40
     * @var bool
45
     * @var bool
-
 
46
     * @access private
41
     */
47
     */
42
    protected static $binary = false;
48
    protected static $binary = false;
43
 
49
 
44
    /**
50
    /**
45
     * Sets the default comment
51
     * Sets the default comment
46
     *
52
     *
-
 
53
     * @access public
47
     * @param string $comment
54
     * @param string $comment
48
     */
55
     */
49
    public static function setComment($comment)
56
    public static function setComment($comment)
50
    {
57
    {
51
        self::$comment = str_replace(["\r", "\n"], '', $comment);
58
        self::$comment = str_replace(["\r", "\n"], '', $comment);
Line 54... Line 61...
54
    /**
61
    /**
55
     * Break a public or private key down into its constituent components
62
     * Break a public or private key down into its constituent components
56
     *
63
     *
57
     * $type can be either ssh-dss or ssh-rsa
64
     * $type can be either ssh-dss or ssh-rsa
58
     *
65
     *
-
 
66
     * @access public
59
     * @param string $key
67
     * @param string $key
60
     * @param string $password
68
     * @param string $password
61
     * @return array
69
     * @return array
62
     */
70
     */
63
    public static function load($key, $password = '')
71
    public static function load($key, $password = '')
Line 159... Line 167...
159
     * Toggle between binary and printable keys
167
     * Toggle between binary and printable keys
160
     *
168
     *
161
     * Printable keys are what are generated by default. These are the ones that go in
169
     * Printable keys are what are generated by default. These are the ones that go in
162
     * $HOME/.ssh/authorized_key.
170
     * $HOME/.ssh/authorized_key.
163
     *
171
     *
-
 
172
     * @access public
164
     * @param bool $enabled
173
     * @param bool $enabled
165
     */
174
     */
166
    public static function setBinaryOutput($enabled)
175
    public static function setBinaryOutput($enabled)
167
    {
176
    {
168
        self::$binary = $enabled;
177
        self::$binary = $enabled;
169
    }
178
    }
170
 
179
 
171
    /**
180
    /**
172
     * Checks to see if the type is valid
181
     * Checks to see if the type is valid
173
     *
182
     *
-
 
183
     * @access private
174
     * @param string $candidate
184
     * @param string $candidate
175
     */
185
     */
176
    private static function checkType($candidate)
186
    private static function checkType($candidate)
177
    {
187
    {
178
        if (!in_array($candidate, static::$types)) {
188
        if (!in_array($candidate, static::$types)) {
Line 181... Line 191...
181
    }
191
    }
182
 
192
 
183
    /**
193
    /**
184
     * Wrap a private key appropriately
194
     * Wrap a private key appropriately
185
     *
195
     *
-
 
196
     * @access public
186
     * @param string $publicKey
197
     * @param string $publicKey
187
     * @param string $privateKey
198
     * @param string $privateKey
188
     * @param string $password
199
     * @param string $password
189
     * @param array $options
200
     * @param array $options
190
     * @return string
201
     * @return string