Conditions | 2 |
Paths | 2 |
Total Lines | 21 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 2 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
20 | 9 | public function __construct( |
|
21 | $data, |
||
22 | $cipher, |
||
23 | $key, |
||
24 | $options = 0, |
||
25 | $iv = null, |
||
26 | $tag = null, |
||
27 | $aad = '' |
||
28 | ) { |
||
29 | 9 | if (!in_array($cipher, openssl_get_cipher_methods(), true)) { |
|
30 | 3 | throw new \RuntimeException('cipher: ' . $cipher . 'not support'); |
|
31 | } |
||
32 | 6 | $this->data = $data; |
|
33 | 6 | $this->cipher = $cipher; |
|
34 | 6 | $this->key = $key; |
|
35 | 6 | $this->options = $options; |
|
36 | 6 | $ivLen = openssl_cipher_iv_length($cipher); |
|
37 | 6 | $this->iv = $iv ?? openssl_random_pseudo_bytes($ivLen); |
|
38 | 6 | $this->tag = $tag; |
|
39 | 6 | $this->aad = $aad; |
|
40 | 6 | $this->tagLength = mb_strlen($this->tag); |
|
41 | 6 | } |
|
80 |