@@ -13,15 +13,15 @@ |
||
13 | 13 | */ |
14 | 14 | class AlgorithmParameter extends JWKParameter |
15 | 15 | { |
16 | - use StringParameterValue; |
|
16 | + use StringParameterValue; |
|
17 | 17 | |
18 | - /** |
|
19 | - * Constructor. |
|
20 | - * |
|
21 | - * @param string $algo Algorithm name |
|
22 | - */ |
|
23 | - public function __construct(string $algo) |
|
24 | - { |
|
25 | - parent::__construct(self::PARAM_ALGORITHM, $algo); |
|
26 | - } |
|
18 | + /** |
|
19 | + * Constructor. |
|
20 | + * |
|
21 | + * @param string $algo Algorithm name |
|
22 | + */ |
|
23 | + public function __construct(string $algo) |
|
24 | + { |
|
25 | + parent::__construct(self::PARAM_ALGORITHM, $algo); |
|
26 | + } |
|
27 | 27 | } |
@@ -13,16 +13,16 @@ |
||
13 | 13 | */ |
14 | 14 | class FirstPrimeFactorParameter extends JWKParameter |
15 | 15 | { |
16 | - use Base64UIntValue; |
|
16 | + use Base64UIntValue; |
|
17 | 17 | |
18 | - /** |
|
19 | - * Constructor. |
|
20 | - * |
|
21 | - * @param string $p First prime factor in base64urlUInt encoding |
|
22 | - */ |
|
23 | - public function __construct(string $p) |
|
24 | - { |
|
25 | - $this->_validateEncoding($p); |
|
26 | - parent::__construct(self::PARAM_FIRST_PRIME_FACTOR, $p); |
|
27 | - } |
|
18 | + /** |
|
19 | + * Constructor. |
|
20 | + * |
|
21 | + * @param string $p First prime factor in base64urlUInt encoding |
|
22 | + */ |
|
23 | + public function __construct(string $p) |
|
24 | + { |
|
25 | + $this->_validateEncoding($p); |
|
26 | + parent::__construct(self::PARAM_FIRST_PRIME_FACTOR, $p); |
|
27 | + } |
|
28 | 28 | } |
@@ -13,16 +13,16 @@ |
||
13 | 13 | */ |
14 | 14 | class SecondFactorCRTExponentParameter extends JWKParameter |
15 | 15 | { |
16 | - use Base64UIntValue; |
|
16 | + use Base64UIntValue; |
|
17 | 17 | |
18 | - /** |
|
19 | - * Constructor. |
|
20 | - * |
|
21 | - * @param string $dq Second factor CRT exponent in base64urlUInt encoding |
|
22 | - */ |
|
23 | - public function __construct(string $dq) |
|
24 | - { |
|
25 | - $this->_validateEncoding($dq); |
|
26 | - parent::__construct(self::PARAM_SECOND_FACTOR_CRT_EXPONENT, $dq); |
|
27 | - } |
|
18 | + /** |
|
19 | + * Constructor. |
|
20 | + * |
|
21 | + * @param string $dq Second factor CRT exponent in base64urlUInt encoding |
|
22 | + */ |
|
23 | + public function __construct(string $dq) |
|
24 | + { |
|
25 | + $this->_validateEncoding($dq); |
|
26 | + parent::__construct(self::PARAM_SECOND_FACTOR_CRT_EXPONENT, $dq); |
|
27 | + } |
|
28 | 28 | } |
@@ -13,16 +13,16 @@ |
||
13 | 13 | */ |
14 | 14 | class PrivateExponentParameter extends JWKParameter |
15 | 15 | { |
16 | - use Base64UIntValue; |
|
16 | + use Base64UIntValue; |
|
17 | 17 | |
18 | - /** |
|
19 | - * Constructor. |
|
20 | - * |
|
21 | - * @param string $d Private exponent in base64urlUInt encoding |
|
22 | - */ |
|
23 | - public function __construct(string $d) |
|
24 | - { |
|
25 | - $this->_validateEncoding($d); |
|
26 | - parent::__construct(self::PARAM_PRIVATE_EXPONENT, $d); |
|
27 | - } |
|
18 | + /** |
|
19 | + * Constructor. |
|
20 | + * |
|
21 | + * @param string $d Private exponent in base64urlUInt encoding |
|
22 | + */ |
|
23 | + public function __construct(string $d) |
|
24 | + { |
|
25 | + $this->_validateEncoding($d); |
|
26 | + parent::__construct(self::PARAM_PRIVATE_EXPONENT, $d); |
|
27 | + } |
|
28 | 28 | } |
@@ -13,26 +13,26 @@ |
||
13 | 13 | */ |
14 | 14 | class KeyValueParameter extends JWKParameter |
15 | 15 | { |
16 | - use Base64URLValue; |
|
16 | + use Base64URLValue; |
|
17 | 17 | |
18 | - /** |
|
19 | - * Constructor. |
|
20 | - * |
|
21 | - * @param string $key Base64url encoded key |
|
22 | - */ |
|
23 | - public function __construct(string $key) |
|
24 | - { |
|
25 | - $this->_validateEncoding($key); |
|
26 | - parent::__construct(self::PARAM_KEY_VALUE, $key); |
|
27 | - } |
|
18 | + /** |
|
19 | + * Constructor. |
|
20 | + * |
|
21 | + * @param string $key Base64url encoded key |
|
22 | + */ |
|
23 | + public function __construct(string $key) |
|
24 | + { |
|
25 | + $this->_validateEncoding($key); |
|
26 | + parent::__construct(self::PARAM_KEY_VALUE, $key); |
|
27 | + } |
|
28 | 28 | |
29 | - /** |
|
30 | - * Get key in binary format. |
|
31 | - * |
|
32 | - * @return string |
|
33 | - */ |
|
34 | - public function key(): string |
|
35 | - { |
|
36 | - return $this->string(); |
|
37 | - } |
|
29 | + /** |
|
30 | + * Get key in binary format. |
|
31 | + * |
|
32 | + * @return string |
|
33 | + */ |
|
34 | + public function key(): string |
|
35 | + { |
|
36 | + return $this->string(); |
|
37 | + } |
|
38 | 38 | } |
@@ -13,116 +13,116 @@ |
||
13 | 13 | */ |
14 | 14 | class CurveParameter extends JWKParameter |
15 | 15 | { |
16 | - use StringParameterValue; |
|
16 | + use StringParameterValue; |
|
17 | 17 | |
18 | - /** |
|
19 | - * P-256 Curve. |
|
20 | - * |
|
21 | - * @var string |
|
22 | - */ |
|
23 | - const CURVE_P256 = "P-256"; |
|
18 | + /** |
|
19 | + * P-256 Curve. |
|
20 | + * |
|
21 | + * @var string |
|
22 | + */ |
|
23 | + const CURVE_P256 = "P-256"; |
|
24 | 24 | |
25 | - /** |
|
26 | - * P-384 Curve. |
|
27 | - * |
|
28 | - * @var string |
|
29 | - */ |
|
30 | - const CURVE_P384 = "P-384"; |
|
25 | + /** |
|
26 | + * P-384 Curve. |
|
27 | + * |
|
28 | + * @var string |
|
29 | + */ |
|
30 | + const CURVE_P384 = "P-384"; |
|
31 | 31 | |
32 | - /** |
|
33 | - * P-521 Curve. |
|
34 | - * |
|
35 | - * @var string |
|
36 | - */ |
|
37 | - const CURVE_P521 = "P-521"; |
|
32 | + /** |
|
33 | + * P-521 Curve. |
|
34 | + * |
|
35 | + * @var string |
|
36 | + */ |
|
37 | + const CURVE_P521 = "P-521"; |
|
38 | 38 | |
39 | - /** |
|
40 | - * Mapping from curve OID to curve name. |
|
41 | - * |
|
42 | - * @internal |
|
43 | - * |
|
44 | - * @var array |
|
45 | - */ |
|
46 | - const MAP_OID_TO_CURVE = array( |
|
47 | - /* @formatter:off */ |
|
48 | - "1.2.840.10045.3.1.7" => self::CURVE_P256, |
|
49 | - "1.3.132.0.34" => self::CURVE_P384, |
|
50 | - "1.3.132.0.35" => self::CURVE_P521 |
|
51 | - /* @formatter:on */ |
|
52 | - ); |
|
39 | + /** |
|
40 | + * Mapping from curve OID to curve name. |
|
41 | + * |
|
42 | + * @internal |
|
43 | + * |
|
44 | + * @var array |
|
45 | + */ |
|
46 | + const MAP_OID_TO_CURVE = array( |
|
47 | + /* @formatter:off */ |
|
48 | + "1.2.840.10045.3.1.7" => self::CURVE_P256, |
|
49 | + "1.3.132.0.34" => self::CURVE_P384, |
|
50 | + "1.3.132.0.35" => self::CURVE_P521 |
|
51 | + /* @formatter:on */ |
|
52 | + ); |
|
53 | 53 | |
54 | - /** |
|
55 | - * Mapping from curve name to bit size. |
|
56 | - * |
|
57 | - * @internal |
|
58 | - * |
|
59 | - * @var array |
|
60 | - */ |
|
61 | - const MAP_CURVE_TO_SIZE = array( |
|
62 | - /* @formatter:off */ |
|
63 | - self::CURVE_P256 => 256, |
|
64 | - self::CURVE_P384 => 384, |
|
65 | - self::CURVE_P521 => 521 |
|
66 | - /* @formatter:on */ |
|
67 | - ); |
|
54 | + /** |
|
55 | + * Mapping from curve name to bit size. |
|
56 | + * |
|
57 | + * @internal |
|
58 | + * |
|
59 | + * @var array |
|
60 | + */ |
|
61 | + const MAP_CURVE_TO_SIZE = array( |
|
62 | + /* @formatter:off */ |
|
63 | + self::CURVE_P256 => 256, |
|
64 | + self::CURVE_P384 => 384, |
|
65 | + self::CURVE_P521 => 521 |
|
66 | + /* @formatter:on */ |
|
67 | + ); |
|
68 | 68 | |
69 | - /** |
|
70 | - * Constructor. |
|
71 | - * |
|
72 | - * @param string $curve Curve name |
|
73 | - */ |
|
74 | - public function __construct(string $curve) |
|
75 | - { |
|
76 | - parent::__construct(self::PARAM_CURVE, $curve); |
|
77 | - } |
|
69 | + /** |
|
70 | + * Constructor. |
|
71 | + * |
|
72 | + * @param string $curve Curve name |
|
73 | + */ |
|
74 | + public function __construct(string $curve) |
|
75 | + { |
|
76 | + parent::__construct(self::PARAM_CURVE, $curve); |
|
77 | + } |
|
78 | 78 | |
79 | - /** |
|
80 | - * Initialize from curve OID. |
|
81 | - * |
|
82 | - * @param string $oid Object identifier in dotted format |
|
83 | - * @throws \UnexpectedValueException If the curve is not supported |
|
84 | - * @return self |
|
85 | - */ |
|
86 | - public static function fromOID(string $oid): self |
|
87 | - { |
|
88 | - if (!array_key_exists($oid, self::MAP_OID_TO_CURVE)) { |
|
89 | - throw new \UnexpectedValueException("OID $oid not supported."); |
|
90 | - } |
|
91 | - $curve = self::MAP_OID_TO_CURVE[$oid]; |
|
92 | - return new self($curve); |
|
93 | - } |
|
79 | + /** |
|
80 | + * Initialize from curve OID. |
|
81 | + * |
|
82 | + * @param string $oid Object identifier in dotted format |
|
83 | + * @throws \UnexpectedValueException If the curve is not supported |
|
84 | + * @return self |
|
85 | + */ |
|
86 | + public static function fromOID(string $oid): self |
|
87 | + { |
|
88 | + if (!array_key_exists($oid, self::MAP_OID_TO_CURVE)) { |
|
89 | + throw new \UnexpectedValueException("OID $oid not supported."); |
|
90 | + } |
|
91 | + $curve = self::MAP_OID_TO_CURVE[$oid]; |
|
92 | + return new self($curve); |
|
93 | + } |
|
94 | 94 | |
95 | - /** |
|
96 | - * Get key size in bits for the curve. |
|
97 | - * |
|
98 | - * @throws \UnexpectedValueException |
|
99 | - * @return int |
|
100 | - */ |
|
101 | - public function keySizeBits(): int |
|
102 | - { |
|
103 | - if (!array_key_exists($this->_value, self::MAP_CURVE_TO_SIZE)) { |
|
104 | - throw new \UnexpectedValueException( |
|
105 | - "Curve " . $this->_value . " not supported."); |
|
106 | - } |
|
107 | - return self::MAP_CURVE_TO_SIZE[$this->_value]; |
|
108 | - } |
|
95 | + /** |
|
96 | + * Get key size in bits for the curve. |
|
97 | + * |
|
98 | + * @throws \UnexpectedValueException |
|
99 | + * @return int |
|
100 | + */ |
|
101 | + public function keySizeBits(): int |
|
102 | + { |
|
103 | + if (!array_key_exists($this->_value, self::MAP_CURVE_TO_SIZE)) { |
|
104 | + throw new \UnexpectedValueException( |
|
105 | + "Curve " . $this->_value . " not supported."); |
|
106 | + } |
|
107 | + return self::MAP_CURVE_TO_SIZE[$this->_value]; |
|
108 | + } |
|
109 | 109 | |
110 | - /** |
|
111 | - * Get the curve OID by curve name. |
|
112 | - * |
|
113 | - * @param string $name Curve parameter name |
|
114 | - * @throws \UnexpectedValueException If the curve is not supported |
|
115 | - * @return string OID in dotted format |
|
116 | - */ |
|
117 | - public static function nameToOID(string $name): string |
|
118 | - { |
|
119 | - static $reverseMap; |
|
120 | - if (!isset($reverseMap)) { |
|
121 | - $reverseMap = array_flip(self::MAP_OID_TO_CURVE); |
|
122 | - } |
|
123 | - if (!isset($reverseMap[$name])) { |
|
124 | - throw new \UnexpectedValueException("Curve $name not supported."); |
|
125 | - } |
|
126 | - return $reverseMap[$name]; |
|
127 | - } |
|
110 | + /** |
|
111 | + * Get the curve OID by curve name. |
|
112 | + * |
|
113 | + * @param string $name Curve parameter name |
|
114 | + * @throws \UnexpectedValueException If the curve is not supported |
|
115 | + * @return string OID in dotted format |
|
116 | + */ |
|
117 | + public static function nameToOID(string $name): string |
|
118 | + { |
|
119 | + static $reverseMap; |
|
120 | + if (!isset($reverseMap)) { |
|
121 | + $reverseMap = array_flip(self::MAP_OID_TO_CURVE); |
|
122 | + } |
|
123 | + if (!isset($reverseMap[$name])) { |
|
124 | + throw new \UnexpectedValueException("Curve $name not supported."); |
|
125 | + } |
|
126 | + return $reverseMap[$name]; |
|
127 | + } |
|
128 | 128 | } |
@@ -13,16 +13,16 @@ |
||
13 | 13 | */ |
14 | 14 | class ExponentParameter extends JWKParameter |
15 | 15 | { |
16 | - use Base64UIntValue; |
|
16 | + use Base64UIntValue; |
|
17 | 17 | |
18 | - /** |
|
19 | - * Constructor. |
|
20 | - * |
|
21 | - * @param string $e Exponent in base64urlUInt encoding |
|
22 | - */ |
|
23 | - public function __construct(string $e) |
|
24 | - { |
|
25 | - $this->_validateEncoding($e); |
|
26 | - parent::__construct(self::PARAM_EXPONENT, $e); |
|
27 | - } |
|
18 | + /** |
|
19 | + * Constructor. |
|
20 | + * |
|
21 | + * @param string $e Exponent in base64urlUInt encoding |
|
22 | + */ |
|
23 | + public function __construct(string $e) |
|
24 | + { |
|
25 | + $this->_validateEncoding($e); |
|
26 | + parent::__construct(self::PARAM_EXPONENT, $e); |
|
27 | + } |
|
28 | 28 | } |
@@ -13,24 +13,24 @@ |
||
13 | 13 | */ |
14 | 14 | class KeyOperationsParameter extends JWKParameter |
15 | 15 | { |
16 | - use ArrayParameterValue; |
|
16 | + use ArrayParameterValue; |
|
17 | 17 | |
18 | - const OP_SIGN = "sign"; |
|
19 | - const OP_VERIFY = "verify"; |
|
20 | - const OP_ENCRYPT = "encrypt"; |
|
21 | - const OP_DECRYPT = "decrypt"; |
|
22 | - const OP_WRAP_KEY = "wrapKey"; |
|
23 | - const OP_UNWRAP_KEY = "unwrapKey"; |
|
24 | - const OP_DERIVE_KEY = "deriveKey"; |
|
25 | - const OP_DERIVE_BITS = "deriveBits"; |
|
18 | + const OP_SIGN = "sign"; |
|
19 | + const OP_VERIFY = "verify"; |
|
20 | + const OP_ENCRYPT = "encrypt"; |
|
21 | + const OP_DECRYPT = "decrypt"; |
|
22 | + const OP_WRAP_KEY = "wrapKey"; |
|
23 | + const OP_UNWRAP_KEY = "unwrapKey"; |
|
24 | + const OP_DERIVE_KEY = "deriveKey"; |
|
25 | + const OP_DERIVE_BITS = "deriveBits"; |
|
26 | 26 | |
27 | - /** |
|
28 | - * Constructor. |
|
29 | - * |
|
30 | - * @param string ...$ops Key operations |
|
31 | - */ |
|
32 | - public function __construct(string ...$ops) |
|
33 | - { |
|
34 | - parent::__construct(self::PARAM_KEY_OPERATIONS, $ops); |
|
35 | - } |
|
27 | + /** |
|
28 | + * Constructor. |
|
29 | + * |
|
30 | + * @param string ...$ops Key operations |
|
31 | + */ |
|
32 | + public function __construct(string ...$ops) |
|
33 | + { |
|
34 | + parent::__construct(self::PARAM_KEY_OPERATIONS, $ops); |
|
35 | + } |
|
36 | 36 | } |
@@ -13,26 +13,26 @@ |
||
13 | 13 | */ |
14 | 14 | class ECCPrivateKeyParameter extends JWKParameter |
15 | 15 | { |
16 | - use Base64URLValue; |
|
16 | + use Base64URLValue; |
|
17 | 17 | |
18 | - /** |
|
19 | - * Constructor. |
|
20 | - * |
|
21 | - * @param string $key Private key in base64url encoding |
|
22 | - */ |
|
23 | - public function __construct(string $key) |
|
24 | - { |
|
25 | - $this->_validateEncoding($key); |
|
26 | - parent::__construct(self::PARAM_ECC_PRIVATE_KEY, $key); |
|
27 | - } |
|
18 | + /** |
|
19 | + * Constructor. |
|
20 | + * |
|
21 | + * @param string $key Private key in base64url encoding |
|
22 | + */ |
|
23 | + public function __construct(string $key) |
|
24 | + { |
|
25 | + $this->_validateEncoding($key); |
|
26 | + parent::__construct(self::PARAM_ECC_PRIVATE_KEY, $key); |
|
27 | + } |
|
28 | 28 | |
29 | - /** |
|
30 | - * Get the EC private key in octet string representation. |
|
31 | - * |
|
32 | - * @return string |
|
33 | - */ |
|
34 | - public function privateKeyOctets(): string |
|
35 | - { |
|
36 | - return $this->string(); |
|
37 | - } |
|
29 | + /** |
|
30 | + * Get the EC private key in octet string representation. |
|
31 | + * |
|
32 | + * @return string |
|
33 | + */ |
|
34 | + public function privateKeyOctets(): string |
|
35 | + { |
|
36 | + return $this->string(); |
|
37 | + } |
|
38 | 38 | } |