1 | <?php |
||
34 | final class OpensslKey |
||
35 | { |
||
36 | private $_iv, $_key, $_algo, $_cipher; |
||
37 | |||
38 | /** |
||
39 | * OpensslKey constructor. |
||
40 | * |
||
41 | * @param string $key Key to use for encryption |
||
42 | * @param string $algo Algo to use for HKDF |
||
43 | * @param string $cipher Name of cipher |
||
44 | * @param string $iv Initialization vector |
||
45 | * |
||
46 | * @throws InvalidKeyLengthException |
||
47 | * @throws InvalidKeyEncodingException |
||
48 | */ |
||
49 | 49 | public function __construct( |
|
71 | |||
72 | /** |
||
73 | * Generate the authentication key. |
||
74 | * |
||
75 | * @return string |
||
76 | */ |
||
77 | 37 | public function authenticationKey(): string |
|
81 | |||
82 | /** |
||
83 | * Generate the encryption key. |
||
84 | * |
||
85 | * @return string |
||
86 | */ |
||
87 | 38 | public function encryptionKey(): string |
|
91 | |||
92 | /** |
||
93 | * Derive a key with differing info string parameters. |
||
94 | * |
||
95 | * @param string $info Info parameter to provide to hash_hkdf |
||
96 | * |
||
97 | * @return string |
||
98 | */ |
||
99 | 40 | public function deriveKey(string $info): string |
|
103 | |||
104 | /** |
||
105 | * Calculates a given message HMAC. |
||
106 | * |
||
107 | * @param string $message |
||
108 | * |
||
109 | * @return string |
||
110 | */ |
||
111 | 37 | public function messageChecksum(string $message): string |
|
115 | |||
116 | /** |
||
117 | * Allows read only access to the internal variables needed by the openssl wrapper. |
||
118 | * |
||
119 | * @return array |
||
120 | */ |
||
121 | 38 | public function wrapperVariables(): array |
|
129 | |||
130 | /** |
||
131 | * Generate a new key. |
||
132 | * |
||
133 | * @param int $bytes Size of key in bytes |
||
134 | * |
||
135 | * @throws Exception |
||
136 | * @throws InvalidKeyLengthException |
||
137 | * |
||
138 | * @return string |
||
139 | */ |
||
140 | 32 | public static function create(int $bytes = 32): string |
|
148 | } |
||
149 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.