@@ 41-50 (lines=10) @@ | ||
38 | * |
|
39 | * @return string |
|
40 | */ |
|
41 | protected static function opensslEncrypt(string $data, OpensslKey $key, string &$tag): string |
|
42 | { |
|
43 | list($iv, $enc, $cipher) = $key->wrapperVariables(); |
|
44 | ||
45 | if (self::tagLength($cipher) > 0) { |
|
46 | return openssl_encrypt($data, $cipher, $enc, 1, $iv, $tag, '', 16); |
|
47 | } |
|
48 | ||
49 | return openssl_encrypt($data, $cipher, $enc, 1, $iv); |
|
50 | } |
|
51 | ||
52 | /** |
|
53 | * OpenSSL decrypt wrapper function. |
|
@@ 61-70 (lines=10) @@ | ||
58 | * |
|
59 | * @return string |
|
60 | */ |
|
61 | protected static function opensslDecrypt(string $input, OpensslKey $key, string $tag): string |
|
62 | { |
|
63 | list($iv, $enc, $cipher) = $key->wrapperVariables(); |
|
64 | ||
65 | if (self::tagLength($cipher) > 0) { |
|
66 | return openssl_decrypt($input, $cipher, $enc, 1, $iv, $tag, ''); |
|
67 | } |
|
68 | ||
69 | return openssl_decrypt($input, $cipher, $enc, 1, $iv); |
|
70 | } |
|
71 | ||
72 | /** |
|
73 | * Get IV size for specified CIPHER. |