@@ -30,26 +30,26 @@ discard block |
||
30 | 30 | */ |
31 | 31 | |
32 | 32 | if (!defined('PHP_VERSION_ID')) { |
33 | - // This constant was introduced in PHP 5.2.7 |
|
34 | - $RandomCompatversion = array_map('intval', explode('.', PHP_VERSION)); |
|
35 | - define( |
|
36 | - 'PHP_VERSION_ID', |
|
37 | - $RandomCompatversion[0] * 10000 |
|
38 | - + $RandomCompatversion[1] * 100 |
|
39 | - + $RandomCompatversion[2] |
|
40 | - ); |
|
41 | - $RandomCompatversion = null; |
|
33 | + // This constant was introduced in PHP 5.2.7 |
|
34 | + $RandomCompatversion = array_map('intval', explode('.', PHP_VERSION)); |
|
35 | + define( |
|
36 | + 'PHP_VERSION_ID', |
|
37 | + $RandomCompatversion[0] * 10000 |
|
38 | + + $RandomCompatversion[1] * 100 |
|
39 | + + $RandomCompatversion[2] |
|
40 | + ); |
|
41 | + $RandomCompatversion = null; |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
45 | 45 | * PHP 7.0.0 and newer have these functions natively. |
46 | 46 | */ |
47 | 47 | if (PHP_VERSION_ID >= 70000) { |
48 | - return; |
|
48 | + return; |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | if (!defined('RANDOM_COMPAT_READ_BUFFER')) { |
52 | - define('RANDOM_COMPAT_READ_BUFFER', 8); |
|
52 | + define('RANDOM_COMPAT_READ_BUFFER', 8); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | $RandomCompatDIR = dirname(__FILE__); |
@@ -59,168 +59,168 @@ discard block |
||
59 | 59 | require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'error_polyfill.php'; |
60 | 60 | |
61 | 61 | if (!is_callable('random_bytes')) { |
62 | - /** |
|
63 | - * PHP 5.2.0 - 5.6.x way to implement random_bytes() |
|
64 | - * |
|
65 | - * We use conditional statements here to define the function in accordance |
|
66 | - * to the operating environment. It's a micro-optimization. |
|
67 | - * |
|
68 | - * In order of preference: |
|
69 | - * 1. Use libsodium if available. |
|
70 | - * 2. fread() /dev/urandom if available (never on Windows) |
|
71 | - * 3. mcrypt_create_iv($bytes, MCRYPT_DEV_URANDOM) |
|
72 | - * 4. COM('CAPICOM.Utilities.1')->GetRandom() |
|
73 | - * |
|
74 | - * See RATIONALE.md for our reasoning behind this particular order |
|
75 | - */ |
|
76 | - if (extension_loaded('libsodium')) { |
|
77 | - // See random_bytes_libsodium.php |
|
78 | - if (PHP_VERSION_ID >= 50300 && is_callable('\\Sodium\\randombytes_buf')) { |
|
79 | - require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_bytes_libsodium.php'; |
|
80 | - } elseif (method_exists('Sodium', 'randombytes_buf')) { |
|
81 | - require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_bytes_libsodium_legacy.php'; |
|
82 | - } |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * Reading directly from /dev/urandom: |
|
87 | - */ |
|
88 | - if (DIRECTORY_SEPARATOR === '/') { |
|
89 | - // DIRECTORY_SEPARATOR === '/' on Unix-like OSes -- this is a fast |
|
90 | - // way to exclude Windows. |
|
91 | - $RandomCompatUrandom = true; |
|
92 | - $RandomCompat_basedir = ini_get('open_basedir'); |
|
93 | - |
|
94 | - if (!empty($RandomCompat_basedir)) { |
|
95 | - $RandomCompat_open_basedir = explode( |
|
96 | - PATH_SEPARATOR, |
|
97 | - strtolower($RandomCompat_basedir) |
|
98 | - ); |
|
99 | - $RandomCompatUrandom = (array() !== array_intersect( |
|
100 | - array('/dev', '/dev/', '/dev/urandom'), |
|
101 | - $RandomCompat_open_basedir |
|
102 | - )); |
|
103 | - $RandomCompat_open_basedir = null; |
|
104 | - } |
|
105 | - |
|
106 | - if ( |
|
107 | - !is_callable('random_bytes') |
|
108 | - && |
|
109 | - $RandomCompatUrandom |
|
110 | - && |
|
111 | - @is_readable('/dev/urandom') |
|
112 | - ) { |
|
113 | - // Error suppression on is_readable() in case of an open_basedir |
|
114 | - // or safe_mode failure. All we care about is whether or not we |
|
115 | - // can read it at this point. If the PHP environment is going to |
|
116 | - // panic over trying to see if the file can be read in the first |
|
117 | - // place, that is not helpful to us here. |
|
118 | - |
|
119 | - // See random_bytes_dev_urandom.php |
|
120 | - require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_bytes_dev_urandom.php'; |
|
121 | - } |
|
122 | - // Unset variables after use |
|
123 | - $RandomCompat_basedir = null; |
|
124 | - } else { |
|
125 | - $RandomCompatUrandom = false; |
|
126 | - } |
|
127 | - |
|
128 | - /** |
|
129 | - * mcrypt_create_iv() |
|
130 | - * |
|
131 | - * We only want to use mcypt_create_iv() if: |
|
132 | - * |
|
133 | - * - random_bytes() hasn't already been defined |
|
134 | - * - the mcrypt extensions is loaded |
|
135 | - * - One of these two conditions is true: |
|
136 | - * - We're on Windows (DIRECTORY_SEPARATOR !== '/') |
|
137 | - * - We're not on Windows and /dev/urandom is readabale |
|
138 | - * (i.e. we're not in a chroot jail) |
|
139 | - * - Special case: |
|
140 | - * - If we're not on Windows, but the PHP version is between |
|
141 | - * 5.6.10 and 5.6.12, we don't want to use mcrypt. It will |
|
142 | - * hang indefinitely. This is bad. |
|
143 | - * - If we're on Windows, we want to use PHP >= 5.3.7 or else |
|
144 | - * we get insufficient entropy errors. |
|
145 | - */ |
|
146 | - if ( |
|
147 | - !is_callable('random_bytes') |
|
148 | - && |
|
149 | - // Windows on PHP < 5.3.7 is broken, but non-Windows is not known to be. |
|
150 | - (DIRECTORY_SEPARATOR === '/' || PHP_VERSION_ID >= 50307) |
|
151 | - && |
|
152 | - // Prevent this code from hanging indefinitely on non-Windows; |
|
153 | - // see https://bugs.php.net/bug.php?id=69833 |
|
154 | - ( |
|
155 | - DIRECTORY_SEPARATOR !== '/' || |
|
156 | - (PHP_VERSION_ID <= 50609 || PHP_VERSION_ID >= 50613) |
|
157 | - ) |
|
158 | - && |
|
159 | - extension_loaded('mcrypt') |
|
160 | - ) { |
|
161 | - // See random_bytes_mcrypt.php |
|
162 | - require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_bytes_mcrypt.php'; |
|
163 | - } |
|
164 | - $RandomCompatUrandom = null; |
|
165 | - |
|
166 | - /** |
|
167 | - * This is a Windows-specific fallback, for when the mcrypt extension |
|
168 | - * isn't loaded. |
|
169 | - */ |
|
170 | - if ( |
|
171 | - !is_callable('random_bytes') |
|
172 | - && |
|
173 | - extension_loaded('com_dotnet') |
|
174 | - && |
|
175 | - class_exists('COM') |
|
176 | - ) { |
|
177 | - $RandomCompat_disabled_classes = preg_split( |
|
178 | - '#\s*,\s*#', |
|
179 | - strtolower(ini_get('disable_classes')) |
|
180 | - ); |
|
181 | - |
|
182 | - if (!in_array('com', $RandomCompat_disabled_classes)) { |
|
183 | - try { |
|
184 | - $RandomCompatCOMtest = new COM('CAPICOM.Utilities.1'); |
|
185 | - /** @psalm-suppress TypeDoesNotContainType */ |
|
186 | - if (method_exists($RandomCompatCOMtest, 'GetRandom')) { |
|
187 | - // See random_bytes_com_dotnet.php |
|
188 | - require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_bytes_com_dotnet.php'; |
|
189 | - } |
|
190 | - } catch (com_exception $e) { |
|
191 | - // Don't try to use it. |
|
192 | - } |
|
193 | - } |
|
194 | - $RandomCompat_disabled_classes = null; |
|
195 | - $RandomCompatCOMtest = null; |
|
196 | - } |
|
197 | - |
|
198 | - /** |
|
199 | - * throw new Exception |
|
200 | - */ |
|
201 | - if (!is_callable('random_bytes')) { |
|
202 | - /** |
|
203 | - * We don't have any more options, so let's throw an exception right now |
|
204 | - * and hope the developer won't let it fail silently. |
|
205 | - * |
|
206 | - * @param mixed $length |
|
207 | - * @psalm-suppress InvalidReturnType |
|
208 | - * @throws Exception |
|
209 | - * @return string |
|
210 | - */ |
|
211 | - function random_bytes($length) |
|
212 | - { |
|
213 | - unset($length); // Suppress "variable not used" warnings. |
|
214 | - throw new Exception( |
|
215 | - 'There is no suitable CSPRNG installed on your system' |
|
216 | - ); |
|
217 | - return ''; |
|
218 | - } |
|
219 | - } |
|
62 | + /** |
|
63 | + * PHP 5.2.0 - 5.6.x way to implement random_bytes() |
|
64 | + * |
|
65 | + * We use conditional statements here to define the function in accordance |
|
66 | + * to the operating environment. It's a micro-optimization. |
|
67 | + * |
|
68 | + * In order of preference: |
|
69 | + * 1. Use libsodium if available. |
|
70 | + * 2. fread() /dev/urandom if available (never on Windows) |
|
71 | + * 3. mcrypt_create_iv($bytes, MCRYPT_DEV_URANDOM) |
|
72 | + * 4. COM('CAPICOM.Utilities.1')->GetRandom() |
|
73 | + * |
|
74 | + * See RATIONALE.md for our reasoning behind this particular order |
|
75 | + */ |
|
76 | + if (extension_loaded('libsodium')) { |
|
77 | + // See random_bytes_libsodium.php |
|
78 | + if (PHP_VERSION_ID >= 50300 && is_callable('\\Sodium\\randombytes_buf')) { |
|
79 | + require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_bytes_libsodium.php'; |
|
80 | + } elseif (method_exists('Sodium', 'randombytes_buf')) { |
|
81 | + require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_bytes_libsodium_legacy.php'; |
|
82 | + } |
|
83 | + } |
|
84 | + |
|
85 | + /** |
|
86 | + * Reading directly from /dev/urandom: |
|
87 | + */ |
|
88 | + if (DIRECTORY_SEPARATOR === '/') { |
|
89 | + // DIRECTORY_SEPARATOR === '/' on Unix-like OSes -- this is a fast |
|
90 | + // way to exclude Windows. |
|
91 | + $RandomCompatUrandom = true; |
|
92 | + $RandomCompat_basedir = ini_get('open_basedir'); |
|
93 | + |
|
94 | + if (!empty($RandomCompat_basedir)) { |
|
95 | + $RandomCompat_open_basedir = explode( |
|
96 | + PATH_SEPARATOR, |
|
97 | + strtolower($RandomCompat_basedir) |
|
98 | + ); |
|
99 | + $RandomCompatUrandom = (array() !== array_intersect( |
|
100 | + array('/dev', '/dev/', '/dev/urandom'), |
|
101 | + $RandomCompat_open_basedir |
|
102 | + )); |
|
103 | + $RandomCompat_open_basedir = null; |
|
104 | + } |
|
105 | + |
|
106 | + if ( |
|
107 | + !is_callable('random_bytes') |
|
108 | + && |
|
109 | + $RandomCompatUrandom |
|
110 | + && |
|
111 | + @is_readable('/dev/urandom') |
|
112 | + ) { |
|
113 | + // Error suppression on is_readable() in case of an open_basedir |
|
114 | + // or safe_mode failure. All we care about is whether or not we |
|
115 | + // can read it at this point. If the PHP environment is going to |
|
116 | + // panic over trying to see if the file can be read in the first |
|
117 | + // place, that is not helpful to us here. |
|
118 | + |
|
119 | + // See random_bytes_dev_urandom.php |
|
120 | + require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_bytes_dev_urandom.php'; |
|
121 | + } |
|
122 | + // Unset variables after use |
|
123 | + $RandomCompat_basedir = null; |
|
124 | + } else { |
|
125 | + $RandomCompatUrandom = false; |
|
126 | + } |
|
127 | + |
|
128 | + /** |
|
129 | + * mcrypt_create_iv() |
|
130 | + * |
|
131 | + * We only want to use mcypt_create_iv() if: |
|
132 | + * |
|
133 | + * - random_bytes() hasn't already been defined |
|
134 | + * - the mcrypt extensions is loaded |
|
135 | + * - One of these two conditions is true: |
|
136 | + * - We're on Windows (DIRECTORY_SEPARATOR !== '/') |
|
137 | + * - We're not on Windows and /dev/urandom is readabale |
|
138 | + * (i.e. we're not in a chroot jail) |
|
139 | + * - Special case: |
|
140 | + * - If we're not on Windows, but the PHP version is between |
|
141 | + * 5.6.10 and 5.6.12, we don't want to use mcrypt. It will |
|
142 | + * hang indefinitely. This is bad. |
|
143 | + * - If we're on Windows, we want to use PHP >= 5.3.7 or else |
|
144 | + * we get insufficient entropy errors. |
|
145 | + */ |
|
146 | + if ( |
|
147 | + !is_callable('random_bytes') |
|
148 | + && |
|
149 | + // Windows on PHP < 5.3.7 is broken, but non-Windows is not known to be. |
|
150 | + (DIRECTORY_SEPARATOR === '/' || PHP_VERSION_ID >= 50307) |
|
151 | + && |
|
152 | + // Prevent this code from hanging indefinitely on non-Windows; |
|
153 | + // see https://bugs.php.net/bug.php?id=69833 |
|
154 | + ( |
|
155 | + DIRECTORY_SEPARATOR !== '/' || |
|
156 | + (PHP_VERSION_ID <= 50609 || PHP_VERSION_ID >= 50613) |
|
157 | + ) |
|
158 | + && |
|
159 | + extension_loaded('mcrypt') |
|
160 | + ) { |
|
161 | + // See random_bytes_mcrypt.php |
|
162 | + require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_bytes_mcrypt.php'; |
|
163 | + } |
|
164 | + $RandomCompatUrandom = null; |
|
165 | + |
|
166 | + /** |
|
167 | + * This is a Windows-specific fallback, for when the mcrypt extension |
|
168 | + * isn't loaded. |
|
169 | + */ |
|
170 | + if ( |
|
171 | + !is_callable('random_bytes') |
|
172 | + && |
|
173 | + extension_loaded('com_dotnet') |
|
174 | + && |
|
175 | + class_exists('COM') |
|
176 | + ) { |
|
177 | + $RandomCompat_disabled_classes = preg_split( |
|
178 | + '#\s*,\s*#', |
|
179 | + strtolower(ini_get('disable_classes')) |
|
180 | + ); |
|
181 | + |
|
182 | + if (!in_array('com', $RandomCompat_disabled_classes)) { |
|
183 | + try { |
|
184 | + $RandomCompatCOMtest = new COM('CAPICOM.Utilities.1'); |
|
185 | + /** @psalm-suppress TypeDoesNotContainType */ |
|
186 | + if (method_exists($RandomCompatCOMtest, 'GetRandom')) { |
|
187 | + // See random_bytes_com_dotnet.php |
|
188 | + require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_bytes_com_dotnet.php'; |
|
189 | + } |
|
190 | + } catch (com_exception $e) { |
|
191 | + // Don't try to use it. |
|
192 | + } |
|
193 | + } |
|
194 | + $RandomCompat_disabled_classes = null; |
|
195 | + $RandomCompatCOMtest = null; |
|
196 | + } |
|
197 | + |
|
198 | + /** |
|
199 | + * throw new Exception |
|
200 | + */ |
|
201 | + if (!is_callable('random_bytes')) { |
|
202 | + /** |
|
203 | + * We don't have any more options, so let's throw an exception right now |
|
204 | + * and hope the developer won't let it fail silently. |
|
205 | + * |
|
206 | + * @param mixed $length |
|
207 | + * @psalm-suppress InvalidReturnType |
|
208 | + * @throws Exception |
|
209 | + * @return string |
|
210 | + */ |
|
211 | + function random_bytes($length) |
|
212 | + { |
|
213 | + unset($length); // Suppress "variable not used" warnings. |
|
214 | + throw new Exception( |
|
215 | + 'There is no suitable CSPRNG installed on your system' |
|
216 | + ); |
|
217 | + return ''; |
|
218 | + } |
|
219 | + } |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | if (!is_callable('random_int')) { |
223 | - require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_int.php'; |
|
223 | + require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_int.php'; |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | $RandomCompatDIR = null; |
@@ -29,14 +29,14 @@ discard block |
||
29 | 29 | * SOFTWARE. |
30 | 30 | */ |
31 | 31 | |
32 | -if (!defined('PHP_VERSION_ID')) { |
|
32 | +if ( ! defined( 'PHP_VERSION_ID' ) ) { |
|
33 | 33 | // This constant was introduced in PHP 5.2.7 |
34 | - $RandomCompatversion = array_map('intval', explode('.', PHP_VERSION)); |
|
34 | + $RandomCompatversion = array_map( 'intval', explode( '.', PHP_VERSION ) ); |
|
35 | 35 | define( |
36 | 36 | 'PHP_VERSION_ID', |
37 | - $RandomCompatversion[0] * 10000 |
|
38 | - + $RandomCompatversion[1] * 100 |
|
39 | - + $RandomCompatversion[2] |
|
37 | + $RandomCompatversion[ 0 ] * 10000 |
|
38 | + + $RandomCompatversion[ 1 ] * 100 |
|
39 | + + $RandomCompatversion[ 2 ] |
|
40 | 40 | ); |
41 | 41 | $RandomCompatversion = null; |
42 | 42 | } |
@@ -44,21 +44,21 @@ discard block |
||
44 | 44 | /** |
45 | 45 | * PHP 7.0.0 and newer have these functions natively. |
46 | 46 | */ |
47 | -if (PHP_VERSION_ID >= 70000) { |
|
47 | +if ( PHP_VERSION_ID >= 70000 ) { |
|
48 | 48 | return; |
49 | 49 | } |
50 | 50 | |
51 | -if (!defined('RANDOM_COMPAT_READ_BUFFER')) { |
|
52 | - define('RANDOM_COMPAT_READ_BUFFER', 8); |
|
51 | +if ( ! defined( 'RANDOM_COMPAT_READ_BUFFER' ) ) { |
|
52 | + define( 'RANDOM_COMPAT_READ_BUFFER', 8 ); |
|
53 | 53 | } |
54 | 54 | |
55 | -$RandomCompatDIR = dirname(__FILE__); |
|
55 | +$RandomCompatDIR = dirname( __FILE__ ); |
|
56 | 56 | |
57 | -require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'byte_safe_strings.php'; |
|
58 | -require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'cast_to_int.php'; |
|
59 | -require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'error_polyfill.php'; |
|
57 | +require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'byte_safe_strings.php'; |
|
58 | +require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'cast_to_int.php'; |
|
59 | +require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'error_polyfill.php'; |
|
60 | 60 | |
61 | -if (!is_callable('random_bytes')) { |
|
61 | +if ( ! is_callable( 'random_bytes' ) ) { |
|
62 | 62 | /** |
63 | 63 | * PHP 5.2.0 - 5.6.x way to implement random_bytes() |
64 | 64 | * |
@@ -73,42 +73,42 @@ discard block |
||
73 | 73 | * |
74 | 74 | * See RATIONALE.md for our reasoning behind this particular order |
75 | 75 | */ |
76 | - if (extension_loaded('libsodium')) { |
|
76 | + if ( extension_loaded( 'libsodium' ) ) { |
|
77 | 77 | // See random_bytes_libsodium.php |
78 | - if (PHP_VERSION_ID >= 50300 && is_callable('\\Sodium\\randombytes_buf')) { |
|
79 | - require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_bytes_libsodium.php'; |
|
80 | - } elseif (method_exists('Sodium', 'randombytes_buf')) { |
|
81 | - require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_bytes_libsodium_legacy.php'; |
|
78 | + if ( PHP_VERSION_ID >= 50300 && is_callable( '\\Sodium\\randombytes_buf' ) ) { |
|
79 | + require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'random_bytes_libsodium.php'; |
|
80 | + } elseif ( method_exists( 'Sodium', 'randombytes_buf' ) ) { |
|
81 | + require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'random_bytes_libsodium_legacy.php'; |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
86 | 86 | * Reading directly from /dev/urandom: |
87 | 87 | */ |
88 | - if (DIRECTORY_SEPARATOR === '/') { |
|
88 | + if ( DIRECTORY_SEPARATOR === '/' ) { |
|
89 | 89 | // DIRECTORY_SEPARATOR === '/' on Unix-like OSes -- this is a fast |
90 | 90 | // way to exclude Windows. |
91 | 91 | $RandomCompatUrandom = true; |
92 | - $RandomCompat_basedir = ini_get('open_basedir'); |
|
92 | + $RandomCompat_basedir = ini_get( 'open_basedir' ); |
|
93 | 93 | |
94 | - if (!empty($RandomCompat_basedir)) { |
|
94 | + if ( ! empty( $RandomCompat_basedir ) ) { |
|
95 | 95 | $RandomCompat_open_basedir = explode( |
96 | 96 | PATH_SEPARATOR, |
97 | - strtolower($RandomCompat_basedir) |
|
97 | + strtolower( $RandomCompat_basedir ) |
|
98 | 98 | ); |
99 | - $RandomCompatUrandom = (array() !== array_intersect( |
|
100 | - array('/dev', '/dev/', '/dev/urandom'), |
|
99 | + $RandomCompatUrandom = ( array() !== array_intersect( |
|
100 | + array( '/dev', '/dev/', '/dev/urandom' ), |
|
101 | 101 | $RandomCompat_open_basedir |
102 | - )); |
|
102 | + ) ); |
|
103 | 103 | $RandomCompat_open_basedir = null; |
104 | 104 | } |
105 | 105 | |
106 | 106 | if ( |
107 | - !is_callable('random_bytes') |
|
107 | + ! is_callable( 'random_bytes' ) |
|
108 | 108 | && |
109 | 109 | $RandomCompatUrandom |
110 | 110 | && |
111 | - @is_readable('/dev/urandom') |
|
111 | + @is_readable( '/dev/urandom' ) |
|
112 | 112 | ) { |
113 | 113 | // Error suppression on is_readable() in case of an open_basedir |
114 | 114 | // or safe_mode failure. All we care about is whether or not we |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | // place, that is not helpful to us here. |
118 | 118 | |
119 | 119 | // See random_bytes_dev_urandom.php |
120 | - require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_bytes_dev_urandom.php'; |
|
120 | + require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'random_bytes_dev_urandom.php'; |
|
121 | 121 | } |
122 | 122 | // Unset variables after use |
123 | 123 | $RandomCompat_basedir = null; |
@@ -144,22 +144,22 @@ discard block |
||
144 | 144 | * we get insufficient entropy errors. |
145 | 145 | */ |
146 | 146 | if ( |
147 | - !is_callable('random_bytes') |
|
147 | + ! is_callable( 'random_bytes' ) |
|
148 | 148 | && |
149 | 149 | // Windows on PHP < 5.3.7 is broken, but non-Windows is not known to be. |
150 | - (DIRECTORY_SEPARATOR === '/' || PHP_VERSION_ID >= 50307) |
|
150 | + ( DIRECTORY_SEPARATOR === '/' || PHP_VERSION_ID >= 50307 ) |
|
151 | 151 | && |
152 | 152 | // Prevent this code from hanging indefinitely on non-Windows; |
153 | 153 | // see https://bugs.php.net/bug.php?id=69833 |
154 | 154 | ( |
155 | 155 | DIRECTORY_SEPARATOR !== '/' || |
156 | - (PHP_VERSION_ID <= 50609 || PHP_VERSION_ID >= 50613) |
|
156 | + ( PHP_VERSION_ID <= 50609 || PHP_VERSION_ID >= 50613 ) |
|
157 | 157 | ) |
158 | 158 | && |
159 | - extension_loaded('mcrypt') |
|
159 | + extension_loaded( 'mcrypt' ) |
|
160 | 160 | ) { |
161 | 161 | // See random_bytes_mcrypt.php |
162 | - require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_bytes_mcrypt.php'; |
|
162 | + require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'random_bytes_mcrypt.php'; |
|
163 | 163 | } |
164 | 164 | $RandomCompatUrandom = null; |
165 | 165 | |
@@ -168,26 +168,26 @@ discard block |
||
168 | 168 | * isn't loaded. |
169 | 169 | */ |
170 | 170 | if ( |
171 | - !is_callable('random_bytes') |
|
171 | + ! is_callable( 'random_bytes' ) |
|
172 | 172 | && |
173 | - extension_loaded('com_dotnet') |
|
173 | + extension_loaded( 'com_dotnet' ) |
|
174 | 174 | && |
175 | - class_exists('COM') |
|
175 | + class_exists( 'COM' ) |
|
176 | 176 | ) { |
177 | 177 | $RandomCompat_disabled_classes = preg_split( |
178 | 178 | '#\s*,\s*#', |
179 | - strtolower(ini_get('disable_classes')) |
|
179 | + strtolower( ini_get( 'disable_classes' ) ) |
|
180 | 180 | ); |
181 | 181 | |
182 | - if (!in_array('com', $RandomCompat_disabled_classes)) { |
|
182 | + if ( ! in_array( 'com', $RandomCompat_disabled_classes ) ) { |
|
183 | 183 | try { |
184 | - $RandomCompatCOMtest = new COM('CAPICOM.Utilities.1'); |
|
184 | + $RandomCompatCOMtest = new COM( 'CAPICOM.Utilities.1' ); |
|
185 | 185 | /** @psalm-suppress TypeDoesNotContainType */ |
186 | - if (method_exists($RandomCompatCOMtest, 'GetRandom')) { |
|
186 | + if ( method_exists( $RandomCompatCOMtest, 'GetRandom' ) ) { |
|
187 | 187 | // See random_bytes_com_dotnet.php |
188 | - require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_bytes_com_dotnet.php'; |
|
188 | + require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'random_bytes_com_dotnet.php'; |
|
189 | 189 | } |
190 | - } catch (com_exception $e) { |
|
190 | + } catch ( com_exception $e ) { |
|
191 | 191 | // Don't try to use it. |
192 | 192 | } |
193 | 193 | } |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | /** |
199 | 199 | * throw new Exception |
200 | 200 | */ |
201 | - if (!is_callable('random_bytes')) { |
|
201 | + if ( ! is_callable( 'random_bytes' ) ) { |
|
202 | 202 | /** |
203 | 203 | * We don't have any more options, so let's throw an exception right now |
204 | 204 | * and hope the developer won't let it fail silently. |
@@ -208,9 +208,9 @@ discard block |
||
208 | 208 | * @throws Exception |
209 | 209 | * @return string |
210 | 210 | */ |
211 | - function random_bytes($length) |
|
211 | + function random_bytes( $length ) |
|
212 | 212 | { |
213 | - unset($length); // Suppress "variable not used" warnings. |
|
213 | + unset( $length ); // Suppress "variable not used" warnings. |
|
214 | 214 | throw new Exception( |
215 | 215 | 'There is no suitable CSPRNG installed on your system' |
216 | 216 | ); |
@@ -219,8 +219,8 @@ discard block |
||
219 | 219 | } |
220 | 220 | } |
221 | 221 | |
222 | -if (!is_callable('random_int')) { |
|
223 | - require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_int.php'; |
|
222 | +if ( ! is_callable( 'random_int' ) ) { |
|
223 | + require_once $RandomCompatDIR . DIRECTORY_SEPARATOR . 'random_int.php'; |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | $RandomCompatDIR = null; |
@@ -208,8 +208,7 @@ |
||
208 | 208 | * @throws Exception |
209 | 209 | * @return string |
210 | 210 | */ |
211 | - function random_bytes($length) |
|
212 | - { |
|
211 | + function random_bytes($length) { |
|
213 | 212 | unset($length); // Suppress "variable not used" warnings. |
214 | 213 | throw new Exception( |
215 | 214 | 'There is no suitable CSPRNG installed on your system' |
@@ -27,23 +27,23 @@ |
||
27 | 27 | */ |
28 | 28 | |
29 | 29 | if (!class_exists('Error', false)) { |
30 | - // We can't really avoid making this extend Exception in PHP 5. |
|
31 | - class Error extends Exception |
|
32 | - { |
|
30 | + // We can't really avoid making this extend Exception in PHP 5. |
|
31 | + class Error extends Exception |
|
32 | + { |
|
33 | 33 | |
34 | - } |
|
34 | + } |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | if (!class_exists('TypeError', false)) { |
38 | - if (is_subclass_of('Error', 'Exception')) { |
|
39 | - class TypeError extends Error |
|
40 | - { |
|
38 | + if (is_subclass_of('Error', 'Exception')) { |
|
39 | + class TypeError extends Error |
|
40 | + { |
|
41 | 41 | |
42 | - } |
|
43 | - } else { |
|
44 | - class TypeError extends Exception |
|
45 | - { |
|
42 | + } |
|
43 | + } else { |
|
44 | + class TypeError extends Exception |
|
45 | + { |
|
46 | 46 | |
47 | - } |
|
48 | - } |
|
47 | + } |
|
48 | + } |
|
49 | 49 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * SOFTWARE. |
27 | 27 | */ |
28 | 28 | |
29 | -if (!class_exists('Error', false)) { |
|
29 | +if ( ! class_exists( 'Error', false ) ) { |
|
30 | 30 | // We can't really avoid making this extend Exception in PHP 5. |
31 | 31 | class Error extends Exception |
32 | 32 | { |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | } |
35 | 35 | } |
36 | 36 | |
37 | -if (!class_exists('TypeError', false)) { |
|
38 | - if (is_subclass_of('Error', 'Exception')) { |
|
37 | +if ( ! class_exists( 'TypeError', false ) ) { |
|
38 | + if ( is_subclass_of( 'Error', 'Exception' ) ) { |
|
39 | 39 | class TypeError extends Error |
40 | 40 | { |
41 | 41 |
@@ -28,21 +28,18 @@ |
||
28 | 28 | |
29 | 29 | if (!class_exists('Error', false)) { |
30 | 30 | // We can't really avoid making this extend Exception in PHP 5. |
31 | - class Error extends Exception |
|
32 | - { |
|
31 | + class Error extends Exception { |
|
33 | 32 | |
34 | 33 | } |
35 | 34 | } |
36 | 35 | |
37 | 36 | if (!class_exists('TypeError', false)) { |
38 | 37 | if (is_subclass_of('Error', 'Exception')) { |
39 | - class TypeError extends Error |
|
40 | - { |
|
38 | + class TypeError extends Error { |
|
41 | 39 | |
42 | 40 | } |
43 | 41 | } else { |
44 | - class TypeError extends Exception |
|
45 | - { |
|
42 | + class TypeError extends Exception { |
|
46 | 43 | |
47 | 44 | } |
48 | 45 | } |
@@ -27,169 +27,169 @@ |
||
27 | 27 | */ |
28 | 28 | |
29 | 29 | if (!is_callable('RandomCompat_strlen')) { |
30 | - if ( |
|
31 | - defined('MB_OVERLOAD_STRING') |
|
32 | - && |
|
33 | - ((int) ini_get('mbstring.func_overload')) & MB_OVERLOAD_STRING |
|
34 | - ) { |
|
35 | - /** |
|
36 | - * strlen() implementation that isn't brittle to mbstring.func_overload |
|
37 | - * |
|
38 | - * This version uses mb_strlen() in '8bit' mode to treat strings as raw |
|
39 | - * binary rather than UTF-8, ISO-8859-1, etc |
|
40 | - * |
|
41 | - * @param string $binary_string |
|
42 | - * |
|
43 | - * @throws TypeError |
|
44 | - * |
|
45 | - * @return int |
|
46 | - */ |
|
47 | - function RandomCompat_strlen($binary_string) |
|
48 | - { |
|
49 | - if (!is_string($binary_string)) { |
|
50 | - throw new TypeError( |
|
51 | - 'RandomCompat_strlen() expects a string' |
|
52 | - ); |
|
53 | - } |
|
30 | + if ( |
|
31 | + defined('MB_OVERLOAD_STRING') |
|
32 | + && |
|
33 | + ((int) ini_get('mbstring.func_overload')) & MB_OVERLOAD_STRING |
|
34 | + ) { |
|
35 | + /** |
|
36 | + * strlen() implementation that isn't brittle to mbstring.func_overload |
|
37 | + * |
|
38 | + * This version uses mb_strlen() in '8bit' mode to treat strings as raw |
|
39 | + * binary rather than UTF-8, ISO-8859-1, etc |
|
40 | + * |
|
41 | + * @param string $binary_string |
|
42 | + * |
|
43 | + * @throws TypeError |
|
44 | + * |
|
45 | + * @return int |
|
46 | + */ |
|
47 | + function RandomCompat_strlen($binary_string) |
|
48 | + { |
|
49 | + if (!is_string($binary_string)) { |
|
50 | + throw new TypeError( |
|
51 | + 'RandomCompat_strlen() expects a string' |
|
52 | + ); |
|
53 | + } |
|
54 | 54 | |
55 | - return (int) mb_strlen($binary_string, '8bit'); |
|
56 | - } |
|
55 | + return (int) mb_strlen($binary_string, '8bit'); |
|
56 | + } |
|
57 | 57 | |
58 | - } else { |
|
59 | - /** |
|
60 | - * strlen() implementation that isn't brittle to mbstring.func_overload |
|
61 | - * |
|
62 | - * This version just used the default strlen() |
|
63 | - * |
|
64 | - * @param string $binary_string |
|
65 | - * |
|
66 | - * @throws TypeError |
|
67 | - * |
|
68 | - * @return int |
|
69 | - */ |
|
70 | - function RandomCompat_strlen($binary_string) |
|
71 | - { |
|
72 | - if (!is_string($binary_string)) { |
|
73 | - throw new TypeError( |
|
74 | - 'RandomCompat_strlen() expects a string' |
|
75 | - ); |
|
76 | - } |
|
77 | - return (int) strlen($binary_string); |
|
78 | - } |
|
79 | - } |
|
58 | + } else { |
|
59 | + /** |
|
60 | + * strlen() implementation that isn't brittle to mbstring.func_overload |
|
61 | + * |
|
62 | + * This version just used the default strlen() |
|
63 | + * |
|
64 | + * @param string $binary_string |
|
65 | + * |
|
66 | + * @throws TypeError |
|
67 | + * |
|
68 | + * @return int |
|
69 | + */ |
|
70 | + function RandomCompat_strlen($binary_string) |
|
71 | + { |
|
72 | + if (!is_string($binary_string)) { |
|
73 | + throw new TypeError( |
|
74 | + 'RandomCompat_strlen() expects a string' |
|
75 | + ); |
|
76 | + } |
|
77 | + return (int) strlen($binary_string); |
|
78 | + } |
|
79 | + } |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | if (!is_callable('RandomCompat_substr')) { |
83 | 83 | |
84 | - if ( |
|
85 | - defined('MB_OVERLOAD_STRING') |
|
86 | - && |
|
87 | - ((int) ini_get('mbstring.func_overload')) & MB_OVERLOAD_STRING |
|
88 | - ) { |
|
89 | - /** |
|
90 | - * substr() implementation that isn't brittle to mbstring.func_overload |
|
91 | - * |
|
92 | - * This version uses mb_substr() in '8bit' mode to treat strings as raw |
|
93 | - * binary rather than UTF-8, ISO-8859-1, etc |
|
94 | - * |
|
95 | - * @param string $binary_string |
|
96 | - * @param int $start |
|
97 | - * @param int|null $length (optional) |
|
98 | - * |
|
99 | - * @throws TypeError |
|
100 | - * |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - function RandomCompat_substr($binary_string, $start, $length = null) |
|
104 | - { |
|
105 | - if (!is_string($binary_string)) { |
|
106 | - throw new TypeError( |
|
107 | - 'RandomCompat_substr(): First argument should be a string' |
|
108 | - ); |
|
109 | - } |
|
84 | + if ( |
|
85 | + defined('MB_OVERLOAD_STRING') |
|
86 | + && |
|
87 | + ((int) ini_get('mbstring.func_overload')) & MB_OVERLOAD_STRING |
|
88 | + ) { |
|
89 | + /** |
|
90 | + * substr() implementation that isn't brittle to mbstring.func_overload |
|
91 | + * |
|
92 | + * This version uses mb_substr() in '8bit' mode to treat strings as raw |
|
93 | + * binary rather than UTF-8, ISO-8859-1, etc |
|
94 | + * |
|
95 | + * @param string $binary_string |
|
96 | + * @param int $start |
|
97 | + * @param int|null $length (optional) |
|
98 | + * |
|
99 | + * @throws TypeError |
|
100 | + * |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + function RandomCompat_substr($binary_string, $start, $length = null) |
|
104 | + { |
|
105 | + if (!is_string($binary_string)) { |
|
106 | + throw new TypeError( |
|
107 | + 'RandomCompat_substr(): First argument should be a string' |
|
108 | + ); |
|
109 | + } |
|
110 | 110 | |
111 | - if (!is_int($start)) { |
|
112 | - throw new TypeError( |
|
113 | - 'RandomCompat_substr(): Second argument should be an integer' |
|
114 | - ); |
|
115 | - } |
|
111 | + if (!is_int($start)) { |
|
112 | + throw new TypeError( |
|
113 | + 'RandomCompat_substr(): Second argument should be an integer' |
|
114 | + ); |
|
115 | + } |
|
116 | 116 | |
117 | - if ($length === null) { |
|
118 | - /** |
|
119 | - * mb_substr($str, 0, NULL, '8bit') returns an empty string on |
|
120 | - * PHP 5.3, so we have to find the length ourselves. |
|
121 | - */ |
|
122 | - /** @var int $length */ |
|
123 | - $length = RandomCompat_strlen($binary_string) - $start; |
|
124 | - } elseif (!is_int($length)) { |
|
125 | - throw new TypeError( |
|
126 | - 'RandomCompat_substr(): Third argument should be an integer, or omitted' |
|
127 | - ); |
|
128 | - } |
|
117 | + if ($length === null) { |
|
118 | + /** |
|
119 | + * mb_substr($str, 0, NULL, '8bit') returns an empty string on |
|
120 | + * PHP 5.3, so we have to find the length ourselves. |
|
121 | + */ |
|
122 | + /** @var int $length */ |
|
123 | + $length = RandomCompat_strlen($binary_string) - $start; |
|
124 | + } elseif (!is_int($length)) { |
|
125 | + throw new TypeError( |
|
126 | + 'RandomCompat_substr(): Third argument should be an integer, or omitted' |
|
127 | + ); |
|
128 | + } |
|
129 | 129 | |
130 | - // Consistency with PHP's behavior |
|
131 | - if ($start === RandomCompat_strlen($binary_string) && $length === 0) { |
|
132 | - return ''; |
|
133 | - } |
|
134 | - if ($start > RandomCompat_strlen($binary_string)) { |
|
135 | - return ''; |
|
136 | - } |
|
130 | + // Consistency with PHP's behavior |
|
131 | + if ($start === RandomCompat_strlen($binary_string) && $length === 0) { |
|
132 | + return ''; |
|
133 | + } |
|
134 | + if ($start > RandomCompat_strlen($binary_string)) { |
|
135 | + return ''; |
|
136 | + } |
|
137 | 137 | |
138 | - return (string) mb_substr( |
|
139 | - (string) $binary_string, |
|
140 | - (int) $start, |
|
141 | - (int) $length, |
|
142 | - '8bit' |
|
143 | - ); |
|
144 | - } |
|
138 | + return (string) mb_substr( |
|
139 | + (string) $binary_string, |
|
140 | + (int) $start, |
|
141 | + (int) $length, |
|
142 | + '8bit' |
|
143 | + ); |
|
144 | + } |
|
145 | 145 | |
146 | - } else { |
|
146 | + } else { |
|
147 | 147 | |
148 | - /** |
|
149 | - * substr() implementation that isn't brittle to mbstring.func_overload |
|
150 | - * |
|
151 | - * This version just uses the default substr() |
|
152 | - * |
|
153 | - * @param string $binary_string |
|
154 | - * @param int $start |
|
155 | - * @param int|null $length (optional) |
|
156 | - * |
|
157 | - * @throws TypeError |
|
158 | - * |
|
159 | - * @return string |
|
160 | - */ |
|
161 | - function RandomCompat_substr($binary_string, $start, $length = null) |
|
162 | - { |
|
163 | - if (!is_string($binary_string)) { |
|
164 | - throw new TypeError( |
|
165 | - 'RandomCompat_substr(): First argument should be a string' |
|
166 | - ); |
|
167 | - } |
|
148 | + /** |
|
149 | + * substr() implementation that isn't brittle to mbstring.func_overload |
|
150 | + * |
|
151 | + * This version just uses the default substr() |
|
152 | + * |
|
153 | + * @param string $binary_string |
|
154 | + * @param int $start |
|
155 | + * @param int|null $length (optional) |
|
156 | + * |
|
157 | + * @throws TypeError |
|
158 | + * |
|
159 | + * @return string |
|
160 | + */ |
|
161 | + function RandomCompat_substr($binary_string, $start, $length = null) |
|
162 | + { |
|
163 | + if (!is_string($binary_string)) { |
|
164 | + throw new TypeError( |
|
165 | + 'RandomCompat_substr(): First argument should be a string' |
|
166 | + ); |
|
167 | + } |
|
168 | 168 | |
169 | - if (!is_int($start)) { |
|
170 | - throw new TypeError( |
|
171 | - 'RandomCompat_substr(): Second argument should be an integer' |
|
172 | - ); |
|
173 | - } |
|
169 | + if (!is_int($start)) { |
|
170 | + throw new TypeError( |
|
171 | + 'RandomCompat_substr(): Second argument should be an integer' |
|
172 | + ); |
|
173 | + } |
|
174 | 174 | |
175 | - if ($length !== null) { |
|
176 | - if (!is_int($length)) { |
|
177 | - throw new TypeError( |
|
178 | - 'RandomCompat_substr(): Third argument should be an integer, or omitted' |
|
179 | - ); |
|
180 | - } |
|
175 | + if ($length !== null) { |
|
176 | + if (!is_int($length)) { |
|
177 | + throw new TypeError( |
|
178 | + 'RandomCompat_substr(): Third argument should be an integer, or omitted' |
|
179 | + ); |
|
180 | + } |
|
181 | 181 | |
182 | - return (string) substr( |
|
183 | - (string )$binary_string, |
|
184 | - (int) $start, |
|
185 | - (int) $length |
|
186 | - ); |
|
187 | - } |
|
182 | + return (string) substr( |
|
183 | + (string )$binary_string, |
|
184 | + (int) $start, |
|
185 | + (int) $length |
|
186 | + ); |
|
187 | + } |
|
188 | 188 | |
189 | - return (string) substr( |
|
190 | - (string) $binary_string, |
|
191 | - (int) $start |
|
192 | - ); |
|
193 | - } |
|
194 | - } |
|
189 | + return (string) substr( |
|
190 | + (string) $binary_string, |
|
191 | + (int) $start |
|
192 | + ); |
|
193 | + } |
|
194 | + } |
|
195 | 195 | } |
@@ -26,11 +26,11 @@ discard block |
||
26 | 26 | * SOFTWARE. |
27 | 27 | */ |
28 | 28 | |
29 | -if (!is_callable('RandomCompat_strlen')) { |
|
29 | +if ( ! is_callable( 'RandomCompat_strlen' ) ) { |
|
30 | 30 | if ( |
31 | - defined('MB_OVERLOAD_STRING') |
|
31 | + defined( 'MB_OVERLOAD_STRING' ) |
|
32 | 32 | && |
33 | - ((int) ini_get('mbstring.func_overload')) & MB_OVERLOAD_STRING |
|
33 | + ( (int)ini_get( 'mbstring.func_overload' ) ) & MB_OVERLOAD_STRING |
|
34 | 34 | ) { |
35 | 35 | /** |
36 | 36 | * strlen() implementation that isn't brittle to mbstring.func_overload |
@@ -44,15 +44,15 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return int |
46 | 46 | */ |
47 | - function RandomCompat_strlen($binary_string) |
|
47 | + function RandomCompat_strlen( $binary_string ) |
|
48 | 48 | { |
49 | - if (!is_string($binary_string)) { |
|
49 | + if ( ! is_string( $binary_string ) ) { |
|
50 | 50 | throw new TypeError( |
51 | 51 | 'RandomCompat_strlen() expects a string' |
52 | 52 | ); |
53 | 53 | } |
54 | 54 | |
55 | - return (int) mb_strlen($binary_string, '8bit'); |
|
55 | + return (int)mb_strlen( $binary_string, '8bit' ); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | } else { |
@@ -67,24 +67,24 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @return int |
69 | 69 | */ |
70 | - function RandomCompat_strlen($binary_string) |
|
70 | + function RandomCompat_strlen( $binary_string ) |
|
71 | 71 | { |
72 | - if (!is_string($binary_string)) { |
|
72 | + if ( ! is_string( $binary_string ) ) { |
|
73 | 73 | throw new TypeError( |
74 | 74 | 'RandomCompat_strlen() expects a string' |
75 | 75 | ); |
76 | 76 | } |
77 | - return (int) strlen($binary_string); |
|
77 | + return (int)strlen( $binary_string ); |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | } |
81 | 81 | |
82 | -if (!is_callable('RandomCompat_substr')) { |
|
82 | +if ( ! is_callable( 'RandomCompat_substr' ) ) { |
|
83 | 83 | |
84 | 84 | if ( |
85 | - defined('MB_OVERLOAD_STRING') |
|
85 | + defined( 'MB_OVERLOAD_STRING' ) |
|
86 | 86 | && |
87 | - ((int) ini_get('mbstring.func_overload')) & MB_OVERLOAD_STRING |
|
87 | + ( (int)ini_get( 'mbstring.func_overload' ) ) & MB_OVERLOAD_STRING |
|
88 | 88 | ) { |
89 | 89 | /** |
90 | 90 | * substr() implementation that isn't brittle to mbstring.func_overload |
@@ -100,45 +100,45 @@ discard block |
||
100 | 100 | * |
101 | 101 | * @return string |
102 | 102 | */ |
103 | - function RandomCompat_substr($binary_string, $start, $length = null) |
|
103 | + function RandomCompat_substr( $binary_string, $start, $length = null ) |
|
104 | 104 | { |
105 | - if (!is_string($binary_string)) { |
|
105 | + if ( ! is_string( $binary_string ) ) { |
|
106 | 106 | throw new TypeError( |
107 | 107 | 'RandomCompat_substr(): First argument should be a string' |
108 | 108 | ); |
109 | 109 | } |
110 | 110 | |
111 | - if (!is_int($start)) { |
|
111 | + if ( ! is_int( $start ) ) { |
|
112 | 112 | throw new TypeError( |
113 | 113 | 'RandomCompat_substr(): Second argument should be an integer' |
114 | 114 | ); |
115 | 115 | } |
116 | 116 | |
117 | - if ($length === null) { |
|
117 | + if ( $length === null ) { |
|
118 | 118 | /** |
119 | 119 | * mb_substr($str, 0, NULL, '8bit') returns an empty string on |
120 | 120 | * PHP 5.3, so we have to find the length ourselves. |
121 | 121 | */ |
122 | 122 | /** @var int $length */ |
123 | - $length = RandomCompat_strlen($binary_string) - $start; |
|
124 | - } elseif (!is_int($length)) { |
|
123 | + $length = RandomCompat_strlen( $binary_string ) - $start; |
|
124 | + } elseif ( ! is_int( $length ) ) { |
|
125 | 125 | throw new TypeError( |
126 | 126 | 'RandomCompat_substr(): Third argument should be an integer, or omitted' |
127 | 127 | ); |
128 | 128 | } |
129 | 129 | |
130 | 130 | // Consistency with PHP's behavior |
131 | - if ($start === RandomCompat_strlen($binary_string) && $length === 0) { |
|
131 | + if ( $start === RandomCompat_strlen( $binary_string ) && $length === 0 ) { |
|
132 | 132 | return ''; |
133 | 133 | } |
134 | - if ($start > RandomCompat_strlen($binary_string)) { |
|
134 | + if ( $start > RandomCompat_strlen( $binary_string ) ) { |
|
135 | 135 | return ''; |
136 | 136 | } |
137 | 137 | |
138 | - return (string) mb_substr( |
|
139 | - (string) $binary_string, |
|
140 | - (int) $start, |
|
141 | - (int) $length, |
|
138 | + return (string)mb_substr( |
|
139 | + (string)$binary_string, |
|
140 | + (int)$start, |
|
141 | + (int)$length, |
|
142 | 142 | '8bit' |
143 | 143 | ); |
144 | 144 | } |
@@ -158,37 +158,37 @@ discard block |
||
158 | 158 | * |
159 | 159 | * @return string |
160 | 160 | */ |
161 | - function RandomCompat_substr($binary_string, $start, $length = null) |
|
161 | + function RandomCompat_substr( $binary_string, $start, $length = null ) |
|
162 | 162 | { |
163 | - if (!is_string($binary_string)) { |
|
163 | + if ( ! is_string( $binary_string ) ) { |
|
164 | 164 | throw new TypeError( |
165 | 165 | 'RandomCompat_substr(): First argument should be a string' |
166 | 166 | ); |
167 | 167 | } |
168 | 168 | |
169 | - if (!is_int($start)) { |
|
169 | + if ( ! is_int( $start ) ) { |
|
170 | 170 | throw new TypeError( |
171 | 171 | 'RandomCompat_substr(): Second argument should be an integer' |
172 | 172 | ); |
173 | 173 | } |
174 | 174 | |
175 | - if ($length !== null) { |
|
176 | - if (!is_int($length)) { |
|
175 | + if ( $length !== null ) { |
|
176 | + if ( ! is_int( $length ) ) { |
|
177 | 177 | throw new TypeError( |
178 | 178 | 'RandomCompat_substr(): Third argument should be an integer, or omitted' |
179 | 179 | ); |
180 | 180 | } |
181 | 181 | |
182 | - return (string) substr( |
|
183 | - (string )$binary_string, |
|
184 | - (int) $start, |
|
185 | - (int) $length |
|
182 | + return (string)substr( |
|
183 | + (string)$binary_string, |
|
184 | + (int)$start, |
|
185 | + (int)$length |
|
186 | 186 | ); |
187 | 187 | } |
188 | 188 | |
189 | - return (string) substr( |
|
190 | - (string) $binary_string, |
|
191 | - (int) $start |
|
189 | + return (string)substr( |
|
190 | + (string)$binary_string, |
|
191 | + (int)$start |
|
192 | 192 | ); |
193 | 193 | } |
194 | 194 | } |
@@ -44,8 +44,7 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return int |
46 | 46 | */ |
47 | - function RandomCompat_strlen($binary_string) |
|
48 | - { |
|
47 | + function RandomCompat_strlen($binary_string) { |
|
49 | 48 | if (!is_string($binary_string)) { |
50 | 49 | throw new TypeError( |
51 | 50 | 'RandomCompat_strlen() expects a string' |
@@ -67,8 +66,7 @@ discard block |
||
67 | 66 | * |
68 | 67 | * @return int |
69 | 68 | */ |
70 | - function RandomCompat_strlen($binary_string) |
|
71 | - { |
|
69 | + function RandomCompat_strlen($binary_string) { |
|
72 | 70 | if (!is_string($binary_string)) { |
73 | 71 | throw new TypeError( |
74 | 72 | 'RandomCompat_strlen() expects a string' |
@@ -100,8 +98,7 @@ discard block |
||
100 | 98 | * |
101 | 99 | * @return string |
102 | 100 | */ |
103 | - function RandomCompat_substr($binary_string, $start, $length = null) |
|
104 | - { |
|
101 | + function RandomCompat_substr($binary_string, $start, $length = null) { |
|
105 | 102 | if (!is_string($binary_string)) { |
106 | 103 | throw new TypeError( |
107 | 104 | 'RandomCompat_substr(): First argument should be a string' |
@@ -158,8 +155,7 @@ discard block |
||
158 | 155 | * |
159 | 156 | * @return string |
160 | 157 | */ |
161 | - function RandomCompat_substr($binary_string, $start, $length = null) |
|
162 | - { |
|
158 | + function RandomCompat_substr($binary_string, $start, $length = null) { |
|
163 | 159 | if (!is_string($binary_string)) { |
164 | 160 | throw new TypeError( |
165 | 161 | 'RandomCompat_substr(): First argument should be a string' |
@@ -27,65 +27,65 @@ |
||
27 | 27 | */ |
28 | 28 | |
29 | 29 | if (!is_callable('random_bytes')) { |
30 | - /** |
|
31 | - * Windows with PHP < 5.3.0 will not have the function |
|
32 | - * openssl_random_pseudo_bytes() available, so let's use |
|
33 | - * CAPICOM to work around this deficiency. |
|
34 | - * |
|
35 | - * @param int $bytes |
|
36 | - * |
|
37 | - * @throws Exception |
|
38 | - * |
|
39 | - * @return string |
|
40 | - */ |
|
41 | - function random_bytes($bytes) |
|
42 | - { |
|
43 | - try { |
|
44 | - /** @var int $bytes */ |
|
45 | - $bytes = RandomCompat_intval($bytes); |
|
46 | - } catch (TypeError $ex) { |
|
47 | - throw new TypeError( |
|
48 | - 'random_bytes(): $bytes must be an integer' |
|
49 | - ); |
|
50 | - } |
|
30 | + /** |
|
31 | + * Windows with PHP < 5.3.0 will not have the function |
|
32 | + * openssl_random_pseudo_bytes() available, so let's use |
|
33 | + * CAPICOM to work around this deficiency. |
|
34 | + * |
|
35 | + * @param int $bytes |
|
36 | + * |
|
37 | + * @throws Exception |
|
38 | + * |
|
39 | + * @return string |
|
40 | + */ |
|
41 | + function random_bytes($bytes) |
|
42 | + { |
|
43 | + try { |
|
44 | + /** @var int $bytes */ |
|
45 | + $bytes = RandomCompat_intval($bytes); |
|
46 | + } catch (TypeError $ex) { |
|
47 | + throw new TypeError( |
|
48 | + 'random_bytes(): $bytes must be an integer' |
|
49 | + ); |
|
50 | + } |
|
51 | 51 | |
52 | - if ($bytes < 1) { |
|
53 | - throw new Error( |
|
54 | - 'Length must be greater than 0' |
|
55 | - ); |
|
56 | - } |
|
52 | + if ($bytes < 1) { |
|
53 | + throw new Error( |
|
54 | + 'Length must be greater than 0' |
|
55 | + ); |
|
56 | + } |
|
57 | 57 | |
58 | - /** @var string $buf */ |
|
59 | - $buf = ''; |
|
60 | - if (!class_exists('COM')) { |
|
61 | - throw new Error( |
|
62 | - 'COM does not exist' |
|
63 | - ); |
|
64 | - } |
|
65 | - /** @var COM $util */ |
|
66 | - $util = new COM('CAPICOM.Utilities.1'); |
|
67 | - $execCount = 0; |
|
58 | + /** @var string $buf */ |
|
59 | + $buf = ''; |
|
60 | + if (!class_exists('COM')) { |
|
61 | + throw new Error( |
|
62 | + 'COM does not exist' |
|
63 | + ); |
|
64 | + } |
|
65 | + /** @var COM $util */ |
|
66 | + $util = new COM('CAPICOM.Utilities.1'); |
|
67 | + $execCount = 0; |
|
68 | 68 | |
69 | - /** |
|
70 | - * Let's not let it loop forever. If we run N times and fail to |
|
71 | - * get N bytes of random data, then CAPICOM has failed us. |
|
72 | - */ |
|
73 | - do { |
|
74 | - $buf .= base64_decode((string) $util->GetRandom($bytes, 0)); |
|
75 | - if (RandomCompat_strlen($buf) >= $bytes) { |
|
76 | - /** |
|
77 | - * Return our random entropy buffer here: |
|
78 | - */ |
|
79 | - return (string) RandomCompat_substr($buf, 0, $bytes); |
|
80 | - } |
|
81 | - ++$execCount; |
|
82 | - } while ($execCount < $bytes); |
|
69 | + /** |
|
70 | + * Let's not let it loop forever. If we run N times and fail to |
|
71 | + * get N bytes of random data, then CAPICOM has failed us. |
|
72 | + */ |
|
73 | + do { |
|
74 | + $buf .= base64_decode((string) $util->GetRandom($bytes, 0)); |
|
75 | + if (RandomCompat_strlen($buf) >= $bytes) { |
|
76 | + /** |
|
77 | + * Return our random entropy buffer here: |
|
78 | + */ |
|
79 | + return (string) RandomCompat_substr($buf, 0, $bytes); |
|
80 | + } |
|
81 | + ++$execCount; |
|
82 | + } while ($execCount < $bytes); |
|
83 | 83 | |
84 | - /** |
|
85 | - * If we reach here, PHP has failed us. |
|
86 | - */ |
|
87 | - throw new Exception( |
|
88 | - 'Could not gather sufficient random data' |
|
89 | - ); |
|
90 | - } |
|
84 | + /** |
|
85 | + * If we reach here, PHP has failed us. |
|
86 | + */ |
|
87 | + throw new Exception( |
|
88 | + 'Could not gather sufficient random data' |
|
89 | + ); |
|
90 | + } |
|
91 | 91 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * SOFTWARE. |
27 | 27 | */ |
28 | 28 | |
29 | -if (!is_callable('random_bytes')) { |
|
29 | +if ( ! is_callable( 'random_bytes' ) ) { |
|
30 | 30 | /** |
31 | 31 | * Windows with PHP < 5.3.0 will not have the function |
32 | 32 | * openssl_random_pseudo_bytes() available, so let's use |
@@ -38,18 +38,18 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @return string |
40 | 40 | */ |
41 | - function random_bytes($bytes) |
|
41 | + function random_bytes( $bytes ) |
|
42 | 42 | { |
43 | 43 | try { |
44 | 44 | /** @var int $bytes */ |
45 | - $bytes = RandomCompat_intval($bytes); |
|
46 | - } catch (TypeError $ex) { |
|
45 | + $bytes = RandomCompat_intval( $bytes ); |
|
46 | + } catch ( TypeError $ex ) { |
|
47 | 47 | throw new TypeError( |
48 | 48 | 'random_bytes(): $bytes must be an integer' |
49 | 49 | ); |
50 | 50 | } |
51 | 51 | |
52 | - if ($bytes < 1) { |
|
52 | + if ( $bytes < 1 ) { |
|
53 | 53 | throw new Error( |
54 | 54 | 'Length must be greater than 0' |
55 | 55 | ); |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | |
58 | 58 | /** @var string $buf */ |
59 | 59 | $buf = ''; |
60 | - if (!class_exists('COM')) { |
|
60 | + if ( ! class_exists( 'COM' ) ) { |
|
61 | 61 | throw new Error( |
62 | 62 | 'COM does not exist' |
63 | 63 | ); |
64 | 64 | } |
65 | 65 | /** @var COM $util */ |
66 | - $util = new COM('CAPICOM.Utilities.1'); |
|
66 | + $util = new COM( 'CAPICOM.Utilities.1' ); |
|
67 | 67 | $execCount = 0; |
68 | 68 | |
69 | 69 | /** |
@@ -71,15 +71,15 @@ discard block |
||
71 | 71 | * get N bytes of random data, then CAPICOM has failed us. |
72 | 72 | */ |
73 | 73 | do { |
74 | - $buf .= base64_decode((string) $util->GetRandom($bytes, 0)); |
|
75 | - if (RandomCompat_strlen($buf) >= $bytes) { |
|
74 | + $buf .= base64_decode( (string)$util->GetRandom( $bytes, 0 ) ); |
|
75 | + if ( RandomCompat_strlen( $buf ) >= $bytes ) { |
|
76 | 76 | /** |
77 | 77 | * Return our random entropy buffer here: |
78 | 78 | */ |
79 | - return (string) RandomCompat_substr($buf, 0, $bytes); |
|
79 | + return (string)RandomCompat_substr( $buf, 0, $bytes ); |
|
80 | 80 | } |
81 | 81 | ++$execCount; |
82 | - } while ($execCount < $bytes); |
|
82 | + } while ( $execCount < $bytes ); |
|
83 | 83 | |
84 | 84 | /** |
85 | 85 | * If we reach here, PHP has failed us. |
@@ -40,8 +40,7 @@ |
||
40 | 40 | * |
41 | 41 | * @return string |
42 | 42 | */ |
43 | - function random_bytes($bytes) |
|
44 | - { |
|
43 | + function random_bytes($bytes) { |
|
45 | 44 | try { |
46 | 45 | /** @var int $bytes */ |
47 | 46 | $bytes = RandomCompat_intval($bytes); |
@@ -13,815 +13,815 @@ |
||
13 | 13 | * method. |
14 | 14 | */ |
15 | 15 | if (!is_callable('\\Sodium\\bin2hex')) { |
16 | - /** |
|
17 | - * @see ParagonIE_Sodium_Compat::bin2hex() |
|
18 | - * @param string $string |
|
19 | - * @return string |
|
20 | - * @throws \SodiumException |
|
21 | - * @throws \TypeError |
|
22 | - */ |
|
23 | - function bin2hex($string) |
|
24 | - { |
|
25 | - return ParagonIE_Sodium_Compat::bin2hex($string); |
|
26 | - } |
|
16 | + /** |
|
17 | + * @see ParagonIE_Sodium_Compat::bin2hex() |
|
18 | + * @param string $string |
|
19 | + * @return string |
|
20 | + * @throws \SodiumException |
|
21 | + * @throws \TypeError |
|
22 | + */ |
|
23 | + function bin2hex($string) |
|
24 | + { |
|
25 | + return ParagonIE_Sodium_Compat::bin2hex($string); |
|
26 | + } |
|
27 | 27 | } |
28 | 28 | if (!is_callable('\\Sodium\\compare')) { |
29 | - /** |
|
30 | - * @see ParagonIE_Sodium_Compat::compare() |
|
31 | - * @param string $a |
|
32 | - * @param string $b |
|
33 | - * @return int |
|
34 | - * @throws \SodiumException |
|
35 | - * @throws \TypeError |
|
36 | - */ |
|
37 | - function compare($a, $b) |
|
38 | - { |
|
39 | - return ParagonIE_Sodium_Compat::compare($a, $b); |
|
40 | - } |
|
29 | + /** |
|
30 | + * @see ParagonIE_Sodium_Compat::compare() |
|
31 | + * @param string $a |
|
32 | + * @param string $b |
|
33 | + * @return int |
|
34 | + * @throws \SodiumException |
|
35 | + * @throws \TypeError |
|
36 | + */ |
|
37 | + function compare($a, $b) |
|
38 | + { |
|
39 | + return ParagonIE_Sodium_Compat::compare($a, $b); |
|
40 | + } |
|
41 | 41 | } |
42 | 42 | if (!is_callable('\\Sodium\\crypto_aead_aes256gcm_decrypt')) { |
43 | - /** |
|
44 | - * @see ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_decrypt() |
|
45 | - * @param string $message |
|
46 | - * @param string $assocData |
|
47 | - * @param string $nonce |
|
48 | - * @param string $key |
|
49 | - * @return string|bool |
|
50 | - */ |
|
51 | - function crypto_aead_aes256gcm_decrypt($message, $assocData, $nonce, $key) |
|
52 | - { |
|
53 | - try { |
|
54 | - return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_decrypt($message, $assocData, $nonce, $key); |
|
55 | - } catch (\TypeError $ex) { |
|
56 | - return false; |
|
57 | - } catch (\SodiumException $ex) { |
|
58 | - return false; |
|
59 | - } |
|
60 | - } |
|
43 | + /** |
|
44 | + * @see ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_decrypt() |
|
45 | + * @param string $message |
|
46 | + * @param string $assocData |
|
47 | + * @param string $nonce |
|
48 | + * @param string $key |
|
49 | + * @return string|bool |
|
50 | + */ |
|
51 | + function crypto_aead_aes256gcm_decrypt($message, $assocData, $nonce, $key) |
|
52 | + { |
|
53 | + try { |
|
54 | + return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_decrypt($message, $assocData, $nonce, $key); |
|
55 | + } catch (\TypeError $ex) { |
|
56 | + return false; |
|
57 | + } catch (\SodiumException $ex) { |
|
58 | + return false; |
|
59 | + } |
|
60 | + } |
|
61 | 61 | } |
62 | 62 | if (!is_callable('\\Sodium\\crypto_aead_aes256gcm_encrypt')) { |
63 | - /** |
|
64 | - * @see ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_encrypt() |
|
65 | - * @param string $message |
|
66 | - * @param string $assocData |
|
67 | - * @param string $nonce |
|
68 | - * @param string $key |
|
69 | - * @return string |
|
70 | - * @throws \SodiumException |
|
71 | - * @throws \TypeError |
|
72 | - */ |
|
73 | - function crypto_aead_aes256gcm_encrypt($message, $assocData, $nonce, $key) |
|
74 | - { |
|
75 | - return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_encrypt($message, $assocData, $nonce, $key); |
|
76 | - } |
|
63 | + /** |
|
64 | + * @see ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_encrypt() |
|
65 | + * @param string $message |
|
66 | + * @param string $assocData |
|
67 | + * @param string $nonce |
|
68 | + * @param string $key |
|
69 | + * @return string |
|
70 | + * @throws \SodiumException |
|
71 | + * @throws \TypeError |
|
72 | + */ |
|
73 | + function crypto_aead_aes256gcm_encrypt($message, $assocData, $nonce, $key) |
|
74 | + { |
|
75 | + return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_encrypt($message, $assocData, $nonce, $key); |
|
76 | + } |
|
77 | 77 | } |
78 | 78 | if (!is_callable('\\Sodium\\crypto_aead_aes256gcm_is_available')) { |
79 | - /** |
|
80 | - * @see ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_is_available() |
|
81 | - * @return bool |
|
82 | - */ |
|
83 | - function crypto_aead_aes256gcm_is_available() |
|
84 | - { |
|
85 | - return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_is_available(); |
|
86 | - } |
|
79 | + /** |
|
80 | + * @see ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_is_available() |
|
81 | + * @return bool |
|
82 | + */ |
|
83 | + function crypto_aead_aes256gcm_is_available() |
|
84 | + { |
|
85 | + return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_is_available(); |
|
86 | + } |
|
87 | 87 | } |
88 | 88 | if (!is_callable('\\Sodium\\crypto_aead_chacha20poly1305_decrypt')) { |
89 | - /** |
|
90 | - * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_decrypt() |
|
91 | - * @param string $message |
|
92 | - * @param string $assocData |
|
93 | - * @param string $nonce |
|
94 | - * @param string $key |
|
95 | - * @return string|bool |
|
96 | - */ |
|
97 | - function crypto_aead_chacha20poly1305_decrypt($message, $assocData, $nonce, $key) |
|
98 | - { |
|
99 | - try { |
|
100 | - return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_decrypt($message, $assocData, $nonce, $key); |
|
101 | - } catch (\TypeError $ex) { |
|
102 | - return false; |
|
103 | - } catch (\SodiumException $ex) { |
|
104 | - return false; |
|
105 | - } |
|
106 | - } |
|
89 | + /** |
|
90 | + * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_decrypt() |
|
91 | + * @param string $message |
|
92 | + * @param string $assocData |
|
93 | + * @param string $nonce |
|
94 | + * @param string $key |
|
95 | + * @return string|bool |
|
96 | + */ |
|
97 | + function crypto_aead_chacha20poly1305_decrypt($message, $assocData, $nonce, $key) |
|
98 | + { |
|
99 | + try { |
|
100 | + return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_decrypt($message, $assocData, $nonce, $key); |
|
101 | + } catch (\TypeError $ex) { |
|
102 | + return false; |
|
103 | + } catch (\SodiumException $ex) { |
|
104 | + return false; |
|
105 | + } |
|
106 | + } |
|
107 | 107 | } |
108 | 108 | if (!is_callable('\\Sodium\\crypto_aead_chacha20poly1305_encrypt')) { |
109 | - /** |
|
110 | - * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_encrypt() |
|
111 | - * @param string $message |
|
112 | - * @param string $assocData |
|
113 | - * @param string $nonce |
|
114 | - * @param string $key |
|
115 | - * @return string |
|
116 | - * @throws \SodiumException |
|
117 | - * @throws \TypeError |
|
118 | - */ |
|
119 | - function crypto_aead_chacha20poly1305_encrypt($message, $assocData, $nonce, $key) |
|
120 | - { |
|
121 | - return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_encrypt($message, $assocData, $nonce, $key); |
|
122 | - } |
|
109 | + /** |
|
110 | + * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_encrypt() |
|
111 | + * @param string $message |
|
112 | + * @param string $assocData |
|
113 | + * @param string $nonce |
|
114 | + * @param string $key |
|
115 | + * @return string |
|
116 | + * @throws \SodiumException |
|
117 | + * @throws \TypeError |
|
118 | + */ |
|
119 | + function crypto_aead_chacha20poly1305_encrypt($message, $assocData, $nonce, $key) |
|
120 | + { |
|
121 | + return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_encrypt($message, $assocData, $nonce, $key); |
|
122 | + } |
|
123 | 123 | } |
124 | 124 | if (!is_callable('\\Sodium\\crypto_aead_chacha20poly1305_ietf_decrypt')) { |
125 | - /** |
|
126 | - * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_decrypt() |
|
127 | - * @param string $message |
|
128 | - * @param string $assocData |
|
129 | - * @param string $nonce |
|
130 | - * @param string $key |
|
131 | - * @return string|bool |
|
132 | - */ |
|
133 | - function crypto_aead_chacha20poly1305_ietf_decrypt($message, $assocData, $nonce, $key) |
|
134 | - { |
|
135 | - try { |
|
136 | - return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_decrypt($message, $assocData, $nonce, $key); |
|
137 | - } catch (\TypeError $ex) { |
|
138 | - return false; |
|
139 | - } catch (\SodiumException $ex) { |
|
140 | - return false; |
|
141 | - } |
|
142 | - } |
|
125 | + /** |
|
126 | + * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_decrypt() |
|
127 | + * @param string $message |
|
128 | + * @param string $assocData |
|
129 | + * @param string $nonce |
|
130 | + * @param string $key |
|
131 | + * @return string|bool |
|
132 | + */ |
|
133 | + function crypto_aead_chacha20poly1305_ietf_decrypt($message, $assocData, $nonce, $key) |
|
134 | + { |
|
135 | + try { |
|
136 | + return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_decrypt($message, $assocData, $nonce, $key); |
|
137 | + } catch (\TypeError $ex) { |
|
138 | + return false; |
|
139 | + } catch (\SodiumException $ex) { |
|
140 | + return false; |
|
141 | + } |
|
142 | + } |
|
143 | 143 | } |
144 | 144 | if (!is_callable('\\Sodium\\crypto_aead_chacha20poly1305_ietf_encrypt')) { |
145 | - /** |
|
146 | - * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_encrypt() |
|
147 | - * @param string $message |
|
148 | - * @param string $assocData |
|
149 | - * @param string $nonce |
|
150 | - * @param string $key |
|
151 | - * @return string |
|
152 | - * @throws \SodiumException |
|
153 | - * @throws \TypeError |
|
154 | - */ |
|
155 | - function crypto_aead_chacha20poly1305_ietf_encrypt($message, $assocData, $nonce, $key) |
|
156 | - { |
|
157 | - return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_encrypt($message, $assocData, $nonce, $key); |
|
158 | - } |
|
145 | + /** |
|
146 | + * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_encrypt() |
|
147 | + * @param string $message |
|
148 | + * @param string $assocData |
|
149 | + * @param string $nonce |
|
150 | + * @param string $key |
|
151 | + * @return string |
|
152 | + * @throws \SodiumException |
|
153 | + * @throws \TypeError |
|
154 | + */ |
|
155 | + function crypto_aead_chacha20poly1305_ietf_encrypt($message, $assocData, $nonce, $key) |
|
156 | + { |
|
157 | + return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_encrypt($message, $assocData, $nonce, $key); |
|
158 | + } |
|
159 | 159 | } |
160 | 160 | if (!is_callable('\\Sodium\\crypto_auth')) { |
161 | - /** |
|
162 | - * @see ParagonIE_Sodium_Compat::crypto_auth() |
|
163 | - * @param string $message |
|
164 | - * @param string $key |
|
165 | - * @return string |
|
166 | - * @throws \SodiumException |
|
167 | - * @throws \TypeError |
|
168 | - */ |
|
169 | - function crypto_auth($message, $key) |
|
170 | - { |
|
171 | - return ParagonIE_Sodium_Compat::crypto_auth($message, $key); |
|
172 | - } |
|
161 | + /** |
|
162 | + * @see ParagonIE_Sodium_Compat::crypto_auth() |
|
163 | + * @param string $message |
|
164 | + * @param string $key |
|
165 | + * @return string |
|
166 | + * @throws \SodiumException |
|
167 | + * @throws \TypeError |
|
168 | + */ |
|
169 | + function crypto_auth($message, $key) |
|
170 | + { |
|
171 | + return ParagonIE_Sodium_Compat::crypto_auth($message, $key); |
|
172 | + } |
|
173 | 173 | } |
174 | 174 | if (!is_callable('\\Sodium\\crypto_auth_verify')) { |
175 | - /** |
|
176 | - * @see ParagonIE_Sodium_Compat::crypto_auth_verify() |
|
177 | - * @param string $mac |
|
178 | - * @param string $message |
|
179 | - * @param string $key |
|
180 | - * @return bool |
|
181 | - * @throws \SodiumException |
|
182 | - * @throws \TypeError |
|
183 | - */ |
|
184 | - function crypto_auth_verify($mac, $message, $key) |
|
185 | - { |
|
186 | - return ParagonIE_Sodium_Compat::crypto_auth_verify($mac, $message, $key); |
|
187 | - } |
|
175 | + /** |
|
176 | + * @see ParagonIE_Sodium_Compat::crypto_auth_verify() |
|
177 | + * @param string $mac |
|
178 | + * @param string $message |
|
179 | + * @param string $key |
|
180 | + * @return bool |
|
181 | + * @throws \SodiumException |
|
182 | + * @throws \TypeError |
|
183 | + */ |
|
184 | + function crypto_auth_verify($mac, $message, $key) |
|
185 | + { |
|
186 | + return ParagonIE_Sodium_Compat::crypto_auth_verify($mac, $message, $key); |
|
187 | + } |
|
188 | 188 | } |
189 | 189 | if (!is_callable('\\Sodium\\crypto_box')) { |
190 | - /** |
|
191 | - * @see ParagonIE_Sodium_Compat::crypto_box() |
|
192 | - * @param string $message |
|
193 | - * @param string $nonce |
|
194 | - * @param string $kp |
|
195 | - * @return string |
|
196 | - * @throws \SodiumException |
|
197 | - * @throws \TypeError |
|
198 | - */ |
|
199 | - function crypto_box($message, $nonce, $kp) |
|
200 | - { |
|
201 | - return ParagonIE_Sodium_Compat::crypto_box($message, $nonce, $kp); |
|
202 | - } |
|
190 | + /** |
|
191 | + * @see ParagonIE_Sodium_Compat::crypto_box() |
|
192 | + * @param string $message |
|
193 | + * @param string $nonce |
|
194 | + * @param string $kp |
|
195 | + * @return string |
|
196 | + * @throws \SodiumException |
|
197 | + * @throws \TypeError |
|
198 | + */ |
|
199 | + function crypto_box($message, $nonce, $kp) |
|
200 | + { |
|
201 | + return ParagonIE_Sodium_Compat::crypto_box($message, $nonce, $kp); |
|
202 | + } |
|
203 | 203 | } |
204 | 204 | if (!is_callable('\\Sodium\\crypto_box_keypair')) { |
205 | - /** |
|
206 | - * @see ParagonIE_Sodium_Compat::crypto_box_keypair() |
|
207 | - * @return string |
|
208 | - * @throws \SodiumException |
|
209 | - * @throws \TypeError |
|
210 | - */ |
|
211 | - function crypto_box_keypair() |
|
212 | - { |
|
213 | - return ParagonIE_Sodium_Compat::crypto_box_keypair(); |
|
214 | - } |
|
205 | + /** |
|
206 | + * @see ParagonIE_Sodium_Compat::crypto_box_keypair() |
|
207 | + * @return string |
|
208 | + * @throws \SodiumException |
|
209 | + * @throws \TypeError |
|
210 | + */ |
|
211 | + function crypto_box_keypair() |
|
212 | + { |
|
213 | + return ParagonIE_Sodium_Compat::crypto_box_keypair(); |
|
214 | + } |
|
215 | 215 | } |
216 | 216 | if (!is_callable('\\Sodium\\crypto_box_keypair_from_secretkey_and_publickey')) { |
217 | - /** |
|
218 | - * @see ParagonIE_Sodium_Compat::crypto_box_keypair_from_secretkey_and_publickey() |
|
219 | - * @param string $sk |
|
220 | - * @param string $pk |
|
221 | - * @return string |
|
222 | - * @throws \SodiumException |
|
223 | - * @throws \TypeError |
|
224 | - */ |
|
225 | - function crypto_box_keypair_from_secretkey_and_publickey($sk, $pk) |
|
226 | - { |
|
227 | - return ParagonIE_Sodium_Compat::crypto_box_keypair_from_secretkey_and_publickey($sk, $pk); |
|
228 | - } |
|
217 | + /** |
|
218 | + * @see ParagonIE_Sodium_Compat::crypto_box_keypair_from_secretkey_and_publickey() |
|
219 | + * @param string $sk |
|
220 | + * @param string $pk |
|
221 | + * @return string |
|
222 | + * @throws \SodiumException |
|
223 | + * @throws \TypeError |
|
224 | + */ |
|
225 | + function crypto_box_keypair_from_secretkey_and_publickey($sk, $pk) |
|
226 | + { |
|
227 | + return ParagonIE_Sodium_Compat::crypto_box_keypair_from_secretkey_and_publickey($sk, $pk); |
|
228 | + } |
|
229 | 229 | } |
230 | 230 | if (!is_callable('\\Sodium\\crypto_box_open')) { |
231 | - /** |
|
232 | - * @see ParagonIE_Sodium_Compat::crypto_box_open() |
|
233 | - * @param string $message |
|
234 | - * @param string $nonce |
|
235 | - * @param string $kp |
|
236 | - * @return string|bool |
|
237 | - */ |
|
238 | - function crypto_box_open($message, $nonce, $kp) |
|
239 | - { |
|
240 | - try { |
|
241 | - return ParagonIE_Sodium_Compat::crypto_box_open($message, $nonce, $kp); |
|
242 | - } catch (\TypeError $ex) { |
|
243 | - return false; |
|
244 | - } catch (\SodiumException $ex) { |
|
245 | - return false; |
|
246 | - } |
|
247 | - } |
|
231 | + /** |
|
232 | + * @see ParagonIE_Sodium_Compat::crypto_box_open() |
|
233 | + * @param string $message |
|
234 | + * @param string $nonce |
|
235 | + * @param string $kp |
|
236 | + * @return string|bool |
|
237 | + */ |
|
238 | + function crypto_box_open($message, $nonce, $kp) |
|
239 | + { |
|
240 | + try { |
|
241 | + return ParagonIE_Sodium_Compat::crypto_box_open($message, $nonce, $kp); |
|
242 | + } catch (\TypeError $ex) { |
|
243 | + return false; |
|
244 | + } catch (\SodiumException $ex) { |
|
245 | + return false; |
|
246 | + } |
|
247 | + } |
|
248 | 248 | } |
249 | 249 | if (!is_callable('\\Sodium\\crypto_box_publickey')) { |
250 | - /** |
|
251 | - * @see ParagonIE_Sodium_Compat::crypto_box_publickey() |
|
252 | - * @param string $keypair |
|
253 | - * @return string |
|
254 | - * @throws \SodiumException |
|
255 | - * @throws \TypeError |
|
256 | - */ |
|
257 | - function crypto_box_publickey($keypair) |
|
258 | - { |
|
259 | - return ParagonIE_Sodium_Compat::crypto_box_publickey($keypair); |
|
260 | - } |
|
250 | + /** |
|
251 | + * @see ParagonIE_Sodium_Compat::crypto_box_publickey() |
|
252 | + * @param string $keypair |
|
253 | + * @return string |
|
254 | + * @throws \SodiumException |
|
255 | + * @throws \TypeError |
|
256 | + */ |
|
257 | + function crypto_box_publickey($keypair) |
|
258 | + { |
|
259 | + return ParagonIE_Sodium_Compat::crypto_box_publickey($keypair); |
|
260 | + } |
|
261 | 261 | } |
262 | 262 | if (!is_callable('\\Sodium\\crypto_box_publickey_from_secretkey')) { |
263 | - /** |
|
264 | - * @see ParagonIE_Sodium_Compat::crypto_box_publickey_from_secretkey() |
|
265 | - * @param string $sk |
|
266 | - * @return string |
|
267 | - * @throws \SodiumException |
|
268 | - * @throws \TypeError |
|
269 | - */ |
|
270 | - function crypto_box_publickey_from_secretkey($sk) |
|
271 | - { |
|
272 | - return ParagonIE_Sodium_Compat::crypto_box_publickey_from_secretkey($sk); |
|
273 | - } |
|
263 | + /** |
|
264 | + * @see ParagonIE_Sodium_Compat::crypto_box_publickey_from_secretkey() |
|
265 | + * @param string $sk |
|
266 | + * @return string |
|
267 | + * @throws \SodiumException |
|
268 | + * @throws \TypeError |
|
269 | + */ |
|
270 | + function crypto_box_publickey_from_secretkey($sk) |
|
271 | + { |
|
272 | + return ParagonIE_Sodium_Compat::crypto_box_publickey_from_secretkey($sk); |
|
273 | + } |
|
274 | 274 | } |
275 | 275 | if (!is_callable('\\Sodium\\crypto_box_seal')) { |
276 | - /** |
|
277 | - * @see ParagonIE_Sodium_Compat::crypto_box_seal_open() |
|
278 | - * @param string $message |
|
279 | - * @param string $publicKey |
|
280 | - * @return string |
|
281 | - * @throws \SodiumException |
|
282 | - * @throws \TypeError |
|
283 | - */ |
|
284 | - function crypto_box_seal($message, $publicKey) |
|
285 | - { |
|
286 | - return ParagonIE_Sodium_Compat::crypto_box_seal($message, $publicKey); |
|
287 | - } |
|
276 | + /** |
|
277 | + * @see ParagonIE_Sodium_Compat::crypto_box_seal_open() |
|
278 | + * @param string $message |
|
279 | + * @param string $publicKey |
|
280 | + * @return string |
|
281 | + * @throws \SodiumException |
|
282 | + * @throws \TypeError |
|
283 | + */ |
|
284 | + function crypto_box_seal($message, $publicKey) |
|
285 | + { |
|
286 | + return ParagonIE_Sodium_Compat::crypto_box_seal($message, $publicKey); |
|
287 | + } |
|
288 | 288 | } |
289 | 289 | if (!is_callable('\\Sodium\\crypto_box_seal_open')) { |
290 | - /** |
|
291 | - * @see ParagonIE_Sodium_Compat::crypto_box_seal_open() |
|
292 | - * @param string $message |
|
293 | - * @param string $kp |
|
294 | - * @return string|bool |
|
295 | - */ |
|
296 | - function crypto_box_seal_open($message, $kp) |
|
297 | - { |
|
298 | - try { |
|
299 | - return ParagonIE_Sodium_Compat::crypto_box_seal_open($message, $kp); |
|
300 | - } catch (\TypeError $ex) { |
|
301 | - return false; |
|
302 | - } catch (\SodiumException $ex) { |
|
303 | - return false; |
|
304 | - } |
|
305 | - } |
|
290 | + /** |
|
291 | + * @see ParagonIE_Sodium_Compat::crypto_box_seal_open() |
|
292 | + * @param string $message |
|
293 | + * @param string $kp |
|
294 | + * @return string|bool |
|
295 | + */ |
|
296 | + function crypto_box_seal_open($message, $kp) |
|
297 | + { |
|
298 | + try { |
|
299 | + return ParagonIE_Sodium_Compat::crypto_box_seal_open($message, $kp); |
|
300 | + } catch (\TypeError $ex) { |
|
301 | + return false; |
|
302 | + } catch (\SodiumException $ex) { |
|
303 | + return false; |
|
304 | + } |
|
305 | + } |
|
306 | 306 | } |
307 | 307 | if (!is_callable('\\Sodium\\crypto_box_secretkey')) { |
308 | - /** |
|
309 | - * @see ParagonIE_Sodium_Compat::crypto_box_secretkey() |
|
310 | - * @param string $keypair |
|
311 | - * @return string |
|
312 | - * @throws \SodiumException |
|
313 | - * @throws \TypeError |
|
314 | - */ |
|
315 | - function crypto_box_secretkey($keypair) |
|
316 | - { |
|
317 | - return ParagonIE_Sodium_Compat::crypto_box_secretkey($keypair); |
|
318 | - } |
|
308 | + /** |
|
309 | + * @see ParagonIE_Sodium_Compat::crypto_box_secretkey() |
|
310 | + * @param string $keypair |
|
311 | + * @return string |
|
312 | + * @throws \SodiumException |
|
313 | + * @throws \TypeError |
|
314 | + */ |
|
315 | + function crypto_box_secretkey($keypair) |
|
316 | + { |
|
317 | + return ParagonIE_Sodium_Compat::crypto_box_secretkey($keypair); |
|
318 | + } |
|
319 | 319 | } |
320 | 320 | if (!is_callable('\\Sodium\\crypto_generichash')) { |
321 | - /** |
|
322 | - * @see ParagonIE_Sodium_Compat::crypto_generichash() |
|
323 | - * @param string $message |
|
324 | - * @param string|null $key |
|
325 | - * @param int $outLen |
|
326 | - * @return string |
|
327 | - * @throws \SodiumException |
|
328 | - * @throws \TypeError |
|
329 | - */ |
|
330 | - function crypto_generichash($message, $key = null, $outLen = 32) |
|
331 | - { |
|
332 | - return ParagonIE_Sodium_Compat::crypto_generichash($message, $key, $outLen); |
|
333 | - } |
|
321 | + /** |
|
322 | + * @see ParagonIE_Sodium_Compat::crypto_generichash() |
|
323 | + * @param string $message |
|
324 | + * @param string|null $key |
|
325 | + * @param int $outLen |
|
326 | + * @return string |
|
327 | + * @throws \SodiumException |
|
328 | + * @throws \TypeError |
|
329 | + */ |
|
330 | + function crypto_generichash($message, $key = null, $outLen = 32) |
|
331 | + { |
|
332 | + return ParagonIE_Sodium_Compat::crypto_generichash($message, $key, $outLen); |
|
333 | + } |
|
334 | 334 | } |
335 | 335 | if (!is_callable('\\Sodium\\crypto_generichash_final')) { |
336 | - /** |
|
337 | - * @see ParagonIE_Sodium_Compat::crypto_generichash_final() |
|
338 | - * @param string|null $ctx |
|
339 | - * @param int $outputLength |
|
340 | - * @return string |
|
341 | - * @throws \SodiumException |
|
342 | - * @throws \TypeError |
|
343 | - */ |
|
344 | - function crypto_generichash_final(&$ctx, $outputLength = 32) |
|
345 | - { |
|
346 | - return ParagonIE_Sodium_Compat::crypto_generichash_final($ctx, $outputLength); |
|
347 | - } |
|
336 | + /** |
|
337 | + * @see ParagonIE_Sodium_Compat::crypto_generichash_final() |
|
338 | + * @param string|null $ctx |
|
339 | + * @param int $outputLength |
|
340 | + * @return string |
|
341 | + * @throws \SodiumException |
|
342 | + * @throws \TypeError |
|
343 | + */ |
|
344 | + function crypto_generichash_final(&$ctx, $outputLength = 32) |
|
345 | + { |
|
346 | + return ParagonIE_Sodium_Compat::crypto_generichash_final($ctx, $outputLength); |
|
347 | + } |
|
348 | 348 | } |
349 | 349 | if (!is_callable('\\Sodium\\crypto_generichash_init')) { |
350 | - /** |
|
351 | - * @see ParagonIE_Sodium_Compat::crypto_generichash_init() |
|
352 | - * @param string|null $key |
|
353 | - * @param int $outLen |
|
354 | - * @return string |
|
355 | - * @throws \SodiumException |
|
356 | - * @throws \TypeError |
|
357 | - */ |
|
358 | - function crypto_generichash_init($key = null, $outLen = 32) |
|
359 | - { |
|
360 | - return ParagonIE_Sodium_Compat::crypto_generichash_init($key, $outLen); |
|
361 | - } |
|
350 | + /** |
|
351 | + * @see ParagonIE_Sodium_Compat::crypto_generichash_init() |
|
352 | + * @param string|null $key |
|
353 | + * @param int $outLen |
|
354 | + * @return string |
|
355 | + * @throws \SodiumException |
|
356 | + * @throws \TypeError |
|
357 | + */ |
|
358 | + function crypto_generichash_init($key = null, $outLen = 32) |
|
359 | + { |
|
360 | + return ParagonIE_Sodium_Compat::crypto_generichash_init($key, $outLen); |
|
361 | + } |
|
362 | 362 | } |
363 | 363 | if (!is_callable('\\Sodium\\crypto_generichash_update')) { |
364 | - /** |
|
365 | - * @see ParagonIE_Sodium_Compat::crypto_generichash_update() |
|
366 | - * @param string|null $ctx |
|
367 | - * @param string $message |
|
368 | - * @return void |
|
369 | - * @throws \SodiumException |
|
370 | - * @throws \TypeError |
|
371 | - */ |
|
372 | - function crypto_generichash_update(&$ctx, $message = '') |
|
373 | - { |
|
374 | - ParagonIE_Sodium_Compat::crypto_generichash_update($ctx, $message); |
|
375 | - } |
|
364 | + /** |
|
365 | + * @see ParagonIE_Sodium_Compat::crypto_generichash_update() |
|
366 | + * @param string|null $ctx |
|
367 | + * @param string $message |
|
368 | + * @return void |
|
369 | + * @throws \SodiumException |
|
370 | + * @throws \TypeError |
|
371 | + */ |
|
372 | + function crypto_generichash_update(&$ctx, $message = '') |
|
373 | + { |
|
374 | + ParagonIE_Sodium_Compat::crypto_generichash_update($ctx, $message); |
|
375 | + } |
|
376 | 376 | } |
377 | 377 | if (!is_callable('\\Sodium\\crypto_kx')) { |
378 | - /** |
|
379 | - * @see ParagonIE_Sodium_Compat::crypto_kx() |
|
380 | - * @param string $my_secret |
|
381 | - * @param string $their_public |
|
382 | - * @param string $client_public |
|
383 | - * @param string $server_public |
|
384 | - * @return string |
|
385 | - * @throws \SodiumException |
|
386 | - * @throws \TypeError |
|
387 | - */ |
|
388 | - function crypto_kx($my_secret, $their_public, $client_public, $server_public) |
|
389 | - { |
|
390 | - return ParagonIE_Sodium_Compat::crypto_kx( |
|
391 | - $my_secret, |
|
392 | - $their_public, |
|
393 | - $client_public, |
|
394 | - $server_public, |
|
395 | - true |
|
396 | - ); |
|
397 | - } |
|
378 | + /** |
|
379 | + * @see ParagonIE_Sodium_Compat::crypto_kx() |
|
380 | + * @param string $my_secret |
|
381 | + * @param string $their_public |
|
382 | + * @param string $client_public |
|
383 | + * @param string $server_public |
|
384 | + * @return string |
|
385 | + * @throws \SodiumException |
|
386 | + * @throws \TypeError |
|
387 | + */ |
|
388 | + function crypto_kx($my_secret, $their_public, $client_public, $server_public) |
|
389 | + { |
|
390 | + return ParagonIE_Sodium_Compat::crypto_kx( |
|
391 | + $my_secret, |
|
392 | + $their_public, |
|
393 | + $client_public, |
|
394 | + $server_public, |
|
395 | + true |
|
396 | + ); |
|
397 | + } |
|
398 | 398 | } |
399 | 399 | if (!is_callable('\\Sodium\\crypto_pwhash')) { |
400 | - /** |
|
401 | - * @see ParagonIE_Sodium_Compat::crypto_pwhash() |
|
402 | - * @param int $outlen |
|
403 | - * @param string $passwd |
|
404 | - * @param string $salt |
|
405 | - * @param int $opslimit |
|
406 | - * @param int $memlimit |
|
407 | - * @return string |
|
408 | - * @throws \SodiumException |
|
409 | - * @throws \TypeError |
|
410 | - */ |
|
411 | - function crypto_pwhash($outlen, $passwd, $salt, $opslimit, $memlimit) |
|
412 | - { |
|
413 | - return ParagonIE_Sodium_Compat::crypto_pwhash($outlen, $passwd, $salt, $opslimit, $memlimit); |
|
414 | - } |
|
400 | + /** |
|
401 | + * @see ParagonIE_Sodium_Compat::crypto_pwhash() |
|
402 | + * @param int $outlen |
|
403 | + * @param string $passwd |
|
404 | + * @param string $salt |
|
405 | + * @param int $opslimit |
|
406 | + * @param int $memlimit |
|
407 | + * @return string |
|
408 | + * @throws \SodiumException |
|
409 | + * @throws \TypeError |
|
410 | + */ |
|
411 | + function crypto_pwhash($outlen, $passwd, $salt, $opslimit, $memlimit) |
|
412 | + { |
|
413 | + return ParagonIE_Sodium_Compat::crypto_pwhash($outlen, $passwd, $salt, $opslimit, $memlimit); |
|
414 | + } |
|
415 | 415 | } |
416 | 416 | if (!is_callable('\\Sodium\\crypto_pwhash_str')) { |
417 | - /** |
|
418 | - * @see ParagonIE_Sodium_Compat::crypto_pwhash_str() |
|
419 | - * @param string $passwd |
|
420 | - * @param int $opslimit |
|
421 | - * @param int $memlimit |
|
422 | - * @return string |
|
423 | - * @throws \SodiumException |
|
424 | - * @throws \TypeError |
|
425 | - */ |
|
426 | - function crypto_pwhash_str($passwd, $opslimit, $memlimit) |
|
427 | - { |
|
428 | - return ParagonIE_Sodium_Compat::crypto_pwhash_str($passwd, $opslimit, $memlimit); |
|
429 | - } |
|
417 | + /** |
|
418 | + * @see ParagonIE_Sodium_Compat::crypto_pwhash_str() |
|
419 | + * @param string $passwd |
|
420 | + * @param int $opslimit |
|
421 | + * @param int $memlimit |
|
422 | + * @return string |
|
423 | + * @throws \SodiumException |
|
424 | + * @throws \TypeError |
|
425 | + */ |
|
426 | + function crypto_pwhash_str($passwd, $opslimit, $memlimit) |
|
427 | + { |
|
428 | + return ParagonIE_Sodium_Compat::crypto_pwhash_str($passwd, $opslimit, $memlimit); |
|
429 | + } |
|
430 | 430 | } |
431 | 431 | if (!is_callable('\\Sodium\\crypto_pwhash_str_verify')) { |
432 | - /** |
|
433 | - * @see ParagonIE_Sodium_Compat::crypto_pwhash_str_verify() |
|
434 | - * @param string $passwd |
|
435 | - * @param string $hash |
|
436 | - * @return bool |
|
437 | - * @throws \SodiumException |
|
438 | - * @throws \TypeError |
|
439 | - */ |
|
440 | - function crypto_pwhash_str_verify($passwd, $hash) |
|
441 | - { |
|
442 | - return ParagonIE_Sodium_Compat::crypto_pwhash_str_verify($passwd, $hash); |
|
443 | - } |
|
432 | + /** |
|
433 | + * @see ParagonIE_Sodium_Compat::crypto_pwhash_str_verify() |
|
434 | + * @param string $passwd |
|
435 | + * @param string $hash |
|
436 | + * @return bool |
|
437 | + * @throws \SodiumException |
|
438 | + * @throws \TypeError |
|
439 | + */ |
|
440 | + function crypto_pwhash_str_verify($passwd, $hash) |
|
441 | + { |
|
442 | + return ParagonIE_Sodium_Compat::crypto_pwhash_str_verify($passwd, $hash); |
|
443 | + } |
|
444 | 444 | } |
445 | 445 | if (!is_callable('\\Sodium\\crypto_pwhash_scryptsalsa208sha256')) { |
446 | - /** |
|
447 | - * @see ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256() |
|
448 | - * @param int $outlen |
|
449 | - * @param string $passwd |
|
450 | - * @param string $salt |
|
451 | - * @param int $opslimit |
|
452 | - * @param int $memlimit |
|
453 | - * @return string |
|
454 | - * @throws \SodiumException |
|
455 | - * @throws \TypeError |
|
456 | - */ |
|
457 | - function crypto_pwhash_scryptsalsa208sha256($outlen, $passwd, $salt, $opslimit, $memlimit) |
|
458 | - { |
|
459 | - return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256($outlen, $passwd, $salt, $opslimit, $memlimit); |
|
460 | - } |
|
446 | + /** |
|
447 | + * @see ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256() |
|
448 | + * @param int $outlen |
|
449 | + * @param string $passwd |
|
450 | + * @param string $salt |
|
451 | + * @param int $opslimit |
|
452 | + * @param int $memlimit |
|
453 | + * @return string |
|
454 | + * @throws \SodiumException |
|
455 | + * @throws \TypeError |
|
456 | + */ |
|
457 | + function crypto_pwhash_scryptsalsa208sha256($outlen, $passwd, $salt, $opslimit, $memlimit) |
|
458 | + { |
|
459 | + return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256($outlen, $passwd, $salt, $opslimit, $memlimit); |
|
460 | + } |
|
461 | 461 | } |
462 | 462 | if (!is_callable('\\Sodium\\crypto_pwhash_scryptsalsa208sha256_str')) { |
463 | - /** |
|
464 | - * @see ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str() |
|
465 | - * @param string $passwd |
|
466 | - * @param int $opslimit |
|
467 | - * @param int $memlimit |
|
468 | - * @return string |
|
469 | - * @throws \SodiumException |
|
470 | - * @throws \TypeError |
|
471 | - */ |
|
472 | - function crypto_pwhash_scryptsalsa208sha256_str($passwd, $opslimit, $memlimit) |
|
473 | - { |
|
474 | - return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str($passwd, $opslimit, $memlimit); |
|
475 | - } |
|
463 | + /** |
|
464 | + * @see ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str() |
|
465 | + * @param string $passwd |
|
466 | + * @param int $opslimit |
|
467 | + * @param int $memlimit |
|
468 | + * @return string |
|
469 | + * @throws \SodiumException |
|
470 | + * @throws \TypeError |
|
471 | + */ |
|
472 | + function crypto_pwhash_scryptsalsa208sha256_str($passwd, $opslimit, $memlimit) |
|
473 | + { |
|
474 | + return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str($passwd, $opslimit, $memlimit); |
|
475 | + } |
|
476 | 476 | } |
477 | 477 | if (!is_callable('\\Sodium\\crypto_pwhash_scryptsalsa208sha256_str_verify')) { |
478 | - /** |
|
479 | - * @see ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str_verify() |
|
480 | - * @param string $passwd |
|
481 | - * @param string $hash |
|
482 | - * @return bool |
|
483 | - * @throws \SodiumException |
|
484 | - * @throws \TypeError |
|
485 | - */ |
|
486 | - function crypto_pwhash_scryptsalsa208sha256_str_verify($passwd, $hash) |
|
487 | - { |
|
488 | - return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str_verify($passwd, $hash); |
|
489 | - } |
|
478 | + /** |
|
479 | + * @see ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str_verify() |
|
480 | + * @param string $passwd |
|
481 | + * @param string $hash |
|
482 | + * @return bool |
|
483 | + * @throws \SodiumException |
|
484 | + * @throws \TypeError |
|
485 | + */ |
|
486 | + function crypto_pwhash_scryptsalsa208sha256_str_verify($passwd, $hash) |
|
487 | + { |
|
488 | + return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str_verify($passwd, $hash); |
|
489 | + } |
|
490 | 490 | } |
491 | 491 | if (!is_callable('\\Sodium\\crypto_scalarmult')) { |
492 | - /** |
|
493 | - * @see ParagonIE_Sodium_Compat::crypto_scalarmult() |
|
494 | - * @param string $n |
|
495 | - * @param string $p |
|
496 | - * @return string |
|
497 | - * @throws \SodiumException |
|
498 | - * @throws \TypeError |
|
499 | - */ |
|
500 | - function crypto_scalarmult($n, $p) |
|
501 | - { |
|
502 | - return ParagonIE_Sodium_Compat::crypto_scalarmult($n, $p); |
|
503 | - } |
|
492 | + /** |
|
493 | + * @see ParagonIE_Sodium_Compat::crypto_scalarmult() |
|
494 | + * @param string $n |
|
495 | + * @param string $p |
|
496 | + * @return string |
|
497 | + * @throws \SodiumException |
|
498 | + * @throws \TypeError |
|
499 | + */ |
|
500 | + function crypto_scalarmult($n, $p) |
|
501 | + { |
|
502 | + return ParagonIE_Sodium_Compat::crypto_scalarmult($n, $p); |
|
503 | + } |
|
504 | 504 | } |
505 | 505 | if (!is_callable('\\Sodium\\crypto_scalarmult_base')) { |
506 | - /** |
|
507 | - * @see ParagonIE_Sodium_Compat::crypto_scalarmult_base() |
|
508 | - * @param string $n |
|
509 | - * @return string |
|
510 | - * @throws \SodiumException |
|
511 | - * @throws \TypeError |
|
512 | - */ |
|
513 | - function crypto_scalarmult_base($n) |
|
514 | - { |
|
515 | - return ParagonIE_Sodium_Compat::crypto_scalarmult_base($n); |
|
516 | - } |
|
506 | + /** |
|
507 | + * @see ParagonIE_Sodium_Compat::crypto_scalarmult_base() |
|
508 | + * @param string $n |
|
509 | + * @return string |
|
510 | + * @throws \SodiumException |
|
511 | + * @throws \TypeError |
|
512 | + */ |
|
513 | + function crypto_scalarmult_base($n) |
|
514 | + { |
|
515 | + return ParagonIE_Sodium_Compat::crypto_scalarmult_base($n); |
|
516 | + } |
|
517 | 517 | } |
518 | 518 | if (!is_callable('\\Sodium\\crypto_secretbox')) { |
519 | - /** |
|
520 | - * @see ParagonIE_Sodium_Compat::crypto_secretbox() |
|
521 | - * @param string $message |
|
522 | - * @param string $nonce |
|
523 | - * @param string $key |
|
524 | - * @return string |
|
525 | - * @throws \SodiumException |
|
526 | - * @throws \TypeError |
|
527 | - */ |
|
528 | - function crypto_secretbox($message, $nonce, $key) |
|
529 | - { |
|
530 | - return ParagonIE_Sodium_Compat::crypto_secretbox($message, $nonce, $key); |
|
531 | - } |
|
519 | + /** |
|
520 | + * @see ParagonIE_Sodium_Compat::crypto_secretbox() |
|
521 | + * @param string $message |
|
522 | + * @param string $nonce |
|
523 | + * @param string $key |
|
524 | + * @return string |
|
525 | + * @throws \SodiumException |
|
526 | + * @throws \TypeError |
|
527 | + */ |
|
528 | + function crypto_secretbox($message, $nonce, $key) |
|
529 | + { |
|
530 | + return ParagonIE_Sodium_Compat::crypto_secretbox($message, $nonce, $key); |
|
531 | + } |
|
532 | 532 | } |
533 | 533 | if (!is_callable('\\Sodium\\crypto_secretbox_open')) { |
534 | - /** |
|
535 | - * @see ParagonIE_Sodium_Compat::crypto_secretbox_open() |
|
536 | - * @param string $message |
|
537 | - * @param string $nonce |
|
538 | - * @param string $key |
|
539 | - * @return string|bool |
|
540 | - */ |
|
541 | - function crypto_secretbox_open($message, $nonce, $key) |
|
542 | - { |
|
543 | - try { |
|
544 | - return ParagonIE_Sodium_Compat::crypto_secretbox_open($message, $nonce, $key); |
|
545 | - } catch (\TypeError $ex) { |
|
546 | - return false; |
|
547 | - } catch (\SodiumException $ex) { |
|
548 | - return false; |
|
549 | - } |
|
550 | - } |
|
534 | + /** |
|
535 | + * @see ParagonIE_Sodium_Compat::crypto_secretbox_open() |
|
536 | + * @param string $message |
|
537 | + * @param string $nonce |
|
538 | + * @param string $key |
|
539 | + * @return string|bool |
|
540 | + */ |
|
541 | + function crypto_secretbox_open($message, $nonce, $key) |
|
542 | + { |
|
543 | + try { |
|
544 | + return ParagonIE_Sodium_Compat::crypto_secretbox_open($message, $nonce, $key); |
|
545 | + } catch (\TypeError $ex) { |
|
546 | + return false; |
|
547 | + } catch (\SodiumException $ex) { |
|
548 | + return false; |
|
549 | + } |
|
550 | + } |
|
551 | 551 | } |
552 | 552 | if (!is_callable('\\Sodium\\crypto_shorthash')) { |
553 | - /** |
|
554 | - * @see ParagonIE_Sodium_Compat::crypto_shorthash() |
|
555 | - * @param string $message |
|
556 | - * @param string $key |
|
557 | - * @return string |
|
558 | - * @throws \SodiumException |
|
559 | - * @throws \TypeError |
|
560 | - */ |
|
561 | - function crypto_shorthash($message, $key = '') |
|
562 | - { |
|
563 | - return ParagonIE_Sodium_Compat::crypto_shorthash($message, $key); |
|
564 | - } |
|
553 | + /** |
|
554 | + * @see ParagonIE_Sodium_Compat::crypto_shorthash() |
|
555 | + * @param string $message |
|
556 | + * @param string $key |
|
557 | + * @return string |
|
558 | + * @throws \SodiumException |
|
559 | + * @throws \TypeError |
|
560 | + */ |
|
561 | + function crypto_shorthash($message, $key = '') |
|
562 | + { |
|
563 | + return ParagonIE_Sodium_Compat::crypto_shorthash($message, $key); |
|
564 | + } |
|
565 | 565 | } |
566 | 566 | if (!is_callable('\\Sodium\\crypto_sign')) { |
567 | - /** |
|
568 | - * @see ParagonIE_Sodium_Compat::crypto_sign() |
|
569 | - * @param string $message |
|
570 | - * @param string $sk |
|
571 | - * @return string |
|
572 | - * @throws \SodiumException |
|
573 | - * @throws \TypeError |
|
574 | - */ |
|
575 | - function crypto_sign($message, $sk) |
|
576 | - { |
|
577 | - return ParagonIE_Sodium_Compat::crypto_sign($message, $sk); |
|
578 | - } |
|
567 | + /** |
|
568 | + * @see ParagonIE_Sodium_Compat::crypto_sign() |
|
569 | + * @param string $message |
|
570 | + * @param string $sk |
|
571 | + * @return string |
|
572 | + * @throws \SodiumException |
|
573 | + * @throws \TypeError |
|
574 | + */ |
|
575 | + function crypto_sign($message, $sk) |
|
576 | + { |
|
577 | + return ParagonIE_Sodium_Compat::crypto_sign($message, $sk); |
|
578 | + } |
|
579 | 579 | } |
580 | 580 | if (!is_callable('\\Sodium\\crypto_sign_detached')) { |
581 | - /** |
|
582 | - * @see ParagonIE_Sodium_Compat::crypto_sign_detached() |
|
583 | - * @param string $message |
|
584 | - * @param string $sk |
|
585 | - * @return string |
|
586 | - * @throws \SodiumException |
|
587 | - * @throws \TypeError |
|
588 | - */ |
|
589 | - function crypto_sign_detached($message, $sk) |
|
590 | - { |
|
591 | - return ParagonIE_Sodium_Compat::crypto_sign_detached($message, $sk); |
|
592 | - } |
|
581 | + /** |
|
582 | + * @see ParagonIE_Sodium_Compat::crypto_sign_detached() |
|
583 | + * @param string $message |
|
584 | + * @param string $sk |
|
585 | + * @return string |
|
586 | + * @throws \SodiumException |
|
587 | + * @throws \TypeError |
|
588 | + */ |
|
589 | + function crypto_sign_detached($message, $sk) |
|
590 | + { |
|
591 | + return ParagonIE_Sodium_Compat::crypto_sign_detached($message, $sk); |
|
592 | + } |
|
593 | 593 | } |
594 | 594 | if (!is_callable('\\Sodium\\crypto_sign_keypair')) { |
595 | - /** |
|
596 | - * @see ParagonIE_Sodium_Compat::crypto_sign_keypair() |
|
597 | - * @return string |
|
598 | - * @throws \SodiumException |
|
599 | - * @throws \TypeError |
|
600 | - */ |
|
601 | - function crypto_sign_keypair() |
|
602 | - { |
|
603 | - return ParagonIE_Sodium_Compat::crypto_sign_keypair(); |
|
604 | - } |
|
595 | + /** |
|
596 | + * @see ParagonIE_Sodium_Compat::crypto_sign_keypair() |
|
597 | + * @return string |
|
598 | + * @throws \SodiumException |
|
599 | + * @throws \TypeError |
|
600 | + */ |
|
601 | + function crypto_sign_keypair() |
|
602 | + { |
|
603 | + return ParagonIE_Sodium_Compat::crypto_sign_keypair(); |
|
604 | + } |
|
605 | 605 | } |
606 | 606 | if (!is_callable('\\Sodium\\crypto_sign_open')) { |
607 | - /** |
|
608 | - * @see ParagonIE_Sodium_Compat::crypto_sign_open() |
|
609 | - * @param string $signedMessage |
|
610 | - * @param string $pk |
|
611 | - * @return string|bool |
|
612 | - */ |
|
613 | - function crypto_sign_open($signedMessage, $pk) |
|
614 | - { |
|
615 | - try { |
|
616 | - return ParagonIE_Sodium_Compat::crypto_sign_open($signedMessage, $pk); |
|
617 | - } catch (\TypeError $ex) { |
|
618 | - return false; |
|
619 | - } catch (\SodiumException $ex) { |
|
620 | - return false; |
|
621 | - } |
|
622 | - } |
|
607 | + /** |
|
608 | + * @see ParagonIE_Sodium_Compat::crypto_sign_open() |
|
609 | + * @param string $signedMessage |
|
610 | + * @param string $pk |
|
611 | + * @return string|bool |
|
612 | + */ |
|
613 | + function crypto_sign_open($signedMessage, $pk) |
|
614 | + { |
|
615 | + try { |
|
616 | + return ParagonIE_Sodium_Compat::crypto_sign_open($signedMessage, $pk); |
|
617 | + } catch (\TypeError $ex) { |
|
618 | + return false; |
|
619 | + } catch (\SodiumException $ex) { |
|
620 | + return false; |
|
621 | + } |
|
622 | + } |
|
623 | 623 | } |
624 | 624 | if (!is_callable('\\Sodium\\crypto_sign_publickey')) { |
625 | - /** |
|
626 | - * @see ParagonIE_Sodium_Compat::crypto_sign_publickey() |
|
627 | - * @param string $keypair |
|
628 | - * @return string |
|
629 | - * @throws \SodiumException |
|
630 | - * @throws \TypeError |
|
631 | - */ |
|
632 | - function crypto_sign_publickey($keypair) |
|
633 | - { |
|
634 | - return ParagonIE_Sodium_Compat::crypto_sign_publickey($keypair); |
|
635 | - } |
|
625 | + /** |
|
626 | + * @see ParagonIE_Sodium_Compat::crypto_sign_publickey() |
|
627 | + * @param string $keypair |
|
628 | + * @return string |
|
629 | + * @throws \SodiumException |
|
630 | + * @throws \TypeError |
|
631 | + */ |
|
632 | + function crypto_sign_publickey($keypair) |
|
633 | + { |
|
634 | + return ParagonIE_Sodium_Compat::crypto_sign_publickey($keypair); |
|
635 | + } |
|
636 | 636 | } |
637 | 637 | if (!is_callable('\\Sodium\\crypto_sign_publickey_from_secretkey')) { |
638 | - /** |
|
639 | - * @see ParagonIE_Sodium_Compat::crypto_sign_publickey_from_secretkey() |
|
640 | - * @param string $sk |
|
641 | - * @return string |
|
642 | - * @throws \SodiumException |
|
643 | - * @throws \TypeError |
|
644 | - */ |
|
645 | - function crypto_sign_publickey_from_secretkey($sk) |
|
646 | - { |
|
647 | - return ParagonIE_Sodium_Compat::crypto_sign_publickey_from_secretkey($sk); |
|
648 | - } |
|
638 | + /** |
|
639 | + * @see ParagonIE_Sodium_Compat::crypto_sign_publickey_from_secretkey() |
|
640 | + * @param string $sk |
|
641 | + * @return string |
|
642 | + * @throws \SodiumException |
|
643 | + * @throws \TypeError |
|
644 | + */ |
|
645 | + function crypto_sign_publickey_from_secretkey($sk) |
|
646 | + { |
|
647 | + return ParagonIE_Sodium_Compat::crypto_sign_publickey_from_secretkey($sk); |
|
648 | + } |
|
649 | 649 | } |
650 | 650 | if (!is_callable('\\Sodium\\crypto_sign_secretkey')) { |
651 | - /** |
|
652 | - * @see ParagonIE_Sodium_Compat::crypto_sign_secretkey() |
|
653 | - * @param string $keypair |
|
654 | - * @return string |
|
655 | - * @throws \SodiumException |
|
656 | - * @throws \TypeError |
|
657 | - */ |
|
658 | - function crypto_sign_secretkey($keypair) |
|
659 | - { |
|
660 | - return ParagonIE_Sodium_Compat::crypto_sign_secretkey($keypair); |
|
661 | - } |
|
651 | + /** |
|
652 | + * @see ParagonIE_Sodium_Compat::crypto_sign_secretkey() |
|
653 | + * @param string $keypair |
|
654 | + * @return string |
|
655 | + * @throws \SodiumException |
|
656 | + * @throws \TypeError |
|
657 | + */ |
|
658 | + function crypto_sign_secretkey($keypair) |
|
659 | + { |
|
660 | + return ParagonIE_Sodium_Compat::crypto_sign_secretkey($keypair); |
|
661 | + } |
|
662 | 662 | } |
663 | 663 | if (!is_callable('\\Sodium\\crypto_sign_seed_keypair')) { |
664 | - /** |
|
665 | - * @see ParagonIE_Sodium_Compat::crypto_sign_seed_keypair() |
|
666 | - * @param string $seed |
|
667 | - * @return string |
|
668 | - * @throws \SodiumException |
|
669 | - * @throws \TypeError |
|
670 | - */ |
|
671 | - function crypto_sign_seed_keypair($seed) |
|
672 | - { |
|
673 | - return ParagonIE_Sodium_Compat::crypto_sign_seed_keypair($seed); |
|
674 | - } |
|
664 | + /** |
|
665 | + * @see ParagonIE_Sodium_Compat::crypto_sign_seed_keypair() |
|
666 | + * @param string $seed |
|
667 | + * @return string |
|
668 | + * @throws \SodiumException |
|
669 | + * @throws \TypeError |
|
670 | + */ |
|
671 | + function crypto_sign_seed_keypair($seed) |
|
672 | + { |
|
673 | + return ParagonIE_Sodium_Compat::crypto_sign_seed_keypair($seed); |
|
674 | + } |
|
675 | 675 | } |
676 | 676 | if (!is_callable('\\Sodium\\crypto_sign_verify_detached')) { |
677 | - /** |
|
678 | - * @see ParagonIE_Sodium_Compat::crypto_sign_verify_detached() |
|
679 | - * @param string $signature |
|
680 | - * @param string $message |
|
681 | - * @param string $pk |
|
682 | - * @return bool |
|
683 | - * @throws \SodiumException |
|
684 | - * @throws \TypeError |
|
685 | - */ |
|
686 | - function crypto_sign_verify_detached($signature, $message, $pk) |
|
687 | - { |
|
688 | - return ParagonIE_Sodium_Compat::crypto_sign_verify_detached($signature, $message, $pk); |
|
689 | - } |
|
677 | + /** |
|
678 | + * @see ParagonIE_Sodium_Compat::crypto_sign_verify_detached() |
|
679 | + * @param string $signature |
|
680 | + * @param string $message |
|
681 | + * @param string $pk |
|
682 | + * @return bool |
|
683 | + * @throws \SodiumException |
|
684 | + * @throws \TypeError |
|
685 | + */ |
|
686 | + function crypto_sign_verify_detached($signature, $message, $pk) |
|
687 | + { |
|
688 | + return ParagonIE_Sodium_Compat::crypto_sign_verify_detached($signature, $message, $pk); |
|
689 | + } |
|
690 | 690 | } |
691 | 691 | if (!is_callable('\\Sodium\\crypto_sign_ed25519_pk_to_curve25519')) { |
692 | - /** |
|
693 | - * @see ParagonIE_Sodium_Compat::crypto_sign_ed25519_pk_to_curve25519() |
|
694 | - * @param string $pk |
|
695 | - * @return string |
|
696 | - * @throws \SodiumException |
|
697 | - * @throws \TypeError |
|
698 | - */ |
|
699 | - function crypto_sign_ed25519_pk_to_curve25519($pk) |
|
700 | - { |
|
701 | - return ParagonIE_Sodium_Compat::crypto_sign_ed25519_pk_to_curve25519($pk); |
|
702 | - } |
|
692 | + /** |
|
693 | + * @see ParagonIE_Sodium_Compat::crypto_sign_ed25519_pk_to_curve25519() |
|
694 | + * @param string $pk |
|
695 | + * @return string |
|
696 | + * @throws \SodiumException |
|
697 | + * @throws \TypeError |
|
698 | + */ |
|
699 | + function crypto_sign_ed25519_pk_to_curve25519($pk) |
|
700 | + { |
|
701 | + return ParagonIE_Sodium_Compat::crypto_sign_ed25519_pk_to_curve25519($pk); |
|
702 | + } |
|
703 | 703 | } |
704 | 704 | if (!is_callable('\\Sodium\\crypto_sign_ed25519_sk_to_curve25519')) { |
705 | - /** |
|
706 | - * @see ParagonIE_Sodium_Compat::crypto_sign_ed25519_sk_to_curve25519() |
|
707 | - * @param string $sk |
|
708 | - * @return string |
|
709 | - * @throws \SodiumException |
|
710 | - * @throws \TypeError |
|
711 | - */ |
|
712 | - function crypto_sign_ed25519_sk_to_curve25519($sk) |
|
713 | - { |
|
714 | - return ParagonIE_Sodium_Compat::crypto_sign_ed25519_sk_to_curve25519($sk); |
|
715 | - } |
|
705 | + /** |
|
706 | + * @see ParagonIE_Sodium_Compat::crypto_sign_ed25519_sk_to_curve25519() |
|
707 | + * @param string $sk |
|
708 | + * @return string |
|
709 | + * @throws \SodiumException |
|
710 | + * @throws \TypeError |
|
711 | + */ |
|
712 | + function crypto_sign_ed25519_sk_to_curve25519($sk) |
|
713 | + { |
|
714 | + return ParagonIE_Sodium_Compat::crypto_sign_ed25519_sk_to_curve25519($sk); |
|
715 | + } |
|
716 | 716 | } |
717 | 717 | if (!is_callable('\\Sodium\\crypto_stream')) { |
718 | - /** |
|
719 | - * @see ParagonIE_Sodium_Compat::crypto_stream() |
|
720 | - * @param int $len |
|
721 | - * @param string $nonce |
|
722 | - * @param string $key |
|
723 | - * @return string |
|
724 | - * @throws \SodiumException |
|
725 | - * @throws \TypeError |
|
726 | - */ |
|
727 | - function crypto_stream($len, $nonce, $key) |
|
728 | - { |
|
729 | - return ParagonIE_Sodium_Compat::crypto_stream($len, $nonce, $key); |
|
730 | - } |
|
718 | + /** |
|
719 | + * @see ParagonIE_Sodium_Compat::crypto_stream() |
|
720 | + * @param int $len |
|
721 | + * @param string $nonce |
|
722 | + * @param string $key |
|
723 | + * @return string |
|
724 | + * @throws \SodiumException |
|
725 | + * @throws \TypeError |
|
726 | + */ |
|
727 | + function crypto_stream($len, $nonce, $key) |
|
728 | + { |
|
729 | + return ParagonIE_Sodium_Compat::crypto_stream($len, $nonce, $key); |
|
730 | + } |
|
731 | 731 | } |
732 | 732 | if (!is_callable('\\Sodium\\crypto_stream_xor')) { |
733 | - /** |
|
734 | - * @see ParagonIE_Sodium_Compat::crypto_stream_xor() |
|
735 | - * @param string $message |
|
736 | - * @param string $nonce |
|
737 | - * @param string $key |
|
738 | - * @return string |
|
739 | - * @throws \SodiumException |
|
740 | - * @throws \TypeError |
|
741 | - */ |
|
742 | - function crypto_stream_xor($message, $nonce, $key) |
|
743 | - { |
|
744 | - return ParagonIE_Sodium_Compat::crypto_stream_xor($message, $nonce, $key); |
|
745 | - } |
|
733 | + /** |
|
734 | + * @see ParagonIE_Sodium_Compat::crypto_stream_xor() |
|
735 | + * @param string $message |
|
736 | + * @param string $nonce |
|
737 | + * @param string $key |
|
738 | + * @return string |
|
739 | + * @throws \SodiumException |
|
740 | + * @throws \TypeError |
|
741 | + */ |
|
742 | + function crypto_stream_xor($message, $nonce, $key) |
|
743 | + { |
|
744 | + return ParagonIE_Sodium_Compat::crypto_stream_xor($message, $nonce, $key); |
|
745 | + } |
|
746 | 746 | } |
747 | 747 | if (!is_callable('\\Sodium\\hex2bin')) { |
748 | - /** |
|
749 | - * @see ParagonIE_Sodium_Compat::hex2bin() |
|
750 | - * @param string $string |
|
751 | - * @return string |
|
752 | - * @throws \SodiumException |
|
753 | - * @throws \TypeError |
|
754 | - */ |
|
755 | - function hex2bin($string) |
|
756 | - { |
|
757 | - return ParagonIE_Sodium_Compat::hex2bin($string); |
|
758 | - } |
|
748 | + /** |
|
749 | + * @see ParagonIE_Sodium_Compat::hex2bin() |
|
750 | + * @param string $string |
|
751 | + * @return string |
|
752 | + * @throws \SodiumException |
|
753 | + * @throws \TypeError |
|
754 | + */ |
|
755 | + function hex2bin($string) |
|
756 | + { |
|
757 | + return ParagonIE_Sodium_Compat::hex2bin($string); |
|
758 | + } |
|
759 | 759 | } |
760 | 760 | if (!is_callable('\\Sodium\\memcmp')) { |
761 | - /** |
|
762 | - * @see ParagonIE_Sodium_Compat::memcmp() |
|
763 | - * @param string $a |
|
764 | - * @param string $b |
|
765 | - * @return int |
|
766 | - * @throws \SodiumException |
|
767 | - * @throws \TypeError |
|
768 | - */ |
|
769 | - function memcmp($a, $b) |
|
770 | - { |
|
771 | - return ParagonIE_Sodium_Compat::memcmp($a, $b); |
|
772 | - } |
|
761 | + /** |
|
762 | + * @see ParagonIE_Sodium_Compat::memcmp() |
|
763 | + * @param string $a |
|
764 | + * @param string $b |
|
765 | + * @return int |
|
766 | + * @throws \SodiumException |
|
767 | + * @throws \TypeError |
|
768 | + */ |
|
769 | + function memcmp($a, $b) |
|
770 | + { |
|
771 | + return ParagonIE_Sodium_Compat::memcmp($a, $b); |
|
772 | + } |
|
773 | 773 | } |
774 | 774 | if (!is_callable('\\Sodium\\memzero')) { |
775 | - /** |
|
776 | - * @see ParagonIE_Sodium_Compat::memzero() |
|
777 | - * @param string $str |
|
778 | - * @return void |
|
779 | - * @throws \SodiumException |
|
780 | - * @throws \TypeError |
|
781 | - */ |
|
782 | - function memzero(&$str) |
|
783 | - { |
|
784 | - ParagonIE_Sodium_Compat::memzero($str); |
|
785 | - } |
|
775 | + /** |
|
776 | + * @see ParagonIE_Sodium_Compat::memzero() |
|
777 | + * @param string $str |
|
778 | + * @return void |
|
779 | + * @throws \SodiumException |
|
780 | + * @throws \TypeError |
|
781 | + */ |
|
782 | + function memzero(&$str) |
|
783 | + { |
|
784 | + ParagonIE_Sodium_Compat::memzero($str); |
|
785 | + } |
|
786 | 786 | } |
787 | 787 | if (!is_callable('\\Sodium\\randombytes_buf')) { |
788 | - /** |
|
789 | - * @see ParagonIE_Sodium_Compat::randombytes_buf() |
|
790 | - * @param int $amount |
|
791 | - * @return string |
|
792 | - * @throws \TypeError |
|
793 | - */ |
|
794 | - function randombytes_buf($amount) |
|
795 | - { |
|
796 | - return ParagonIE_Sodium_Compat::randombytes_buf($amount); |
|
797 | - } |
|
788 | + /** |
|
789 | + * @see ParagonIE_Sodium_Compat::randombytes_buf() |
|
790 | + * @param int $amount |
|
791 | + * @return string |
|
792 | + * @throws \TypeError |
|
793 | + */ |
|
794 | + function randombytes_buf($amount) |
|
795 | + { |
|
796 | + return ParagonIE_Sodium_Compat::randombytes_buf($amount); |
|
797 | + } |
|
798 | 798 | } |
799 | 799 | |
800 | 800 | if (!is_callable('\\Sodium\\randombytes_uniform')) { |
801 | - /** |
|
802 | - * @see ParagonIE_Sodium_Compat::randombytes_uniform() |
|
803 | - * @param int $upperLimit |
|
804 | - * @return int |
|
805 | - * @throws \SodiumException |
|
806 | - * @throws \Error |
|
807 | - */ |
|
808 | - function randombytes_uniform($upperLimit) |
|
809 | - { |
|
810 | - return ParagonIE_Sodium_Compat::randombytes_uniform($upperLimit); |
|
811 | - } |
|
801 | + /** |
|
802 | + * @see ParagonIE_Sodium_Compat::randombytes_uniform() |
|
803 | + * @param int $upperLimit |
|
804 | + * @return int |
|
805 | + * @throws \SodiumException |
|
806 | + * @throws \Error |
|
807 | + */ |
|
808 | + function randombytes_uniform($upperLimit) |
|
809 | + { |
|
810 | + return ParagonIE_Sodium_Compat::randombytes_uniform($upperLimit); |
|
811 | + } |
|
812 | 812 | } |
813 | 813 | |
814 | 814 | if (!is_callable('\\Sodium\\randombytes_random16')) { |
815 | - /** |
|
816 | - * @see ParagonIE_Sodium_Compat::randombytes_random16() |
|
817 | - * @return int |
|
818 | - */ |
|
819 | - function randombytes_random16() |
|
820 | - { |
|
821 | - return ParagonIE_Sodium_Compat::randombytes_random16(); |
|
822 | - } |
|
815 | + /** |
|
816 | + * @see ParagonIE_Sodium_Compat::randombytes_random16() |
|
817 | + * @return int |
|
818 | + */ |
|
819 | + function randombytes_random16() |
|
820 | + { |
|
821 | + return ParagonIE_Sodium_Compat::randombytes_random16(); |
|
822 | + } |
|
823 | 823 | } |
824 | 824 | |
825 | 825 | if (!defined('\\Sodium\\CRYPTO_AUTH_BYTES')) { |
826 | - require_once dirname(__FILE__) . '/constants.php'; |
|
826 | + require_once dirname(__FILE__) . '/constants.php'; |
|
827 | 827 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace Sodium; |
3 | 3 | |
4 | -require_once dirname(dirname(__FILE__)) . '/autoload.php'; |
|
4 | +require_once dirname( dirname( __FILE__ ) ) . '/autoload.php'; |
|
5 | 5 | |
6 | 6 | use ParagonIE_Sodium_Compat; |
7 | 7 | |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * Thus, the functions just proxy to the appropriate ParagonIE_Sodium_Compat |
13 | 13 | * method. |
14 | 14 | */ |
15 | -if (!is_callable('\\Sodium\\bin2hex')) { |
|
15 | +if ( ! is_callable( '\\Sodium\\bin2hex' ) ) { |
|
16 | 16 | /** |
17 | 17 | * @see ParagonIE_Sodium_Compat::bin2hex() |
18 | 18 | * @param string $string |
@@ -20,12 +20,12 @@ discard block |
||
20 | 20 | * @throws \SodiumException |
21 | 21 | * @throws \TypeError |
22 | 22 | */ |
23 | - function bin2hex($string) |
|
23 | + function bin2hex( $string ) |
|
24 | 24 | { |
25 | - return ParagonIE_Sodium_Compat::bin2hex($string); |
|
25 | + return ParagonIE_Sodium_Compat::bin2hex( $string ); |
|
26 | 26 | } |
27 | 27 | } |
28 | -if (!is_callable('\\Sodium\\compare')) { |
|
28 | +if ( ! is_callable( '\\Sodium\\compare' ) ) { |
|
29 | 29 | /** |
30 | 30 | * @see ParagonIE_Sodium_Compat::compare() |
31 | 31 | * @param string $a |
@@ -34,12 +34,12 @@ discard block |
||
34 | 34 | * @throws \SodiumException |
35 | 35 | * @throws \TypeError |
36 | 36 | */ |
37 | - function compare($a, $b) |
|
37 | + function compare( $a, $b ) |
|
38 | 38 | { |
39 | - return ParagonIE_Sodium_Compat::compare($a, $b); |
|
39 | + return ParagonIE_Sodium_Compat::compare( $a, $b ); |
|
40 | 40 | } |
41 | 41 | } |
42 | -if (!is_callable('\\Sodium\\crypto_aead_aes256gcm_decrypt')) { |
|
42 | +if ( ! is_callable( '\\Sodium\\crypto_aead_aes256gcm_decrypt' ) ) { |
|
43 | 43 | /** |
44 | 44 | * @see ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_decrypt() |
45 | 45 | * @param string $message |
@@ -48,18 +48,18 @@ discard block |
||
48 | 48 | * @param string $key |
49 | 49 | * @return string|bool |
50 | 50 | */ |
51 | - function crypto_aead_aes256gcm_decrypt($message, $assocData, $nonce, $key) |
|
51 | + function crypto_aead_aes256gcm_decrypt( $message, $assocData, $nonce, $key ) |
|
52 | 52 | { |
53 | 53 | try { |
54 | - return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_decrypt($message, $assocData, $nonce, $key); |
|
55 | - } catch (\TypeError $ex) { |
|
54 | + return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_decrypt( $message, $assocData, $nonce, $key ); |
|
55 | + } catch ( \TypeError $ex ) { |
|
56 | 56 | return false; |
57 | - } catch (\SodiumException $ex) { |
|
57 | + } catch ( \SodiumException $ex ) { |
|
58 | 58 | return false; |
59 | 59 | } |
60 | 60 | } |
61 | 61 | } |
62 | -if (!is_callable('\\Sodium\\crypto_aead_aes256gcm_encrypt')) { |
|
62 | +if ( ! is_callable( '\\Sodium\\crypto_aead_aes256gcm_encrypt' ) ) { |
|
63 | 63 | /** |
64 | 64 | * @see ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_encrypt() |
65 | 65 | * @param string $message |
@@ -70,12 +70,12 @@ discard block |
||
70 | 70 | * @throws \SodiumException |
71 | 71 | * @throws \TypeError |
72 | 72 | */ |
73 | - function crypto_aead_aes256gcm_encrypt($message, $assocData, $nonce, $key) |
|
73 | + function crypto_aead_aes256gcm_encrypt( $message, $assocData, $nonce, $key ) |
|
74 | 74 | { |
75 | - return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_encrypt($message, $assocData, $nonce, $key); |
|
75 | + return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_encrypt( $message, $assocData, $nonce, $key ); |
|
76 | 76 | } |
77 | 77 | } |
78 | -if (!is_callable('\\Sodium\\crypto_aead_aes256gcm_is_available')) { |
|
78 | +if ( ! is_callable( '\\Sodium\\crypto_aead_aes256gcm_is_available' ) ) { |
|
79 | 79 | /** |
80 | 80 | * @see ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_is_available() |
81 | 81 | * @return bool |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_is_available(); |
86 | 86 | } |
87 | 87 | } |
88 | -if (!is_callable('\\Sodium\\crypto_aead_chacha20poly1305_decrypt')) { |
|
88 | +if ( ! is_callable( '\\Sodium\\crypto_aead_chacha20poly1305_decrypt' ) ) { |
|
89 | 89 | /** |
90 | 90 | * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_decrypt() |
91 | 91 | * @param string $message |
@@ -94,18 +94,18 @@ discard block |
||
94 | 94 | * @param string $key |
95 | 95 | * @return string|bool |
96 | 96 | */ |
97 | - function crypto_aead_chacha20poly1305_decrypt($message, $assocData, $nonce, $key) |
|
97 | + function crypto_aead_chacha20poly1305_decrypt( $message, $assocData, $nonce, $key ) |
|
98 | 98 | { |
99 | 99 | try { |
100 | - return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_decrypt($message, $assocData, $nonce, $key); |
|
101 | - } catch (\TypeError $ex) { |
|
100 | + return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_decrypt( $message, $assocData, $nonce, $key ); |
|
101 | + } catch ( \TypeError $ex ) { |
|
102 | 102 | return false; |
103 | - } catch (\SodiumException $ex) { |
|
103 | + } catch ( \SodiumException $ex ) { |
|
104 | 104 | return false; |
105 | 105 | } |
106 | 106 | } |
107 | 107 | } |
108 | -if (!is_callable('\\Sodium\\crypto_aead_chacha20poly1305_encrypt')) { |
|
108 | +if ( ! is_callable( '\\Sodium\\crypto_aead_chacha20poly1305_encrypt' ) ) { |
|
109 | 109 | /** |
110 | 110 | * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_encrypt() |
111 | 111 | * @param string $message |
@@ -116,12 +116,12 @@ discard block |
||
116 | 116 | * @throws \SodiumException |
117 | 117 | * @throws \TypeError |
118 | 118 | */ |
119 | - function crypto_aead_chacha20poly1305_encrypt($message, $assocData, $nonce, $key) |
|
119 | + function crypto_aead_chacha20poly1305_encrypt( $message, $assocData, $nonce, $key ) |
|
120 | 120 | { |
121 | - return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_encrypt($message, $assocData, $nonce, $key); |
|
121 | + return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_encrypt( $message, $assocData, $nonce, $key ); |
|
122 | 122 | } |
123 | 123 | } |
124 | -if (!is_callable('\\Sodium\\crypto_aead_chacha20poly1305_ietf_decrypt')) { |
|
124 | +if ( ! is_callable( '\\Sodium\\crypto_aead_chacha20poly1305_ietf_decrypt' ) ) { |
|
125 | 125 | /** |
126 | 126 | * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_decrypt() |
127 | 127 | * @param string $message |
@@ -130,18 +130,18 @@ discard block |
||
130 | 130 | * @param string $key |
131 | 131 | * @return string|bool |
132 | 132 | */ |
133 | - function crypto_aead_chacha20poly1305_ietf_decrypt($message, $assocData, $nonce, $key) |
|
133 | + function crypto_aead_chacha20poly1305_ietf_decrypt( $message, $assocData, $nonce, $key ) |
|
134 | 134 | { |
135 | 135 | try { |
136 | - return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_decrypt($message, $assocData, $nonce, $key); |
|
137 | - } catch (\TypeError $ex) { |
|
136 | + return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_decrypt( $message, $assocData, $nonce, $key ); |
|
137 | + } catch ( \TypeError $ex ) { |
|
138 | 138 | return false; |
139 | - } catch (\SodiumException $ex) { |
|
139 | + } catch ( \SodiumException $ex ) { |
|
140 | 140 | return false; |
141 | 141 | } |
142 | 142 | } |
143 | 143 | } |
144 | -if (!is_callable('\\Sodium\\crypto_aead_chacha20poly1305_ietf_encrypt')) { |
|
144 | +if ( ! is_callable( '\\Sodium\\crypto_aead_chacha20poly1305_ietf_encrypt' ) ) { |
|
145 | 145 | /** |
146 | 146 | * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_encrypt() |
147 | 147 | * @param string $message |
@@ -152,12 +152,12 @@ discard block |
||
152 | 152 | * @throws \SodiumException |
153 | 153 | * @throws \TypeError |
154 | 154 | */ |
155 | - function crypto_aead_chacha20poly1305_ietf_encrypt($message, $assocData, $nonce, $key) |
|
155 | + function crypto_aead_chacha20poly1305_ietf_encrypt( $message, $assocData, $nonce, $key ) |
|
156 | 156 | { |
157 | - return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_encrypt($message, $assocData, $nonce, $key); |
|
157 | + return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_encrypt( $message, $assocData, $nonce, $key ); |
|
158 | 158 | } |
159 | 159 | } |
160 | -if (!is_callable('\\Sodium\\crypto_auth')) { |
|
160 | +if ( ! is_callable( '\\Sodium\\crypto_auth' ) ) { |
|
161 | 161 | /** |
162 | 162 | * @see ParagonIE_Sodium_Compat::crypto_auth() |
163 | 163 | * @param string $message |
@@ -166,12 +166,12 @@ discard block |
||
166 | 166 | * @throws \SodiumException |
167 | 167 | * @throws \TypeError |
168 | 168 | */ |
169 | - function crypto_auth($message, $key) |
|
169 | + function crypto_auth( $message, $key ) |
|
170 | 170 | { |
171 | - return ParagonIE_Sodium_Compat::crypto_auth($message, $key); |
|
171 | + return ParagonIE_Sodium_Compat::crypto_auth( $message, $key ); |
|
172 | 172 | } |
173 | 173 | } |
174 | -if (!is_callable('\\Sodium\\crypto_auth_verify')) { |
|
174 | +if ( ! is_callable( '\\Sodium\\crypto_auth_verify' ) ) { |
|
175 | 175 | /** |
176 | 176 | * @see ParagonIE_Sodium_Compat::crypto_auth_verify() |
177 | 177 | * @param string $mac |
@@ -181,12 +181,12 @@ discard block |
||
181 | 181 | * @throws \SodiumException |
182 | 182 | * @throws \TypeError |
183 | 183 | */ |
184 | - function crypto_auth_verify($mac, $message, $key) |
|
184 | + function crypto_auth_verify( $mac, $message, $key ) |
|
185 | 185 | { |
186 | - return ParagonIE_Sodium_Compat::crypto_auth_verify($mac, $message, $key); |
|
186 | + return ParagonIE_Sodium_Compat::crypto_auth_verify( $mac, $message, $key ); |
|
187 | 187 | } |
188 | 188 | } |
189 | -if (!is_callable('\\Sodium\\crypto_box')) { |
|
189 | +if ( ! is_callable( '\\Sodium\\crypto_box' ) ) { |
|
190 | 190 | /** |
191 | 191 | * @see ParagonIE_Sodium_Compat::crypto_box() |
192 | 192 | * @param string $message |
@@ -196,12 +196,12 @@ discard block |
||
196 | 196 | * @throws \SodiumException |
197 | 197 | * @throws \TypeError |
198 | 198 | */ |
199 | - function crypto_box($message, $nonce, $kp) |
|
199 | + function crypto_box( $message, $nonce, $kp ) |
|
200 | 200 | { |
201 | - return ParagonIE_Sodium_Compat::crypto_box($message, $nonce, $kp); |
|
201 | + return ParagonIE_Sodium_Compat::crypto_box( $message, $nonce, $kp ); |
|
202 | 202 | } |
203 | 203 | } |
204 | -if (!is_callable('\\Sodium\\crypto_box_keypair')) { |
|
204 | +if ( ! is_callable( '\\Sodium\\crypto_box_keypair' ) ) { |
|
205 | 205 | /** |
206 | 206 | * @see ParagonIE_Sodium_Compat::crypto_box_keypair() |
207 | 207 | * @return string |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | return ParagonIE_Sodium_Compat::crypto_box_keypair(); |
214 | 214 | } |
215 | 215 | } |
216 | -if (!is_callable('\\Sodium\\crypto_box_keypair_from_secretkey_and_publickey')) { |
|
216 | +if ( ! is_callable( '\\Sodium\\crypto_box_keypair_from_secretkey_and_publickey' ) ) { |
|
217 | 217 | /** |
218 | 218 | * @see ParagonIE_Sodium_Compat::crypto_box_keypair_from_secretkey_and_publickey() |
219 | 219 | * @param string $sk |
@@ -222,12 +222,12 @@ discard block |
||
222 | 222 | * @throws \SodiumException |
223 | 223 | * @throws \TypeError |
224 | 224 | */ |
225 | - function crypto_box_keypair_from_secretkey_and_publickey($sk, $pk) |
|
225 | + function crypto_box_keypair_from_secretkey_and_publickey( $sk, $pk ) |
|
226 | 226 | { |
227 | - return ParagonIE_Sodium_Compat::crypto_box_keypair_from_secretkey_and_publickey($sk, $pk); |
|
227 | + return ParagonIE_Sodium_Compat::crypto_box_keypair_from_secretkey_and_publickey( $sk, $pk ); |
|
228 | 228 | } |
229 | 229 | } |
230 | -if (!is_callable('\\Sodium\\crypto_box_open')) { |
|
230 | +if ( ! is_callable( '\\Sodium\\crypto_box_open' ) ) { |
|
231 | 231 | /** |
232 | 232 | * @see ParagonIE_Sodium_Compat::crypto_box_open() |
233 | 233 | * @param string $message |
@@ -235,18 +235,18 @@ discard block |
||
235 | 235 | * @param string $kp |
236 | 236 | * @return string|bool |
237 | 237 | */ |
238 | - function crypto_box_open($message, $nonce, $kp) |
|
238 | + function crypto_box_open( $message, $nonce, $kp ) |
|
239 | 239 | { |
240 | 240 | try { |
241 | - return ParagonIE_Sodium_Compat::crypto_box_open($message, $nonce, $kp); |
|
242 | - } catch (\TypeError $ex) { |
|
241 | + return ParagonIE_Sodium_Compat::crypto_box_open( $message, $nonce, $kp ); |
|
242 | + } catch ( \TypeError $ex ) { |
|
243 | 243 | return false; |
244 | - } catch (\SodiumException $ex) { |
|
244 | + } catch ( \SodiumException $ex ) { |
|
245 | 245 | return false; |
246 | 246 | } |
247 | 247 | } |
248 | 248 | } |
249 | -if (!is_callable('\\Sodium\\crypto_box_publickey')) { |
|
249 | +if ( ! is_callable( '\\Sodium\\crypto_box_publickey' ) ) { |
|
250 | 250 | /** |
251 | 251 | * @see ParagonIE_Sodium_Compat::crypto_box_publickey() |
252 | 252 | * @param string $keypair |
@@ -254,12 +254,12 @@ discard block |
||
254 | 254 | * @throws \SodiumException |
255 | 255 | * @throws \TypeError |
256 | 256 | */ |
257 | - function crypto_box_publickey($keypair) |
|
257 | + function crypto_box_publickey( $keypair ) |
|
258 | 258 | { |
259 | - return ParagonIE_Sodium_Compat::crypto_box_publickey($keypair); |
|
259 | + return ParagonIE_Sodium_Compat::crypto_box_publickey( $keypair ); |
|
260 | 260 | } |
261 | 261 | } |
262 | -if (!is_callable('\\Sodium\\crypto_box_publickey_from_secretkey')) { |
|
262 | +if ( ! is_callable( '\\Sodium\\crypto_box_publickey_from_secretkey' ) ) { |
|
263 | 263 | /** |
264 | 264 | * @see ParagonIE_Sodium_Compat::crypto_box_publickey_from_secretkey() |
265 | 265 | * @param string $sk |
@@ -267,12 +267,12 @@ discard block |
||
267 | 267 | * @throws \SodiumException |
268 | 268 | * @throws \TypeError |
269 | 269 | */ |
270 | - function crypto_box_publickey_from_secretkey($sk) |
|
270 | + function crypto_box_publickey_from_secretkey( $sk ) |
|
271 | 271 | { |
272 | - return ParagonIE_Sodium_Compat::crypto_box_publickey_from_secretkey($sk); |
|
272 | + return ParagonIE_Sodium_Compat::crypto_box_publickey_from_secretkey( $sk ); |
|
273 | 273 | } |
274 | 274 | } |
275 | -if (!is_callable('\\Sodium\\crypto_box_seal')) { |
|
275 | +if ( ! is_callable( '\\Sodium\\crypto_box_seal' ) ) { |
|
276 | 276 | /** |
277 | 277 | * @see ParagonIE_Sodium_Compat::crypto_box_seal_open() |
278 | 278 | * @param string $message |
@@ -281,30 +281,30 @@ discard block |
||
281 | 281 | * @throws \SodiumException |
282 | 282 | * @throws \TypeError |
283 | 283 | */ |
284 | - function crypto_box_seal($message, $publicKey) |
|
284 | + function crypto_box_seal( $message, $publicKey ) |
|
285 | 285 | { |
286 | - return ParagonIE_Sodium_Compat::crypto_box_seal($message, $publicKey); |
|
286 | + return ParagonIE_Sodium_Compat::crypto_box_seal( $message, $publicKey ); |
|
287 | 287 | } |
288 | 288 | } |
289 | -if (!is_callable('\\Sodium\\crypto_box_seal_open')) { |
|
289 | +if ( ! is_callable( '\\Sodium\\crypto_box_seal_open' ) ) { |
|
290 | 290 | /** |
291 | 291 | * @see ParagonIE_Sodium_Compat::crypto_box_seal_open() |
292 | 292 | * @param string $message |
293 | 293 | * @param string $kp |
294 | 294 | * @return string|bool |
295 | 295 | */ |
296 | - function crypto_box_seal_open($message, $kp) |
|
296 | + function crypto_box_seal_open( $message, $kp ) |
|
297 | 297 | { |
298 | 298 | try { |
299 | - return ParagonIE_Sodium_Compat::crypto_box_seal_open($message, $kp); |
|
300 | - } catch (\TypeError $ex) { |
|
299 | + return ParagonIE_Sodium_Compat::crypto_box_seal_open( $message, $kp ); |
|
300 | + } catch ( \TypeError $ex ) { |
|
301 | 301 | return false; |
302 | - } catch (\SodiumException $ex) { |
|
302 | + } catch ( \SodiumException $ex ) { |
|
303 | 303 | return false; |
304 | 304 | } |
305 | 305 | } |
306 | 306 | } |
307 | -if (!is_callable('\\Sodium\\crypto_box_secretkey')) { |
|
307 | +if ( ! is_callable( '\\Sodium\\crypto_box_secretkey' ) ) { |
|
308 | 308 | /** |
309 | 309 | * @see ParagonIE_Sodium_Compat::crypto_box_secretkey() |
310 | 310 | * @param string $keypair |
@@ -312,12 +312,12 @@ discard block |
||
312 | 312 | * @throws \SodiumException |
313 | 313 | * @throws \TypeError |
314 | 314 | */ |
315 | - function crypto_box_secretkey($keypair) |
|
315 | + function crypto_box_secretkey( $keypair ) |
|
316 | 316 | { |
317 | - return ParagonIE_Sodium_Compat::crypto_box_secretkey($keypair); |
|
317 | + return ParagonIE_Sodium_Compat::crypto_box_secretkey( $keypair ); |
|
318 | 318 | } |
319 | 319 | } |
320 | -if (!is_callable('\\Sodium\\crypto_generichash')) { |
|
320 | +if ( ! is_callable( '\\Sodium\\crypto_generichash' ) ) { |
|
321 | 321 | /** |
322 | 322 | * @see ParagonIE_Sodium_Compat::crypto_generichash() |
323 | 323 | * @param string $message |
@@ -327,12 +327,12 @@ discard block |
||
327 | 327 | * @throws \SodiumException |
328 | 328 | * @throws \TypeError |
329 | 329 | */ |
330 | - function crypto_generichash($message, $key = null, $outLen = 32) |
|
330 | + function crypto_generichash( $message, $key = null, $outLen = 32 ) |
|
331 | 331 | { |
332 | - return ParagonIE_Sodium_Compat::crypto_generichash($message, $key, $outLen); |
|
332 | + return ParagonIE_Sodium_Compat::crypto_generichash( $message, $key, $outLen ); |
|
333 | 333 | } |
334 | 334 | } |
335 | -if (!is_callable('\\Sodium\\crypto_generichash_final')) { |
|
335 | +if ( ! is_callable( '\\Sodium\\crypto_generichash_final' ) ) { |
|
336 | 336 | /** |
337 | 337 | * @see ParagonIE_Sodium_Compat::crypto_generichash_final() |
338 | 338 | * @param string|null $ctx |
@@ -341,12 +341,12 @@ discard block |
||
341 | 341 | * @throws \SodiumException |
342 | 342 | * @throws \TypeError |
343 | 343 | */ |
344 | - function crypto_generichash_final(&$ctx, $outputLength = 32) |
|
344 | + function crypto_generichash_final( &$ctx, $outputLength = 32 ) |
|
345 | 345 | { |
346 | - return ParagonIE_Sodium_Compat::crypto_generichash_final($ctx, $outputLength); |
|
346 | + return ParagonIE_Sodium_Compat::crypto_generichash_final( $ctx, $outputLength ); |
|
347 | 347 | } |
348 | 348 | } |
349 | -if (!is_callable('\\Sodium\\crypto_generichash_init')) { |
|
349 | +if ( ! is_callable( '\\Sodium\\crypto_generichash_init' ) ) { |
|
350 | 350 | /** |
351 | 351 | * @see ParagonIE_Sodium_Compat::crypto_generichash_init() |
352 | 352 | * @param string|null $key |
@@ -355,12 +355,12 @@ discard block |
||
355 | 355 | * @throws \SodiumException |
356 | 356 | * @throws \TypeError |
357 | 357 | */ |
358 | - function crypto_generichash_init($key = null, $outLen = 32) |
|
358 | + function crypto_generichash_init( $key = null, $outLen = 32 ) |
|
359 | 359 | { |
360 | - return ParagonIE_Sodium_Compat::crypto_generichash_init($key, $outLen); |
|
360 | + return ParagonIE_Sodium_Compat::crypto_generichash_init( $key, $outLen ); |
|
361 | 361 | } |
362 | 362 | } |
363 | -if (!is_callable('\\Sodium\\crypto_generichash_update')) { |
|
363 | +if ( ! is_callable( '\\Sodium\\crypto_generichash_update' ) ) { |
|
364 | 364 | /** |
365 | 365 | * @see ParagonIE_Sodium_Compat::crypto_generichash_update() |
366 | 366 | * @param string|null $ctx |
@@ -369,12 +369,12 @@ discard block |
||
369 | 369 | * @throws \SodiumException |
370 | 370 | * @throws \TypeError |
371 | 371 | */ |
372 | - function crypto_generichash_update(&$ctx, $message = '') |
|
372 | + function crypto_generichash_update( &$ctx, $message = '' ) |
|
373 | 373 | { |
374 | - ParagonIE_Sodium_Compat::crypto_generichash_update($ctx, $message); |
|
374 | + ParagonIE_Sodium_Compat::crypto_generichash_update( $ctx, $message ); |
|
375 | 375 | } |
376 | 376 | } |
377 | -if (!is_callable('\\Sodium\\crypto_kx')) { |
|
377 | +if ( ! is_callable( '\\Sodium\\crypto_kx' ) ) { |
|
378 | 378 | /** |
379 | 379 | * @see ParagonIE_Sodium_Compat::crypto_kx() |
380 | 380 | * @param string $my_secret |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | * @throws \SodiumException |
386 | 386 | * @throws \TypeError |
387 | 387 | */ |
388 | - function crypto_kx($my_secret, $their_public, $client_public, $server_public) |
|
388 | + function crypto_kx( $my_secret, $their_public, $client_public, $server_public ) |
|
389 | 389 | { |
390 | 390 | return ParagonIE_Sodium_Compat::crypto_kx( |
391 | 391 | $my_secret, |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | ); |
397 | 397 | } |
398 | 398 | } |
399 | -if (!is_callable('\\Sodium\\crypto_pwhash')) { |
|
399 | +if ( ! is_callable( '\\Sodium\\crypto_pwhash' ) ) { |
|
400 | 400 | /** |
401 | 401 | * @see ParagonIE_Sodium_Compat::crypto_pwhash() |
402 | 402 | * @param int $outlen |
@@ -408,12 +408,12 @@ discard block |
||
408 | 408 | * @throws \SodiumException |
409 | 409 | * @throws \TypeError |
410 | 410 | */ |
411 | - function crypto_pwhash($outlen, $passwd, $salt, $opslimit, $memlimit) |
|
411 | + function crypto_pwhash( $outlen, $passwd, $salt, $opslimit, $memlimit ) |
|
412 | 412 | { |
413 | - return ParagonIE_Sodium_Compat::crypto_pwhash($outlen, $passwd, $salt, $opslimit, $memlimit); |
|
413 | + return ParagonIE_Sodium_Compat::crypto_pwhash( $outlen, $passwd, $salt, $opslimit, $memlimit ); |
|
414 | 414 | } |
415 | 415 | } |
416 | -if (!is_callable('\\Sodium\\crypto_pwhash_str')) { |
|
416 | +if ( ! is_callable( '\\Sodium\\crypto_pwhash_str' ) ) { |
|
417 | 417 | /** |
418 | 418 | * @see ParagonIE_Sodium_Compat::crypto_pwhash_str() |
419 | 419 | * @param string $passwd |
@@ -423,12 +423,12 @@ discard block |
||
423 | 423 | * @throws \SodiumException |
424 | 424 | * @throws \TypeError |
425 | 425 | */ |
426 | - function crypto_pwhash_str($passwd, $opslimit, $memlimit) |
|
426 | + function crypto_pwhash_str( $passwd, $opslimit, $memlimit ) |
|
427 | 427 | { |
428 | - return ParagonIE_Sodium_Compat::crypto_pwhash_str($passwd, $opslimit, $memlimit); |
|
428 | + return ParagonIE_Sodium_Compat::crypto_pwhash_str( $passwd, $opslimit, $memlimit ); |
|
429 | 429 | } |
430 | 430 | } |
431 | -if (!is_callable('\\Sodium\\crypto_pwhash_str_verify')) { |
|
431 | +if ( ! is_callable( '\\Sodium\\crypto_pwhash_str_verify' ) ) { |
|
432 | 432 | /** |
433 | 433 | * @see ParagonIE_Sodium_Compat::crypto_pwhash_str_verify() |
434 | 434 | * @param string $passwd |
@@ -437,12 +437,12 @@ discard block |
||
437 | 437 | * @throws \SodiumException |
438 | 438 | * @throws \TypeError |
439 | 439 | */ |
440 | - function crypto_pwhash_str_verify($passwd, $hash) |
|
440 | + function crypto_pwhash_str_verify( $passwd, $hash ) |
|
441 | 441 | { |
442 | - return ParagonIE_Sodium_Compat::crypto_pwhash_str_verify($passwd, $hash); |
|
442 | + return ParagonIE_Sodium_Compat::crypto_pwhash_str_verify( $passwd, $hash ); |
|
443 | 443 | } |
444 | 444 | } |
445 | -if (!is_callable('\\Sodium\\crypto_pwhash_scryptsalsa208sha256')) { |
|
445 | +if ( ! is_callable( '\\Sodium\\crypto_pwhash_scryptsalsa208sha256' ) ) { |
|
446 | 446 | /** |
447 | 447 | * @see ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256() |
448 | 448 | * @param int $outlen |
@@ -454,12 +454,12 @@ discard block |
||
454 | 454 | * @throws \SodiumException |
455 | 455 | * @throws \TypeError |
456 | 456 | */ |
457 | - function crypto_pwhash_scryptsalsa208sha256($outlen, $passwd, $salt, $opslimit, $memlimit) |
|
457 | + function crypto_pwhash_scryptsalsa208sha256( $outlen, $passwd, $salt, $opslimit, $memlimit ) |
|
458 | 458 | { |
459 | - return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256($outlen, $passwd, $salt, $opslimit, $memlimit); |
|
459 | + return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256( $outlen, $passwd, $salt, $opslimit, $memlimit ); |
|
460 | 460 | } |
461 | 461 | } |
462 | -if (!is_callable('\\Sodium\\crypto_pwhash_scryptsalsa208sha256_str')) { |
|
462 | +if ( ! is_callable( '\\Sodium\\crypto_pwhash_scryptsalsa208sha256_str' ) ) { |
|
463 | 463 | /** |
464 | 464 | * @see ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str() |
465 | 465 | * @param string $passwd |
@@ -469,12 +469,12 @@ discard block |
||
469 | 469 | * @throws \SodiumException |
470 | 470 | * @throws \TypeError |
471 | 471 | */ |
472 | - function crypto_pwhash_scryptsalsa208sha256_str($passwd, $opslimit, $memlimit) |
|
472 | + function crypto_pwhash_scryptsalsa208sha256_str( $passwd, $opslimit, $memlimit ) |
|
473 | 473 | { |
474 | - return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str($passwd, $opslimit, $memlimit); |
|
474 | + return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str( $passwd, $opslimit, $memlimit ); |
|
475 | 475 | } |
476 | 476 | } |
477 | -if (!is_callable('\\Sodium\\crypto_pwhash_scryptsalsa208sha256_str_verify')) { |
|
477 | +if ( ! is_callable( '\\Sodium\\crypto_pwhash_scryptsalsa208sha256_str_verify' ) ) { |
|
478 | 478 | /** |
479 | 479 | * @see ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str_verify() |
480 | 480 | * @param string $passwd |
@@ -483,12 +483,12 @@ discard block |
||
483 | 483 | * @throws \SodiumException |
484 | 484 | * @throws \TypeError |
485 | 485 | */ |
486 | - function crypto_pwhash_scryptsalsa208sha256_str_verify($passwd, $hash) |
|
486 | + function crypto_pwhash_scryptsalsa208sha256_str_verify( $passwd, $hash ) |
|
487 | 487 | { |
488 | - return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str_verify($passwd, $hash); |
|
488 | + return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str_verify( $passwd, $hash ); |
|
489 | 489 | } |
490 | 490 | } |
491 | -if (!is_callable('\\Sodium\\crypto_scalarmult')) { |
|
491 | +if ( ! is_callable( '\\Sodium\\crypto_scalarmult' ) ) { |
|
492 | 492 | /** |
493 | 493 | * @see ParagonIE_Sodium_Compat::crypto_scalarmult() |
494 | 494 | * @param string $n |
@@ -497,12 +497,12 @@ discard block |
||
497 | 497 | * @throws \SodiumException |
498 | 498 | * @throws \TypeError |
499 | 499 | */ |
500 | - function crypto_scalarmult($n, $p) |
|
500 | + function crypto_scalarmult( $n, $p ) |
|
501 | 501 | { |
502 | - return ParagonIE_Sodium_Compat::crypto_scalarmult($n, $p); |
|
502 | + return ParagonIE_Sodium_Compat::crypto_scalarmult( $n, $p ); |
|
503 | 503 | } |
504 | 504 | } |
505 | -if (!is_callable('\\Sodium\\crypto_scalarmult_base')) { |
|
505 | +if ( ! is_callable( '\\Sodium\\crypto_scalarmult_base' ) ) { |
|
506 | 506 | /** |
507 | 507 | * @see ParagonIE_Sodium_Compat::crypto_scalarmult_base() |
508 | 508 | * @param string $n |
@@ -510,12 +510,12 @@ discard block |
||
510 | 510 | * @throws \SodiumException |
511 | 511 | * @throws \TypeError |
512 | 512 | */ |
513 | - function crypto_scalarmult_base($n) |
|
513 | + function crypto_scalarmult_base( $n ) |
|
514 | 514 | { |
515 | - return ParagonIE_Sodium_Compat::crypto_scalarmult_base($n); |
|
515 | + return ParagonIE_Sodium_Compat::crypto_scalarmult_base( $n ); |
|
516 | 516 | } |
517 | 517 | } |
518 | -if (!is_callable('\\Sodium\\crypto_secretbox')) { |
|
518 | +if ( ! is_callable( '\\Sodium\\crypto_secretbox' ) ) { |
|
519 | 519 | /** |
520 | 520 | * @see ParagonIE_Sodium_Compat::crypto_secretbox() |
521 | 521 | * @param string $message |
@@ -525,12 +525,12 @@ discard block |
||
525 | 525 | * @throws \SodiumException |
526 | 526 | * @throws \TypeError |
527 | 527 | */ |
528 | - function crypto_secretbox($message, $nonce, $key) |
|
528 | + function crypto_secretbox( $message, $nonce, $key ) |
|
529 | 529 | { |
530 | - return ParagonIE_Sodium_Compat::crypto_secretbox($message, $nonce, $key); |
|
530 | + return ParagonIE_Sodium_Compat::crypto_secretbox( $message, $nonce, $key ); |
|
531 | 531 | } |
532 | 532 | } |
533 | -if (!is_callable('\\Sodium\\crypto_secretbox_open')) { |
|
533 | +if ( ! is_callable( '\\Sodium\\crypto_secretbox_open' ) ) { |
|
534 | 534 | /** |
535 | 535 | * @see ParagonIE_Sodium_Compat::crypto_secretbox_open() |
536 | 536 | * @param string $message |
@@ -538,18 +538,18 @@ discard block |
||
538 | 538 | * @param string $key |
539 | 539 | * @return string|bool |
540 | 540 | */ |
541 | - function crypto_secretbox_open($message, $nonce, $key) |
|
541 | + function crypto_secretbox_open( $message, $nonce, $key ) |
|
542 | 542 | { |
543 | 543 | try { |
544 | - return ParagonIE_Sodium_Compat::crypto_secretbox_open($message, $nonce, $key); |
|
545 | - } catch (\TypeError $ex) { |
|
544 | + return ParagonIE_Sodium_Compat::crypto_secretbox_open( $message, $nonce, $key ); |
|
545 | + } catch ( \TypeError $ex ) { |
|
546 | 546 | return false; |
547 | - } catch (\SodiumException $ex) { |
|
547 | + } catch ( \SodiumException $ex ) { |
|
548 | 548 | return false; |
549 | 549 | } |
550 | 550 | } |
551 | 551 | } |
552 | -if (!is_callable('\\Sodium\\crypto_shorthash')) { |
|
552 | +if ( ! is_callable( '\\Sodium\\crypto_shorthash' ) ) { |
|
553 | 553 | /** |
554 | 554 | * @see ParagonIE_Sodium_Compat::crypto_shorthash() |
555 | 555 | * @param string $message |
@@ -558,12 +558,12 @@ discard block |
||
558 | 558 | * @throws \SodiumException |
559 | 559 | * @throws \TypeError |
560 | 560 | */ |
561 | - function crypto_shorthash($message, $key = '') |
|
561 | + function crypto_shorthash( $message, $key = '' ) |
|
562 | 562 | { |
563 | - return ParagonIE_Sodium_Compat::crypto_shorthash($message, $key); |
|
563 | + return ParagonIE_Sodium_Compat::crypto_shorthash( $message, $key ); |
|
564 | 564 | } |
565 | 565 | } |
566 | -if (!is_callable('\\Sodium\\crypto_sign')) { |
|
566 | +if ( ! is_callable( '\\Sodium\\crypto_sign' ) ) { |
|
567 | 567 | /** |
568 | 568 | * @see ParagonIE_Sodium_Compat::crypto_sign() |
569 | 569 | * @param string $message |
@@ -572,12 +572,12 @@ discard block |
||
572 | 572 | * @throws \SodiumException |
573 | 573 | * @throws \TypeError |
574 | 574 | */ |
575 | - function crypto_sign($message, $sk) |
|
575 | + function crypto_sign( $message, $sk ) |
|
576 | 576 | { |
577 | - return ParagonIE_Sodium_Compat::crypto_sign($message, $sk); |
|
577 | + return ParagonIE_Sodium_Compat::crypto_sign( $message, $sk ); |
|
578 | 578 | } |
579 | 579 | } |
580 | -if (!is_callable('\\Sodium\\crypto_sign_detached')) { |
|
580 | +if ( ! is_callable( '\\Sodium\\crypto_sign_detached' ) ) { |
|
581 | 581 | /** |
582 | 582 | * @see ParagonIE_Sodium_Compat::crypto_sign_detached() |
583 | 583 | * @param string $message |
@@ -586,12 +586,12 @@ discard block |
||
586 | 586 | * @throws \SodiumException |
587 | 587 | * @throws \TypeError |
588 | 588 | */ |
589 | - function crypto_sign_detached($message, $sk) |
|
589 | + function crypto_sign_detached( $message, $sk ) |
|
590 | 590 | { |
591 | - return ParagonIE_Sodium_Compat::crypto_sign_detached($message, $sk); |
|
591 | + return ParagonIE_Sodium_Compat::crypto_sign_detached( $message, $sk ); |
|
592 | 592 | } |
593 | 593 | } |
594 | -if (!is_callable('\\Sodium\\crypto_sign_keypair')) { |
|
594 | +if ( ! is_callable( '\\Sodium\\crypto_sign_keypair' ) ) { |
|
595 | 595 | /** |
596 | 596 | * @see ParagonIE_Sodium_Compat::crypto_sign_keypair() |
597 | 597 | * @return string |
@@ -603,25 +603,25 @@ discard block |
||
603 | 603 | return ParagonIE_Sodium_Compat::crypto_sign_keypair(); |
604 | 604 | } |
605 | 605 | } |
606 | -if (!is_callable('\\Sodium\\crypto_sign_open')) { |
|
606 | +if ( ! is_callable( '\\Sodium\\crypto_sign_open' ) ) { |
|
607 | 607 | /** |
608 | 608 | * @see ParagonIE_Sodium_Compat::crypto_sign_open() |
609 | 609 | * @param string $signedMessage |
610 | 610 | * @param string $pk |
611 | 611 | * @return string|bool |
612 | 612 | */ |
613 | - function crypto_sign_open($signedMessage, $pk) |
|
613 | + function crypto_sign_open( $signedMessage, $pk ) |
|
614 | 614 | { |
615 | 615 | try { |
616 | - return ParagonIE_Sodium_Compat::crypto_sign_open($signedMessage, $pk); |
|
617 | - } catch (\TypeError $ex) { |
|
616 | + return ParagonIE_Sodium_Compat::crypto_sign_open( $signedMessage, $pk ); |
|
617 | + } catch ( \TypeError $ex ) { |
|
618 | 618 | return false; |
619 | - } catch (\SodiumException $ex) { |
|
619 | + } catch ( \SodiumException $ex ) { |
|
620 | 620 | return false; |
621 | 621 | } |
622 | 622 | } |
623 | 623 | } |
624 | -if (!is_callable('\\Sodium\\crypto_sign_publickey')) { |
|
624 | +if ( ! is_callable( '\\Sodium\\crypto_sign_publickey' ) ) { |
|
625 | 625 | /** |
626 | 626 | * @see ParagonIE_Sodium_Compat::crypto_sign_publickey() |
627 | 627 | * @param string $keypair |
@@ -629,12 +629,12 @@ discard block |
||
629 | 629 | * @throws \SodiumException |
630 | 630 | * @throws \TypeError |
631 | 631 | */ |
632 | - function crypto_sign_publickey($keypair) |
|
632 | + function crypto_sign_publickey( $keypair ) |
|
633 | 633 | { |
634 | - return ParagonIE_Sodium_Compat::crypto_sign_publickey($keypair); |
|
634 | + return ParagonIE_Sodium_Compat::crypto_sign_publickey( $keypair ); |
|
635 | 635 | } |
636 | 636 | } |
637 | -if (!is_callable('\\Sodium\\crypto_sign_publickey_from_secretkey')) { |
|
637 | +if ( ! is_callable( '\\Sodium\\crypto_sign_publickey_from_secretkey' ) ) { |
|
638 | 638 | /** |
639 | 639 | * @see ParagonIE_Sodium_Compat::crypto_sign_publickey_from_secretkey() |
640 | 640 | * @param string $sk |
@@ -642,12 +642,12 @@ discard block |
||
642 | 642 | * @throws \SodiumException |
643 | 643 | * @throws \TypeError |
644 | 644 | */ |
645 | - function crypto_sign_publickey_from_secretkey($sk) |
|
645 | + function crypto_sign_publickey_from_secretkey( $sk ) |
|
646 | 646 | { |
647 | - return ParagonIE_Sodium_Compat::crypto_sign_publickey_from_secretkey($sk); |
|
647 | + return ParagonIE_Sodium_Compat::crypto_sign_publickey_from_secretkey( $sk ); |
|
648 | 648 | } |
649 | 649 | } |
650 | -if (!is_callable('\\Sodium\\crypto_sign_secretkey')) { |
|
650 | +if ( ! is_callable( '\\Sodium\\crypto_sign_secretkey' ) ) { |
|
651 | 651 | /** |
652 | 652 | * @see ParagonIE_Sodium_Compat::crypto_sign_secretkey() |
653 | 653 | * @param string $keypair |
@@ -655,12 +655,12 @@ discard block |
||
655 | 655 | * @throws \SodiumException |
656 | 656 | * @throws \TypeError |
657 | 657 | */ |
658 | - function crypto_sign_secretkey($keypair) |
|
658 | + function crypto_sign_secretkey( $keypair ) |
|
659 | 659 | { |
660 | - return ParagonIE_Sodium_Compat::crypto_sign_secretkey($keypair); |
|
660 | + return ParagonIE_Sodium_Compat::crypto_sign_secretkey( $keypair ); |
|
661 | 661 | } |
662 | 662 | } |
663 | -if (!is_callable('\\Sodium\\crypto_sign_seed_keypair')) { |
|
663 | +if ( ! is_callable( '\\Sodium\\crypto_sign_seed_keypair' ) ) { |
|
664 | 664 | /** |
665 | 665 | * @see ParagonIE_Sodium_Compat::crypto_sign_seed_keypair() |
666 | 666 | * @param string $seed |
@@ -668,12 +668,12 @@ discard block |
||
668 | 668 | * @throws \SodiumException |
669 | 669 | * @throws \TypeError |
670 | 670 | */ |
671 | - function crypto_sign_seed_keypair($seed) |
|
671 | + function crypto_sign_seed_keypair( $seed ) |
|
672 | 672 | { |
673 | - return ParagonIE_Sodium_Compat::crypto_sign_seed_keypair($seed); |
|
673 | + return ParagonIE_Sodium_Compat::crypto_sign_seed_keypair( $seed ); |
|
674 | 674 | } |
675 | 675 | } |
676 | -if (!is_callable('\\Sodium\\crypto_sign_verify_detached')) { |
|
676 | +if ( ! is_callable( '\\Sodium\\crypto_sign_verify_detached' ) ) { |
|
677 | 677 | /** |
678 | 678 | * @see ParagonIE_Sodium_Compat::crypto_sign_verify_detached() |
679 | 679 | * @param string $signature |
@@ -683,12 +683,12 @@ discard block |
||
683 | 683 | * @throws \SodiumException |
684 | 684 | * @throws \TypeError |
685 | 685 | */ |
686 | - function crypto_sign_verify_detached($signature, $message, $pk) |
|
686 | + function crypto_sign_verify_detached( $signature, $message, $pk ) |
|
687 | 687 | { |
688 | - return ParagonIE_Sodium_Compat::crypto_sign_verify_detached($signature, $message, $pk); |
|
688 | + return ParagonIE_Sodium_Compat::crypto_sign_verify_detached( $signature, $message, $pk ); |
|
689 | 689 | } |
690 | 690 | } |
691 | -if (!is_callable('\\Sodium\\crypto_sign_ed25519_pk_to_curve25519')) { |
|
691 | +if ( ! is_callable( '\\Sodium\\crypto_sign_ed25519_pk_to_curve25519' ) ) { |
|
692 | 692 | /** |
693 | 693 | * @see ParagonIE_Sodium_Compat::crypto_sign_ed25519_pk_to_curve25519() |
694 | 694 | * @param string $pk |
@@ -696,12 +696,12 @@ discard block |
||
696 | 696 | * @throws \SodiumException |
697 | 697 | * @throws \TypeError |
698 | 698 | */ |
699 | - function crypto_sign_ed25519_pk_to_curve25519($pk) |
|
699 | + function crypto_sign_ed25519_pk_to_curve25519( $pk ) |
|
700 | 700 | { |
701 | - return ParagonIE_Sodium_Compat::crypto_sign_ed25519_pk_to_curve25519($pk); |
|
701 | + return ParagonIE_Sodium_Compat::crypto_sign_ed25519_pk_to_curve25519( $pk ); |
|
702 | 702 | } |
703 | 703 | } |
704 | -if (!is_callable('\\Sodium\\crypto_sign_ed25519_sk_to_curve25519')) { |
|
704 | +if ( ! is_callable( '\\Sodium\\crypto_sign_ed25519_sk_to_curve25519' ) ) { |
|
705 | 705 | /** |
706 | 706 | * @see ParagonIE_Sodium_Compat::crypto_sign_ed25519_sk_to_curve25519() |
707 | 707 | * @param string $sk |
@@ -709,12 +709,12 @@ discard block |
||
709 | 709 | * @throws \SodiumException |
710 | 710 | * @throws \TypeError |
711 | 711 | */ |
712 | - function crypto_sign_ed25519_sk_to_curve25519($sk) |
|
712 | + function crypto_sign_ed25519_sk_to_curve25519( $sk ) |
|
713 | 713 | { |
714 | - return ParagonIE_Sodium_Compat::crypto_sign_ed25519_sk_to_curve25519($sk); |
|
714 | + return ParagonIE_Sodium_Compat::crypto_sign_ed25519_sk_to_curve25519( $sk ); |
|
715 | 715 | } |
716 | 716 | } |
717 | -if (!is_callable('\\Sodium\\crypto_stream')) { |
|
717 | +if ( ! is_callable( '\\Sodium\\crypto_stream' ) ) { |
|
718 | 718 | /** |
719 | 719 | * @see ParagonIE_Sodium_Compat::crypto_stream() |
720 | 720 | * @param int $len |
@@ -724,12 +724,12 @@ discard block |
||
724 | 724 | * @throws \SodiumException |
725 | 725 | * @throws \TypeError |
726 | 726 | */ |
727 | - function crypto_stream($len, $nonce, $key) |
|
727 | + function crypto_stream( $len, $nonce, $key ) |
|
728 | 728 | { |
729 | - return ParagonIE_Sodium_Compat::crypto_stream($len, $nonce, $key); |
|
729 | + return ParagonIE_Sodium_Compat::crypto_stream( $len, $nonce, $key ); |
|
730 | 730 | } |
731 | 731 | } |
732 | -if (!is_callable('\\Sodium\\crypto_stream_xor')) { |
|
732 | +if ( ! is_callable( '\\Sodium\\crypto_stream_xor' ) ) { |
|
733 | 733 | /** |
734 | 734 | * @see ParagonIE_Sodium_Compat::crypto_stream_xor() |
735 | 735 | * @param string $message |
@@ -739,12 +739,12 @@ discard block |
||
739 | 739 | * @throws \SodiumException |
740 | 740 | * @throws \TypeError |
741 | 741 | */ |
742 | - function crypto_stream_xor($message, $nonce, $key) |
|
742 | + function crypto_stream_xor( $message, $nonce, $key ) |
|
743 | 743 | { |
744 | - return ParagonIE_Sodium_Compat::crypto_stream_xor($message, $nonce, $key); |
|
744 | + return ParagonIE_Sodium_Compat::crypto_stream_xor( $message, $nonce, $key ); |
|
745 | 745 | } |
746 | 746 | } |
747 | -if (!is_callable('\\Sodium\\hex2bin')) { |
|
747 | +if ( ! is_callable( '\\Sodium\\hex2bin' ) ) { |
|
748 | 748 | /** |
749 | 749 | * @see ParagonIE_Sodium_Compat::hex2bin() |
750 | 750 | * @param string $string |
@@ -752,12 +752,12 @@ discard block |
||
752 | 752 | * @throws \SodiumException |
753 | 753 | * @throws \TypeError |
754 | 754 | */ |
755 | - function hex2bin($string) |
|
755 | + function hex2bin( $string ) |
|
756 | 756 | { |
757 | - return ParagonIE_Sodium_Compat::hex2bin($string); |
|
757 | + return ParagonIE_Sodium_Compat::hex2bin( $string ); |
|
758 | 758 | } |
759 | 759 | } |
760 | -if (!is_callable('\\Sodium\\memcmp')) { |
|
760 | +if ( ! is_callable( '\\Sodium\\memcmp' ) ) { |
|
761 | 761 | /** |
762 | 762 | * @see ParagonIE_Sodium_Compat::memcmp() |
763 | 763 | * @param string $a |
@@ -766,12 +766,12 @@ discard block |
||
766 | 766 | * @throws \SodiumException |
767 | 767 | * @throws \TypeError |
768 | 768 | */ |
769 | - function memcmp($a, $b) |
|
769 | + function memcmp( $a, $b ) |
|
770 | 770 | { |
771 | - return ParagonIE_Sodium_Compat::memcmp($a, $b); |
|
771 | + return ParagonIE_Sodium_Compat::memcmp( $a, $b ); |
|
772 | 772 | } |
773 | 773 | } |
774 | -if (!is_callable('\\Sodium\\memzero')) { |
|
774 | +if ( ! is_callable( '\\Sodium\\memzero' ) ) { |
|
775 | 775 | /** |
776 | 776 | * @see ParagonIE_Sodium_Compat::memzero() |
777 | 777 | * @param string $str |
@@ -779,25 +779,25 @@ discard block |
||
779 | 779 | * @throws \SodiumException |
780 | 780 | * @throws \TypeError |
781 | 781 | */ |
782 | - function memzero(&$str) |
|
782 | + function memzero( &$str ) |
|
783 | 783 | { |
784 | - ParagonIE_Sodium_Compat::memzero($str); |
|
784 | + ParagonIE_Sodium_Compat::memzero( $str ); |
|
785 | 785 | } |
786 | 786 | } |
787 | -if (!is_callable('\\Sodium\\randombytes_buf')) { |
|
787 | +if ( ! is_callable( '\\Sodium\\randombytes_buf' ) ) { |
|
788 | 788 | /** |
789 | 789 | * @see ParagonIE_Sodium_Compat::randombytes_buf() |
790 | 790 | * @param int $amount |
791 | 791 | * @return string |
792 | 792 | * @throws \TypeError |
793 | 793 | */ |
794 | - function randombytes_buf($amount) |
|
794 | + function randombytes_buf( $amount ) |
|
795 | 795 | { |
796 | - return ParagonIE_Sodium_Compat::randombytes_buf($amount); |
|
796 | + return ParagonIE_Sodium_Compat::randombytes_buf( $amount ); |
|
797 | 797 | } |
798 | 798 | } |
799 | 799 | |
800 | -if (!is_callable('\\Sodium\\randombytes_uniform')) { |
|
800 | +if ( ! is_callable( '\\Sodium\\randombytes_uniform' ) ) { |
|
801 | 801 | /** |
802 | 802 | * @see ParagonIE_Sodium_Compat::randombytes_uniform() |
803 | 803 | * @param int $upperLimit |
@@ -805,13 +805,13 @@ discard block |
||
805 | 805 | * @throws \SodiumException |
806 | 806 | * @throws \Error |
807 | 807 | */ |
808 | - function randombytes_uniform($upperLimit) |
|
808 | + function randombytes_uniform( $upperLimit ) |
|
809 | 809 | { |
810 | - return ParagonIE_Sodium_Compat::randombytes_uniform($upperLimit); |
|
810 | + return ParagonIE_Sodium_Compat::randombytes_uniform( $upperLimit ); |
|
811 | 811 | } |
812 | 812 | } |
813 | 813 | |
814 | -if (!is_callable('\\Sodium\\randombytes_random16')) { |
|
814 | +if ( ! is_callable( '\\Sodium\\randombytes_random16' ) ) { |
|
815 | 815 | /** |
816 | 816 | * @see ParagonIE_Sodium_Compat::randombytes_random16() |
817 | 817 | * @return int |
@@ -822,6 +822,6 @@ discard block |
||
822 | 822 | } |
823 | 823 | } |
824 | 824 | |
825 | -if (!defined('\\Sodium\\CRYPTO_AUTH_BYTES')) { |
|
826 | - require_once dirname(__FILE__) . '/constants.php'; |
|
825 | +if ( ! defined( '\\Sodium\\CRYPTO_AUTH_BYTES' ) ) { |
|
826 | + require_once dirname( __FILE__ ) . '/constants.php'; |
|
827 | 827 | } |
@@ -20,8 +20,7 @@ discard block |
||
20 | 20 | * @throws \SodiumException |
21 | 21 | * @throws \TypeError |
22 | 22 | */ |
23 | - function bin2hex($string) |
|
24 | - { |
|
23 | + function bin2hex($string) { |
|
25 | 24 | return ParagonIE_Sodium_Compat::bin2hex($string); |
26 | 25 | } |
27 | 26 | } |
@@ -34,8 +33,7 @@ discard block |
||
34 | 33 | * @throws \SodiumException |
35 | 34 | * @throws \TypeError |
36 | 35 | */ |
37 | - function compare($a, $b) |
|
38 | - { |
|
36 | + function compare($a, $b) { |
|
39 | 37 | return ParagonIE_Sodium_Compat::compare($a, $b); |
40 | 38 | } |
41 | 39 | } |
@@ -48,8 +46,7 @@ discard block |
||
48 | 46 | * @param string $key |
49 | 47 | * @return string|bool |
50 | 48 | */ |
51 | - function crypto_aead_aes256gcm_decrypt($message, $assocData, $nonce, $key) |
|
52 | - { |
|
49 | + function crypto_aead_aes256gcm_decrypt($message, $assocData, $nonce, $key) { |
|
53 | 50 | try { |
54 | 51 | return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_decrypt($message, $assocData, $nonce, $key); |
55 | 52 | } catch (\TypeError $ex) { |
@@ -70,8 +67,7 @@ discard block |
||
70 | 67 | * @throws \SodiumException |
71 | 68 | * @throws \TypeError |
72 | 69 | */ |
73 | - function crypto_aead_aes256gcm_encrypt($message, $assocData, $nonce, $key) |
|
74 | - { |
|
70 | + function crypto_aead_aes256gcm_encrypt($message, $assocData, $nonce, $key) { |
|
75 | 71 | return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_encrypt($message, $assocData, $nonce, $key); |
76 | 72 | } |
77 | 73 | } |
@@ -80,8 +76,7 @@ discard block |
||
80 | 76 | * @see ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_is_available() |
81 | 77 | * @return bool |
82 | 78 | */ |
83 | - function crypto_aead_aes256gcm_is_available() |
|
84 | - { |
|
79 | + function crypto_aead_aes256gcm_is_available() { |
|
85 | 80 | return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_is_available(); |
86 | 81 | } |
87 | 82 | } |
@@ -94,8 +89,7 @@ discard block |
||
94 | 89 | * @param string $key |
95 | 90 | * @return string|bool |
96 | 91 | */ |
97 | - function crypto_aead_chacha20poly1305_decrypt($message, $assocData, $nonce, $key) |
|
98 | - { |
|
92 | + function crypto_aead_chacha20poly1305_decrypt($message, $assocData, $nonce, $key) { |
|
99 | 93 | try { |
100 | 94 | return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_decrypt($message, $assocData, $nonce, $key); |
101 | 95 | } catch (\TypeError $ex) { |
@@ -116,8 +110,7 @@ discard block |
||
116 | 110 | * @throws \SodiumException |
117 | 111 | * @throws \TypeError |
118 | 112 | */ |
119 | - function crypto_aead_chacha20poly1305_encrypt($message, $assocData, $nonce, $key) |
|
120 | - { |
|
113 | + function crypto_aead_chacha20poly1305_encrypt($message, $assocData, $nonce, $key) { |
|
121 | 114 | return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_encrypt($message, $assocData, $nonce, $key); |
122 | 115 | } |
123 | 116 | } |
@@ -130,8 +123,7 @@ discard block |
||
130 | 123 | * @param string $key |
131 | 124 | * @return string|bool |
132 | 125 | */ |
133 | - function crypto_aead_chacha20poly1305_ietf_decrypt($message, $assocData, $nonce, $key) |
|
134 | - { |
|
126 | + function crypto_aead_chacha20poly1305_ietf_decrypt($message, $assocData, $nonce, $key) { |
|
135 | 127 | try { |
136 | 128 | return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_decrypt($message, $assocData, $nonce, $key); |
137 | 129 | } catch (\TypeError $ex) { |
@@ -152,8 +144,7 @@ discard block |
||
152 | 144 | * @throws \SodiumException |
153 | 145 | * @throws \TypeError |
154 | 146 | */ |
155 | - function crypto_aead_chacha20poly1305_ietf_encrypt($message, $assocData, $nonce, $key) |
|
156 | - { |
|
147 | + function crypto_aead_chacha20poly1305_ietf_encrypt($message, $assocData, $nonce, $key) { |
|
157 | 148 | return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_encrypt($message, $assocData, $nonce, $key); |
158 | 149 | } |
159 | 150 | } |
@@ -166,8 +157,7 @@ discard block |
||
166 | 157 | * @throws \SodiumException |
167 | 158 | * @throws \TypeError |
168 | 159 | */ |
169 | - function crypto_auth($message, $key) |
|
170 | - { |
|
160 | + function crypto_auth($message, $key) { |
|
171 | 161 | return ParagonIE_Sodium_Compat::crypto_auth($message, $key); |
172 | 162 | } |
173 | 163 | } |
@@ -181,8 +171,7 @@ discard block |
||
181 | 171 | * @throws \SodiumException |
182 | 172 | * @throws \TypeError |
183 | 173 | */ |
184 | - function crypto_auth_verify($mac, $message, $key) |
|
185 | - { |
|
174 | + function crypto_auth_verify($mac, $message, $key) { |
|
186 | 175 | return ParagonIE_Sodium_Compat::crypto_auth_verify($mac, $message, $key); |
187 | 176 | } |
188 | 177 | } |
@@ -196,8 +185,7 @@ discard block |
||
196 | 185 | * @throws \SodiumException |
197 | 186 | * @throws \TypeError |
198 | 187 | */ |
199 | - function crypto_box($message, $nonce, $kp) |
|
200 | - { |
|
188 | + function crypto_box($message, $nonce, $kp) { |
|
201 | 189 | return ParagonIE_Sodium_Compat::crypto_box($message, $nonce, $kp); |
202 | 190 | } |
203 | 191 | } |
@@ -208,8 +196,7 @@ discard block |
||
208 | 196 | * @throws \SodiumException |
209 | 197 | * @throws \TypeError |
210 | 198 | */ |
211 | - function crypto_box_keypair() |
|
212 | - { |
|
199 | + function crypto_box_keypair() { |
|
213 | 200 | return ParagonIE_Sodium_Compat::crypto_box_keypair(); |
214 | 201 | } |
215 | 202 | } |
@@ -222,8 +209,7 @@ discard block |
||
222 | 209 | * @throws \SodiumException |
223 | 210 | * @throws \TypeError |
224 | 211 | */ |
225 | - function crypto_box_keypair_from_secretkey_and_publickey($sk, $pk) |
|
226 | - { |
|
212 | + function crypto_box_keypair_from_secretkey_and_publickey($sk, $pk) { |
|
227 | 213 | return ParagonIE_Sodium_Compat::crypto_box_keypair_from_secretkey_and_publickey($sk, $pk); |
228 | 214 | } |
229 | 215 | } |
@@ -235,8 +221,7 @@ discard block |
||
235 | 221 | * @param string $kp |
236 | 222 | * @return string|bool |
237 | 223 | */ |
238 | - function crypto_box_open($message, $nonce, $kp) |
|
239 | - { |
|
224 | + function crypto_box_open($message, $nonce, $kp) { |
|
240 | 225 | try { |
241 | 226 | return ParagonIE_Sodium_Compat::crypto_box_open($message, $nonce, $kp); |
242 | 227 | } catch (\TypeError $ex) { |
@@ -254,8 +239,7 @@ discard block |
||
254 | 239 | * @throws \SodiumException |
255 | 240 | * @throws \TypeError |
256 | 241 | */ |
257 | - function crypto_box_publickey($keypair) |
|
258 | - { |
|
242 | + function crypto_box_publickey($keypair) { |
|
259 | 243 | return ParagonIE_Sodium_Compat::crypto_box_publickey($keypair); |
260 | 244 | } |
261 | 245 | } |
@@ -267,8 +251,7 @@ discard block |
||
267 | 251 | * @throws \SodiumException |
268 | 252 | * @throws \TypeError |
269 | 253 | */ |
270 | - function crypto_box_publickey_from_secretkey($sk) |
|
271 | - { |
|
254 | + function crypto_box_publickey_from_secretkey($sk) { |
|
272 | 255 | return ParagonIE_Sodium_Compat::crypto_box_publickey_from_secretkey($sk); |
273 | 256 | } |
274 | 257 | } |
@@ -281,8 +264,7 @@ discard block |
||
281 | 264 | * @throws \SodiumException |
282 | 265 | * @throws \TypeError |
283 | 266 | */ |
284 | - function crypto_box_seal($message, $publicKey) |
|
285 | - { |
|
267 | + function crypto_box_seal($message, $publicKey) { |
|
286 | 268 | return ParagonIE_Sodium_Compat::crypto_box_seal($message, $publicKey); |
287 | 269 | } |
288 | 270 | } |
@@ -293,8 +275,7 @@ discard block |
||
293 | 275 | * @param string $kp |
294 | 276 | * @return string|bool |
295 | 277 | */ |
296 | - function crypto_box_seal_open($message, $kp) |
|
297 | - { |
|
278 | + function crypto_box_seal_open($message, $kp) { |
|
298 | 279 | try { |
299 | 280 | return ParagonIE_Sodium_Compat::crypto_box_seal_open($message, $kp); |
300 | 281 | } catch (\TypeError $ex) { |
@@ -312,8 +293,7 @@ discard block |
||
312 | 293 | * @throws \SodiumException |
313 | 294 | * @throws \TypeError |
314 | 295 | */ |
315 | - function crypto_box_secretkey($keypair) |
|
316 | - { |
|
296 | + function crypto_box_secretkey($keypair) { |
|
317 | 297 | return ParagonIE_Sodium_Compat::crypto_box_secretkey($keypair); |
318 | 298 | } |
319 | 299 | } |
@@ -327,8 +307,7 @@ discard block |
||
327 | 307 | * @throws \SodiumException |
328 | 308 | * @throws \TypeError |
329 | 309 | */ |
330 | - function crypto_generichash($message, $key = null, $outLen = 32) |
|
331 | - { |
|
310 | + function crypto_generichash($message, $key = null, $outLen = 32) { |
|
332 | 311 | return ParagonIE_Sodium_Compat::crypto_generichash($message, $key, $outLen); |
333 | 312 | } |
334 | 313 | } |
@@ -341,8 +320,7 @@ discard block |
||
341 | 320 | * @throws \SodiumException |
342 | 321 | * @throws \TypeError |
343 | 322 | */ |
344 | - function crypto_generichash_final(&$ctx, $outputLength = 32) |
|
345 | - { |
|
323 | + function crypto_generichash_final(&$ctx, $outputLength = 32) { |
|
346 | 324 | return ParagonIE_Sodium_Compat::crypto_generichash_final($ctx, $outputLength); |
347 | 325 | } |
348 | 326 | } |
@@ -355,8 +333,7 @@ discard block |
||
355 | 333 | * @throws \SodiumException |
356 | 334 | * @throws \TypeError |
357 | 335 | */ |
358 | - function crypto_generichash_init($key = null, $outLen = 32) |
|
359 | - { |
|
336 | + function crypto_generichash_init($key = null, $outLen = 32) { |
|
360 | 337 | return ParagonIE_Sodium_Compat::crypto_generichash_init($key, $outLen); |
361 | 338 | } |
362 | 339 | } |
@@ -369,8 +346,7 @@ discard block |
||
369 | 346 | * @throws \SodiumException |
370 | 347 | * @throws \TypeError |
371 | 348 | */ |
372 | - function crypto_generichash_update(&$ctx, $message = '') |
|
373 | - { |
|
349 | + function crypto_generichash_update(&$ctx, $message = '') { |
|
374 | 350 | ParagonIE_Sodium_Compat::crypto_generichash_update($ctx, $message); |
375 | 351 | } |
376 | 352 | } |
@@ -385,8 +361,7 @@ discard block |
||
385 | 361 | * @throws \SodiumException |
386 | 362 | * @throws \TypeError |
387 | 363 | */ |
388 | - function crypto_kx($my_secret, $their_public, $client_public, $server_public) |
|
389 | - { |
|
364 | + function crypto_kx($my_secret, $their_public, $client_public, $server_public) { |
|
390 | 365 | return ParagonIE_Sodium_Compat::crypto_kx( |
391 | 366 | $my_secret, |
392 | 367 | $their_public, |
@@ -408,8 +383,7 @@ discard block |
||
408 | 383 | * @throws \SodiumException |
409 | 384 | * @throws \TypeError |
410 | 385 | */ |
411 | - function crypto_pwhash($outlen, $passwd, $salt, $opslimit, $memlimit) |
|
412 | - { |
|
386 | + function crypto_pwhash($outlen, $passwd, $salt, $opslimit, $memlimit) { |
|
413 | 387 | return ParagonIE_Sodium_Compat::crypto_pwhash($outlen, $passwd, $salt, $opslimit, $memlimit); |
414 | 388 | } |
415 | 389 | } |
@@ -423,8 +397,7 @@ discard block |
||
423 | 397 | * @throws \SodiumException |
424 | 398 | * @throws \TypeError |
425 | 399 | */ |
426 | - function crypto_pwhash_str($passwd, $opslimit, $memlimit) |
|
427 | - { |
|
400 | + function crypto_pwhash_str($passwd, $opslimit, $memlimit) { |
|
428 | 401 | return ParagonIE_Sodium_Compat::crypto_pwhash_str($passwd, $opslimit, $memlimit); |
429 | 402 | } |
430 | 403 | } |
@@ -437,8 +410,7 @@ discard block |
||
437 | 410 | * @throws \SodiumException |
438 | 411 | * @throws \TypeError |
439 | 412 | */ |
440 | - function crypto_pwhash_str_verify($passwd, $hash) |
|
441 | - { |
|
413 | + function crypto_pwhash_str_verify($passwd, $hash) { |
|
442 | 414 | return ParagonIE_Sodium_Compat::crypto_pwhash_str_verify($passwd, $hash); |
443 | 415 | } |
444 | 416 | } |
@@ -454,8 +426,7 @@ discard block |
||
454 | 426 | * @throws \SodiumException |
455 | 427 | * @throws \TypeError |
456 | 428 | */ |
457 | - function crypto_pwhash_scryptsalsa208sha256($outlen, $passwd, $salt, $opslimit, $memlimit) |
|
458 | - { |
|
429 | + function crypto_pwhash_scryptsalsa208sha256($outlen, $passwd, $salt, $opslimit, $memlimit) { |
|
459 | 430 | return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256($outlen, $passwd, $salt, $opslimit, $memlimit); |
460 | 431 | } |
461 | 432 | } |
@@ -469,8 +440,7 @@ discard block |
||
469 | 440 | * @throws \SodiumException |
470 | 441 | * @throws \TypeError |
471 | 442 | */ |
472 | - function crypto_pwhash_scryptsalsa208sha256_str($passwd, $opslimit, $memlimit) |
|
473 | - { |
|
443 | + function crypto_pwhash_scryptsalsa208sha256_str($passwd, $opslimit, $memlimit) { |
|
474 | 444 | return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str($passwd, $opslimit, $memlimit); |
475 | 445 | } |
476 | 446 | } |
@@ -483,8 +453,7 @@ discard block |
||
483 | 453 | * @throws \SodiumException |
484 | 454 | * @throws \TypeError |
485 | 455 | */ |
486 | - function crypto_pwhash_scryptsalsa208sha256_str_verify($passwd, $hash) |
|
487 | - { |
|
456 | + function crypto_pwhash_scryptsalsa208sha256_str_verify($passwd, $hash) { |
|
488 | 457 | return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str_verify($passwd, $hash); |
489 | 458 | } |
490 | 459 | } |
@@ -497,8 +466,7 @@ discard block |
||
497 | 466 | * @throws \SodiumException |
498 | 467 | * @throws \TypeError |
499 | 468 | */ |
500 | - function crypto_scalarmult($n, $p) |
|
501 | - { |
|
469 | + function crypto_scalarmult($n, $p) { |
|
502 | 470 | return ParagonIE_Sodium_Compat::crypto_scalarmult($n, $p); |
503 | 471 | } |
504 | 472 | } |
@@ -510,8 +478,7 @@ discard block |
||
510 | 478 | * @throws \SodiumException |
511 | 479 | * @throws \TypeError |
512 | 480 | */ |
513 | - function crypto_scalarmult_base($n) |
|
514 | - { |
|
481 | + function crypto_scalarmult_base($n) { |
|
515 | 482 | return ParagonIE_Sodium_Compat::crypto_scalarmult_base($n); |
516 | 483 | } |
517 | 484 | } |
@@ -525,8 +492,7 @@ discard block |
||
525 | 492 | * @throws \SodiumException |
526 | 493 | * @throws \TypeError |
527 | 494 | */ |
528 | - function crypto_secretbox($message, $nonce, $key) |
|
529 | - { |
|
495 | + function crypto_secretbox($message, $nonce, $key) { |
|
530 | 496 | return ParagonIE_Sodium_Compat::crypto_secretbox($message, $nonce, $key); |
531 | 497 | } |
532 | 498 | } |
@@ -538,8 +504,7 @@ discard block |
||
538 | 504 | * @param string $key |
539 | 505 | * @return string|bool |
540 | 506 | */ |
541 | - function crypto_secretbox_open($message, $nonce, $key) |
|
542 | - { |
|
507 | + function crypto_secretbox_open($message, $nonce, $key) { |
|
543 | 508 | try { |
544 | 509 | return ParagonIE_Sodium_Compat::crypto_secretbox_open($message, $nonce, $key); |
545 | 510 | } catch (\TypeError $ex) { |
@@ -558,8 +523,7 @@ discard block |
||
558 | 523 | * @throws \SodiumException |
559 | 524 | * @throws \TypeError |
560 | 525 | */ |
561 | - function crypto_shorthash($message, $key = '') |
|
562 | - { |
|
526 | + function crypto_shorthash($message, $key = '') { |
|
563 | 527 | return ParagonIE_Sodium_Compat::crypto_shorthash($message, $key); |
564 | 528 | } |
565 | 529 | } |
@@ -572,8 +536,7 @@ discard block |
||
572 | 536 | * @throws \SodiumException |
573 | 537 | * @throws \TypeError |
574 | 538 | */ |
575 | - function crypto_sign($message, $sk) |
|
576 | - { |
|
539 | + function crypto_sign($message, $sk) { |
|
577 | 540 | return ParagonIE_Sodium_Compat::crypto_sign($message, $sk); |
578 | 541 | } |
579 | 542 | } |
@@ -586,8 +549,7 @@ discard block |
||
586 | 549 | * @throws \SodiumException |
587 | 550 | * @throws \TypeError |
588 | 551 | */ |
589 | - function crypto_sign_detached($message, $sk) |
|
590 | - { |
|
552 | + function crypto_sign_detached($message, $sk) { |
|
591 | 553 | return ParagonIE_Sodium_Compat::crypto_sign_detached($message, $sk); |
592 | 554 | } |
593 | 555 | } |
@@ -598,8 +560,7 @@ discard block |
||
598 | 560 | * @throws \SodiumException |
599 | 561 | * @throws \TypeError |
600 | 562 | */ |
601 | - function crypto_sign_keypair() |
|
602 | - { |
|
563 | + function crypto_sign_keypair() { |
|
603 | 564 | return ParagonIE_Sodium_Compat::crypto_sign_keypair(); |
604 | 565 | } |
605 | 566 | } |
@@ -610,8 +571,7 @@ discard block |
||
610 | 571 | * @param string $pk |
611 | 572 | * @return string|bool |
612 | 573 | */ |
613 | - function crypto_sign_open($signedMessage, $pk) |
|
614 | - { |
|
574 | + function crypto_sign_open($signedMessage, $pk) { |
|
615 | 575 | try { |
616 | 576 | return ParagonIE_Sodium_Compat::crypto_sign_open($signedMessage, $pk); |
617 | 577 | } catch (\TypeError $ex) { |
@@ -629,8 +589,7 @@ discard block |
||
629 | 589 | * @throws \SodiumException |
630 | 590 | * @throws \TypeError |
631 | 591 | */ |
632 | - function crypto_sign_publickey($keypair) |
|
633 | - { |
|
592 | + function crypto_sign_publickey($keypair) { |
|
634 | 593 | return ParagonIE_Sodium_Compat::crypto_sign_publickey($keypair); |
635 | 594 | } |
636 | 595 | } |
@@ -642,8 +601,7 @@ discard block |
||
642 | 601 | * @throws \SodiumException |
643 | 602 | * @throws \TypeError |
644 | 603 | */ |
645 | - function crypto_sign_publickey_from_secretkey($sk) |
|
646 | - { |
|
604 | + function crypto_sign_publickey_from_secretkey($sk) { |
|
647 | 605 | return ParagonIE_Sodium_Compat::crypto_sign_publickey_from_secretkey($sk); |
648 | 606 | } |
649 | 607 | } |
@@ -655,8 +613,7 @@ discard block |
||
655 | 613 | * @throws \SodiumException |
656 | 614 | * @throws \TypeError |
657 | 615 | */ |
658 | - function crypto_sign_secretkey($keypair) |
|
659 | - { |
|
616 | + function crypto_sign_secretkey($keypair) { |
|
660 | 617 | return ParagonIE_Sodium_Compat::crypto_sign_secretkey($keypair); |
661 | 618 | } |
662 | 619 | } |
@@ -668,8 +625,7 @@ discard block |
||
668 | 625 | * @throws \SodiumException |
669 | 626 | * @throws \TypeError |
670 | 627 | */ |
671 | - function crypto_sign_seed_keypair($seed) |
|
672 | - { |
|
628 | + function crypto_sign_seed_keypair($seed) { |
|
673 | 629 | return ParagonIE_Sodium_Compat::crypto_sign_seed_keypair($seed); |
674 | 630 | } |
675 | 631 | } |
@@ -683,8 +639,7 @@ discard block |
||
683 | 639 | * @throws \SodiumException |
684 | 640 | * @throws \TypeError |
685 | 641 | */ |
686 | - function crypto_sign_verify_detached($signature, $message, $pk) |
|
687 | - { |
|
642 | + function crypto_sign_verify_detached($signature, $message, $pk) { |
|
688 | 643 | return ParagonIE_Sodium_Compat::crypto_sign_verify_detached($signature, $message, $pk); |
689 | 644 | } |
690 | 645 | } |
@@ -696,8 +651,7 @@ discard block |
||
696 | 651 | * @throws \SodiumException |
697 | 652 | * @throws \TypeError |
698 | 653 | */ |
699 | - function crypto_sign_ed25519_pk_to_curve25519($pk) |
|
700 | - { |
|
654 | + function crypto_sign_ed25519_pk_to_curve25519($pk) { |
|
701 | 655 | return ParagonIE_Sodium_Compat::crypto_sign_ed25519_pk_to_curve25519($pk); |
702 | 656 | } |
703 | 657 | } |
@@ -709,8 +663,7 @@ discard block |
||
709 | 663 | * @throws \SodiumException |
710 | 664 | * @throws \TypeError |
711 | 665 | */ |
712 | - function crypto_sign_ed25519_sk_to_curve25519($sk) |
|
713 | - { |
|
666 | + function crypto_sign_ed25519_sk_to_curve25519($sk) { |
|
714 | 667 | return ParagonIE_Sodium_Compat::crypto_sign_ed25519_sk_to_curve25519($sk); |
715 | 668 | } |
716 | 669 | } |
@@ -724,8 +677,7 @@ discard block |
||
724 | 677 | * @throws \SodiumException |
725 | 678 | * @throws \TypeError |
726 | 679 | */ |
727 | - function crypto_stream($len, $nonce, $key) |
|
728 | - { |
|
680 | + function crypto_stream($len, $nonce, $key) { |
|
729 | 681 | return ParagonIE_Sodium_Compat::crypto_stream($len, $nonce, $key); |
730 | 682 | } |
731 | 683 | } |
@@ -739,8 +691,7 @@ discard block |
||
739 | 691 | * @throws \SodiumException |
740 | 692 | * @throws \TypeError |
741 | 693 | */ |
742 | - function crypto_stream_xor($message, $nonce, $key) |
|
743 | - { |
|
694 | + function crypto_stream_xor($message, $nonce, $key) { |
|
744 | 695 | return ParagonIE_Sodium_Compat::crypto_stream_xor($message, $nonce, $key); |
745 | 696 | } |
746 | 697 | } |
@@ -752,8 +703,7 @@ discard block |
||
752 | 703 | * @throws \SodiumException |
753 | 704 | * @throws \TypeError |
754 | 705 | */ |
755 | - function hex2bin($string) |
|
756 | - { |
|
706 | + function hex2bin($string) { |
|
757 | 707 | return ParagonIE_Sodium_Compat::hex2bin($string); |
758 | 708 | } |
759 | 709 | } |
@@ -766,8 +716,7 @@ discard block |
||
766 | 716 | * @throws \SodiumException |
767 | 717 | * @throws \TypeError |
768 | 718 | */ |
769 | - function memcmp($a, $b) |
|
770 | - { |
|
719 | + function memcmp($a, $b) { |
|
771 | 720 | return ParagonIE_Sodium_Compat::memcmp($a, $b); |
772 | 721 | } |
773 | 722 | } |
@@ -779,8 +728,7 @@ discard block |
||
779 | 728 | * @throws \SodiumException |
780 | 729 | * @throws \TypeError |
781 | 730 | */ |
782 | - function memzero(&$str) |
|
783 | - { |
|
731 | + function memzero(&$str) { |
|
784 | 732 | ParagonIE_Sodium_Compat::memzero($str); |
785 | 733 | } |
786 | 734 | } |
@@ -791,8 +739,7 @@ discard block |
||
791 | 739 | * @return string |
792 | 740 | * @throws \TypeError |
793 | 741 | */ |
794 | - function randombytes_buf($amount) |
|
795 | - { |
|
742 | + function randombytes_buf($amount) { |
|
796 | 743 | return ParagonIE_Sodium_Compat::randombytes_buf($amount); |
797 | 744 | } |
798 | 745 | } |
@@ -805,8 +752,7 @@ discard block |
||
805 | 752 | * @throws \SodiumException |
806 | 753 | * @throws \Error |
807 | 754 | */ |
808 | - function randombytes_uniform($upperLimit) |
|
809 | - { |
|
755 | + function randombytes_uniform($upperLimit) { |
|
810 | 756 | return ParagonIE_Sodium_Compat::randombytes_uniform($upperLimit); |
811 | 757 | } |
812 | 758 | } |
@@ -816,8 +762,7 @@ discard block |
||
816 | 762 | * @see ParagonIE_Sodium_Compat::randombytes_random16() |
817 | 763 | * @return int |
818 | 764 | */ |
819 | - function randombytes_random16() |
|
820 | - { |
|
765 | + function randombytes_random16() { |
|
821 | 766 | return ParagonIE_Sodium_Compat::randombytes_random16(); |
822 | 767 | } |
823 | 768 | } |
@@ -1,239 +1,239 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | if (!defined('SODIUM_CRYPTO_CORE_RISTRETTO255_BYTES')) { |
4 | - define( |
|
5 | - 'SODIUM_CRYPTO_CORE_RISTRETTO255_BYTES', |
|
6 | - ParagonIE_Sodium_Compat::CRYPTO_CORE_RISTRETTO255_BYTES |
|
7 | - ); |
|
8 | - define('SODIUM_COMPAT_POLYFILLED_RISTRETTO255', true); |
|
4 | + define( |
|
5 | + 'SODIUM_CRYPTO_CORE_RISTRETTO255_BYTES', |
|
6 | + ParagonIE_Sodium_Compat::CRYPTO_CORE_RISTRETTO255_BYTES |
|
7 | + ); |
|
8 | + define('SODIUM_COMPAT_POLYFILLED_RISTRETTO255', true); |
|
9 | 9 | } |
10 | 10 | if (!defined('SODIUM_CRYPTO_CORE_RISTRETTO255_HASHBYTES')) { |
11 | - define( |
|
12 | - 'SODIUM_CRYPTO_CORE_RISTRETTO255_HASHBYTES', |
|
13 | - ParagonIE_Sodium_Compat::CRYPTO_CORE_RISTRETTO255_HASHBYTES |
|
14 | - ); |
|
11 | + define( |
|
12 | + 'SODIUM_CRYPTO_CORE_RISTRETTO255_HASHBYTES', |
|
13 | + ParagonIE_Sodium_Compat::CRYPTO_CORE_RISTRETTO255_HASHBYTES |
|
14 | + ); |
|
15 | 15 | } |
16 | 16 | if (!defined('SODIUM_CRYPTO_CORE_RISTRETTO255_SCALARBYTES')) { |
17 | - define( |
|
18 | - 'SODIUM_CRYPTO_CORE_RISTRETTO255_SCALARBYTES', |
|
19 | - ParagonIE_Sodium_Compat::CRYPTO_CORE_RISTRETTO255_SCALARBYTES |
|
20 | - ); |
|
17 | + define( |
|
18 | + 'SODIUM_CRYPTO_CORE_RISTRETTO255_SCALARBYTES', |
|
19 | + ParagonIE_Sodium_Compat::CRYPTO_CORE_RISTRETTO255_SCALARBYTES |
|
20 | + ); |
|
21 | 21 | } |
22 | 22 | if (!defined('SODIUM_CRYPTO_CORE_RISTRETTO255_NONREDUCEDSCALARBYTES')) { |
23 | - define( |
|
24 | - 'SODIUM_CRYPTO_CORE_RISTRETTO255_NONREDUCEDSCALARBYTES', |
|
25 | - ParagonIE_Sodium_Compat::CRYPTO_CORE_RISTRETTO255_NONREDUCEDSCALARBYTES |
|
26 | - ); |
|
23 | + define( |
|
24 | + 'SODIUM_CRYPTO_CORE_RISTRETTO255_NONREDUCEDSCALARBYTES', |
|
25 | + ParagonIE_Sodium_Compat::CRYPTO_CORE_RISTRETTO255_NONREDUCEDSCALARBYTES |
|
26 | + ); |
|
27 | 27 | } |
28 | 28 | if (!defined('SODIUM_CRYPTO_SCALARMULT_RISTRETTO255_SCALARBYTES')) { |
29 | - define( |
|
30 | - 'SODIUM_CRYPTO_SCALARMULT_RISTRETTO255_SCALARBYTES', |
|
31 | - ParagonIE_Sodium_Compat::CRYPTO_SCALARMULT_RISTRETTO255_SCALARBYTES |
|
32 | - ); |
|
29 | + define( |
|
30 | + 'SODIUM_CRYPTO_SCALARMULT_RISTRETTO255_SCALARBYTES', |
|
31 | + ParagonIE_Sodium_Compat::CRYPTO_SCALARMULT_RISTRETTO255_SCALARBYTES |
|
32 | + ); |
|
33 | 33 | } |
34 | 34 | if (!defined('SODIUM_CRYPTO_SCALARMULT_RISTRETTO255_BYTES')) { |
35 | - define( |
|
36 | - 'SODIUM_CRYPTO_SCALARMULT_RISTRETTO255_BYTES', |
|
37 | - ParagonIE_Sodium_Compat::CRYPTO_SCALARMULT_RISTRETTO255_BYTES |
|
38 | - ); |
|
35 | + define( |
|
36 | + 'SODIUM_CRYPTO_SCALARMULT_RISTRETTO255_BYTES', |
|
37 | + ParagonIE_Sodium_Compat::CRYPTO_SCALARMULT_RISTRETTO255_BYTES |
|
38 | + ); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | if (!is_callable('sodium_crypto_core_ristretto255_add')) { |
42 | - /** |
|
43 | - * @see ParagonIE_Sodium_Compat::ristretto255_add() |
|
44 | - * |
|
45 | - * @param string $p |
|
46 | - * @param string $q |
|
47 | - * @return string |
|
48 | - * @throws SodiumException |
|
49 | - */ |
|
50 | - function sodium_crypto_core_ristretto255_add($p, $q) |
|
51 | - { |
|
52 | - return ParagonIE_Sodium_Compat::ristretto255_add($p, $q, true); |
|
53 | - } |
|
42 | + /** |
|
43 | + * @see ParagonIE_Sodium_Compat::ristretto255_add() |
|
44 | + * |
|
45 | + * @param string $p |
|
46 | + * @param string $q |
|
47 | + * @return string |
|
48 | + * @throws SodiumException |
|
49 | + */ |
|
50 | + function sodium_crypto_core_ristretto255_add($p, $q) |
|
51 | + { |
|
52 | + return ParagonIE_Sodium_Compat::ristretto255_add($p, $q, true); |
|
53 | + } |
|
54 | 54 | } |
55 | 55 | if (!is_callable('sodium_crypto_core_ristretto255_from_hash')) { |
56 | - /** |
|
57 | - * @see ParagonIE_Sodium_Compat::ristretto255_from_hash() |
|
58 | - * |
|
59 | - * @param string $r |
|
60 | - * @return string |
|
61 | - * @throws SodiumException |
|
62 | - */ |
|
63 | - function sodium_crypto_core_ristretto255_from_hash($r) |
|
64 | - { |
|
65 | - return ParagonIE_Sodium_Compat::ristretto255_from_hash($r, true); |
|
66 | - } |
|
56 | + /** |
|
57 | + * @see ParagonIE_Sodium_Compat::ristretto255_from_hash() |
|
58 | + * |
|
59 | + * @param string $r |
|
60 | + * @return string |
|
61 | + * @throws SodiumException |
|
62 | + */ |
|
63 | + function sodium_crypto_core_ristretto255_from_hash($r) |
|
64 | + { |
|
65 | + return ParagonIE_Sodium_Compat::ristretto255_from_hash($r, true); |
|
66 | + } |
|
67 | 67 | } |
68 | 68 | if (!is_callable('sodium_crypto_core_ristretto255_is_valid_point')) { |
69 | - /** |
|
70 | - * @see ParagonIE_Sodium_Compat::ristretto255_is_valid_point() |
|
71 | - * |
|
72 | - * @param string $p |
|
73 | - * @return bool |
|
74 | - * @throws SodiumException |
|
75 | - */ |
|
76 | - function sodium_crypto_core_ristretto255_is_valid_point($p) |
|
77 | - { |
|
78 | - return ParagonIE_Sodium_Compat::ristretto255_is_valid_point($p, true); |
|
79 | - } |
|
69 | + /** |
|
70 | + * @see ParagonIE_Sodium_Compat::ristretto255_is_valid_point() |
|
71 | + * |
|
72 | + * @param string $p |
|
73 | + * @return bool |
|
74 | + * @throws SodiumException |
|
75 | + */ |
|
76 | + function sodium_crypto_core_ristretto255_is_valid_point($p) |
|
77 | + { |
|
78 | + return ParagonIE_Sodium_Compat::ristretto255_is_valid_point($p, true); |
|
79 | + } |
|
80 | 80 | } |
81 | 81 | if (!is_callable('sodium_crypto_core_ristretto255_random')) { |
82 | - /** |
|
83 | - * @see ParagonIE_Sodium_Compat::ristretto255_random() |
|
84 | - * |
|
85 | - * @return string |
|
86 | - * @throws SodiumException |
|
87 | - */ |
|
88 | - function sodium_crypto_core_ristretto255_random() |
|
89 | - { |
|
90 | - return ParagonIE_Sodium_Compat::ristretto255_random(true); |
|
91 | - } |
|
82 | + /** |
|
83 | + * @see ParagonIE_Sodium_Compat::ristretto255_random() |
|
84 | + * |
|
85 | + * @return string |
|
86 | + * @throws SodiumException |
|
87 | + */ |
|
88 | + function sodium_crypto_core_ristretto255_random() |
|
89 | + { |
|
90 | + return ParagonIE_Sodium_Compat::ristretto255_random(true); |
|
91 | + } |
|
92 | 92 | } |
93 | 93 | if (!is_callable('sodium_crypto_core_ristretto255_scalar_add')) { |
94 | - /** |
|
95 | - * @see ParagonIE_Sodium_Compat::ristretto255_scalar_add() |
|
96 | - * |
|
97 | - * @param string $p |
|
98 | - * @param string $q |
|
99 | - * @return string |
|
100 | - * @throws SodiumException |
|
101 | - */ |
|
102 | - function sodium_crypto_core_ristretto255_scalar_add($p, $q) |
|
103 | - { |
|
104 | - return ParagonIE_Sodium_Compat::ristretto255_scalar_add($p, $q, true); |
|
105 | - } |
|
94 | + /** |
|
95 | + * @see ParagonIE_Sodium_Compat::ristretto255_scalar_add() |
|
96 | + * |
|
97 | + * @param string $p |
|
98 | + * @param string $q |
|
99 | + * @return string |
|
100 | + * @throws SodiumException |
|
101 | + */ |
|
102 | + function sodium_crypto_core_ristretto255_scalar_add($p, $q) |
|
103 | + { |
|
104 | + return ParagonIE_Sodium_Compat::ristretto255_scalar_add($p, $q, true); |
|
105 | + } |
|
106 | 106 | } |
107 | 107 | if (!is_callable('sodium_crypto_core_ristretto255_scalar_complement')) { |
108 | - /** |
|
109 | - * @see ParagonIE_Sodium_Compat::ristretto255_scalar_complement() |
|
110 | - * |
|
111 | - * @param string $p |
|
112 | - * @return string |
|
113 | - * @throws SodiumException |
|
114 | - */ |
|
115 | - function sodium_crypto_core_ristretto255_scalar_complement($p) |
|
116 | - { |
|
117 | - return ParagonIE_Sodium_Compat::ristretto255_scalar_complement($p, true); |
|
118 | - } |
|
108 | + /** |
|
109 | + * @see ParagonIE_Sodium_Compat::ristretto255_scalar_complement() |
|
110 | + * |
|
111 | + * @param string $p |
|
112 | + * @return string |
|
113 | + * @throws SodiumException |
|
114 | + */ |
|
115 | + function sodium_crypto_core_ristretto255_scalar_complement($p) |
|
116 | + { |
|
117 | + return ParagonIE_Sodium_Compat::ristretto255_scalar_complement($p, true); |
|
118 | + } |
|
119 | 119 | } |
120 | 120 | if (!is_callable('sodium_crypto_core_ristretto255_scalar_invert')) { |
121 | - /** |
|
122 | - * @see ParagonIE_Sodium_Compat::ristretto255_scalar_invert() |
|
123 | - * |
|
124 | - * @param string $p |
|
125 | - * @return string |
|
126 | - * @throws SodiumException |
|
127 | - */ |
|
128 | - function sodium_crypto_core_ristretto255_scalar_invert($p) |
|
129 | - { |
|
130 | - return ParagonIE_Sodium_Compat::ristretto255_scalar_invert($p, true); |
|
131 | - } |
|
121 | + /** |
|
122 | + * @see ParagonIE_Sodium_Compat::ristretto255_scalar_invert() |
|
123 | + * |
|
124 | + * @param string $p |
|
125 | + * @return string |
|
126 | + * @throws SodiumException |
|
127 | + */ |
|
128 | + function sodium_crypto_core_ristretto255_scalar_invert($p) |
|
129 | + { |
|
130 | + return ParagonIE_Sodium_Compat::ristretto255_scalar_invert($p, true); |
|
131 | + } |
|
132 | 132 | } |
133 | 133 | if (!is_callable('sodium_crypto_core_ristretto255_scalar_mul')) { |
134 | - /** |
|
135 | - * @see ParagonIE_Sodium_Compat::ristretto255_scalar_mul() |
|
136 | - * |
|
137 | - * @param string $p |
|
138 | - * @param string $q |
|
139 | - * @return string |
|
140 | - * @throws SodiumException |
|
141 | - */ |
|
142 | - function sodium_crypto_core_ristretto255_scalar_mul($p, $q) |
|
143 | - { |
|
144 | - return ParagonIE_Sodium_Compat::ristretto255_scalar_mul($p, $q, true); |
|
145 | - } |
|
134 | + /** |
|
135 | + * @see ParagonIE_Sodium_Compat::ristretto255_scalar_mul() |
|
136 | + * |
|
137 | + * @param string $p |
|
138 | + * @param string $q |
|
139 | + * @return string |
|
140 | + * @throws SodiumException |
|
141 | + */ |
|
142 | + function sodium_crypto_core_ristretto255_scalar_mul($p, $q) |
|
143 | + { |
|
144 | + return ParagonIE_Sodium_Compat::ristretto255_scalar_mul($p, $q, true); |
|
145 | + } |
|
146 | 146 | } |
147 | 147 | if (!is_callable('sodium_crypto_core_ristretto255_scalar_negate')) { |
148 | - /** |
|
149 | - * @see ParagonIE_Sodium_Compat::ristretto255_scalar_negate() |
|
150 | - * |
|
151 | - * @param string $p |
|
152 | - * @return string |
|
153 | - * @throws SodiumException |
|
154 | - */ |
|
155 | - function sodium_crypto_core_ristretto255_scalar_negate($p) |
|
156 | - { |
|
157 | - return ParagonIE_Sodium_Compat::ristretto255_scalar_negate($p, true); |
|
158 | - } |
|
148 | + /** |
|
149 | + * @see ParagonIE_Sodium_Compat::ristretto255_scalar_negate() |
|
150 | + * |
|
151 | + * @param string $p |
|
152 | + * @return string |
|
153 | + * @throws SodiumException |
|
154 | + */ |
|
155 | + function sodium_crypto_core_ristretto255_scalar_negate($p) |
|
156 | + { |
|
157 | + return ParagonIE_Sodium_Compat::ristretto255_scalar_negate($p, true); |
|
158 | + } |
|
159 | 159 | } |
160 | 160 | if (!is_callable('sodium_crypto_core_ristretto255_scalar_random')) { |
161 | - /** |
|
162 | - * @see ParagonIE_Sodium_Compat::ristretto255_scalar_random() |
|
163 | - * |
|
164 | - * @return string |
|
165 | - * @throws SodiumException |
|
166 | - */ |
|
167 | - function sodium_crypto_core_ristretto255_scalar_random() |
|
168 | - { |
|
169 | - return ParagonIE_Sodium_Compat::ristretto255_scalar_random(true); |
|
170 | - } |
|
161 | + /** |
|
162 | + * @see ParagonIE_Sodium_Compat::ristretto255_scalar_random() |
|
163 | + * |
|
164 | + * @return string |
|
165 | + * @throws SodiumException |
|
166 | + */ |
|
167 | + function sodium_crypto_core_ristretto255_scalar_random() |
|
168 | + { |
|
169 | + return ParagonIE_Sodium_Compat::ristretto255_scalar_random(true); |
|
170 | + } |
|
171 | 171 | } |
172 | 172 | if (!is_callable('sodium_crypto_core_ristretto255_scalar_reduce')) { |
173 | - /** |
|
174 | - * @see ParagonIE_Sodium_Compat::ristretto255_scalar_reduce() |
|
175 | - * |
|
176 | - * @param string $p |
|
177 | - * @return string |
|
178 | - * @throws SodiumException |
|
179 | - */ |
|
180 | - function sodium_crypto_core_ristretto255_scalar_reduce($p) |
|
181 | - { |
|
182 | - return ParagonIE_Sodium_Compat::ristretto255_scalar_reduce($p, true); |
|
183 | - } |
|
173 | + /** |
|
174 | + * @see ParagonIE_Sodium_Compat::ristretto255_scalar_reduce() |
|
175 | + * |
|
176 | + * @param string $p |
|
177 | + * @return string |
|
178 | + * @throws SodiumException |
|
179 | + */ |
|
180 | + function sodium_crypto_core_ristretto255_scalar_reduce($p) |
|
181 | + { |
|
182 | + return ParagonIE_Sodium_Compat::ristretto255_scalar_reduce($p, true); |
|
183 | + } |
|
184 | 184 | } |
185 | 185 | if (!is_callable('sodium_crypto_core_ristretto255_scalar_sub')) { |
186 | - /** |
|
187 | - * @see ParagonIE_Sodium_Compat::ristretto255_scalar_sub() |
|
188 | - * |
|
189 | - * @param string $p |
|
190 | - * @param string $q |
|
191 | - * @return string |
|
192 | - * @throws SodiumException |
|
193 | - */ |
|
194 | - function sodium_crypto_core_ristretto255_scalar_sub($p, $q) |
|
195 | - { |
|
196 | - return ParagonIE_Sodium_Compat::ristretto255_scalar_sub($p, $q, true); |
|
197 | - } |
|
186 | + /** |
|
187 | + * @see ParagonIE_Sodium_Compat::ristretto255_scalar_sub() |
|
188 | + * |
|
189 | + * @param string $p |
|
190 | + * @param string $q |
|
191 | + * @return string |
|
192 | + * @throws SodiumException |
|
193 | + */ |
|
194 | + function sodium_crypto_core_ristretto255_scalar_sub($p, $q) |
|
195 | + { |
|
196 | + return ParagonIE_Sodium_Compat::ristretto255_scalar_sub($p, $q, true); |
|
197 | + } |
|
198 | 198 | } |
199 | 199 | if (!is_callable('sodium_crypto_core_ristretto255_sub')) { |
200 | - /** |
|
201 | - * @see ParagonIE_Sodium_Compat::ristretto255_sub() |
|
202 | - * |
|
203 | - * @param string $p |
|
204 | - * @param string $q |
|
205 | - * @return string |
|
206 | - * @throws SodiumException |
|
207 | - */ |
|
208 | - function sodium_crypto_core_ristretto255_sub($p, $q) |
|
209 | - { |
|
210 | - return ParagonIE_Sodium_Compat::ristretto255_sub($p, $q, true); |
|
211 | - } |
|
200 | + /** |
|
201 | + * @see ParagonIE_Sodium_Compat::ristretto255_sub() |
|
202 | + * |
|
203 | + * @param string $p |
|
204 | + * @param string $q |
|
205 | + * @return string |
|
206 | + * @throws SodiumException |
|
207 | + */ |
|
208 | + function sodium_crypto_core_ristretto255_sub($p, $q) |
|
209 | + { |
|
210 | + return ParagonIE_Sodium_Compat::ristretto255_sub($p, $q, true); |
|
211 | + } |
|
212 | 212 | } |
213 | 213 | if (!is_callable('sodium_crypto_scalarmult_ristretto255')) { |
214 | - /** |
|
215 | - * @see ParagonIE_Sodium_Compat::crypto_scalarmult_ristretto255() |
|
216 | - * @param string $n |
|
217 | - * @param string $p |
|
218 | - * @return string |
|
219 | - * @throws SodiumException |
|
220 | - * @throws TypeError |
|
221 | - */ |
|
222 | - function sodium_crypto_scalarmult_ristretto255($n, $p) |
|
223 | - { |
|
224 | - return ParagonIE_Sodium_Compat::scalarmult_ristretto255($n, $p, true); |
|
225 | - } |
|
214 | + /** |
|
215 | + * @see ParagonIE_Sodium_Compat::crypto_scalarmult_ristretto255() |
|
216 | + * @param string $n |
|
217 | + * @param string $p |
|
218 | + * @return string |
|
219 | + * @throws SodiumException |
|
220 | + * @throws TypeError |
|
221 | + */ |
|
222 | + function sodium_crypto_scalarmult_ristretto255($n, $p) |
|
223 | + { |
|
224 | + return ParagonIE_Sodium_Compat::scalarmult_ristretto255($n, $p, true); |
|
225 | + } |
|
226 | 226 | } |
227 | 227 | if (!is_callable('sodium_crypto_scalarmult_ristretto255_base')) { |
228 | - /** |
|
229 | - * @see ParagonIE_Sodium_Compat::crypto_scalarmult_ristretto255_base() |
|
230 | - * @param string $n |
|
231 | - * @return string |
|
232 | - * @throws SodiumException |
|
233 | - * @throws TypeError |
|
234 | - */ |
|
235 | - function sodium_crypto_scalarmult_ristretto255_base($n) |
|
236 | - { |
|
237 | - return ParagonIE_Sodium_Compat::scalarmult_ristretto255_base($n, true); |
|
238 | - } |
|
228 | + /** |
|
229 | + * @see ParagonIE_Sodium_Compat::crypto_scalarmult_ristretto255_base() |
|
230 | + * @param string $n |
|
231 | + * @return string |
|
232 | + * @throws SodiumException |
|
233 | + * @throws TypeError |
|
234 | + */ |
|
235 | + function sodium_crypto_scalarmult_ristretto255_base($n) |
|
236 | + { |
|
237 | + return ParagonIE_Sodium_Compat::scalarmult_ristretto255_base($n, true); |
|
238 | + } |
|
239 | 239 | } |
240 | 240 | \ No newline at end of file |
@@ -1,44 +1,44 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('SODIUM_CRYPTO_CORE_RISTRETTO255_BYTES')) { |
|
3 | +if ( ! defined( 'SODIUM_CRYPTO_CORE_RISTRETTO255_BYTES' ) ) { |
|
4 | 4 | define( |
5 | 5 | 'SODIUM_CRYPTO_CORE_RISTRETTO255_BYTES', |
6 | 6 | ParagonIE_Sodium_Compat::CRYPTO_CORE_RISTRETTO255_BYTES |
7 | 7 | ); |
8 | - define('SODIUM_COMPAT_POLYFILLED_RISTRETTO255', true); |
|
8 | + define( 'SODIUM_COMPAT_POLYFILLED_RISTRETTO255', true ); |
|
9 | 9 | } |
10 | -if (!defined('SODIUM_CRYPTO_CORE_RISTRETTO255_HASHBYTES')) { |
|
10 | +if ( ! defined( 'SODIUM_CRYPTO_CORE_RISTRETTO255_HASHBYTES' ) ) { |
|
11 | 11 | define( |
12 | 12 | 'SODIUM_CRYPTO_CORE_RISTRETTO255_HASHBYTES', |
13 | 13 | ParagonIE_Sodium_Compat::CRYPTO_CORE_RISTRETTO255_HASHBYTES |
14 | 14 | ); |
15 | 15 | } |
16 | -if (!defined('SODIUM_CRYPTO_CORE_RISTRETTO255_SCALARBYTES')) { |
|
16 | +if ( ! defined( 'SODIUM_CRYPTO_CORE_RISTRETTO255_SCALARBYTES' ) ) { |
|
17 | 17 | define( |
18 | 18 | 'SODIUM_CRYPTO_CORE_RISTRETTO255_SCALARBYTES', |
19 | 19 | ParagonIE_Sodium_Compat::CRYPTO_CORE_RISTRETTO255_SCALARBYTES |
20 | 20 | ); |
21 | 21 | } |
22 | -if (!defined('SODIUM_CRYPTO_CORE_RISTRETTO255_NONREDUCEDSCALARBYTES')) { |
|
22 | +if ( ! defined( 'SODIUM_CRYPTO_CORE_RISTRETTO255_NONREDUCEDSCALARBYTES' ) ) { |
|
23 | 23 | define( |
24 | 24 | 'SODIUM_CRYPTO_CORE_RISTRETTO255_NONREDUCEDSCALARBYTES', |
25 | 25 | ParagonIE_Sodium_Compat::CRYPTO_CORE_RISTRETTO255_NONREDUCEDSCALARBYTES |
26 | 26 | ); |
27 | 27 | } |
28 | -if (!defined('SODIUM_CRYPTO_SCALARMULT_RISTRETTO255_SCALARBYTES')) { |
|
28 | +if ( ! defined( 'SODIUM_CRYPTO_SCALARMULT_RISTRETTO255_SCALARBYTES' ) ) { |
|
29 | 29 | define( |
30 | 30 | 'SODIUM_CRYPTO_SCALARMULT_RISTRETTO255_SCALARBYTES', |
31 | 31 | ParagonIE_Sodium_Compat::CRYPTO_SCALARMULT_RISTRETTO255_SCALARBYTES |
32 | 32 | ); |
33 | 33 | } |
34 | -if (!defined('SODIUM_CRYPTO_SCALARMULT_RISTRETTO255_BYTES')) { |
|
34 | +if ( ! defined( 'SODIUM_CRYPTO_SCALARMULT_RISTRETTO255_BYTES' ) ) { |
|
35 | 35 | define( |
36 | 36 | 'SODIUM_CRYPTO_SCALARMULT_RISTRETTO255_BYTES', |
37 | 37 | ParagonIE_Sodium_Compat::CRYPTO_SCALARMULT_RISTRETTO255_BYTES |
38 | 38 | ); |
39 | 39 | } |
40 | 40 | |
41 | -if (!is_callable('sodium_crypto_core_ristretto255_add')) { |
|
41 | +if ( ! is_callable( 'sodium_crypto_core_ristretto255_add' ) ) { |
|
42 | 42 | /** |
43 | 43 | * @see ParagonIE_Sodium_Compat::ristretto255_add() |
44 | 44 | * |
@@ -47,12 +47,12 @@ discard block |
||
47 | 47 | * @return string |
48 | 48 | * @throws SodiumException |
49 | 49 | */ |
50 | - function sodium_crypto_core_ristretto255_add($p, $q) |
|
50 | + function sodium_crypto_core_ristretto255_add( $p, $q ) |
|
51 | 51 | { |
52 | - return ParagonIE_Sodium_Compat::ristretto255_add($p, $q, true); |
|
52 | + return ParagonIE_Sodium_Compat::ristretto255_add( $p, $q, true ); |
|
53 | 53 | } |
54 | 54 | } |
55 | -if (!is_callable('sodium_crypto_core_ristretto255_from_hash')) { |
|
55 | +if ( ! is_callable( 'sodium_crypto_core_ristretto255_from_hash' ) ) { |
|
56 | 56 | /** |
57 | 57 | * @see ParagonIE_Sodium_Compat::ristretto255_from_hash() |
58 | 58 | * |
@@ -60,12 +60,12 @@ discard block |
||
60 | 60 | * @return string |
61 | 61 | * @throws SodiumException |
62 | 62 | */ |
63 | - function sodium_crypto_core_ristretto255_from_hash($r) |
|
63 | + function sodium_crypto_core_ristretto255_from_hash( $r ) |
|
64 | 64 | { |
65 | - return ParagonIE_Sodium_Compat::ristretto255_from_hash($r, true); |
|
65 | + return ParagonIE_Sodium_Compat::ristretto255_from_hash( $r, true ); |
|
66 | 66 | } |
67 | 67 | } |
68 | -if (!is_callable('sodium_crypto_core_ristretto255_is_valid_point')) { |
|
68 | +if ( ! is_callable( 'sodium_crypto_core_ristretto255_is_valid_point' ) ) { |
|
69 | 69 | /** |
70 | 70 | * @see ParagonIE_Sodium_Compat::ristretto255_is_valid_point() |
71 | 71 | * |
@@ -73,12 +73,12 @@ discard block |
||
73 | 73 | * @return bool |
74 | 74 | * @throws SodiumException |
75 | 75 | */ |
76 | - function sodium_crypto_core_ristretto255_is_valid_point($p) |
|
76 | + function sodium_crypto_core_ristretto255_is_valid_point( $p ) |
|
77 | 77 | { |
78 | - return ParagonIE_Sodium_Compat::ristretto255_is_valid_point($p, true); |
|
78 | + return ParagonIE_Sodium_Compat::ristretto255_is_valid_point( $p, true ); |
|
79 | 79 | } |
80 | 80 | } |
81 | -if (!is_callable('sodium_crypto_core_ristretto255_random')) { |
|
81 | +if ( ! is_callable( 'sodium_crypto_core_ristretto255_random' ) ) { |
|
82 | 82 | /** |
83 | 83 | * @see ParagonIE_Sodium_Compat::ristretto255_random() |
84 | 84 | * |
@@ -87,10 +87,10 @@ discard block |
||
87 | 87 | */ |
88 | 88 | function sodium_crypto_core_ristretto255_random() |
89 | 89 | { |
90 | - return ParagonIE_Sodium_Compat::ristretto255_random(true); |
|
90 | + return ParagonIE_Sodium_Compat::ristretto255_random( true ); |
|
91 | 91 | } |
92 | 92 | } |
93 | -if (!is_callable('sodium_crypto_core_ristretto255_scalar_add')) { |
|
93 | +if ( ! is_callable( 'sodium_crypto_core_ristretto255_scalar_add' ) ) { |
|
94 | 94 | /** |
95 | 95 | * @see ParagonIE_Sodium_Compat::ristretto255_scalar_add() |
96 | 96 | * |
@@ -99,12 +99,12 @@ discard block |
||
99 | 99 | * @return string |
100 | 100 | * @throws SodiumException |
101 | 101 | */ |
102 | - function sodium_crypto_core_ristretto255_scalar_add($p, $q) |
|
102 | + function sodium_crypto_core_ristretto255_scalar_add( $p, $q ) |
|
103 | 103 | { |
104 | - return ParagonIE_Sodium_Compat::ristretto255_scalar_add($p, $q, true); |
|
104 | + return ParagonIE_Sodium_Compat::ristretto255_scalar_add( $p, $q, true ); |
|
105 | 105 | } |
106 | 106 | } |
107 | -if (!is_callable('sodium_crypto_core_ristretto255_scalar_complement')) { |
|
107 | +if ( ! is_callable( 'sodium_crypto_core_ristretto255_scalar_complement' ) ) { |
|
108 | 108 | /** |
109 | 109 | * @see ParagonIE_Sodium_Compat::ristretto255_scalar_complement() |
110 | 110 | * |
@@ -112,12 +112,12 @@ discard block |
||
112 | 112 | * @return string |
113 | 113 | * @throws SodiumException |
114 | 114 | */ |
115 | - function sodium_crypto_core_ristretto255_scalar_complement($p) |
|
115 | + function sodium_crypto_core_ristretto255_scalar_complement( $p ) |
|
116 | 116 | { |
117 | - return ParagonIE_Sodium_Compat::ristretto255_scalar_complement($p, true); |
|
117 | + return ParagonIE_Sodium_Compat::ristretto255_scalar_complement( $p, true ); |
|
118 | 118 | } |
119 | 119 | } |
120 | -if (!is_callable('sodium_crypto_core_ristretto255_scalar_invert')) { |
|
120 | +if ( ! is_callable( 'sodium_crypto_core_ristretto255_scalar_invert' ) ) { |
|
121 | 121 | /** |
122 | 122 | * @see ParagonIE_Sodium_Compat::ristretto255_scalar_invert() |
123 | 123 | * |
@@ -125,12 +125,12 @@ discard block |
||
125 | 125 | * @return string |
126 | 126 | * @throws SodiumException |
127 | 127 | */ |
128 | - function sodium_crypto_core_ristretto255_scalar_invert($p) |
|
128 | + function sodium_crypto_core_ristretto255_scalar_invert( $p ) |
|
129 | 129 | { |
130 | - return ParagonIE_Sodium_Compat::ristretto255_scalar_invert($p, true); |
|
130 | + return ParagonIE_Sodium_Compat::ristretto255_scalar_invert( $p, true ); |
|
131 | 131 | } |
132 | 132 | } |
133 | -if (!is_callable('sodium_crypto_core_ristretto255_scalar_mul')) { |
|
133 | +if ( ! is_callable( 'sodium_crypto_core_ristretto255_scalar_mul' ) ) { |
|
134 | 134 | /** |
135 | 135 | * @see ParagonIE_Sodium_Compat::ristretto255_scalar_mul() |
136 | 136 | * |
@@ -139,12 +139,12 @@ discard block |
||
139 | 139 | * @return string |
140 | 140 | * @throws SodiumException |
141 | 141 | */ |
142 | - function sodium_crypto_core_ristretto255_scalar_mul($p, $q) |
|
142 | + function sodium_crypto_core_ristretto255_scalar_mul( $p, $q ) |
|
143 | 143 | { |
144 | - return ParagonIE_Sodium_Compat::ristretto255_scalar_mul($p, $q, true); |
|
144 | + return ParagonIE_Sodium_Compat::ristretto255_scalar_mul( $p, $q, true ); |
|
145 | 145 | } |
146 | 146 | } |
147 | -if (!is_callable('sodium_crypto_core_ristretto255_scalar_negate')) { |
|
147 | +if ( ! is_callable( 'sodium_crypto_core_ristretto255_scalar_negate' ) ) { |
|
148 | 148 | /** |
149 | 149 | * @see ParagonIE_Sodium_Compat::ristretto255_scalar_negate() |
150 | 150 | * |
@@ -152,12 +152,12 @@ discard block |
||
152 | 152 | * @return string |
153 | 153 | * @throws SodiumException |
154 | 154 | */ |
155 | - function sodium_crypto_core_ristretto255_scalar_negate($p) |
|
155 | + function sodium_crypto_core_ristretto255_scalar_negate( $p ) |
|
156 | 156 | { |
157 | - return ParagonIE_Sodium_Compat::ristretto255_scalar_negate($p, true); |
|
157 | + return ParagonIE_Sodium_Compat::ristretto255_scalar_negate( $p, true ); |
|
158 | 158 | } |
159 | 159 | } |
160 | -if (!is_callable('sodium_crypto_core_ristretto255_scalar_random')) { |
|
160 | +if ( ! is_callable( 'sodium_crypto_core_ristretto255_scalar_random' ) ) { |
|
161 | 161 | /** |
162 | 162 | * @see ParagonIE_Sodium_Compat::ristretto255_scalar_random() |
163 | 163 | * |
@@ -166,10 +166,10 @@ discard block |
||
166 | 166 | */ |
167 | 167 | function sodium_crypto_core_ristretto255_scalar_random() |
168 | 168 | { |
169 | - return ParagonIE_Sodium_Compat::ristretto255_scalar_random(true); |
|
169 | + return ParagonIE_Sodium_Compat::ristretto255_scalar_random( true ); |
|
170 | 170 | } |
171 | 171 | } |
172 | -if (!is_callable('sodium_crypto_core_ristretto255_scalar_reduce')) { |
|
172 | +if ( ! is_callable( 'sodium_crypto_core_ristretto255_scalar_reduce' ) ) { |
|
173 | 173 | /** |
174 | 174 | * @see ParagonIE_Sodium_Compat::ristretto255_scalar_reduce() |
175 | 175 | * |
@@ -177,12 +177,12 @@ discard block |
||
177 | 177 | * @return string |
178 | 178 | * @throws SodiumException |
179 | 179 | */ |
180 | - function sodium_crypto_core_ristretto255_scalar_reduce($p) |
|
180 | + function sodium_crypto_core_ristretto255_scalar_reduce( $p ) |
|
181 | 181 | { |
182 | - return ParagonIE_Sodium_Compat::ristretto255_scalar_reduce($p, true); |
|
182 | + return ParagonIE_Sodium_Compat::ristretto255_scalar_reduce( $p, true ); |
|
183 | 183 | } |
184 | 184 | } |
185 | -if (!is_callable('sodium_crypto_core_ristretto255_scalar_sub')) { |
|
185 | +if ( ! is_callable( 'sodium_crypto_core_ristretto255_scalar_sub' ) ) { |
|
186 | 186 | /** |
187 | 187 | * @see ParagonIE_Sodium_Compat::ristretto255_scalar_sub() |
188 | 188 | * |
@@ -191,12 +191,12 @@ discard block |
||
191 | 191 | * @return string |
192 | 192 | * @throws SodiumException |
193 | 193 | */ |
194 | - function sodium_crypto_core_ristretto255_scalar_sub($p, $q) |
|
194 | + function sodium_crypto_core_ristretto255_scalar_sub( $p, $q ) |
|
195 | 195 | { |
196 | - return ParagonIE_Sodium_Compat::ristretto255_scalar_sub($p, $q, true); |
|
196 | + return ParagonIE_Sodium_Compat::ristretto255_scalar_sub( $p, $q, true ); |
|
197 | 197 | } |
198 | 198 | } |
199 | -if (!is_callable('sodium_crypto_core_ristretto255_sub')) { |
|
199 | +if ( ! is_callable( 'sodium_crypto_core_ristretto255_sub' ) ) { |
|
200 | 200 | /** |
201 | 201 | * @see ParagonIE_Sodium_Compat::ristretto255_sub() |
202 | 202 | * |
@@ -205,12 +205,12 @@ discard block |
||
205 | 205 | * @return string |
206 | 206 | * @throws SodiumException |
207 | 207 | */ |
208 | - function sodium_crypto_core_ristretto255_sub($p, $q) |
|
208 | + function sodium_crypto_core_ristretto255_sub( $p, $q ) |
|
209 | 209 | { |
210 | - return ParagonIE_Sodium_Compat::ristretto255_sub($p, $q, true); |
|
210 | + return ParagonIE_Sodium_Compat::ristretto255_sub( $p, $q, true ); |
|
211 | 211 | } |
212 | 212 | } |
213 | -if (!is_callable('sodium_crypto_scalarmult_ristretto255')) { |
|
213 | +if ( ! is_callable( 'sodium_crypto_scalarmult_ristretto255' ) ) { |
|
214 | 214 | /** |
215 | 215 | * @see ParagonIE_Sodium_Compat::crypto_scalarmult_ristretto255() |
216 | 216 | * @param string $n |
@@ -219,12 +219,12 @@ discard block |
||
219 | 219 | * @throws SodiumException |
220 | 220 | * @throws TypeError |
221 | 221 | */ |
222 | - function sodium_crypto_scalarmult_ristretto255($n, $p) |
|
222 | + function sodium_crypto_scalarmult_ristretto255( $n, $p ) |
|
223 | 223 | { |
224 | - return ParagonIE_Sodium_Compat::scalarmult_ristretto255($n, $p, true); |
|
224 | + return ParagonIE_Sodium_Compat::scalarmult_ristretto255( $n, $p, true ); |
|
225 | 225 | } |
226 | 226 | } |
227 | -if (!is_callable('sodium_crypto_scalarmult_ristretto255_base')) { |
|
227 | +if ( ! is_callable( 'sodium_crypto_scalarmult_ristretto255_base' ) ) { |
|
228 | 228 | /** |
229 | 229 | * @see ParagonIE_Sodium_Compat::crypto_scalarmult_ristretto255_base() |
230 | 230 | * @param string $n |
@@ -232,8 +232,8 @@ discard block |
||
232 | 232 | * @throws SodiumException |
233 | 233 | * @throws TypeError |
234 | 234 | */ |
235 | - function sodium_crypto_scalarmult_ristretto255_base($n) |
|
235 | + function sodium_crypto_scalarmult_ristretto255_base( $n ) |
|
236 | 236 | { |
237 | - return ParagonIE_Sodium_Compat::scalarmult_ristretto255_base($n, true); |
|
237 | + return ParagonIE_Sodium_Compat::scalarmult_ristretto255_base( $n, true ); |
|
238 | 238 | } |
239 | 239 | } |
240 | 240 | \ No newline at end of file |
@@ -47,8 +47,7 @@ discard block |
||
47 | 47 | * @return string |
48 | 48 | * @throws SodiumException |
49 | 49 | */ |
50 | - function sodium_crypto_core_ristretto255_add($p, $q) |
|
51 | - { |
|
50 | + function sodium_crypto_core_ristretto255_add($p, $q) { |
|
52 | 51 | return ParagonIE_Sodium_Compat::ristretto255_add($p, $q, true); |
53 | 52 | } |
54 | 53 | } |
@@ -60,8 +59,7 @@ discard block |
||
60 | 59 | * @return string |
61 | 60 | * @throws SodiumException |
62 | 61 | */ |
63 | - function sodium_crypto_core_ristretto255_from_hash($r) |
|
64 | - { |
|
62 | + function sodium_crypto_core_ristretto255_from_hash($r) { |
|
65 | 63 | return ParagonIE_Sodium_Compat::ristretto255_from_hash($r, true); |
66 | 64 | } |
67 | 65 | } |
@@ -73,8 +71,7 @@ discard block |
||
73 | 71 | * @return bool |
74 | 72 | * @throws SodiumException |
75 | 73 | */ |
76 | - function sodium_crypto_core_ristretto255_is_valid_point($p) |
|
77 | - { |
|
74 | + function sodium_crypto_core_ristretto255_is_valid_point($p) { |
|
78 | 75 | return ParagonIE_Sodium_Compat::ristretto255_is_valid_point($p, true); |
79 | 76 | } |
80 | 77 | } |
@@ -85,8 +82,7 @@ discard block |
||
85 | 82 | * @return string |
86 | 83 | * @throws SodiumException |
87 | 84 | */ |
88 | - function sodium_crypto_core_ristretto255_random() |
|
89 | - { |
|
85 | + function sodium_crypto_core_ristretto255_random() { |
|
90 | 86 | return ParagonIE_Sodium_Compat::ristretto255_random(true); |
91 | 87 | } |
92 | 88 | } |
@@ -99,8 +95,7 @@ discard block |
||
99 | 95 | * @return string |
100 | 96 | * @throws SodiumException |
101 | 97 | */ |
102 | - function sodium_crypto_core_ristretto255_scalar_add($p, $q) |
|
103 | - { |
|
98 | + function sodium_crypto_core_ristretto255_scalar_add($p, $q) { |
|
104 | 99 | return ParagonIE_Sodium_Compat::ristretto255_scalar_add($p, $q, true); |
105 | 100 | } |
106 | 101 | } |
@@ -112,8 +107,7 @@ discard block |
||
112 | 107 | * @return string |
113 | 108 | * @throws SodiumException |
114 | 109 | */ |
115 | - function sodium_crypto_core_ristretto255_scalar_complement($p) |
|
116 | - { |
|
110 | + function sodium_crypto_core_ristretto255_scalar_complement($p) { |
|
117 | 111 | return ParagonIE_Sodium_Compat::ristretto255_scalar_complement($p, true); |
118 | 112 | } |
119 | 113 | } |
@@ -125,8 +119,7 @@ discard block |
||
125 | 119 | * @return string |
126 | 120 | * @throws SodiumException |
127 | 121 | */ |
128 | - function sodium_crypto_core_ristretto255_scalar_invert($p) |
|
129 | - { |
|
122 | + function sodium_crypto_core_ristretto255_scalar_invert($p) { |
|
130 | 123 | return ParagonIE_Sodium_Compat::ristretto255_scalar_invert($p, true); |
131 | 124 | } |
132 | 125 | } |
@@ -139,8 +132,7 @@ discard block |
||
139 | 132 | * @return string |
140 | 133 | * @throws SodiumException |
141 | 134 | */ |
142 | - function sodium_crypto_core_ristretto255_scalar_mul($p, $q) |
|
143 | - { |
|
135 | + function sodium_crypto_core_ristretto255_scalar_mul($p, $q) { |
|
144 | 136 | return ParagonIE_Sodium_Compat::ristretto255_scalar_mul($p, $q, true); |
145 | 137 | } |
146 | 138 | } |
@@ -152,8 +144,7 @@ discard block |
||
152 | 144 | * @return string |
153 | 145 | * @throws SodiumException |
154 | 146 | */ |
155 | - function sodium_crypto_core_ristretto255_scalar_negate($p) |
|
156 | - { |
|
147 | + function sodium_crypto_core_ristretto255_scalar_negate($p) { |
|
157 | 148 | return ParagonIE_Sodium_Compat::ristretto255_scalar_negate($p, true); |
158 | 149 | } |
159 | 150 | } |
@@ -164,8 +155,7 @@ discard block |
||
164 | 155 | * @return string |
165 | 156 | * @throws SodiumException |
166 | 157 | */ |
167 | - function sodium_crypto_core_ristretto255_scalar_random() |
|
168 | - { |
|
158 | + function sodium_crypto_core_ristretto255_scalar_random() { |
|
169 | 159 | return ParagonIE_Sodium_Compat::ristretto255_scalar_random(true); |
170 | 160 | } |
171 | 161 | } |
@@ -177,8 +167,7 @@ discard block |
||
177 | 167 | * @return string |
178 | 168 | * @throws SodiumException |
179 | 169 | */ |
180 | - function sodium_crypto_core_ristretto255_scalar_reduce($p) |
|
181 | - { |
|
170 | + function sodium_crypto_core_ristretto255_scalar_reduce($p) { |
|
182 | 171 | return ParagonIE_Sodium_Compat::ristretto255_scalar_reduce($p, true); |
183 | 172 | } |
184 | 173 | } |
@@ -191,8 +180,7 @@ discard block |
||
191 | 180 | * @return string |
192 | 181 | * @throws SodiumException |
193 | 182 | */ |
194 | - function sodium_crypto_core_ristretto255_scalar_sub($p, $q) |
|
195 | - { |
|
183 | + function sodium_crypto_core_ristretto255_scalar_sub($p, $q) { |
|
196 | 184 | return ParagonIE_Sodium_Compat::ristretto255_scalar_sub($p, $q, true); |
197 | 185 | } |
198 | 186 | } |
@@ -205,8 +193,7 @@ discard block |
||
205 | 193 | * @return string |
206 | 194 | * @throws SodiumException |
207 | 195 | */ |
208 | - function sodium_crypto_core_ristretto255_sub($p, $q) |
|
209 | - { |
|
196 | + function sodium_crypto_core_ristretto255_sub($p, $q) { |
|
210 | 197 | return ParagonIE_Sodium_Compat::ristretto255_sub($p, $q, true); |
211 | 198 | } |
212 | 199 | } |
@@ -219,8 +206,7 @@ discard block |
||
219 | 206 | * @throws SodiumException |
220 | 207 | * @throws TypeError |
221 | 208 | */ |
222 | - function sodium_crypto_scalarmult_ristretto255($n, $p) |
|
223 | - { |
|
209 | + function sodium_crypto_scalarmult_ristretto255($n, $p) { |
|
224 | 210 | return ParagonIE_Sodium_Compat::scalarmult_ristretto255($n, $p, true); |
225 | 211 | } |
226 | 212 | } |
@@ -232,8 +218,7 @@ discard block |
||
232 | 218 | * @throws SodiumException |
233 | 219 | * @throws TypeError |
234 | 220 | */ |
235 | - function sodium_crypto_scalarmult_ristretto255_base($n) |
|
236 | - { |
|
221 | + function sodium_crypto_scalarmult_ristretto255_base($n) { |
|
237 | 222 | return ParagonIE_Sodium_Compat::scalarmult_ristretto255_base($n, true); |
238 | 223 | } |
239 | 224 | } |
240 | 225 | \ No newline at end of file |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace Sodium; |
3 | 3 | |
4 | -require_once dirname(dirname(__FILE__)) . '/autoload.php'; |
|
4 | +require_once dirname( dirname( __FILE__ ) ) . '/autoload.php'; |
|
5 | 5 | |
6 | 6 | use ParagonIE_Sodium_Compat; |
7 | 7 |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | require_once dirname(dirname(__FILE__)) . '/autoload.php'; |
4 | 4 | |
5 | 5 | if (PHP_VERSION_ID < 50300) { |
6 | - return; |
|
6 | + return; |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | /* |
@@ -21,28 +21,28 @@ discard block |
||
21 | 21 | * $x = Compat::crypto_aead_xchacha20poly1305_encrypt(...$args); |
22 | 22 | */ |
23 | 23 | spl_autoload_register(function ($class) { |
24 | - if ($class[0] === '\\') { |
|
25 | - $class = substr($class, 1); |
|
26 | - } |
|
27 | - $namespace = 'ParagonIE\\Sodium'; |
|
28 | - // Does the class use the namespace prefix? |
|
29 | - $len = strlen($namespace); |
|
30 | - if (strncmp($namespace, $class, $len) !== 0) { |
|
31 | - // no, move to the next registered autoloader |
|
32 | - return false; |
|
33 | - } |
|
24 | + if ($class[0] === '\\') { |
|
25 | + $class = substr($class, 1); |
|
26 | + } |
|
27 | + $namespace = 'ParagonIE\\Sodium'; |
|
28 | + // Does the class use the namespace prefix? |
|
29 | + $len = strlen($namespace); |
|
30 | + if (strncmp($namespace, $class, $len) !== 0) { |
|
31 | + // no, move to the next registered autoloader |
|
32 | + return false; |
|
33 | + } |
|
34 | 34 | |
35 | - // Get the relative class name |
|
36 | - $relative_class = substr($class, $len); |
|
35 | + // Get the relative class name |
|
36 | + $relative_class = substr($class, $len); |
|
37 | 37 | |
38 | - // Replace the namespace prefix with the base directory, replace namespace |
|
39 | - // separators with directory separators in the relative class name, append |
|
40 | - // with .php |
|
41 | - $file = dirname(dirname(__FILE__)) . '/namespaced/' . str_replace('\\', '/', $relative_class) . '.php'; |
|
42 | - // if the file exists, require it |
|
43 | - if (file_exists($file)) { |
|
44 | - require_once $file; |
|
45 | - return true; |
|
46 | - } |
|
47 | - return false; |
|
38 | + // Replace the namespace prefix with the base directory, replace namespace |
|
39 | + // separators with directory separators in the relative class name, append |
|
40 | + // with .php |
|
41 | + $file = dirname(dirname(__FILE__)) . '/namespaced/' . str_replace('\\', '/', $relative_class) . '.php'; |
|
42 | + // if the file exists, require it |
|
43 | + if (file_exists($file)) { |
|
44 | + require_once $file; |
|
45 | + return true; |
|
46 | + } |
|
47 | + return false; |
|
48 | 48 | }); |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -require_once dirname(dirname(__FILE__)) . '/autoload.php'; |
|
3 | +require_once dirname( dirname( __FILE__ ) ) . '/autoload.php'; |
|
4 | 4 | |
5 | -if (PHP_VERSION_ID < 50300) { |
|
5 | +if ( PHP_VERSION_ID < 50300 ) { |
|
6 | 6 | return; |
7 | 7 | } |
8 | 8 | |
@@ -20,27 +20,27 @@ discard block |
||
20 | 20 | * |
21 | 21 | * $x = Compat::crypto_aead_xchacha20poly1305_encrypt(...$args); |
22 | 22 | */ |
23 | -spl_autoload_register(function ($class) { |
|
24 | - if ($class[0] === '\\') { |
|
25 | - $class = substr($class, 1); |
|
23 | +spl_autoload_register( function( $class ) { |
|
24 | + if ( $class[ 0 ] === '\\' ) { |
|
25 | + $class = substr( $class, 1 ); |
|
26 | 26 | } |
27 | 27 | $namespace = 'ParagonIE\\Sodium'; |
28 | 28 | // Does the class use the namespace prefix? |
29 | - $len = strlen($namespace); |
|
30 | - if (strncmp($namespace, $class, $len) !== 0) { |
|
29 | + $len = strlen( $namespace ); |
|
30 | + if ( strncmp( $namespace, $class, $len ) !== 0 ) { |
|
31 | 31 | // no, move to the next registered autoloader |
32 | 32 | return false; |
33 | 33 | } |
34 | 34 | |
35 | 35 | // Get the relative class name |
36 | - $relative_class = substr($class, $len); |
|
36 | + $relative_class = substr( $class, $len ); |
|
37 | 37 | |
38 | 38 | // Replace the namespace prefix with the base directory, replace namespace |
39 | 39 | // separators with directory separators in the relative class name, append |
40 | 40 | // with .php |
41 | - $file = dirname(dirname(__FILE__)) . '/namespaced/' . str_replace('\\', '/', $relative_class) . '.php'; |
|
41 | + $file = dirname( dirname( __FILE__ ) ) . '/namespaced/' . str_replace( '\\', '/', $relative_class ) . '.php'; |
|
42 | 42 | // if the file exists, require it |
43 | - if (file_exists($file)) { |
|
43 | + if ( file_exists( $file ) ) { |
|
44 | 44 | require_once $file; |
45 | 45 | return true; |
46 | 46 | } |
@@ -1,43 +1,43 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | if (!is_callable('sodium_crypto_stream_xchacha20')) { |
4 | - /** |
|
5 | - * @see ParagonIE_Sodium_Compat::crypto_stream_xchacha20() |
|
6 | - * @param int $len |
|
7 | - * @param string $nonce |
|
8 | - * @param string $key |
|
9 | - * @return string |
|
10 | - * @throws SodiumException |
|
11 | - * @throws TypeError |
|
12 | - */ |
|
13 | - function sodium_crypto_stream_xchacha20($len, $nonce, $key) |
|
14 | - { |
|
15 | - return ParagonIE_Sodium_Compat::crypto_stream_xchacha20($len, $nonce, $key, true); |
|
16 | - } |
|
4 | + /** |
|
5 | + * @see ParagonIE_Sodium_Compat::crypto_stream_xchacha20() |
|
6 | + * @param int $len |
|
7 | + * @param string $nonce |
|
8 | + * @param string $key |
|
9 | + * @return string |
|
10 | + * @throws SodiumException |
|
11 | + * @throws TypeError |
|
12 | + */ |
|
13 | + function sodium_crypto_stream_xchacha20($len, $nonce, $key) |
|
14 | + { |
|
15 | + return ParagonIE_Sodium_Compat::crypto_stream_xchacha20($len, $nonce, $key, true); |
|
16 | + } |
|
17 | 17 | } |
18 | 18 | if (!is_callable('sodium_crypto_stream_xchacha20_keygen')) { |
19 | - /** |
|
20 | - * @see ParagonIE_Sodium_Compat::crypto_stream_xchacha20_keygen() |
|
21 | - * @return string |
|
22 | - * @throws Exception |
|
23 | - */ |
|
24 | - function sodium_crypto_stream_xchacha20_keygen() |
|
25 | - { |
|
26 | - return ParagonIE_Sodium_Compat::crypto_stream_xchacha20_keygen(); |
|
27 | - } |
|
19 | + /** |
|
20 | + * @see ParagonIE_Sodium_Compat::crypto_stream_xchacha20_keygen() |
|
21 | + * @return string |
|
22 | + * @throws Exception |
|
23 | + */ |
|
24 | + function sodium_crypto_stream_xchacha20_keygen() |
|
25 | + { |
|
26 | + return ParagonIE_Sodium_Compat::crypto_stream_xchacha20_keygen(); |
|
27 | + } |
|
28 | 28 | } |
29 | 29 | if (!is_callable('sodium_crypto_stream_xchacha20_xor')) { |
30 | - /** |
|
31 | - * @see ParagonIE_Sodium_Compat::crypto_stream_xchacha20_xor() |
|
32 | - * @param string $message |
|
33 | - * @param string $nonce |
|
34 | - * @param string $key |
|
35 | - * @return string |
|
36 | - * @throws SodiumException |
|
37 | - * @throws TypeError |
|
38 | - */ |
|
39 | - function sodium_crypto_stream_xchacha20_xor($message, $nonce, $key) |
|
40 | - { |
|
41 | - return ParagonIE_Sodium_Compat::crypto_stream_xchacha20_xor($message, $nonce, $key, true); |
|
42 | - } |
|
30 | + /** |
|
31 | + * @see ParagonIE_Sodium_Compat::crypto_stream_xchacha20_xor() |
|
32 | + * @param string $message |
|
33 | + * @param string $nonce |
|
34 | + * @param string $key |
|
35 | + * @return string |
|
36 | + * @throws SodiumException |
|
37 | + * @throws TypeError |
|
38 | + */ |
|
39 | + function sodium_crypto_stream_xchacha20_xor($message, $nonce, $key) |
|
40 | + { |
|
41 | + return ParagonIE_Sodium_Compat::crypto_stream_xchacha20_xor($message, $nonce, $key, true); |
|
42 | + } |
|
43 | 43 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!is_callable('sodium_crypto_stream_xchacha20')) { |
|
3 | +if ( ! is_callable( 'sodium_crypto_stream_xchacha20' ) ) { |
|
4 | 4 | /** |
5 | 5 | * @see ParagonIE_Sodium_Compat::crypto_stream_xchacha20() |
6 | 6 | * @param int $len |
@@ -10,12 +10,12 @@ discard block |
||
10 | 10 | * @throws SodiumException |
11 | 11 | * @throws TypeError |
12 | 12 | */ |
13 | - function sodium_crypto_stream_xchacha20($len, $nonce, $key) |
|
13 | + function sodium_crypto_stream_xchacha20( $len, $nonce, $key ) |
|
14 | 14 | { |
15 | - return ParagonIE_Sodium_Compat::crypto_stream_xchacha20($len, $nonce, $key, true); |
|
15 | + return ParagonIE_Sodium_Compat::crypto_stream_xchacha20( $len, $nonce, $key, true ); |
|
16 | 16 | } |
17 | 17 | } |
18 | -if (!is_callable('sodium_crypto_stream_xchacha20_keygen')) { |
|
18 | +if ( ! is_callable( 'sodium_crypto_stream_xchacha20_keygen' ) ) { |
|
19 | 19 | /** |
20 | 20 | * @see ParagonIE_Sodium_Compat::crypto_stream_xchacha20_keygen() |
21 | 21 | * @return string |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | return ParagonIE_Sodium_Compat::crypto_stream_xchacha20_keygen(); |
27 | 27 | } |
28 | 28 | } |
29 | -if (!is_callable('sodium_crypto_stream_xchacha20_xor')) { |
|
29 | +if ( ! is_callable( 'sodium_crypto_stream_xchacha20_xor' ) ) { |
|
30 | 30 | /** |
31 | 31 | * @see ParagonIE_Sodium_Compat::crypto_stream_xchacha20_xor() |
32 | 32 | * @param string $message |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | * @throws SodiumException |
37 | 37 | * @throws TypeError |
38 | 38 | */ |
39 | - function sodium_crypto_stream_xchacha20_xor($message, $nonce, $key) |
|
39 | + function sodium_crypto_stream_xchacha20_xor( $message, $nonce, $key ) |
|
40 | 40 | { |
41 | - return ParagonIE_Sodium_Compat::crypto_stream_xchacha20_xor($message, $nonce, $key, true); |
|
41 | + return ParagonIE_Sodium_Compat::crypto_stream_xchacha20_xor( $message, $nonce, $key, true ); |
|
42 | 42 | } |
43 | 43 | } |
@@ -10,8 +10,7 @@ discard block |
||
10 | 10 | * @throws SodiumException |
11 | 11 | * @throws TypeError |
12 | 12 | */ |
13 | - function sodium_crypto_stream_xchacha20($len, $nonce, $key) |
|
14 | - { |
|
13 | + function sodium_crypto_stream_xchacha20($len, $nonce, $key) { |
|
15 | 14 | return ParagonIE_Sodium_Compat::crypto_stream_xchacha20($len, $nonce, $key, true); |
16 | 15 | } |
17 | 16 | } |
@@ -21,8 +20,7 @@ discard block |
||
21 | 20 | * @return string |
22 | 21 | * @throws Exception |
23 | 22 | */ |
24 | - function sodium_crypto_stream_xchacha20_keygen() |
|
25 | - { |
|
23 | + function sodium_crypto_stream_xchacha20_keygen() { |
|
26 | 24 | return ParagonIE_Sodium_Compat::crypto_stream_xchacha20_keygen(); |
27 | 25 | } |
28 | 26 | } |
@@ -36,8 +34,7 @@ discard block |
||
36 | 34 | * @throws SodiumException |
37 | 35 | * @throws TypeError |
38 | 36 | */ |
39 | - function sodium_crypto_stream_xchacha20_xor($message, $nonce, $key) |
|
40 | - { |
|
37 | + function sodium_crypto_stream_xchacha20_xor($message, $nonce, $key) { |
|
41 | 38 | return ParagonIE_Sodium_Compat::crypto_stream_xchacha20_xor($message, $nonce, $key, true); |
42 | 39 | } |
43 | 40 | } |