PluginProbe ʕ •ᴥ•ʔ
JetBackup – Backup, Restore & Migrate / 3.1.23.3
JetBackup – Backup, Restore & Migrate v3.1.23.3
3.1.23.3 3.1.22.4 3.1.22.3 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.8.1 1.4.9 1.5.0 1.5.1 1.5.1.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.0 1.6.10 1.6.11 1.6.12 1.6.13 1.6.15 1.6.5.1 1.6.8.8 1.6.9 1.6.9.1 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7.5 2.0.8.7 2.0.9.11 2.0.9.14 2.0.9.15 2.0.9.6 2.0.9.7 2.0.9.9 3.1.10.7 3.1.11.1 3.1.12.3 3.1.13.4 3.1.14.17 3.1.15.4 3.1.16.1 3.1.17.5 3.1.18.10 3.1.18.8 3.1.18.9 3.1.19.8 3.1.20.3 3.1.21.3 3.1.7.9 3.1.9.2 trunk 1.1.90 1.1.91 1.2.0 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2
backup / src / JetBackup / 3rdparty / phpseclib3 / Crypt / RSA / Formats / Keys / PKCS8.php
backup / src / JetBackup / 3rdparty / phpseclib3 / Crypt / RSA / Formats / Keys Last commit date
.htaccess 1 year ago JWK.php 1 year ago MSBLOB.php 1 year ago OpenSSH.php 1 year ago PKCS1.php 1 year ago PKCS8.php 1 year ago PSS.php 1 year ago PuTTY.php 1 year ago Raw.php 1 year ago XML.php 1 year ago index.html 1 year ago web.config 1 year ago
PKCS8.php
110 lines
1 <?php
2
3 /**
4 * PKCS#8 Formatted RSA Key Handler
5 *
6 * PHP version 5
7 *
8 * Used by PHP's openssl_public_encrypt() and openssl's rsautl (when -pubin is set)
9 *
10 * Processes keys with the following headers:
11 *
12 * -----BEGIN ENCRYPTED PRIVATE KEY-----
13 * -----BEGIN PRIVATE KEY-----
14 * -----BEGIN PUBLIC KEY-----
15 *
16 * Analogous to ssh-keygen's pkcs8 format (as specified by -m). Although PKCS8
17 * is specific to private keys it's basically creating a DER-encoded wrapper
18 * for keys. This just extends that same concept to public keys (much like ssh-keygen)
19 *
20 * @author Jim Wigginton <terrafrost@php.net>
21 * @copyright 2015 Jim Wigginton
22 * @license http://www.opensource.org/licenses/mit-license.html MIT License
23 * @link http://phpseclib.sourceforge.net
24 */
25
26 declare(strict_types=1);
27
28 namespace phpseclib3\Crypt\RSA\Formats\Keys;
29
30 use phpseclib3\Crypt\Common\Formats\Keys\PKCS8 as Progenitor;
31 use phpseclib3\File\ASN1;
32 use phpseclib3\Math\BigInteger;
33
34 /**
35 * PKCS#8 Formatted RSA Key Handler
36 *
37 * @author Jim Wigginton <terrafrost@php.net>
38 */
39 abstract class PKCS8 extends Progenitor
40 {
41 /**
42 * OID Name
43 *
44 * @var string
45 */
46 public const OID_NAME = 'rsaEncryption';
47
48 /**
49 * OID Value
50 *
51 * @var string
52 */
53 public const OID_VALUE = '1.2.840.113549.1.1.1';
54
55 /**
56 * Child OIDs loaded
57 *
58 * @var bool
59 */
60 protected static $childOIDsLoaded = false;
61
62 /**
63 * Break a public or private key down into its constituent components
64 *
65 * @param string|array $key
66 */
67 public static function load($key, ?string $password = null): array
68 {
69 $key = parent::load($key, $password);
70
71 if (isset($key['privateKey'])) {
72 $components['isPublicKey'] = false;
73 $type = 'private';
74 } else {
75 $components['isPublicKey'] = true;
76 $type = 'public';
77 }
78
79 $result = $components + PKCS1::load($key[$type . 'Key']);
80
81 if (isset($key['meta'])) {
82 $result['meta'] = $key['meta'];
83 }
84
85 return $result;
86 }
87
88 /**
89 * Convert a private key to the appropriate format.
90 */
91 public static function savePrivateKey(BigInteger $n, BigInteger $e, BigInteger $d, array $primes, array $exponents, array $coefficients, ?string $password = null, array $options = []): string
92 {
93 $key = PKCS1::savePrivateKey($n, $e, $d, $primes, $exponents, $coefficients);
94 $key = ASN1::extractBER($key);
95 return self::wrapPrivateKey($key, [], null, $password, null, '', $options);
96 }
97
98 /**
99 * Convert a public key to the appropriate format
100 *
101 * @param array $options optional
102 */
103 public static function savePublicKey(BigInteger $n, BigInteger $e, array $options = []): string
104 {
105 $key = PKCS1::savePublicKey($n, $e);
106 $key = ASN1::extractBER($key);
107 return self::wrapPublicKey($key, null);
108 }
109 }
110