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 7... Line 7...
7
 *
7
 *
8
 * https://msdn.microsoft.com/en-us/library/windows/desktop/aa375601(v=vs.85).aspx
8
 * https://msdn.microsoft.com/en-us/library/windows/desktop/aa375601(v=vs.85).aspx
9
 *
9
 *
10
 * PHP version 5
10
 * PHP version 5
11
 *
11
 *
-
 
12
 * @category  Crypt
-
 
13
 * @package   RSA
12
 * @author    Jim Wigginton <terrafrost@php.net>
14
 * @author    Jim Wigginton <terrafrost@php.net>
13
 * @copyright 2015 Jim Wigginton
15
 * @copyright 2015 Jim Wigginton
14
 * @license   http://www.opensource.org/licenses/mit-license.html  MIT License
16
 * @license   http://www.opensource.org/licenses/mit-license.html  MIT License
15
 * @link      http://phpseclib.sourceforge.net
17
 * @link      http://phpseclib.sourceforge.net
16
 */
18
 */
Line 23... Line 25...
23
use phpseclib3\Math\BigInteger;
25
use phpseclib3\Math\BigInteger;
24
 
26
 
25
/**
27
/**
26
 * Microsoft BLOB Formatted RSA Key Handler
28
 * Microsoft BLOB Formatted RSA Key Handler
27
 *
29
 *
-
 
30
 * @package RSA
28
 * @author  Jim Wigginton <terrafrost@php.net>
31
 * @author  Jim Wigginton <terrafrost@php.net>
-
 
32
 * @access  public
29
 */
33
 */
30
abstract class MSBLOB
34
abstract class MSBLOB
31
{
35
{
32
    /**
36
    /**
33
     * Public/Private Key Pair
37
     * Public/Private Key Pair
34
     *
38
     *
-
 
39
     * @access private
35
     */
40
     */
36
    const PRIVATEKEYBLOB = 0x7;
41
    const PRIVATEKEYBLOB = 0x7;
37
    /**
42
    /**
38
     * Public Key
43
     * Public Key
39
     *
44
     *
-
 
45
     * @access private
40
     */
46
     */
41
    const PUBLICKEYBLOB = 0x6;
47
    const PUBLICKEYBLOB = 0x6;
42
    /**
48
    /**
43
     * Public Key
49
     * Public Key
44
     *
50
     *
-
 
51
     * @access private
45
     */
52
     */
46
    const PUBLICKEYBLOBEX = 0xA;
53
    const PUBLICKEYBLOBEX = 0xA;
47
    /**
54
    /**
48
     * RSA public key exchange algorithm
55
     * RSA public key exchange algorithm
49
     *
56
     *
-
 
57
     * @access private
50
     */
58
     */
51
    const CALG_RSA_KEYX = 0x0000A400;
59
    const CALG_RSA_KEYX = 0x0000A400;
52
    /**
60
    /**
53
     * RSA public key exchange algorithm
61
     * RSA public key exchange algorithm
54
     *
62
     *
-
 
63
     * @access private
55
     */
64
     */
56
    const CALG_RSA_SIGN = 0x00002400;
65
    const CALG_RSA_SIGN = 0x00002400;
57
    /**
66
    /**
58
     * Public Key
67
     * Public Key
59
     *
68
     *
-
 
69
     * @access private
60
     */
70
     */
61
    const RSA1 = 0x31415352;
71
    const RSA1 = 0x31415352;
62
    /**
72
    /**
63
     * Private Key
73
     * Private Key
64
     *
74
     *
-
 
75
     * @access private
65
     */
76
     */
66
    const RSA2 = 0x32415352;
77
    const RSA2 = 0x32415352;
67
 
78
 
68
    /**
79
    /**
69
     * Break a public or private key down into its constituent components
80
     * Break a public or private key down into its constituent components
70
     *
81
     *
-
 
82
     * @access public
71
     * @param string $key
83
     * @param string $key
72
     * @param string $password optional
84
     * @param string $password optional
73
     * @return array
85
     * @return array
74
     */
86
     */
75
    public static function load($key, $password = '')
87
    public static function load($key, $password = '')
Line 173... Line 185...
173
    }
185
    }
174
 
186
 
175
    /**
187
    /**
176
     * Convert a private key to the appropriate format.
188
     * Convert a private key to the appropriate format.
177
     *
189
     *
-
 
190
     * @access public
178
     * @param \phpseclib3\Math\BigInteger $n
191
     * @param \phpseclib3\Math\BigInteger $n
179
     * @param \phpseclib3\Math\BigInteger $e
192
     * @param \phpseclib3\Math\BigInteger $e
180
     * @param \phpseclib3\Math\BigInteger $d
193
     * @param \phpseclib3\Math\BigInteger $d
181
     * @param array $primes
194
     * @param array $primes
182
     * @param array $exponents
195
     * @param array $exponents
Line 210... Line 223...
210
    }
223
    }
211
 
224
 
212
    /**
225
    /**
213
     * Convert a public key to the appropriate format
226
     * Convert a public key to the appropriate format
214
     *
227
     *
-
 
228
     * @access public
215
     * @param \phpseclib3\Math\BigInteger $n
229
     * @param \phpseclib3\Math\BigInteger $n
216
     * @param \phpseclib3\Math\BigInteger $e
230
     * @param \phpseclib3\Math\BigInteger $e
217
     * @return string
231
     * @return string
218
     */
232
     */
219
    public static function savePublicKey(BigInteger $n, BigInteger $e)
233
    public static function savePublicKey(BigInteger $n, BigInteger $e)