Subversion Repositories oidplus

Rev

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

Rev 846 Rev 874
Line 3... Line 3...
3
/**
3
/**
4
 * PKCS1 Formatted Key Handler
4
 * PKCS1 Formatted Key Handler
5
 *
5
 *
6
 * PHP version 5
6
 * PHP version 5
7
 *
7
 *
-
 
8
 * @category  Crypt
-
 
9
 * @package   Common
8
 * @author    Jim Wigginton <terrafrost@php.net>
10
 * @author    Jim Wigginton <terrafrost@php.net>
9
 * @copyright 2015 Jim Wigginton
11
 * @copyright 2015 Jim Wigginton
10
 * @license   http://www.opensource.org/licenses/mit-license.html  MIT License
12
 * @license   http://www.opensource.org/licenses/mit-license.html  MIT License
11
 * @link      http://phpseclib.sourceforge.net
13
 * @link      http://phpseclib.sourceforge.net
12
 */
14
 */
Line 24... Line 26...
24
use phpseclib3\File\ASN1;
26
use phpseclib3\File\ASN1;
25
 
27
 
26
/**
28
/**
27
 * PKCS1 Formatted Key Handler
29
 * PKCS1 Formatted Key Handler
28
 *
30
 *
-
 
31
 * @package RSA
29
 * @author  Jim Wigginton <terrafrost@php.net>
32
 * @author  Jim Wigginton <terrafrost@php.net>
-
 
33
 * @access  public
30
 */
34
 */
31
abstract class PKCS1 extends PKCS
35
abstract class PKCS1 extends PKCS
32
{
36
{
33
    /**
37
    /**
34
     * Default encryption algorithm
38
     * Default encryption algorithm
35
     *
39
     *
36
     * @var string
40
     * @var string
-
 
41
     * @access private
37
     */
42
     */
38
    private static $defaultEncryptionAlgorithm = 'AES-128-CBC';
43
    private static $defaultEncryptionAlgorithm = 'AES-128-CBC';
39
 
44
 
40
    /**
45
    /**
41
     * Sets the default encryption algorithm
46
     * Sets the default encryption algorithm
42
     *
47
     *
-
 
48
     * @access public
43
     * @param string $algo
49
     * @param string $algo
44
     */
50
     */
45
    public static function setEncryptionAlgorithm($algo)
51
    public static function setEncryptionAlgorithm($algo)
46
    {
52
    {
47
        self::$defaultEncryptionAlgorithm = $algo;
53
        self::$defaultEncryptionAlgorithm = $algo;
48
    }
54
    }
49
 
55
 
50
    /**
56
    /**
51
     * Returns the mode constant corresponding to the mode string
57
     * Returns the mode constant corresponding to the mode string
52
     *
58
     *
-
 
59
     * @access public
53
     * @param string $mode
60
     * @param string $mode
54
     * @return int
61
     * @return int
55
     * @throws \UnexpectedValueException if the block cipher mode is unsupported
62
     * @throws \UnexpectedValueException if the block cipher mode is unsupported
56
     */
63
     */
57
    private static function getEncryptionMode($mode)
64
    private static function getEncryptionMode($mode)
Line 68... Line 75...
68
    }
75
    }
69
 
76
 
70
    /**
77
    /**
71
     * Returns a cipher object corresponding to a string
78
     * Returns a cipher object corresponding to a string
72
     *
79
     *
-
 
80
     * @access public
73
     * @param string $algo
81
     * @param string $algo
74
     * @return string
82
     * @return string
75
     * @throws \UnexpectedValueException if the encryption algorithm is unsupported
83
     * @throws \UnexpectedValueException if the encryption algorithm is unsupported
76
     */
84
     */
77
    private static function getEncryptionObject($algo)
85
    private static function getEncryptionObject($algo)
Line 92... Line 100...
92
    }
100
    }
93
 
101
 
94
    /**
102
    /**
95
     * Generate a symmetric key for PKCS#1 keys
103
     * Generate a symmetric key for PKCS#1 keys
96
     *
104
     *
-
 
105
     * @access private
97
     * @param string $password
106
     * @param string $password
98
     * @param string $iv
107
     * @param string $iv
99
     * @param int $length
108
     * @param int $length
100
     * @return string
109
     * @return string
101
     */
110
     */
Line 110... Line 119...
110
    }
119
    }
111
 
120
 
112
    /**
121
    /**
113
     * Break a public or private key down into its constituent components
122
     * Break a public or private key down into its constituent components
114
     *
123
     *
-
 
124
     * @access public
115
     * @param string $key
125
     * @param string $key
116
     * @param string $password optional
126
     * @param string $password optional
117
     * @return array
127
     * @return array
118
     */
128
     */
119
    protected static function load($key, $password)
129
    protected static function load($key, $password)
Line 164... Line 174...
164
    }
174
    }
165
 
175
 
166
    /**
176
    /**
167
     * Wrap a private key appropriately
177
     * Wrap a private key appropriately
168
     *
178
     *
-
 
179
     * @access public
169
     * @param string $key
180
     * @param string $key
170
     * @param string $type
181
     * @param string $type
171
     * @param string $password
182
     * @param string $password
172
     * @param array $options optional
183
     * @param array $options optional
173
     * @return string
184
     * @return string
Line 196... Line 207...
196
    }
207
    }
197
 
208
 
198
    /**
209
    /**
199
     * Wrap a public key appropriately
210
     * Wrap a public key appropriately
200
     *
211
     *
-
 
212
     * @access public
201
     * @param string $key
213
     * @param string $key
202
     * @param string $type
214
     * @param string $type
203
     * @return string
215
     * @return string
204
     */
216
     */
205
    protected static function wrapPublicKey($key, $type)
217
    protected static function wrapPublicKey($key, $type)