Completed
Pull Request — develop (#1687)
by
unknown
16:12
created
vendor/paragonie/sodium_compat/lib/sodium_compat.php 1 patch
Indentation   +698 added lines, -698 removed lines patch added patch discarded remove patch
@@ -13,815 +13,815 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
vendor/paragonie/sodium_compat/lib/ristretto255.php 1 patch
Indentation   +194 added lines, -194 removed lines patch added patch discarded remove patch
@@ -1,239 +1,239 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
vendor/paragonie/sodium_compat/lib/namespaced.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 });
Please login to merge, or discard this patch.
vendor/paragonie/sodium_compat/lib/stream-xchacha20.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -1,43 +1,43 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
vendor/paragonie/sodium_compat/lib/php72compat.php 1 patch
Indentation   +1170 added lines, -1170 removed lines patch added patch discarded remove patch
@@ -10,1360 +10,1360 @@
 block discarded – undo
10 10
  * ParagonIE_Sodium_Compat method or class constant, respectively.
11 11
  */
12 12
 foreach (array(
13
-    'BASE64_VARIANT_ORIGINAL',
14
-    'BASE64_VARIANT_ORIGINAL_NO_PADDING',
15
-    'BASE64_VARIANT_URLSAFE',
16
-    'BASE64_VARIANT_URLSAFE_NO_PADDING',
17
-    'CRYPTO_AEAD_CHACHA20POLY1305_KEYBYTES',
18
-    'CRYPTO_AEAD_CHACHA20POLY1305_NSECBYTES',
19
-    'CRYPTO_AEAD_CHACHA20POLY1305_NPUBBYTES',
20
-    'CRYPTO_AEAD_CHACHA20POLY1305_ABYTES',
21
-    'CRYPTO_AEAD_AES256GCM_KEYBYTES',
22
-    'CRYPTO_AEAD_AES256GCM_NSECBYTES',
23
-    'CRYPTO_AEAD_AES256GCM_NPUBBYTES',
24
-    'CRYPTO_AEAD_AES256GCM_ABYTES',
25
-    'CRYPTO_AEAD_CHACHA20POLY1305_IETF_KEYBYTES',
26
-    'CRYPTO_AEAD_CHACHA20POLY1305_IETF_NSECBYTES',
27
-    'CRYPTO_AEAD_CHACHA20POLY1305_IETF_NPUBBYTES',
28
-    'CRYPTO_AEAD_CHACHA20POLY1305_IETF_ABYTES',
29
-    'CRYPTO_AEAD_XCHACHA20POLY1305_IETF_KEYBYTES',
30
-    'CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NSECBYTES',
31
-    'CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES',
32
-    'CRYPTO_AEAD_XCHACHA20POLY1305_IETF_ABYTES',
33
-    'CRYPTO_AUTH_BYTES',
34
-    'CRYPTO_AUTH_KEYBYTES',
35
-    'CRYPTO_BOX_SEALBYTES',
36
-    'CRYPTO_BOX_SECRETKEYBYTES',
37
-    'CRYPTO_BOX_PUBLICKEYBYTES',
38
-    'CRYPTO_BOX_KEYPAIRBYTES',
39
-    'CRYPTO_BOX_MACBYTES',
40
-    'CRYPTO_BOX_NONCEBYTES',
41
-    'CRYPTO_BOX_SEEDBYTES',
42
-    'CRYPTO_KDF_BYTES_MIN',
43
-    'CRYPTO_KDF_BYTES_MAX',
44
-    'CRYPTO_KDF_CONTEXTBYTES',
45
-    'CRYPTO_KDF_KEYBYTES',
46
-    'CRYPTO_KX_BYTES',
47
-    'CRYPTO_KX_KEYPAIRBYTES',
48
-    'CRYPTO_KX_PRIMITIVE',
49
-    'CRYPTO_KX_SEEDBYTES',
50
-    'CRYPTO_KX_PUBLICKEYBYTES',
51
-    'CRYPTO_KX_SECRETKEYBYTES',
52
-    'CRYPTO_KX_SESSIONKEYBYTES',
53
-    'CRYPTO_GENERICHASH_BYTES',
54
-    'CRYPTO_GENERICHASH_BYTES_MIN',
55
-    'CRYPTO_GENERICHASH_BYTES_MAX',
56
-    'CRYPTO_GENERICHASH_KEYBYTES',
57
-    'CRYPTO_GENERICHASH_KEYBYTES_MIN',
58
-    'CRYPTO_GENERICHASH_KEYBYTES_MAX',
59
-    'CRYPTO_PWHASH_SALTBYTES',
60
-    'CRYPTO_PWHASH_STRPREFIX',
61
-    'CRYPTO_PWHASH_ALG_ARGON2I13',
62
-    'CRYPTO_PWHASH_ALG_ARGON2ID13',
63
-    'CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE',
64
-    'CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE',
65
-    'CRYPTO_PWHASH_MEMLIMIT_MODERATE',
66
-    'CRYPTO_PWHASH_OPSLIMIT_MODERATE',
67
-    'CRYPTO_PWHASH_MEMLIMIT_SENSITIVE',
68
-    'CRYPTO_PWHASH_OPSLIMIT_SENSITIVE',
69
-    'CRYPTO_PWHASH_SCRYPTSALSA208SHA256_SALTBYTES',
70
-    'CRYPTO_PWHASH_SCRYPTSALSA208SHA256_STRPREFIX',
71
-    'CRYPTO_PWHASH_SCRYPTSALSA208SHA256_MEMLIMIT_INTERACTIVE',
72
-    'CRYPTO_PWHASH_SCRYPTSALSA208SHA256_OPSLIMIT_INTERACTIVE',
73
-    'CRYPTO_PWHASH_SCRYPTSALSA208SHA256_MEMLIMIT_SENSITIVE',
74
-    'CRYPTO_PWHASH_SCRYPTSALSA208SHA256_OPSLIMIT_SENSITIVE',
75
-    'CRYPTO_SCALARMULT_BYTES',
76
-    'CRYPTO_SCALARMULT_SCALARBYTES',
77
-    'CRYPTO_SHORTHASH_BYTES',
78
-    'CRYPTO_SHORTHASH_KEYBYTES',
79
-    'CRYPTO_SECRETBOX_KEYBYTES',
80
-    'CRYPTO_SECRETBOX_MACBYTES',
81
-    'CRYPTO_SECRETBOX_NONCEBYTES',
82
-    'CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_ABYTES',
83
-    'CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_HEADERBYTES',
84
-    'CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_KEYBYTES',
85
-    'CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_PUSH',
86
-    'CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_PULL',
87
-    'CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_REKEY',
88
-    'CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_FINAL',
89
-    'CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_MESSAGEBYTES_MAX',
90
-    'CRYPTO_SIGN_BYTES',
91
-    'CRYPTO_SIGN_SEEDBYTES',
92
-    'CRYPTO_SIGN_PUBLICKEYBYTES',
93
-    'CRYPTO_SIGN_SECRETKEYBYTES',
94
-    'CRYPTO_SIGN_KEYPAIRBYTES',
95
-    'CRYPTO_STREAM_KEYBYTES',
96
-    'CRYPTO_STREAM_NONCEBYTES',
97
-    'CRYPTO_STREAM_XCHACHA20_KEYBYTES',
98
-    'CRYPTO_STREAM_XCHACHA20_NONCEBYTES',
99
-    'LIBRARY_MAJOR_VERSION',
100
-    'LIBRARY_MINOR_VERSION',
101
-    'LIBRARY_VERSION_MAJOR',
102
-    'LIBRARY_VERSION_MINOR',
103
-    'VERSION_STRING'
104
-    ) as $constant
13
+	'BASE64_VARIANT_ORIGINAL',
14
+	'BASE64_VARIANT_ORIGINAL_NO_PADDING',
15
+	'BASE64_VARIANT_URLSAFE',
16
+	'BASE64_VARIANT_URLSAFE_NO_PADDING',
17
+	'CRYPTO_AEAD_CHACHA20POLY1305_KEYBYTES',
18
+	'CRYPTO_AEAD_CHACHA20POLY1305_NSECBYTES',
19
+	'CRYPTO_AEAD_CHACHA20POLY1305_NPUBBYTES',
20
+	'CRYPTO_AEAD_CHACHA20POLY1305_ABYTES',
21
+	'CRYPTO_AEAD_AES256GCM_KEYBYTES',
22
+	'CRYPTO_AEAD_AES256GCM_NSECBYTES',
23
+	'CRYPTO_AEAD_AES256GCM_NPUBBYTES',
24
+	'CRYPTO_AEAD_AES256GCM_ABYTES',
25
+	'CRYPTO_AEAD_CHACHA20POLY1305_IETF_KEYBYTES',
26
+	'CRYPTO_AEAD_CHACHA20POLY1305_IETF_NSECBYTES',
27
+	'CRYPTO_AEAD_CHACHA20POLY1305_IETF_NPUBBYTES',
28
+	'CRYPTO_AEAD_CHACHA20POLY1305_IETF_ABYTES',
29
+	'CRYPTO_AEAD_XCHACHA20POLY1305_IETF_KEYBYTES',
30
+	'CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NSECBYTES',
31
+	'CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES',
32
+	'CRYPTO_AEAD_XCHACHA20POLY1305_IETF_ABYTES',
33
+	'CRYPTO_AUTH_BYTES',
34
+	'CRYPTO_AUTH_KEYBYTES',
35
+	'CRYPTO_BOX_SEALBYTES',
36
+	'CRYPTO_BOX_SECRETKEYBYTES',
37
+	'CRYPTO_BOX_PUBLICKEYBYTES',
38
+	'CRYPTO_BOX_KEYPAIRBYTES',
39
+	'CRYPTO_BOX_MACBYTES',
40
+	'CRYPTO_BOX_NONCEBYTES',
41
+	'CRYPTO_BOX_SEEDBYTES',
42
+	'CRYPTO_KDF_BYTES_MIN',
43
+	'CRYPTO_KDF_BYTES_MAX',
44
+	'CRYPTO_KDF_CONTEXTBYTES',
45
+	'CRYPTO_KDF_KEYBYTES',
46
+	'CRYPTO_KX_BYTES',
47
+	'CRYPTO_KX_KEYPAIRBYTES',
48
+	'CRYPTO_KX_PRIMITIVE',
49
+	'CRYPTO_KX_SEEDBYTES',
50
+	'CRYPTO_KX_PUBLICKEYBYTES',
51
+	'CRYPTO_KX_SECRETKEYBYTES',
52
+	'CRYPTO_KX_SESSIONKEYBYTES',
53
+	'CRYPTO_GENERICHASH_BYTES',
54
+	'CRYPTO_GENERICHASH_BYTES_MIN',
55
+	'CRYPTO_GENERICHASH_BYTES_MAX',
56
+	'CRYPTO_GENERICHASH_KEYBYTES',
57
+	'CRYPTO_GENERICHASH_KEYBYTES_MIN',
58
+	'CRYPTO_GENERICHASH_KEYBYTES_MAX',
59
+	'CRYPTO_PWHASH_SALTBYTES',
60
+	'CRYPTO_PWHASH_STRPREFIX',
61
+	'CRYPTO_PWHASH_ALG_ARGON2I13',
62
+	'CRYPTO_PWHASH_ALG_ARGON2ID13',
63
+	'CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE',
64
+	'CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE',
65
+	'CRYPTO_PWHASH_MEMLIMIT_MODERATE',
66
+	'CRYPTO_PWHASH_OPSLIMIT_MODERATE',
67
+	'CRYPTO_PWHASH_MEMLIMIT_SENSITIVE',
68
+	'CRYPTO_PWHASH_OPSLIMIT_SENSITIVE',
69
+	'CRYPTO_PWHASH_SCRYPTSALSA208SHA256_SALTBYTES',
70
+	'CRYPTO_PWHASH_SCRYPTSALSA208SHA256_STRPREFIX',
71
+	'CRYPTO_PWHASH_SCRYPTSALSA208SHA256_MEMLIMIT_INTERACTIVE',
72
+	'CRYPTO_PWHASH_SCRYPTSALSA208SHA256_OPSLIMIT_INTERACTIVE',
73
+	'CRYPTO_PWHASH_SCRYPTSALSA208SHA256_MEMLIMIT_SENSITIVE',
74
+	'CRYPTO_PWHASH_SCRYPTSALSA208SHA256_OPSLIMIT_SENSITIVE',
75
+	'CRYPTO_SCALARMULT_BYTES',
76
+	'CRYPTO_SCALARMULT_SCALARBYTES',
77
+	'CRYPTO_SHORTHASH_BYTES',
78
+	'CRYPTO_SHORTHASH_KEYBYTES',
79
+	'CRYPTO_SECRETBOX_KEYBYTES',
80
+	'CRYPTO_SECRETBOX_MACBYTES',
81
+	'CRYPTO_SECRETBOX_NONCEBYTES',
82
+	'CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_ABYTES',
83
+	'CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_HEADERBYTES',
84
+	'CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_KEYBYTES',
85
+	'CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_PUSH',
86
+	'CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_PULL',
87
+	'CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_REKEY',
88
+	'CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_FINAL',
89
+	'CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_MESSAGEBYTES_MAX',
90
+	'CRYPTO_SIGN_BYTES',
91
+	'CRYPTO_SIGN_SEEDBYTES',
92
+	'CRYPTO_SIGN_PUBLICKEYBYTES',
93
+	'CRYPTO_SIGN_SECRETKEYBYTES',
94
+	'CRYPTO_SIGN_KEYPAIRBYTES',
95
+	'CRYPTO_STREAM_KEYBYTES',
96
+	'CRYPTO_STREAM_NONCEBYTES',
97
+	'CRYPTO_STREAM_XCHACHA20_KEYBYTES',
98
+	'CRYPTO_STREAM_XCHACHA20_NONCEBYTES',
99
+	'LIBRARY_MAJOR_VERSION',
100
+	'LIBRARY_MINOR_VERSION',
101
+	'LIBRARY_VERSION_MAJOR',
102
+	'LIBRARY_VERSION_MINOR',
103
+	'VERSION_STRING'
104
+	) as $constant
105 105
 ) {
106
-    if (!defined("SODIUM_$constant") && defined("ParagonIE_Sodium_Compat::$constant")) {
107
-        define("SODIUM_$constant", constant("ParagonIE_Sodium_Compat::$constant"));
108
-    }
106
+	if (!defined("SODIUM_$constant") && defined("ParagonIE_Sodium_Compat::$constant")) {
107
+		define("SODIUM_$constant", constant("ParagonIE_Sodium_Compat::$constant"));
108
+	}
109 109
 }
110 110
 if (!is_callable('sodium_add')) {
111
-    /**
112
-     * @see ParagonIE_Sodium_Compat::add()
113
-     * @param string $val
114
-     * @param string $addv
115
-     * @return void
116
-     * @throws SodiumException
117
-     */
118
-    function sodium_add(&$val, $addv)
119
-    {
120
-        ParagonIE_Sodium_Compat::add($val, $addv);
121
-    }
111
+	/**
112
+	 * @see ParagonIE_Sodium_Compat::add()
113
+	 * @param string $val
114
+	 * @param string $addv
115
+	 * @return void
116
+	 * @throws SodiumException
117
+	 */
118
+	function sodium_add(&$val, $addv)
119
+	{
120
+		ParagonIE_Sodium_Compat::add($val, $addv);
121
+	}
122 122
 }
123 123
 if (!is_callable('sodium_base642bin')) {
124
-    /**
125
-     * @see ParagonIE_Sodium_Compat::bin2base64()
126
-     * @param string $string
127
-     * @param int $variant
128
-     * @param string $ignore
129
-     * @return string
130
-     * @throws SodiumException
131
-     * @throws TypeError
132
-     */
133
-    function sodium_base642bin($string, $variant, $ignore ='')
134
-    {
135
-        return ParagonIE_Sodium_Compat::base642bin($string, $variant, $ignore);
136
-    }
124
+	/**
125
+	 * @see ParagonIE_Sodium_Compat::bin2base64()
126
+	 * @param string $string
127
+	 * @param int $variant
128
+	 * @param string $ignore
129
+	 * @return string
130
+	 * @throws SodiumException
131
+	 * @throws TypeError
132
+	 */
133
+	function sodium_base642bin($string, $variant, $ignore ='')
134
+	{
135
+		return ParagonIE_Sodium_Compat::base642bin($string, $variant, $ignore);
136
+	}
137 137
 }
138 138
 if (!is_callable('sodium_bin2base64')) {
139
-    /**
140
-     * @see ParagonIE_Sodium_Compat::bin2base64()
141
-     * @param string $string
142
-     * @param int $variant
143
-     * @return string
144
-     * @throws SodiumException
145
-     * @throws TypeError
146
-     */
147
-    function sodium_bin2base64($string, $variant)
148
-    {
149
-        return ParagonIE_Sodium_Compat::bin2base64($string, $variant);
150
-    }
139
+	/**
140
+	 * @see ParagonIE_Sodium_Compat::bin2base64()
141
+	 * @param string $string
142
+	 * @param int $variant
143
+	 * @return string
144
+	 * @throws SodiumException
145
+	 * @throws TypeError
146
+	 */
147
+	function sodium_bin2base64($string, $variant)
148
+	{
149
+		return ParagonIE_Sodium_Compat::bin2base64($string, $variant);
150
+	}
151 151
 }
152 152
 if (!is_callable('sodium_bin2hex')) {
153
-    /**
154
-     * @see ParagonIE_Sodium_Compat::hex2bin()
155
-     * @param string $string
156
-     * @return string
157
-     * @throws SodiumException
158
-     * @throws TypeError
159
-     */
160
-    function sodium_bin2hex($string)
161
-    {
162
-        return ParagonIE_Sodium_Compat::bin2hex($string);
163
-    }
153
+	/**
154
+	 * @see ParagonIE_Sodium_Compat::hex2bin()
155
+	 * @param string $string
156
+	 * @return string
157
+	 * @throws SodiumException
158
+	 * @throws TypeError
159
+	 */
160
+	function sodium_bin2hex($string)
161
+	{
162
+		return ParagonIE_Sodium_Compat::bin2hex($string);
163
+	}
164 164
 }
165 165
 if (!is_callable('sodium_compare')) {
166
-    /**
167
-     * @see ParagonIE_Sodium_Compat::compare()
168
-     * @param string $a
169
-     * @param string $b
170
-     * @return int
171
-     * @throws SodiumException
172
-     * @throws TypeError
173
-     */
174
-    function sodium_compare($a, $b)
175
-    {
176
-        return ParagonIE_Sodium_Compat::compare($a, $b);
177
-    }
166
+	/**
167
+	 * @see ParagonIE_Sodium_Compat::compare()
168
+	 * @param string $a
169
+	 * @param string $b
170
+	 * @return int
171
+	 * @throws SodiumException
172
+	 * @throws TypeError
173
+	 */
174
+	function sodium_compare($a, $b)
175
+	{
176
+		return ParagonIE_Sodium_Compat::compare($a, $b);
177
+	}
178 178
 }
179 179
 if (!is_callable('sodium_crypto_aead_aes256gcm_decrypt')) {
180
-    /**
181
-     * @see ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_decrypt()
182
-     * @param string $message
183
-     * @param string $assocData
184
-     * @param string $nonce
185
-     * @param string $key
186
-     * @return string|bool
187
-     */
188
-    function sodium_crypto_aead_aes256gcm_decrypt($message, $assocData, $nonce, $key)
189
-    {
190
-        try {
191
-            return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_decrypt($message, $assocData, $nonce, $key);
192
-        } catch (Error $ex) {
193
-            return false;
194
-        } catch (Exception $ex) {
195
-            return false;
196
-        }
197
-    }
180
+	/**
181
+	 * @see ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_decrypt()
182
+	 * @param string $message
183
+	 * @param string $assocData
184
+	 * @param string $nonce
185
+	 * @param string $key
186
+	 * @return string|bool
187
+	 */
188
+	function sodium_crypto_aead_aes256gcm_decrypt($message, $assocData, $nonce, $key)
189
+	{
190
+		try {
191
+			return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_decrypt($message, $assocData, $nonce, $key);
192
+		} catch (Error $ex) {
193
+			return false;
194
+		} catch (Exception $ex) {
195
+			return false;
196
+		}
197
+	}
198 198
 }
199 199
 if (!is_callable('sodium_crypto_aead_aes256gcm_encrypt')) {
200
-    /**
201
-     * @see ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_encrypt()
202
-     * @param string $message
203
-     * @param string $assocData
204
-     * @param string $nonce
205
-     * @param string $key
206
-     * @return string
207
-     * @throws SodiumException
208
-     * @throws TypeError
209
-     */
210
-    function sodium_crypto_aead_aes256gcm_encrypt($message, $assocData, $nonce, $key)
211
-    {
212
-        return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_encrypt($message, $assocData, $nonce, $key);
213
-    }
200
+	/**
201
+	 * @see ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_encrypt()
202
+	 * @param string $message
203
+	 * @param string $assocData
204
+	 * @param string $nonce
205
+	 * @param string $key
206
+	 * @return string
207
+	 * @throws SodiumException
208
+	 * @throws TypeError
209
+	 */
210
+	function sodium_crypto_aead_aes256gcm_encrypt($message, $assocData, $nonce, $key)
211
+	{
212
+		return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_encrypt($message, $assocData, $nonce, $key);
213
+	}
214 214
 }
215 215
 if (!is_callable('sodium_crypto_aead_aes256gcm_is_available')) {
216
-    /**
217
-     * @see ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_is_available()
218
-     * @return bool
219
-     */
220
-    function sodium_crypto_aead_aes256gcm_is_available()
221
-    {
222
-        return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_is_available();
223
-    }
216
+	/**
217
+	 * @see ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_is_available()
218
+	 * @return bool
219
+	 */
220
+	function sodium_crypto_aead_aes256gcm_is_available()
221
+	{
222
+		return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_is_available();
223
+	}
224 224
 }
225 225
 if (!is_callable('sodium_crypto_aead_chacha20poly1305_decrypt')) {
226
-    /**
227
-     * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_decrypt()
228
-     * @param string $message
229
-     * @param string $assocData
230
-     * @param string $nonce
231
-     * @param string $key
232
-     * @return string|bool
233
-     */
234
-    function sodium_crypto_aead_chacha20poly1305_decrypt($message, $assocData, $nonce, $key)
235
-    {
236
-        try {
237
-            return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_decrypt($message, $assocData, $nonce, $key);
238
-        } catch (Error $ex) {
239
-            return false;
240
-        } catch (Exception $ex) {
241
-            return false;
242
-        }
243
-    }
226
+	/**
227
+	 * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_decrypt()
228
+	 * @param string $message
229
+	 * @param string $assocData
230
+	 * @param string $nonce
231
+	 * @param string $key
232
+	 * @return string|bool
233
+	 */
234
+	function sodium_crypto_aead_chacha20poly1305_decrypt($message, $assocData, $nonce, $key)
235
+	{
236
+		try {
237
+			return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_decrypt($message, $assocData, $nonce, $key);
238
+		} catch (Error $ex) {
239
+			return false;
240
+		} catch (Exception $ex) {
241
+			return false;
242
+		}
243
+	}
244 244
 }
245 245
 if (!is_callable('sodium_crypto_aead_chacha20poly1305_encrypt')) {
246
-    /**
247
-     * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_encrypt()
248
-     * @param string $message
249
-     * @param string $assocData
250
-     * @param string $nonce
251
-     * @param string $key
252
-     * @return string
253
-     * @throws SodiumException
254
-     * @throws TypeError
255
-     */
256
-    function sodium_crypto_aead_chacha20poly1305_encrypt($message, $assocData, $nonce, $key)
257
-    {
258
-        return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_encrypt($message, $assocData, $nonce, $key);
259
-    }
246
+	/**
247
+	 * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_encrypt()
248
+	 * @param string $message
249
+	 * @param string $assocData
250
+	 * @param string $nonce
251
+	 * @param string $key
252
+	 * @return string
253
+	 * @throws SodiumException
254
+	 * @throws TypeError
255
+	 */
256
+	function sodium_crypto_aead_chacha20poly1305_encrypt($message, $assocData, $nonce, $key)
257
+	{
258
+		return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_encrypt($message, $assocData, $nonce, $key);
259
+	}
260 260
 }
261 261
 if (!is_callable('sodium_crypto_aead_chacha20poly1305_keygen')) {
262
-    /**
263
-     * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_keygen()
264
-     * @return string
265
-     * @throws Exception
266
-     */
267
-    function sodium_crypto_aead_chacha20poly1305_keygen()
268
-    {
269
-        return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_keygen();
270
-    }
262
+	/**
263
+	 * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_keygen()
264
+	 * @return string
265
+	 * @throws Exception
266
+	 */
267
+	function sodium_crypto_aead_chacha20poly1305_keygen()
268
+	{
269
+		return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_keygen();
270
+	}
271 271
 }
272 272
 if (!is_callable('sodium_crypto_aead_chacha20poly1305_ietf_decrypt')) {
273
-    /**
274
-     * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_decrypt()
275
-     * @param string $message
276
-     * @param string $assocData
277
-     * @param string $nonce
278
-     * @param string $key
279
-     * @return string|bool
280
-     */
281
-    function sodium_crypto_aead_chacha20poly1305_ietf_decrypt($message, $assocData, $nonce, $key)
282
-    {
283
-        try {
284
-            return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_decrypt($message, $assocData, $nonce, $key);
285
-        } catch (Error $ex) {
286
-            return false;
287
-        } catch (Exception $ex) {
288
-            return false;
289
-        }
290
-    }
273
+	/**
274
+	 * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_decrypt()
275
+	 * @param string $message
276
+	 * @param string $assocData
277
+	 * @param string $nonce
278
+	 * @param string $key
279
+	 * @return string|bool
280
+	 */
281
+	function sodium_crypto_aead_chacha20poly1305_ietf_decrypt($message, $assocData, $nonce, $key)
282
+	{
283
+		try {
284
+			return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_decrypt($message, $assocData, $nonce, $key);
285
+		} catch (Error $ex) {
286
+			return false;
287
+		} catch (Exception $ex) {
288
+			return false;
289
+		}
290
+	}
291 291
 }
292 292
 if (!is_callable('sodium_crypto_aead_chacha20poly1305_ietf_encrypt')) {
293
-    /**
294
-     * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_encrypt()
295
-     * @param string $message
296
-     * @param string $assocData
297
-     * @param string $nonce
298
-     * @param string $key
299
-     * @return string
300
-     * @throws SodiumException
301
-     * @throws TypeError
302
-     */
303
-    function sodium_crypto_aead_chacha20poly1305_ietf_encrypt($message, $assocData, $nonce, $key)
304
-    {
305
-        return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_encrypt($message, $assocData, $nonce, $key);
306
-    }
293
+	/**
294
+	 * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_encrypt()
295
+	 * @param string $message
296
+	 * @param string $assocData
297
+	 * @param string $nonce
298
+	 * @param string $key
299
+	 * @return string
300
+	 * @throws SodiumException
301
+	 * @throws TypeError
302
+	 */
303
+	function sodium_crypto_aead_chacha20poly1305_ietf_encrypt($message, $assocData, $nonce, $key)
304
+	{
305
+		return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_encrypt($message, $assocData, $nonce, $key);
306
+	}
307 307
 }
308 308
 if (!is_callable('sodium_crypto_aead_chacha20poly1305_ietf_keygen')) {
309
-    /**
310
-     * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_keygen()
311
-     * @return string
312
-     * @throws Exception
313
-     */
314
-    function sodium_crypto_aead_chacha20poly1305_ietf_keygen()
315
-    {
316
-        return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_keygen();
317
-    }
309
+	/**
310
+	 * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_keygen()
311
+	 * @return string
312
+	 * @throws Exception
313
+	 */
314
+	function sodium_crypto_aead_chacha20poly1305_ietf_keygen()
315
+	{
316
+		return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_keygen();
317
+	}
318 318
 }
319 319
 if (!is_callable('sodium_crypto_aead_xchacha20poly1305_ietf_decrypt')) {
320
-    /**
321
-     * @see ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_decrypt()
322
-     * @param string $message
323
-     * @param string $assocData
324
-     * @param string $nonce
325
-     * @param string $key
326
-     * @return string|bool
327
-     */
328
-    function sodium_crypto_aead_xchacha20poly1305_ietf_decrypt($message, $assocData, $nonce, $key)
329
-    {
330
-        try {
331
-            return ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_decrypt($message, $assocData, $nonce, $key, true);
332
-        } catch (Error $ex) {
333
-            return false;
334
-        } catch (Exception $ex) {
335
-            return false;
336
-        }
337
-    }
320
+	/**
321
+	 * @see ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_decrypt()
322
+	 * @param string $message
323
+	 * @param string $assocData
324
+	 * @param string $nonce
325
+	 * @param string $key
326
+	 * @return string|bool
327
+	 */
328
+	function sodium_crypto_aead_xchacha20poly1305_ietf_decrypt($message, $assocData, $nonce, $key)
329
+	{
330
+		try {
331
+			return ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_decrypt($message, $assocData, $nonce, $key, true);
332
+		} catch (Error $ex) {
333
+			return false;
334
+		} catch (Exception $ex) {
335
+			return false;
336
+		}
337
+	}
338 338
 }
339 339
 if (!is_callable('sodium_crypto_aead_xchacha20poly1305_ietf_encrypt')) {
340
-    /**
341
-     * @see ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_encrypt()
342
-     * @param string $message
343
-     * @param string $assocData
344
-     * @param string $nonce
345
-     * @param string $key
346
-     * @return string
347
-     * @throws SodiumException
348
-     * @throws TypeError
349
-     */
350
-    function sodium_crypto_aead_xchacha20poly1305_ietf_encrypt($message, $assocData, $nonce, $key)
351
-    {
352
-        return ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_encrypt($message, $assocData, $nonce, $key, true);
353
-    }
340
+	/**
341
+	 * @see ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_encrypt()
342
+	 * @param string $message
343
+	 * @param string $assocData
344
+	 * @param string $nonce
345
+	 * @param string $key
346
+	 * @return string
347
+	 * @throws SodiumException
348
+	 * @throws TypeError
349
+	 */
350
+	function sodium_crypto_aead_xchacha20poly1305_ietf_encrypt($message, $assocData, $nonce, $key)
351
+	{
352
+		return ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_encrypt($message, $assocData, $nonce, $key, true);
353
+	}
354 354
 }
355 355
 if (!is_callable('sodium_crypto_aead_xchacha20poly1305_ietf_keygen')) {
356
-    /**
357
-     * @see ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_keygen()
358
-     * @return string
359
-     * @throws Exception
360
-     */
361
-    function sodium_crypto_aead_xchacha20poly1305_ietf_keygen()
362
-    {
363
-        return ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_keygen();
364
-    }
356
+	/**
357
+	 * @see ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_keygen()
358
+	 * @return string
359
+	 * @throws Exception
360
+	 */
361
+	function sodium_crypto_aead_xchacha20poly1305_ietf_keygen()
362
+	{
363
+		return ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_keygen();
364
+	}
365 365
 }
366 366
 if (!is_callable('sodium_crypto_auth')) {
367
-    /**
368
-     * @see ParagonIE_Sodium_Compat::crypto_auth()
369
-     * @param string $message
370
-     * @param string $key
371
-     * @return string
372
-     * @throws SodiumException
373
-     * @throws TypeError
374
-     */
375
-    function sodium_crypto_auth($message, $key)
376
-    {
377
-        return ParagonIE_Sodium_Compat::crypto_auth($message, $key);
378
-    }
367
+	/**
368
+	 * @see ParagonIE_Sodium_Compat::crypto_auth()
369
+	 * @param string $message
370
+	 * @param string $key
371
+	 * @return string
372
+	 * @throws SodiumException
373
+	 * @throws TypeError
374
+	 */
375
+	function sodium_crypto_auth($message, $key)
376
+	{
377
+		return ParagonIE_Sodium_Compat::crypto_auth($message, $key);
378
+	}
379 379
 }
380 380
 if (!is_callable('sodium_crypto_auth_keygen')) {
381
-    /**
382
-     * @see ParagonIE_Sodium_Compat::crypto_auth_keygen()
383
-     * @return string
384
-     * @throws Exception
385
-     */
386
-    function sodium_crypto_auth_keygen()
387
-    {
388
-        return ParagonIE_Sodium_Compat::crypto_auth_keygen();
389
-    }
381
+	/**
382
+	 * @see ParagonIE_Sodium_Compat::crypto_auth_keygen()
383
+	 * @return string
384
+	 * @throws Exception
385
+	 */
386
+	function sodium_crypto_auth_keygen()
387
+	{
388
+		return ParagonIE_Sodium_Compat::crypto_auth_keygen();
389
+	}
390 390
 }
391 391
 if (!is_callable('sodium_crypto_auth_verify')) {
392
-    /**
393
-     * @see ParagonIE_Sodium_Compat::crypto_auth_verify()
394
-     * @param string $mac
395
-     * @param string $message
396
-     * @param string $key
397
-     * @return bool
398
-     * @throws SodiumException
399
-     * @throws TypeError
400
-     */
401
-    function sodium_crypto_auth_verify($mac, $message, $key)
402
-    {
403
-        return ParagonIE_Sodium_Compat::crypto_auth_verify($mac, $message, $key);
404
-    }
392
+	/**
393
+	 * @see ParagonIE_Sodium_Compat::crypto_auth_verify()
394
+	 * @param string $mac
395
+	 * @param string $message
396
+	 * @param string $key
397
+	 * @return bool
398
+	 * @throws SodiumException
399
+	 * @throws TypeError
400
+	 */
401
+	function sodium_crypto_auth_verify($mac, $message, $key)
402
+	{
403
+		return ParagonIE_Sodium_Compat::crypto_auth_verify($mac, $message, $key);
404
+	}
405 405
 }
406 406
 if (!is_callable('sodium_crypto_box')) {
407
-    /**
408
-     * @see ParagonIE_Sodium_Compat::crypto_box()
409
-     * @param string $message
410
-     * @param string $nonce
411
-     * @param string $kp
412
-     * @return string
413
-     * @throws SodiumException
414
-     * @throws TypeError
415
-     */
416
-    function sodium_crypto_box($message, $nonce, $kp)
417
-    {
418
-        return ParagonIE_Sodium_Compat::crypto_box($message, $nonce, $kp);
419
-    }
407
+	/**
408
+	 * @see ParagonIE_Sodium_Compat::crypto_box()
409
+	 * @param string $message
410
+	 * @param string $nonce
411
+	 * @param string $kp
412
+	 * @return string
413
+	 * @throws SodiumException
414
+	 * @throws TypeError
415
+	 */
416
+	function sodium_crypto_box($message, $nonce, $kp)
417
+	{
418
+		return ParagonIE_Sodium_Compat::crypto_box($message, $nonce, $kp);
419
+	}
420 420
 }
421 421
 if (!is_callable('sodium_crypto_box_keypair')) {
422
-    /**
423
-     * @see ParagonIE_Sodium_Compat::crypto_box_keypair()
424
-     * @return string
425
-     * @throws SodiumException
426
-     * @throws TypeError
427
-     */
428
-    function sodium_crypto_box_keypair()
429
-    {
430
-        return ParagonIE_Sodium_Compat::crypto_box_keypair();
431
-    }
422
+	/**
423
+	 * @see ParagonIE_Sodium_Compat::crypto_box_keypair()
424
+	 * @return string
425
+	 * @throws SodiumException
426
+	 * @throws TypeError
427
+	 */
428
+	function sodium_crypto_box_keypair()
429
+	{
430
+		return ParagonIE_Sodium_Compat::crypto_box_keypair();
431
+	}
432 432
 }
433 433
 if (!is_callable('sodium_crypto_box_keypair_from_secretkey_and_publickey')) {
434
-    /**
435
-     * @see ParagonIE_Sodium_Compat::crypto_box_keypair_from_secretkey_and_publickey()
436
-     * @param string $sk
437
-     * @param string $pk
438
-     * @return string
439
-     * @throws SodiumException
440
-     * @throws TypeError
441
-     */
442
-    function sodium_crypto_box_keypair_from_secretkey_and_publickey($sk, $pk)
443
-    {
444
-        return ParagonIE_Sodium_Compat::crypto_box_keypair_from_secretkey_and_publickey($sk, $pk);
445
-    }
434
+	/**
435
+	 * @see ParagonIE_Sodium_Compat::crypto_box_keypair_from_secretkey_and_publickey()
436
+	 * @param string $sk
437
+	 * @param string $pk
438
+	 * @return string
439
+	 * @throws SodiumException
440
+	 * @throws TypeError
441
+	 */
442
+	function sodium_crypto_box_keypair_from_secretkey_and_publickey($sk, $pk)
443
+	{
444
+		return ParagonIE_Sodium_Compat::crypto_box_keypair_from_secretkey_and_publickey($sk, $pk);
445
+	}
446 446
 }
447 447
 if (!is_callable('sodium_crypto_box_open')) {
448
-    /**
449
-     * @see ParagonIE_Sodium_Compat::crypto_box_open()
450
-     * @param string $message
451
-     * @param string $nonce
452
-     * @param string $kp
453
-     * @return string|bool
454
-     */
455
-    function sodium_crypto_box_open($message, $nonce, $kp)
456
-    {
457
-        try {
458
-            return ParagonIE_Sodium_Compat::crypto_box_open($message, $nonce, $kp);
459
-        } catch (Error $ex) {
460
-            return false;
461
-        } catch (Exception $ex) {
462
-            return false;
463
-        }
464
-    }
448
+	/**
449
+	 * @see ParagonIE_Sodium_Compat::crypto_box_open()
450
+	 * @param string $message
451
+	 * @param string $nonce
452
+	 * @param string $kp
453
+	 * @return string|bool
454
+	 */
455
+	function sodium_crypto_box_open($message, $nonce, $kp)
456
+	{
457
+		try {
458
+			return ParagonIE_Sodium_Compat::crypto_box_open($message, $nonce, $kp);
459
+		} catch (Error $ex) {
460
+			return false;
461
+		} catch (Exception $ex) {
462
+			return false;
463
+		}
464
+	}
465 465
 }
466 466
 if (!is_callable('sodium_crypto_box_publickey')) {
467
-    /**
468
-     * @see ParagonIE_Sodium_Compat::crypto_box_publickey()
469
-     * @param string $keypair
470
-     * @return string
471
-     * @throws SodiumException
472
-     * @throws TypeError
473
-     */
474
-    function sodium_crypto_box_publickey($keypair)
475
-    {
476
-        return ParagonIE_Sodium_Compat::crypto_box_publickey($keypair);
477
-    }
467
+	/**
468
+	 * @see ParagonIE_Sodium_Compat::crypto_box_publickey()
469
+	 * @param string $keypair
470
+	 * @return string
471
+	 * @throws SodiumException
472
+	 * @throws TypeError
473
+	 */
474
+	function sodium_crypto_box_publickey($keypair)
475
+	{
476
+		return ParagonIE_Sodium_Compat::crypto_box_publickey($keypair);
477
+	}
478 478
 }
479 479
 if (!is_callable('sodium_crypto_box_publickey_from_secretkey')) {
480
-    /**
481
-     * @see ParagonIE_Sodium_Compat::crypto_box_publickey_from_secretkey()
482
-     * @param string $sk
483
-     * @return string
484
-     * @throws SodiumException
485
-     * @throws TypeError
486
-     */
487
-    function sodium_crypto_box_publickey_from_secretkey($sk)
488
-    {
489
-        return ParagonIE_Sodium_Compat::crypto_box_publickey_from_secretkey($sk);
490
-    }
480
+	/**
481
+	 * @see ParagonIE_Sodium_Compat::crypto_box_publickey_from_secretkey()
482
+	 * @param string $sk
483
+	 * @return string
484
+	 * @throws SodiumException
485
+	 * @throws TypeError
486
+	 */
487
+	function sodium_crypto_box_publickey_from_secretkey($sk)
488
+	{
489
+		return ParagonIE_Sodium_Compat::crypto_box_publickey_from_secretkey($sk);
490
+	}
491 491
 }
492 492
 if (!is_callable('sodium_crypto_box_seal')) {
493
-    /**
494
-     * @see ParagonIE_Sodium_Compat::crypto_box_seal()
495
-     * @param string $message
496
-     * @param string $publicKey
497
-     * @return string
498
-     * @throws SodiumException
499
-     * @throws TypeError
500
-     */
501
-    function sodium_crypto_box_seal($message, $publicKey)
502
-    {
503
-        return ParagonIE_Sodium_Compat::crypto_box_seal($message, $publicKey);
504
-    }
493
+	/**
494
+	 * @see ParagonIE_Sodium_Compat::crypto_box_seal()
495
+	 * @param string $message
496
+	 * @param string $publicKey
497
+	 * @return string
498
+	 * @throws SodiumException
499
+	 * @throws TypeError
500
+	 */
501
+	function sodium_crypto_box_seal($message, $publicKey)
502
+	{
503
+		return ParagonIE_Sodium_Compat::crypto_box_seal($message, $publicKey);
504
+	}
505 505
 }
506 506
 if (!is_callable('sodium_crypto_box_seal_open')) {
507
-    /**
508
-     * @see ParagonIE_Sodium_Compat::crypto_box_seal_open()
509
-     * @param string $message
510
-     * @param string $kp
511
-     * @return string|bool
512
-     * @throws SodiumException
513
-     */
514
-    function sodium_crypto_box_seal_open($message, $kp)
515
-    {
516
-        try {
517
-            return ParagonIE_Sodium_Compat::crypto_box_seal_open($message, $kp);
518
-        } catch (SodiumException $ex) {
519
-            if ($ex->getMessage() === 'Argument 2 must be CRYPTO_BOX_KEYPAIRBYTES long.') {
520
-                throw $ex;
521
-            }
522
-            return false;
523
-        }
524
-    }
507
+	/**
508
+	 * @see ParagonIE_Sodium_Compat::crypto_box_seal_open()
509
+	 * @param string $message
510
+	 * @param string $kp
511
+	 * @return string|bool
512
+	 * @throws SodiumException
513
+	 */
514
+	function sodium_crypto_box_seal_open($message, $kp)
515
+	{
516
+		try {
517
+			return ParagonIE_Sodium_Compat::crypto_box_seal_open($message, $kp);
518
+		} catch (SodiumException $ex) {
519
+			if ($ex->getMessage() === 'Argument 2 must be CRYPTO_BOX_KEYPAIRBYTES long.') {
520
+				throw $ex;
521
+			}
522
+			return false;
523
+		}
524
+	}
525 525
 }
526 526
 if (!is_callable('sodium_crypto_box_secretkey')) {
527
-    /**
528
-     * @see ParagonIE_Sodium_Compat::crypto_box_secretkey()
529
-     * @param string $keypair
530
-     * @return string
531
-     * @throws SodiumException
532
-     * @throws TypeError
533
-     */
534
-    function sodium_crypto_box_secretkey($keypair)
535
-    {
536
-        return ParagonIE_Sodium_Compat::crypto_box_secretkey($keypair);
537
-    }
527
+	/**
528
+	 * @see ParagonIE_Sodium_Compat::crypto_box_secretkey()
529
+	 * @param string $keypair
530
+	 * @return string
531
+	 * @throws SodiumException
532
+	 * @throws TypeError
533
+	 */
534
+	function sodium_crypto_box_secretkey($keypair)
535
+	{
536
+		return ParagonIE_Sodium_Compat::crypto_box_secretkey($keypair);
537
+	}
538 538
 }
539 539
 if (!is_callable('sodium_crypto_box_seed_keypair')) {
540
-    /**
541
-     * @see ParagonIE_Sodium_Compat::crypto_box_seed_keypair()
542
-     * @param string $seed
543
-     * @return string
544
-     * @throws SodiumException
545
-     * @throws TypeError
546
-     */
547
-    function sodium_crypto_box_seed_keypair($seed)
548
-    {
549
-        return ParagonIE_Sodium_Compat::crypto_box_seed_keypair($seed);
550
-    }
540
+	/**
541
+	 * @see ParagonIE_Sodium_Compat::crypto_box_seed_keypair()
542
+	 * @param string $seed
543
+	 * @return string
544
+	 * @throws SodiumException
545
+	 * @throws TypeError
546
+	 */
547
+	function sodium_crypto_box_seed_keypair($seed)
548
+	{
549
+		return ParagonIE_Sodium_Compat::crypto_box_seed_keypair($seed);
550
+	}
551 551
 }
552 552
 if (!is_callable('sodium_crypto_generichash')) {
553
-    /**
554
-     * @see ParagonIE_Sodium_Compat::crypto_generichash()
555
-     * @param string $message
556
-     * @param string|null $key
557
-     * @param int $outLen
558
-     * @return string
559
-     * @throws SodiumException
560
-     * @throws TypeError
561
-     */
562
-    function sodium_crypto_generichash($message, $key = null, $outLen = 32)
563
-    {
564
-        return ParagonIE_Sodium_Compat::crypto_generichash($message, $key, $outLen);
565
-    }
553
+	/**
554
+	 * @see ParagonIE_Sodium_Compat::crypto_generichash()
555
+	 * @param string $message
556
+	 * @param string|null $key
557
+	 * @param int $outLen
558
+	 * @return string
559
+	 * @throws SodiumException
560
+	 * @throws TypeError
561
+	 */
562
+	function sodium_crypto_generichash($message, $key = null, $outLen = 32)
563
+	{
564
+		return ParagonIE_Sodium_Compat::crypto_generichash($message, $key, $outLen);
565
+	}
566 566
 }
567 567
 if (!is_callable('sodium_crypto_generichash_final')) {
568
-    /**
569
-     * @see ParagonIE_Sodium_Compat::crypto_generichash_final()
570
-     * @param string|null $ctx
571
-     * @param int $outputLength
572
-     * @return string
573
-     * @throws SodiumException
574
-     * @throws TypeError
575
-     */
576
-    function sodium_crypto_generichash_final(&$ctx, $outputLength = 32)
577
-    {
578
-        return ParagonIE_Sodium_Compat::crypto_generichash_final($ctx, $outputLength);
579
-    }
568
+	/**
569
+	 * @see ParagonIE_Sodium_Compat::crypto_generichash_final()
570
+	 * @param string|null $ctx
571
+	 * @param int $outputLength
572
+	 * @return string
573
+	 * @throws SodiumException
574
+	 * @throws TypeError
575
+	 */
576
+	function sodium_crypto_generichash_final(&$ctx, $outputLength = 32)
577
+	{
578
+		return ParagonIE_Sodium_Compat::crypto_generichash_final($ctx, $outputLength);
579
+	}
580 580
 }
581 581
 if (!is_callable('sodium_crypto_generichash_init')) {
582
-    /**
583
-     * @see ParagonIE_Sodium_Compat::crypto_generichash_init()
584
-     * @param string|null $key
585
-     * @param int $outLen
586
-     * @return string
587
-     * @throws SodiumException
588
-     * @throws TypeError
589
-     */
590
-    function sodium_crypto_generichash_init($key = null, $outLen = 32)
591
-    {
592
-        return ParagonIE_Sodium_Compat::crypto_generichash_init($key, $outLen);
593
-    }
582
+	/**
583
+	 * @see ParagonIE_Sodium_Compat::crypto_generichash_init()
584
+	 * @param string|null $key
585
+	 * @param int $outLen
586
+	 * @return string
587
+	 * @throws SodiumException
588
+	 * @throws TypeError
589
+	 */
590
+	function sodium_crypto_generichash_init($key = null, $outLen = 32)
591
+	{
592
+		return ParagonIE_Sodium_Compat::crypto_generichash_init($key, $outLen);
593
+	}
594 594
 }
595 595
 if (!is_callable('sodium_crypto_generichash_keygen')) {
596
-    /**
597
-     * @see ParagonIE_Sodium_Compat::crypto_generichash_keygen()
598
-     * @return string
599
-     * @throws Exception
600
-     */
601
-    function sodium_crypto_generichash_keygen()
602
-    {
603
-        return ParagonIE_Sodium_Compat::crypto_generichash_keygen();
604
-    }
596
+	/**
597
+	 * @see ParagonIE_Sodium_Compat::crypto_generichash_keygen()
598
+	 * @return string
599
+	 * @throws Exception
600
+	 */
601
+	function sodium_crypto_generichash_keygen()
602
+	{
603
+		return ParagonIE_Sodium_Compat::crypto_generichash_keygen();
604
+	}
605 605
 }
606 606
 if (!is_callable('sodium_crypto_generichash_update')) {
607
-    /**
608
-     * @see ParagonIE_Sodium_Compat::crypto_generichash_update()
609
-     * @param string|null $ctx
610
-     * @param string $message
611
-     * @return void
612
-     * @throws SodiumException
613
-     * @throws TypeError
614
-     */
615
-    function sodium_crypto_generichash_update(&$ctx, $message = '')
616
-    {
617
-        ParagonIE_Sodium_Compat::crypto_generichash_update($ctx, $message);
618
-    }
607
+	/**
608
+	 * @see ParagonIE_Sodium_Compat::crypto_generichash_update()
609
+	 * @param string|null $ctx
610
+	 * @param string $message
611
+	 * @return void
612
+	 * @throws SodiumException
613
+	 * @throws TypeError
614
+	 */
615
+	function sodium_crypto_generichash_update(&$ctx, $message = '')
616
+	{
617
+		ParagonIE_Sodium_Compat::crypto_generichash_update($ctx, $message);
618
+	}
619 619
 }
620 620
 if (!is_callable('sodium_crypto_kdf_keygen')) {
621
-    /**
622
-     * @see ParagonIE_Sodium_Compat::crypto_kdf_keygen()
623
-     * @return string
624
-     * @throws Exception
625
-     */
626
-    function sodium_crypto_kdf_keygen()
627
-    {
628
-        return ParagonIE_Sodium_Compat::crypto_kdf_keygen();
629
-    }
621
+	/**
622
+	 * @see ParagonIE_Sodium_Compat::crypto_kdf_keygen()
623
+	 * @return string
624
+	 * @throws Exception
625
+	 */
626
+	function sodium_crypto_kdf_keygen()
627
+	{
628
+		return ParagonIE_Sodium_Compat::crypto_kdf_keygen();
629
+	}
630 630
 }
631 631
 if (!is_callable('sodium_crypto_kdf_derive_from_key')) {
632
-    /**
633
-     * @see ParagonIE_Sodium_Compat::crypto_kdf_derive_from_key()
634
-     * @param int $subkey_len
635
-     * @param int $subkey_id
636
-     * @param string $context
637
-     * @param string $key
638
-     * @return string
639
-     * @throws Exception
640
-     */
641
-    function sodium_crypto_kdf_derive_from_key($subkey_len, $subkey_id, $context, $key)
642
-    {
643
-        return ParagonIE_Sodium_Compat::crypto_kdf_derive_from_key(
644
-            $subkey_len,
645
-            $subkey_id,
646
-            $context,
647
-            $key
648
-        );
649
-    }
632
+	/**
633
+	 * @see ParagonIE_Sodium_Compat::crypto_kdf_derive_from_key()
634
+	 * @param int $subkey_len
635
+	 * @param int $subkey_id
636
+	 * @param string $context
637
+	 * @param string $key
638
+	 * @return string
639
+	 * @throws Exception
640
+	 */
641
+	function sodium_crypto_kdf_derive_from_key($subkey_len, $subkey_id, $context, $key)
642
+	{
643
+		return ParagonIE_Sodium_Compat::crypto_kdf_derive_from_key(
644
+			$subkey_len,
645
+			$subkey_id,
646
+			$context,
647
+			$key
648
+		);
649
+	}
650 650
 }
651 651
 if (!is_callable('sodium_crypto_kx')) {
652
-    /**
653
-     * @see ParagonIE_Sodium_Compat::crypto_kx()
654
-     * @param string $my_secret
655
-     * @param string $their_public
656
-     * @param string $client_public
657
-     * @param string $server_public
658
-     * @return string
659
-     * @throws SodiumException
660
-     * @throws TypeError
661
-     */
662
-    function sodium_crypto_kx($my_secret, $their_public, $client_public, $server_public)
663
-    {
664
-        return ParagonIE_Sodium_Compat::crypto_kx(
665
-            $my_secret,
666
-            $their_public,
667
-            $client_public,
668
-            $server_public
669
-        );
670
-    }
652
+	/**
653
+	 * @see ParagonIE_Sodium_Compat::crypto_kx()
654
+	 * @param string $my_secret
655
+	 * @param string $their_public
656
+	 * @param string $client_public
657
+	 * @param string $server_public
658
+	 * @return string
659
+	 * @throws SodiumException
660
+	 * @throws TypeError
661
+	 */
662
+	function sodium_crypto_kx($my_secret, $their_public, $client_public, $server_public)
663
+	{
664
+		return ParagonIE_Sodium_Compat::crypto_kx(
665
+			$my_secret,
666
+			$their_public,
667
+			$client_public,
668
+			$server_public
669
+		);
670
+	}
671 671
 }
672 672
 if (!is_callable('sodium_crypto_kx_seed_keypair')) {
673
-    /**
674
-     * @param string $seed
675
-     * @return string
676
-     * @throws Exception
677
-     */
678
-    function sodium_crypto_kx_seed_keypair($seed)
679
-    {
680
-        return ParagonIE_Sodium_Compat::crypto_kx_seed_keypair($seed);
681
-    }
673
+	/**
674
+	 * @param string $seed
675
+	 * @return string
676
+	 * @throws Exception
677
+	 */
678
+	function sodium_crypto_kx_seed_keypair($seed)
679
+	{
680
+		return ParagonIE_Sodium_Compat::crypto_kx_seed_keypair($seed);
681
+	}
682 682
 }
683 683
 if (!is_callable('sodium_crypto_kx_keypair')) {
684
-    /**
685
-     * @return string
686
-     * @throws Exception
687
-     */
688
-    function sodium_crypto_kx_keypair()
689
-    {
690
-        return ParagonIE_Sodium_Compat::crypto_kx_keypair();
691
-    }
684
+	/**
685
+	 * @return string
686
+	 * @throws Exception
687
+	 */
688
+	function sodium_crypto_kx_keypair()
689
+	{
690
+		return ParagonIE_Sodium_Compat::crypto_kx_keypair();
691
+	}
692 692
 }
693 693
 if (!is_callable('sodium_crypto_kx_client_session_keys')) {
694
-    /**
695
-     * @param string $keypair
696
-     * @param string $serverPublicKey
697
-     * @return array{0: string, 1: string}
698
-     * @throws SodiumException
699
-     */
700
-    function sodium_crypto_kx_client_session_keys($keypair, $serverPublicKey)
701
-    {
702
-        return ParagonIE_Sodium_Compat::crypto_kx_client_session_keys($keypair, $serverPublicKey);
703
-    }
694
+	/**
695
+	 * @param string $keypair
696
+	 * @param string $serverPublicKey
697
+	 * @return array{0: string, 1: string}
698
+	 * @throws SodiumException
699
+	 */
700
+	function sodium_crypto_kx_client_session_keys($keypair, $serverPublicKey)
701
+	{
702
+		return ParagonIE_Sodium_Compat::crypto_kx_client_session_keys($keypair, $serverPublicKey);
703
+	}
704 704
 }
705 705
 if (!is_callable('sodium_crypto_kx_server_session_keys')) {
706
-    /**
707
-     * @param string $keypair
708
-     * @param string $clientPublicKey
709
-     * @return array{0: string, 1: string}
710
-     * @throws SodiumException
711
-     */
712
-    function sodium_crypto_kx_server_session_keys($keypair, $clientPublicKey)
713
-    {
714
-        return ParagonIE_Sodium_Compat::crypto_kx_server_session_keys($keypair, $clientPublicKey);
715
-    }
706
+	/**
707
+	 * @param string $keypair
708
+	 * @param string $clientPublicKey
709
+	 * @return array{0: string, 1: string}
710
+	 * @throws SodiumException
711
+	 */
712
+	function sodium_crypto_kx_server_session_keys($keypair, $clientPublicKey)
713
+	{
714
+		return ParagonIE_Sodium_Compat::crypto_kx_server_session_keys($keypair, $clientPublicKey);
715
+	}
716 716
 }
717 717
 if (!is_callable('sodium_crypto_kx_secretkey')) {
718
-    /**
719
-     * @param string $keypair
720
-     * @return string
721
-     * @throws Exception
722
-     */
723
-    function sodium_crypto_kx_secretkey($keypair)
724
-    {
725
-        return ParagonIE_Sodium_Compat::crypto_kx_secretkey($keypair);
726
-    }
718
+	/**
719
+	 * @param string $keypair
720
+	 * @return string
721
+	 * @throws Exception
722
+	 */
723
+	function sodium_crypto_kx_secretkey($keypair)
724
+	{
725
+		return ParagonIE_Sodium_Compat::crypto_kx_secretkey($keypair);
726
+	}
727 727
 }
728 728
 if (!is_callable('sodium_crypto_kx_publickey')) {
729
-    /**
730
-     * @param string $keypair
731
-     * @return string
732
-     * @throws Exception
733
-     */
734
-    function sodium_crypto_kx_publickey($keypair)
735
-    {
736
-        return ParagonIE_Sodium_Compat::crypto_kx_publickey($keypair);
737
-    }
729
+	/**
730
+	 * @param string $keypair
731
+	 * @return string
732
+	 * @throws Exception
733
+	 */
734
+	function sodium_crypto_kx_publickey($keypair)
735
+	{
736
+		return ParagonIE_Sodium_Compat::crypto_kx_publickey($keypair);
737
+	}
738 738
 }
739 739
 if (!is_callable('sodium_crypto_pwhash')) {
740
-    /**
741
-     * @see ParagonIE_Sodium_Compat::crypto_pwhash()
742
-     * @param int $outlen
743
-     * @param string $passwd
744
-     * @param string $salt
745
-     * @param int $opslimit
746
-     * @param int $memlimit
747
-     * @param int|null $algo
748
-     * @return string
749
-     * @throws SodiumException
750
-     * @throws TypeError
751
-     */
752
-    function sodium_crypto_pwhash($outlen, $passwd, $salt, $opslimit, $memlimit, $algo = null)
753
-    {
754
-        return ParagonIE_Sodium_Compat::crypto_pwhash($outlen, $passwd, $salt, $opslimit, $memlimit, $algo);
755
-    }
740
+	/**
741
+	 * @see ParagonIE_Sodium_Compat::crypto_pwhash()
742
+	 * @param int $outlen
743
+	 * @param string $passwd
744
+	 * @param string $salt
745
+	 * @param int $opslimit
746
+	 * @param int $memlimit
747
+	 * @param int|null $algo
748
+	 * @return string
749
+	 * @throws SodiumException
750
+	 * @throws TypeError
751
+	 */
752
+	function sodium_crypto_pwhash($outlen, $passwd, $salt, $opslimit, $memlimit, $algo = null)
753
+	{
754
+		return ParagonIE_Sodium_Compat::crypto_pwhash($outlen, $passwd, $salt, $opslimit, $memlimit, $algo);
755
+	}
756 756
 }
757 757
 if (!is_callable('sodium_crypto_pwhash_str')) {
758
-    /**
759
-     * @see ParagonIE_Sodium_Compat::crypto_pwhash_str()
760
-     * @param string $passwd
761
-     * @param int $opslimit
762
-     * @param int $memlimit
763
-     * @return string
764
-     * @throws SodiumException
765
-     * @throws TypeError
766
-     */
767
-    function sodium_crypto_pwhash_str($passwd, $opslimit, $memlimit)
768
-    {
769
-        return ParagonIE_Sodium_Compat::crypto_pwhash_str($passwd, $opslimit, $memlimit);
770
-    }
758
+	/**
759
+	 * @see ParagonIE_Sodium_Compat::crypto_pwhash_str()
760
+	 * @param string $passwd
761
+	 * @param int $opslimit
762
+	 * @param int $memlimit
763
+	 * @return string
764
+	 * @throws SodiumException
765
+	 * @throws TypeError
766
+	 */
767
+	function sodium_crypto_pwhash_str($passwd, $opslimit, $memlimit)
768
+	{
769
+		return ParagonIE_Sodium_Compat::crypto_pwhash_str($passwd, $opslimit, $memlimit);
770
+	}
771 771
 }
772 772
 if (!is_callable('sodium_crypto_pwhash_str_needs_rehash')) {
773
-    /**
774
-     * @see ParagonIE_Sodium_Compat::crypto_pwhash_str_needs_rehash()
775
-     * @param string $hash
776
-     * @param int $opslimit
777
-     * @param int $memlimit
778
-     * @return bool
779
-     *
780
-     * @throws SodiumException
781
-     */
782
-    function sodium_crypto_pwhash_str_needs_rehash($hash, $opslimit, $memlimit)
783
-    {
784
-        return ParagonIE_Sodium_Compat::crypto_pwhash_str_needs_rehash($hash, $opslimit, $memlimit);
785
-    }
773
+	/**
774
+	 * @see ParagonIE_Sodium_Compat::crypto_pwhash_str_needs_rehash()
775
+	 * @param string $hash
776
+	 * @param int $opslimit
777
+	 * @param int $memlimit
778
+	 * @return bool
779
+	 *
780
+	 * @throws SodiumException
781
+	 */
782
+	function sodium_crypto_pwhash_str_needs_rehash($hash, $opslimit, $memlimit)
783
+	{
784
+		return ParagonIE_Sodium_Compat::crypto_pwhash_str_needs_rehash($hash, $opslimit, $memlimit);
785
+	}
786 786
 }
787 787
 if (!is_callable('sodium_crypto_pwhash_str_verify')) {
788
-    /**
789
-     * @see ParagonIE_Sodium_Compat::crypto_pwhash_str_verify()
790
-     * @param string $passwd
791
-     * @param string $hash
792
-     * @return bool
793
-     * @throws SodiumException
794
-     * @throws TypeError
795
-     */
796
-    function sodium_crypto_pwhash_str_verify($passwd, $hash)
797
-    {
798
-        return ParagonIE_Sodium_Compat::crypto_pwhash_str_verify($passwd, $hash);
799
-    }
788
+	/**
789
+	 * @see ParagonIE_Sodium_Compat::crypto_pwhash_str_verify()
790
+	 * @param string $passwd
791
+	 * @param string $hash
792
+	 * @return bool
793
+	 * @throws SodiumException
794
+	 * @throws TypeError
795
+	 */
796
+	function sodium_crypto_pwhash_str_verify($passwd, $hash)
797
+	{
798
+		return ParagonIE_Sodium_Compat::crypto_pwhash_str_verify($passwd, $hash);
799
+	}
800 800
 }
801 801
 if (!is_callable('sodium_crypto_pwhash_scryptsalsa208sha256')) {
802
-    /**
803
-     * @see ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256()
804
-     * @param int $outlen
805
-     * @param string $passwd
806
-     * @param string $salt
807
-     * @param int $opslimit
808
-     * @param int $memlimit
809
-     * @return string
810
-     * @throws SodiumException
811
-     * @throws TypeError
812
-     */
813
-    function sodium_crypto_pwhash_scryptsalsa208sha256($outlen, $passwd, $salt, $opslimit, $memlimit)
814
-    {
815
-        return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256($outlen, $passwd, $salt, $opslimit, $memlimit);
816
-    }
802
+	/**
803
+	 * @see ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256()
804
+	 * @param int $outlen
805
+	 * @param string $passwd
806
+	 * @param string $salt
807
+	 * @param int $opslimit
808
+	 * @param int $memlimit
809
+	 * @return string
810
+	 * @throws SodiumException
811
+	 * @throws TypeError
812
+	 */
813
+	function sodium_crypto_pwhash_scryptsalsa208sha256($outlen, $passwd, $salt, $opslimit, $memlimit)
814
+	{
815
+		return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256($outlen, $passwd, $salt, $opslimit, $memlimit);
816
+	}
817 817
 }
818 818
 if (!is_callable('sodium_crypto_pwhash_scryptsalsa208sha256_str')) {
819
-    /**
820
-     * @see ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str()
821
-     * @param string $passwd
822
-     * @param int $opslimit
823
-     * @param int $memlimit
824
-     * @return string
825
-     * @throws SodiumException
826
-     * @throws TypeError
827
-     */
828
-    function sodium_crypto_pwhash_scryptsalsa208sha256_str($passwd, $opslimit, $memlimit)
829
-    {
830
-        return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str($passwd, $opslimit, $memlimit);
831
-    }
819
+	/**
820
+	 * @see ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str()
821
+	 * @param string $passwd
822
+	 * @param int $opslimit
823
+	 * @param int $memlimit
824
+	 * @return string
825
+	 * @throws SodiumException
826
+	 * @throws TypeError
827
+	 */
828
+	function sodium_crypto_pwhash_scryptsalsa208sha256_str($passwd, $opslimit, $memlimit)
829
+	{
830
+		return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str($passwd, $opslimit, $memlimit);
831
+	}
832 832
 }
833 833
 if (!is_callable('sodium_crypto_pwhash_scryptsalsa208sha256_str_verify')) {
834
-    /**
835
-     * @see ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str_verify()
836
-     * @param string $passwd
837
-     * @param string $hash
838
-     * @return bool
839
-     * @throws SodiumException
840
-     * @throws TypeError
841
-     */
842
-    function sodium_crypto_pwhash_scryptsalsa208sha256_str_verify($passwd, $hash)
843
-    {
844
-        return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str_verify($passwd, $hash);
845
-    }
834
+	/**
835
+	 * @see ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str_verify()
836
+	 * @param string $passwd
837
+	 * @param string $hash
838
+	 * @return bool
839
+	 * @throws SodiumException
840
+	 * @throws TypeError
841
+	 */
842
+	function sodium_crypto_pwhash_scryptsalsa208sha256_str_verify($passwd, $hash)
843
+	{
844
+		return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str_verify($passwd, $hash);
845
+	}
846 846
 }
847 847
 if (!is_callable('sodium_crypto_scalarmult')) {
848
-    /**
849
-     * @see ParagonIE_Sodium_Compat::crypto_scalarmult()
850
-     * @param string $n
851
-     * @param string $p
852
-     * @return string
853
-     * @throws SodiumException
854
-     * @throws TypeError
855
-     */
856
-    function sodium_crypto_scalarmult($n, $p)
857
-    {
858
-        return ParagonIE_Sodium_Compat::crypto_scalarmult($n, $p);
859
-    }
848
+	/**
849
+	 * @see ParagonIE_Sodium_Compat::crypto_scalarmult()
850
+	 * @param string $n
851
+	 * @param string $p
852
+	 * @return string
853
+	 * @throws SodiumException
854
+	 * @throws TypeError
855
+	 */
856
+	function sodium_crypto_scalarmult($n, $p)
857
+	{
858
+		return ParagonIE_Sodium_Compat::crypto_scalarmult($n, $p);
859
+	}
860 860
 }
861 861
 if (!is_callable('sodium_crypto_scalarmult_base')) {
862
-    /**
863
-     * @see ParagonIE_Sodium_Compat::crypto_scalarmult_base()
864
-     * @param string $n
865
-     * @return string
866
-     * @throws SodiumException
867
-     * @throws TypeError
868
-     */
869
-    function sodium_crypto_scalarmult_base($n)
870
-    {
871
-        return ParagonIE_Sodium_Compat::crypto_scalarmult_base($n);
872
-    }
862
+	/**
863
+	 * @see ParagonIE_Sodium_Compat::crypto_scalarmult_base()
864
+	 * @param string $n
865
+	 * @return string
866
+	 * @throws SodiumException
867
+	 * @throws TypeError
868
+	 */
869
+	function sodium_crypto_scalarmult_base($n)
870
+	{
871
+		return ParagonIE_Sodium_Compat::crypto_scalarmult_base($n);
872
+	}
873 873
 }
874 874
 if (!is_callable('sodium_crypto_secretbox')) {
875
-    /**
876
-     * @see ParagonIE_Sodium_Compat::crypto_secretbox()
877
-     * @param string $message
878
-     * @param string $nonce
879
-     * @param string $key
880
-     * @return string
881
-     * @throws SodiumException
882
-     * @throws TypeError
883
-     */
884
-    function sodium_crypto_secretbox($message, $nonce, $key)
885
-    {
886
-        return ParagonIE_Sodium_Compat::crypto_secretbox($message, $nonce, $key);
887
-    }
875
+	/**
876
+	 * @see ParagonIE_Sodium_Compat::crypto_secretbox()
877
+	 * @param string $message
878
+	 * @param string $nonce
879
+	 * @param string $key
880
+	 * @return string
881
+	 * @throws SodiumException
882
+	 * @throws TypeError
883
+	 */
884
+	function sodium_crypto_secretbox($message, $nonce, $key)
885
+	{
886
+		return ParagonIE_Sodium_Compat::crypto_secretbox($message, $nonce, $key);
887
+	}
888 888
 }
889 889
 if (!is_callable('sodium_crypto_secretbox_keygen')) {
890
-    /**
891
-     * @see ParagonIE_Sodium_Compat::crypto_secretbox_keygen()
892
-     * @return string
893
-     * @throws Exception
894
-     */
895
-    function sodium_crypto_secretbox_keygen()
896
-    {
897
-        return ParagonIE_Sodium_Compat::crypto_secretbox_keygen();
898
-    }
890
+	/**
891
+	 * @see ParagonIE_Sodium_Compat::crypto_secretbox_keygen()
892
+	 * @return string
893
+	 * @throws Exception
894
+	 */
895
+	function sodium_crypto_secretbox_keygen()
896
+	{
897
+		return ParagonIE_Sodium_Compat::crypto_secretbox_keygen();
898
+	}
899 899
 }
900 900
 if (!is_callable('sodium_crypto_secretbox_open')) {
901
-    /**
902
-     * @see ParagonIE_Sodium_Compat::crypto_secretbox_open()
903
-     * @param string $message
904
-     * @param string $nonce
905
-     * @param string $key
906
-     * @return string|bool
907
-     */
908
-    function sodium_crypto_secretbox_open($message, $nonce, $key)
909
-    {
910
-        try {
911
-            return ParagonIE_Sodium_Compat::crypto_secretbox_open($message, $nonce, $key);
912
-        } catch (Error $ex) {
913
-            return false;
914
-        } catch (Exception $ex) {
915
-            return false;
916
-        }
917
-    }
901
+	/**
902
+	 * @see ParagonIE_Sodium_Compat::crypto_secretbox_open()
903
+	 * @param string $message
904
+	 * @param string $nonce
905
+	 * @param string $key
906
+	 * @return string|bool
907
+	 */
908
+	function sodium_crypto_secretbox_open($message, $nonce, $key)
909
+	{
910
+		try {
911
+			return ParagonIE_Sodium_Compat::crypto_secretbox_open($message, $nonce, $key);
912
+		} catch (Error $ex) {
913
+			return false;
914
+		} catch (Exception $ex) {
915
+			return false;
916
+		}
917
+	}
918 918
 }
919 919
 if (!is_callable('sodium_crypto_secretstream_xchacha20poly1305_init_push')) {
920
-    /**
921
-     * @param string $key
922
-     * @return array<int, string>
923
-     * @throws SodiumException
924
-     */
925
-    function sodium_crypto_secretstream_xchacha20poly1305_init_push($key)
926
-    {
927
-        return ParagonIE_Sodium_Compat::crypto_secretstream_xchacha20poly1305_init_push($key);
928
-    }
920
+	/**
921
+	 * @param string $key
922
+	 * @return array<int, string>
923
+	 * @throws SodiumException
924
+	 */
925
+	function sodium_crypto_secretstream_xchacha20poly1305_init_push($key)
926
+	{
927
+		return ParagonIE_Sodium_Compat::crypto_secretstream_xchacha20poly1305_init_push($key);
928
+	}
929 929
 }
930 930
 if (!is_callable('sodium_crypto_secretstream_xchacha20poly1305_push')) {
931
-    /**
932
-     * @param string $state
933
-     * @param string $msg
934
-     * @param string $aad
935
-     * @param int $tag
936
-     * @return string
937
-     * @throws SodiumException
938
-     */
939
-    function sodium_crypto_secretstream_xchacha20poly1305_push(&$state, $msg, $aad = '', $tag = 0)
940
-    {
941
-        return ParagonIE_Sodium_Compat::crypto_secretstream_xchacha20poly1305_push($state, $msg, $aad, $tag);
942
-    }
931
+	/**
932
+	 * @param string $state
933
+	 * @param string $msg
934
+	 * @param string $aad
935
+	 * @param int $tag
936
+	 * @return string
937
+	 * @throws SodiumException
938
+	 */
939
+	function sodium_crypto_secretstream_xchacha20poly1305_push(&$state, $msg, $aad = '', $tag = 0)
940
+	{
941
+		return ParagonIE_Sodium_Compat::crypto_secretstream_xchacha20poly1305_push($state, $msg, $aad, $tag);
942
+	}
943 943
 }
944 944
 if (!is_callable('sodium_crypto_secretstream_xchacha20poly1305_init_pull')) {
945
-    /**
946
-     * @param string $header
947
-     * @param string $key
948
-     * @return string
949
-     * @throws Exception
950
-     */
951
-    function sodium_crypto_secretstream_xchacha20poly1305_init_pull($header, $key)
952
-    {
953
-        return ParagonIE_Sodium_Compat::crypto_secretstream_xchacha20poly1305_init_pull($header, $key);
954
-    }
945
+	/**
946
+	 * @param string $header
947
+	 * @param string $key
948
+	 * @return string
949
+	 * @throws Exception
950
+	 */
951
+	function sodium_crypto_secretstream_xchacha20poly1305_init_pull($header, $key)
952
+	{
953
+		return ParagonIE_Sodium_Compat::crypto_secretstream_xchacha20poly1305_init_pull($header, $key);
954
+	}
955 955
 }
956 956
 if (!is_callable('sodium_crypto_secretstream_xchacha20poly1305_pull')) {
957
-    /**
958
-     * @param string $state
959
-     * @param string $cipher
960
-     * @param string $aad
961
-     * @return bool|array{0: string, 1: int}
962
-     * @throws SodiumException
963
-     */
964
-    function sodium_crypto_secretstream_xchacha20poly1305_pull(&$state, $cipher, $aad = '')
965
-    {
966
-        return ParagonIE_Sodium_Compat::crypto_secretstream_xchacha20poly1305_pull($state, $cipher, $aad);
967
-    }
957
+	/**
958
+	 * @param string $state
959
+	 * @param string $cipher
960
+	 * @param string $aad
961
+	 * @return bool|array{0: string, 1: int}
962
+	 * @throws SodiumException
963
+	 */
964
+	function sodium_crypto_secretstream_xchacha20poly1305_pull(&$state, $cipher, $aad = '')
965
+	{
966
+		return ParagonIE_Sodium_Compat::crypto_secretstream_xchacha20poly1305_pull($state, $cipher, $aad);
967
+	}
968 968
 }
969 969
 if (!is_callable('sodium_crypto_secretstream_xchacha20poly1305_rekey')) {
970
-    /**
971
-     * @param string $state
972
-     * @return void
973
-     * @throws SodiumException
974
-     */
975
-    function sodium_crypto_secretstream_xchacha20poly1305_rekey(&$state)
976
-    {
977
-        ParagonIE_Sodium_Compat::crypto_secretstream_xchacha20poly1305_rekey($state);
978
-    }
970
+	/**
971
+	 * @param string $state
972
+	 * @return void
973
+	 * @throws SodiumException
974
+	 */
975
+	function sodium_crypto_secretstream_xchacha20poly1305_rekey(&$state)
976
+	{
977
+		ParagonIE_Sodium_Compat::crypto_secretstream_xchacha20poly1305_rekey($state);
978
+	}
979 979
 }
980 980
 if (!is_callable('sodium_crypto_secretstream_xchacha20poly1305_keygen')) {
981
-    /**
982
-     * @return string
983
-     * @throws Exception
984
-     */
985
-    function sodium_crypto_secretstream_xchacha20poly1305_keygen()
986
-    {
987
-        return ParagonIE_Sodium_Compat::crypto_secretstream_xchacha20poly1305_keygen();
988
-    }
981
+	/**
982
+	 * @return string
983
+	 * @throws Exception
984
+	 */
985
+	function sodium_crypto_secretstream_xchacha20poly1305_keygen()
986
+	{
987
+		return ParagonIE_Sodium_Compat::crypto_secretstream_xchacha20poly1305_keygen();
988
+	}
989 989
 }
990 990
 if (!is_callable('sodium_crypto_shorthash')) {
991
-    /**
992
-     * @see ParagonIE_Sodium_Compat::crypto_shorthash()
993
-     * @param string $message
994
-     * @param string $key
995
-     * @return string
996
-     * @throws SodiumException
997
-     * @throws TypeError
998
-     */
999
-    function sodium_crypto_shorthash($message, $key = '')
1000
-    {
1001
-        return ParagonIE_Sodium_Compat::crypto_shorthash($message, $key);
1002
-    }
991
+	/**
992
+	 * @see ParagonIE_Sodium_Compat::crypto_shorthash()
993
+	 * @param string $message
994
+	 * @param string $key
995
+	 * @return string
996
+	 * @throws SodiumException
997
+	 * @throws TypeError
998
+	 */
999
+	function sodium_crypto_shorthash($message, $key = '')
1000
+	{
1001
+		return ParagonIE_Sodium_Compat::crypto_shorthash($message, $key);
1002
+	}
1003 1003
 }
1004 1004
 if (!is_callable('sodium_crypto_shorthash_keygen')) {
1005
-    /**
1006
-     * @see ParagonIE_Sodium_Compat::crypto_shorthash_keygen()
1007
-     * @return string
1008
-     * @throws Exception
1009
-     */
1010
-    function sodium_crypto_shorthash_keygen()
1011
-    {
1012
-        return ParagonIE_Sodium_Compat::crypto_shorthash_keygen();
1013
-    }
1005
+	/**
1006
+	 * @see ParagonIE_Sodium_Compat::crypto_shorthash_keygen()
1007
+	 * @return string
1008
+	 * @throws Exception
1009
+	 */
1010
+	function sodium_crypto_shorthash_keygen()
1011
+	{
1012
+		return ParagonIE_Sodium_Compat::crypto_shorthash_keygen();
1013
+	}
1014 1014
 }
1015 1015
 if (!is_callable('sodium_crypto_sign')) {
1016
-    /**
1017
-     * @see ParagonIE_Sodium_Compat::crypto_sign()
1018
-     * @param string $message
1019
-     * @param string $sk
1020
-     * @return string
1021
-     * @throws SodiumException
1022
-     * @throws TypeError
1023
-     */
1024
-    function sodium_crypto_sign($message, $sk)
1025
-    {
1026
-        return ParagonIE_Sodium_Compat::crypto_sign($message, $sk);
1027
-    }
1016
+	/**
1017
+	 * @see ParagonIE_Sodium_Compat::crypto_sign()
1018
+	 * @param string $message
1019
+	 * @param string $sk
1020
+	 * @return string
1021
+	 * @throws SodiumException
1022
+	 * @throws TypeError
1023
+	 */
1024
+	function sodium_crypto_sign($message, $sk)
1025
+	{
1026
+		return ParagonIE_Sodium_Compat::crypto_sign($message, $sk);
1027
+	}
1028 1028
 }
1029 1029
 if (!is_callable('sodium_crypto_sign_detached')) {
1030
-    /**
1031
-     * @see ParagonIE_Sodium_Compat::crypto_sign_detached()
1032
-     * @param string $message
1033
-     * @param string $sk
1034
-     * @return string
1035
-     * @throws SodiumException
1036
-     * @throws TypeError
1037
-     */
1038
-    function sodium_crypto_sign_detached($message, $sk)
1039
-    {
1040
-        return ParagonIE_Sodium_Compat::crypto_sign_detached($message, $sk);
1041
-    }
1030
+	/**
1031
+	 * @see ParagonIE_Sodium_Compat::crypto_sign_detached()
1032
+	 * @param string $message
1033
+	 * @param string $sk
1034
+	 * @return string
1035
+	 * @throws SodiumException
1036
+	 * @throws TypeError
1037
+	 */
1038
+	function sodium_crypto_sign_detached($message, $sk)
1039
+	{
1040
+		return ParagonIE_Sodium_Compat::crypto_sign_detached($message, $sk);
1041
+	}
1042 1042
 }
1043 1043
 if (!is_callable('sodium_crypto_sign_keypair_from_secretkey_and_publickey')) {
1044
-    /**
1045
-     * @see ParagonIE_Sodium_Compat::crypto_sign_keypair_from_secretkey_and_publickey()
1046
-     * @param string $sk
1047
-     * @param string $pk
1048
-     * @return string
1049
-     * @throws SodiumException
1050
-     * @throws TypeError
1051
-     */
1052
-    function sodium_crypto_sign_keypair_from_secretkey_and_publickey($sk, $pk)
1053
-    {
1054
-        return ParagonIE_Sodium_Compat::crypto_sign_keypair_from_secretkey_and_publickey($sk, $pk);
1055
-    }
1044
+	/**
1045
+	 * @see ParagonIE_Sodium_Compat::crypto_sign_keypair_from_secretkey_and_publickey()
1046
+	 * @param string $sk
1047
+	 * @param string $pk
1048
+	 * @return string
1049
+	 * @throws SodiumException
1050
+	 * @throws TypeError
1051
+	 */
1052
+	function sodium_crypto_sign_keypair_from_secretkey_and_publickey($sk, $pk)
1053
+	{
1054
+		return ParagonIE_Sodium_Compat::crypto_sign_keypair_from_secretkey_and_publickey($sk, $pk);
1055
+	}
1056 1056
 }
1057 1057
 if (!is_callable('sodium_crypto_sign_keypair')) {
1058
-    /**
1059
-     * @see ParagonIE_Sodium_Compat::crypto_sign_keypair()
1060
-     * @return string
1061
-     * @throws SodiumException
1062
-     * @throws TypeError
1063
-     */
1064
-    function sodium_crypto_sign_keypair()
1065
-    {
1066
-        return ParagonIE_Sodium_Compat::crypto_sign_keypair();
1067
-    }
1058
+	/**
1059
+	 * @see ParagonIE_Sodium_Compat::crypto_sign_keypair()
1060
+	 * @return string
1061
+	 * @throws SodiumException
1062
+	 * @throws TypeError
1063
+	 */
1064
+	function sodium_crypto_sign_keypair()
1065
+	{
1066
+		return ParagonIE_Sodium_Compat::crypto_sign_keypair();
1067
+	}
1068 1068
 }
1069 1069
 if (!is_callable('sodium_crypto_sign_open')) {
1070
-    /**
1071
-     * @see ParagonIE_Sodium_Compat::crypto_sign_open()
1072
-     * @param string $signedMessage
1073
-     * @param string $pk
1074
-     * @return string|bool
1075
-     */
1076
-    function sodium_crypto_sign_open($signedMessage, $pk)
1077
-    {
1078
-        try {
1079
-            return ParagonIE_Sodium_Compat::crypto_sign_open($signedMessage, $pk);
1080
-        } catch (Error $ex) {
1081
-            return false;
1082
-        } catch (Exception $ex) {
1083
-            return false;
1084
-        }
1085
-    }
1070
+	/**
1071
+	 * @see ParagonIE_Sodium_Compat::crypto_sign_open()
1072
+	 * @param string $signedMessage
1073
+	 * @param string $pk
1074
+	 * @return string|bool
1075
+	 */
1076
+	function sodium_crypto_sign_open($signedMessage, $pk)
1077
+	{
1078
+		try {
1079
+			return ParagonIE_Sodium_Compat::crypto_sign_open($signedMessage, $pk);
1080
+		} catch (Error $ex) {
1081
+			return false;
1082
+		} catch (Exception $ex) {
1083
+			return false;
1084
+		}
1085
+	}
1086 1086
 }
1087 1087
 if (!is_callable('sodium_crypto_sign_publickey')) {
1088
-    /**
1089
-     * @see ParagonIE_Sodium_Compat::crypto_sign_publickey()
1090
-     * @param string $keypair
1091
-     * @return string
1092
-     * @throws SodiumException
1093
-     * @throws TypeError
1094
-     */
1095
-    function sodium_crypto_sign_publickey($keypair)
1096
-    {
1097
-        return ParagonIE_Sodium_Compat::crypto_sign_publickey($keypair);
1098
-    }
1088
+	/**
1089
+	 * @see ParagonIE_Sodium_Compat::crypto_sign_publickey()
1090
+	 * @param string $keypair
1091
+	 * @return string
1092
+	 * @throws SodiumException
1093
+	 * @throws TypeError
1094
+	 */
1095
+	function sodium_crypto_sign_publickey($keypair)
1096
+	{
1097
+		return ParagonIE_Sodium_Compat::crypto_sign_publickey($keypair);
1098
+	}
1099 1099
 }
1100 1100
 if (!is_callable('sodium_crypto_sign_publickey_from_secretkey')) {
1101
-    /**
1102
-     * @see ParagonIE_Sodium_Compat::crypto_sign_publickey_from_secretkey()
1103
-     * @param string $sk
1104
-     * @return string
1105
-     * @throws SodiumException
1106
-     * @throws TypeError
1107
-     */
1108
-    function sodium_crypto_sign_publickey_from_secretkey($sk)
1109
-    {
1110
-        return ParagonIE_Sodium_Compat::crypto_sign_publickey_from_secretkey($sk);
1111
-    }
1101
+	/**
1102
+	 * @see ParagonIE_Sodium_Compat::crypto_sign_publickey_from_secretkey()
1103
+	 * @param string $sk
1104
+	 * @return string
1105
+	 * @throws SodiumException
1106
+	 * @throws TypeError
1107
+	 */
1108
+	function sodium_crypto_sign_publickey_from_secretkey($sk)
1109
+	{
1110
+		return ParagonIE_Sodium_Compat::crypto_sign_publickey_from_secretkey($sk);
1111
+	}
1112 1112
 }
1113 1113
 if (!is_callable('sodium_crypto_sign_secretkey')) {
1114
-    /**
1115
-     * @see ParagonIE_Sodium_Compat::crypto_sign_secretkey()
1116
-     * @param string $keypair
1117
-     * @return string
1118
-     * @throws SodiumException
1119
-     * @throws TypeError
1120
-     */
1121
-    function sodium_crypto_sign_secretkey($keypair)
1122
-    {
1123
-        return ParagonIE_Sodium_Compat::crypto_sign_secretkey($keypair);
1124
-    }
1114
+	/**
1115
+	 * @see ParagonIE_Sodium_Compat::crypto_sign_secretkey()
1116
+	 * @param string $keypair
1117
+	 * @return string
1118
+	 * @throws SodiumException
1119
+	 * @throws TypeError
1120
+	 */
1121
+	function sodium_crypto_sign_secretkey($keypair)
1122
+	{
1123
+		return ParagonIE_Sodium_Compat::crypto_sign_secretkey($keypair);
1124
+	}
1125 1125
 }
1126 1126
 if (!is_callable('sodium_crypto_sign_seed_keypair')) {
1127
-    /**
1128
-     * @see ParagonIE_Sodium_Compat::crypto_sign_seed_keypair()
1129
-     * @param string $seed
1130
-     * @return string
1131
-     * @throws SodiumException
1132
-     * @throws TypeError
1133
-     */
1134
-    function sodium_crypto_sign_seed_keypair($seed)
1135
-    {
1136
-        return ParagonIE_Sodium_Compat::crypto_sign_seed_keypair($seed);
1137
-    }
1127
+	/**
1128
+	 * @see ParagonIE_Sodium_Compat::crypto_sign_seed_keypair()
1129
+	 * @param string $seed
1130
+	 * @return string
1131
+	 * @throws SodiumException
1132
+	 * @throws TypeError
1133
+	 */
1134
+	function sodium_crypto_sign_seed_keypair($seed)
1135
+	{
1136
+		return ParagonIE_Sodium_Compat::crypto_sign_seed_keypair($seed);
1137
+	}
1138 1138
 }
1139 1139
 if (!is_callable('sodium_crypto_sign_verify_detached')) {
1140
-    /**
1141
-     * @see ParagonIE_Sodium_Compat::crypto_sign_verify_detached()
1142
-     * @param string $signature
1143
-     * @param string $message
1144
-     * @param string $pk
1145
-     * @return bool
1146
-     * @throws SodiumException
1147
-     * @throws TypeError
1148
-     */
1149
-    function sodium_crypto_sign_verify_detached($signature, $message, $pk)
1150
-    {
1151
-        return ParagonIE_Sodium_Compat::crypto_sign_verify_detached($signature, $message, $pk);
1152
-    }
1140
+	/**
1141
+	 * @see ParagonIE_Sodium_Compat::crypto_sign_verify_detached()
1142
+	 * @param string $signature
1143
+	 * @param string $message
1144
+	 * @param string $pk
1145
+	 * @return bool
1146
+	 * @throws SodiumException
1147
+	 * @throws TypeError
1148
+	 */
1149
+	function sodium_crypto_sign_verify_detached($signature, $message, $pk)
1150
+	{
1151
+		return ParagonIE_Sodium_Compat::crypto_sign_verify_detached($signature, $message, $pk);
1152
+	}
1153 1153
 }
1154 1154
 if (!is_callable('sodium_crypto_sign_ed25519_pk_to_curve25519')) {
1155
-    /**
1156
-     * @see ParagonIE_Sodium_Compat::crypto_sign_ed25519_pk_to_curve25519()
1157
-     * @param string $pk
1158
-     * @return string
1159
-     * @throws SodiumException
1160
-     * @throws TypeError
1161
-     */
1162
-    function sodium_crypto_sign_ed25519_pk_to_curve25519($pk)
1163
-    {
1164
-        return ParagonIE_Sodium_Compat::crypto_sign_ed25519_pk_to_curve25519($pk);
1165
-    }
1155
+	/**
1156
+	 * @see ParagonIE_Sodium_Compat::crypto_sign_ed25519_pk_to_curve25519()
1157
+	 * @param string $pk
1158
+	 * @return string
1159
+	 * @throws SodiumException
1160
+	 * @throws TypeError
1161
+	 */
1162
+	function sodium_crypto_sign_ed25519_pk_to_curve25519($pk)
1163
+	{
1164
+		return ParagonIE_Sodium_Compat::crypto_sign_ed25519_pk_to_curve25519($pk);
1165
+	}
1166 1166
 }
1167 1167
 if (!is_callable('sodium_crypto_sign_ed25519_sk_to_curve25519')) {
1168
-    /**
1169
-     * @see ParagonIE_Sodium_Compat::crypto_sign_ed25519_sk_to_curve25519()
1170
-     * @param string $sk
1171
-     * @return string
1172
-     * @throws SodiumException
1173
-     * @throws TypeError
1174
-     */
1175
-    function sodium_crypto_sign_ed25519_sk_to_curve25519($sk)
1176
-    {
1177
-        return ParagonIE_Sodium_Compat::crypto_sign_ed25519_sk_to_curve25519($sk);
1178
-    }
1168
+	/**
1169
+	 * @see ParagonIE_Sodium_Compat::crypto_sign_ed25519_sk_to_curve25519()
1170
+	 * @param string $sk
1171
+	 * @return string
1172
+	 * @throws SodiumException
1173
+	 * @throws TypeError
1174
+	 */
1175
+	function sodium_crypto_sign_ed25519_sk_to_curve25519($sk)
1176
+	{
1177
+		return ParagonIE_Sodium_Compat::crypto_sign_ed25519_sk_to_curve25519($sk);
1178
+	}
1179 1179
 }
1180 1180
 if (!is_callable('sodium_crypto_stream')) {
1181
-    /**
1182
-     * @see ParagonIE_Sodium_Compat::crypto_stream()
1183
-     * @param int $len
1184
-     * @param string $nonce
1185
-     * @param string $key
1186
-     * @return string
1187
-     * @throws SodiumException
1188
-     * @throws TypeError
1189
-     */
1190
-    function sodium_crypto_stream($len, $nonce, $key)
1191
-    {
1192
-        return ParagonIE_Sodium_Compat::crypto_stream($len, $nonce, $key);
1193
-    }
1181
+	/**
1182
+	 * @see ParagonIE_Sodium_Compat::crypto_stream()
1183
+	 * @param int $len
1184
+	 * @param string $nonce
1185
+	 * @param string $key
1186
+	 * @return string
1187
+	 * @throws SodiumException
1188
+	 * @throws TypeError
1189
+	 */
1190
+	function sodium_crypto_stream($len, $nonce, $key)
1191
+	{
1192
+		return ParagonIE_Sodium_Compat::crypto_stream($len, $nonce, $key);
1193
+	}
1194 1194
 }
1195 1195
 if (!is_callable('sodium_crypto_stream_keygen')) {
1196
-    /**
1197
-     * @see ParagonIE_Sodium_Compat::crypto_stream_keygen()
1198
-     * @return string
1199
-     * @throws Exception
1200
-     */
1201
-    function sodium_crypto_stream_keygen()
1202
-    {
1203
-        return ParagonIE_Sodium_Compat::crypto_stream_keygen();
1204
-    }
1196
+	/**
1197
+	 * @see ParagonIE_Sodium_Compat::crypto_stream_keygen()
1198
+	 * @return string
1199
+	 * @throws Exception
1200
+	 */
1201
+	function sodium_crypto_stream_keygen()
1202
+	{
1203
+		return ParagonIE_Sodium_Compat::crypto_stream_keygen();
1204
+	}
1205 1205
 }
1206 1206
 if (!is_callable('sodium_crypto_stream_xor')) {
1207
-    /**
1208
-     * @see ParagonIE_Sodium_Compat::crypto_stream_xor()
1209
-     * @param string $message
1210
-     * @param string $nonce
1211
-     * @param string $key
1212
-     * @return string
1213
-     * @throws SodiumException
1214
-     * @throws TypeError
1215
-     */
1216
-    function sodium_crypto_stream_xor($message, $nonce, $key)
1217
-    {
1218
-        return ParagonIE_Sodium_Compat::crypto_stream_xor($message, $nonce, $key);
1219
-    }
1207
+	/**
1208
+	 * @see ParagonIE_Sodium_Compat::crypto_stream_xor()
1209
+	 * @param string $message
1210
+	 * @param string $nonce
1211
+	 * @param string $key
1212
+	 * @return string
1213
+	 * @throws SodiumException
1214
+	 * @throws TypeError
1215
+	 */
1216
+	function sodium_crypto_stream_xor($message, $nonce, $key)
1217
+	{
1218
+		return ParagonIE_Sodium_Compat::crypto_stream_xor($message, $nonce, $key);
1219
+	}
1220 1220
 }
1221 1221
 require_once dirname(__FILE__) . '/stream-xchacha20.php';
1222 1222
 if (!is_callable('sodium_hex2bin')) {
1223
-    /**
1224
-     * @see ParagonIE_Sodium_Compat::hex2bin()
1225
-     * @param string $string
1226
-     * @return string
1227
-     * @throws SodiumException
1228
-     * @throws TypeError
1229
-     */
1230
-    function sodium_hex2bin($string)
1231
-    {
1232
-        return ParagonIE_Sodium_Compat::hex2bin($string);
1233
-    }
1223
+	/**
1224
+	 * @see ParagonIE_Sodium_Compat::hex2bin()
1225
+	 * @param string $string
1226
+	 * @return string
1227
+	 * @throws SodiumException
1228
+	 * @throws TypeError
1229
+	 */
1230
+	function sodium_hex2bin($string)
1231
+	{
1232
+		return ParagonIE_Sodium_Compat::hex2bin($string);
1233
+	}
1234 1234
 }
1235 1235
 if (!is_callable('sodium_increment')) {
1236
-    /**
1237
-     * @see ParagonIE_Sodium_Compat::increment()
1238
-     * @param string $string
1239
-     * @return void
1240
-     * @throws SodiumException
1241
-     * @throws TypeError
1242
-     */
1243
-    function sodium_increment(&$string)
1244
-    {
1245
-        ParagonIE_Sodium_Compat::increment($string);
1246
-    }
1236
+	/**
1237
+	 * @see ParagonIE_Sodium_Compat::increment()
1238
+	 * @param string $string
1239
+	 * @return void
1240
+	 * @throws SodiumException
1241
+	 * @throws TypeError
1242
+	 */
1243
+	function sodium_increment(&$string)
1244
+	{
1245
+		ParagonIE_Sodium_Compat::increment($string);
1246
+	}
1247 1247
 }
1248 1248
 if (!is_callable('sodium_library_version_major')) {
1249
-    /**
1250
-     * @see ParagonIE_Sodium_Compat::library_version_major()
1251
-     * @return int
1252
-     */
1253
-    function sodium_library_version_major()
1254
-    {
1255
-        return ParagonIE_Sodium_Compat::library_version_major();
1256
-    }
1249
+	/**
1250
+	 * @see ParagonIE_Sodium_Compat::library_version_major()
1251
+	 * @return int
1252
+	 */
1253
+	function sodium_library_version_major()
1254
+	{
1255
+		return ParagonIE_Sodium_Compat::library_version_major();
1256
+	}
1257 1257
 }
1258 1258
 if (!is_callable('sodium_library_version_minor')) {
1259
-    /**
1260
-     * @see ParagonIE_Sodium_Compat::library_version_minor()
1261
-     * @return int
1262
-     */
1263
-    function sodium_library_version_minor()
1264
-    {
1265
-        return ParagonIE_Sodium_Compat::library_version_minor();
1266
-    }
1259
+	/**
1260
+	 * @see ParagonIE_Sodium_Compat::library_version_minor()
1261
+	 * @return int
1262
+	 */
1263
+	function sodium_library_version_minor()
1264
+	{
1265
+		return ParagonIE_Sodium_Compat::library_version_minor();
1266
+	}
1267 1267
 }
1268 1268
 if (!is_callable('sodium_version_string')) {
1269
-    /**
1270
-     * @see ParagonIE_Sodium_Compat::version_string()
1271
-     * @return string
1272
-     */
1273
-    function sodium_version_string()
1274
-    {
1275
-        return ParagonIE_Sodium_Compat::version_string();
1276
-    }
1269
+	/**
1270
+	 * @see ParagonIE_Sodium_Compat::version_string()
1271
+	 * @return string
1272
+	 */
1273
+	function sodium_version_string()
1274
+	{
1275
+		return ParagonIE_Sodium_Compat::version_string();
1276
+	}
1277 1277
 }
1278 1278
 if (!is_callable('sodium_memcmp')) {
1279
-    /**
1280
-     * @see ParagonIE_Sodium_Compat::memcmp()
1281
-     * @param string $a
1282
-     * @param string $b
1283
-     * @return int
1284
-     * @throws SodiumException
1285
-     * @throws TypeError
1286
-     */
1287
-    function sodium_memcmp($a, $b)
1288
-    {
1289
-        return ParagonIE_Sodium_Compat::memcmp($a, $b);
1290
-    }
1279
+	/**
1280
+	 * @see ParagonIE_Sodium_Compat::memcmp()
1281
+	 * @param string $a
1282
+	 * @param string $b
1283
+	 * @return int
1284
+	 * @throws SodiumException
1285
+	 * @throws TypeError
1286
+	 */
1287
+	function sodium_memcmp($a, $b)
1288
+	{
1289
+		return ParagonIE_Sodium_Compat::memcmp($a, $b);
1290
+	}
1291 1291
 }
1292 1292
 if (!is_callable('sodium_memzero')) {
1293
-    /**
1294
-     * @see ParagonIE_Sodium_Compat::memzero()
1295
-     * @param string $str
1296
-     * @return void
1297
-     * @throws SodiumException
1298
-     * @throws TypeError
1299
-     */
1300
-    function sodium_memzero(&$str)
1301
-    {
1302
-        ParagonIE_Sodium_Compat::memzero($str);
1303
-    }
1293
+	/**
1294
+	 * @see ParagonIE_Sodium_Compat::memzero()
1295
+	 * @param string $str
1296
+	 * @return void
1297
+	 * @throws SodiumException
1298
+	 * @throws TypeError
1299
+	 */
1300
+	function sodium_memzero(&$str)
1301
+	{
1302
+		ParagonIE_Sodium_Compat::memzero($str);
1303
+	}
1304 1304
 }
1305 1305
 if (!is_callable('sodium_pad')) {
1306
-    /**
1307
-     * @see ParagonIE_Sodium_Compat::pad()
1308
-     * @param string $unpadded
1309
-     * @param int $blockSize
1310
-     * @return int
1311
-     * @throws SodiumException
1312
-     * @throws TypeError
1313
-     */
1314
-    function sodium_pad($unpadded, $blockSize)
1315
-    {
1316
-        return ParagonIE_Sodium_Compat::pad($unpadded, $blockSize, true);
1317
-    }
1306
+	/**
1307
+	 * @see ParagonIE_Sodium_Compat::pad()
1308
+	 * @param string $unpadded
1309
+	 * @param int $blockSize
1310
+	 * @return int
1311
+	 * @throws SodiumException
1312
+	 * @throws TypeError
1313
+	 */
1314
+	function sodium_pad($unpadded, $blockSize)
1315
+	{
1316
+		return ParagonIE_Sodium_Compat::pad($unpadded, $blockSize, true);
1317
+	}
1318 1318
 }
1319 1319
 if (!is_callable('sodium_unpad')) {
1320
-    /**
1321
-     * @see ParagonIE_Sodium_Compat::pad()
1322
-     * @param string $padded
1323
-     * @param int $blockSize
1324
-     * @return int
1325
-     * @throws SodiumException
1326
-     * @throws TypeError
1327
-     */
1328
-    function sodium_unpad($padded, $blockSize)
1329
-    {
1330
-        return ParagonIE_Sodium_Compat::unpad($padded, $blockSize, true);
1331
-    }
1320
+	/**
1321
+	 * @see ParagonIE_Sodium_Compat::pad()
1322
+	 * @param string $padded
1323
+	 * @param int $blockSize
1324
+	 * @return int
1325
+	 * @throws SodiumException
1326
+	 * @throws TypeError
1327
+	 */
1328
+	function sodium_unpad($padded, $blockSize)
1329
+	{
1330
+		return ParagonIE_Sodium_Compat::unpad($padded, $blockSize, true);
1331
+	}
1332 1332
 }
1333 1333
 if (!is_callable('sodium_randombytes_buf')) {
1334
-    /**
1335
-     * @see ParagonIE_Sodium_Compat::randombytes_buf()
1336
-     * @param int $amount
1337
-     * @return string
1338
-     * @throws Exception
1339
-     */
1340
-    function sodium_randombytes_buf($amount)
1341
-    {
1342
-        return ParagonIE_Sodium_Compat::randombytes_buf($amount);
1343
-    }
1334
+	/**
1335
+	 * @see ParagonIE_Sodium_Compat::randombytes_buf()
1336
+	 * @param int $amount
1337
+	 * @return string
1338
+	 * @throws Exception
1339
+	 */
1340
+	function sodium_randombytes_buf($amount)
1341
+	{
1342
+		return ParagonIE_Sodium_Compat::randombytes_buf($amount);
1343
+	}
1344 1344
 }
1345 1345
 
1346 1346
 if (!is_callable('sodium_randombytes_uniform')) {
1347
-    /**
1348
-     * @see ParagonIE_Sodium_Compat::randombytes_uniform()
1349
-     * @param int $upperLimit
1350
-     * @return int
1351
-     * @throws Exception
1352
-     */
1353
-    function sodium_randombytes_uniform($upperLimit)
1354
-    {
1355
-        return ParagonIE_Sodium_Compat::randombytes_uniform($upperLimit);
1356
-    }
1347
+	/**
1348
+	 * @see ParagonIE_Sodium_Compat::randombytes_uniform()
1349
+	 * @param int $upperLimit
1350
+	 * @return int
1351
+	 * @throws Exception
1352
+	 */
1353
+	function sodium_randombytes_uniform($upperLimit)
1354
+	{
1355
+		return ParagonIE_Sodium_Compat::randombytes_uniform($upperLimit);
1356
+	}
1357 1357
 }
1358 1358
 
1359 1359
 if (!is_callable('sodium_randombytes_random16')) {
1360
-    /**
1361
-     * @see ParagonIE_Sodium_Compat::randombytes_random16()
1362
-     * @return int
1363
-     * @throws Exception
1364
-     */
1365
-    function sodium_randombytes_random16()
1366
-    {
1367
-        return ParagonIE_Sodium_Compat::randombytes_random16();
1368
-    }
1360
+	/**
1361
+	 * @see ParagonIE_Sodium_Compat::randombytes_random16()
1362
+	 * @return int
1363
+	 * @throws Exception
1364
+	 */
1365
+	function sodium_randombytes_random16()
1366
+	{
1367
+		return ParagonIE_Sodium_Compat::randombytes_random16();
1368
+	}
1369 1369
 }
Please login to merge, or discard this patch.
vendor/paragonie/sodium_compat/autoload.php 1 patch
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -1,72 +1,72 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if (PHP_VERSION_ID < 70000) {
4
-    if (!is_callable('sodiumCompatAutoloader')) {
5
-        /**
6
-         * Sodium_Compat autoloader.
7
-         *
8
-         * @param string $class Class name to be autoloaded.
9
-         *
10
-         * @return bool         Stop autoloading?
11
-         */
12
-        function sodiumCompatAutoloader($class)
13
-        {
14
-            $namespace = 'ParagonIE_Sodium_';
15
-            // Does the class use the namespace prefix?
16
-            $len = strlen($namespace);
17
-            if (strncmp($namespace, $class, $len) !== 0) {
18
-                // no, move to the next registered autoloader
19
-                return false;
20
-            }
4
+	if (!is_callable('sodiumCompatAutoloader')) {
5
+		/**
6
+		 * Sodium_Compat autoloader.
7
+		 *
8
+		 * @param string $class Class name to be autoloaded.
9
+		 *
10
+		 * @return bool         Stop autoloading?
11
+		 */
12
+		function sodiumCompatAutoloader($class)
13
+		{
14
+			$namespace = 'ParagonIE_Sodium_';
15
+			// Does the class use the namespace prefix?
16
+			$len = strlen($namespace);
17
+			if (strncmp($namespace, $class, $len) !== 0) {
18
+				// no, move to the next registered autoloader
19
+				return false;
20
+			}
21 21
 
22
-            // Get the relative class name
23
-            $relative_class = substr($class, $len);
22
+			// Get the relative class name
23
+			$relative_class = substr($class, $len);
24 24
 
25
-            // Replace the namespace prefix with the base directory, replace namespace
26
-            // separators with directory separators in the relative class name, append
27
-            // with .php
28
-            $file = dirname(__FILE__) . '/src/' . str_replace('_', '/', $relative_class) . '.php';
29
-            // if the file exists, require it
30
-            if (file_exists($file)) {
31
-                require_once $file;
32
-                return true;
33
-            }
34
-            return false;
35
-        }
25
+			// Replace the namespace prefix with the base directory, replace namespace
26
+			// separators with directory separators in the relative class name, append
27
+			// with .php
28
+			$file = dirname(__FILE__) . '/src/' . str_replace('_', '/', $relative_class) . '.php';
29
+			// if the file exists, require it
30
+			if (file_exists($file)) {
31
+				require_once $file;
32
+				return true;
33
+			}
34
+			return false;
35
+		}
36 36
 
37
-        // Now that we have an autoloader, let's register it!
38
-        spl_autoload_register('sodiumCompatAutoloader');
39
-    }
37
+		// Now that we have an autoloader, let's register it!
38
+		spl_autoload_register('sodiumCompatAutoloader');
39
+	}
40 40
 } else {
41
-    require_once dirname(__FILE__) . '/autoload-php7.php';
41
+	require_once dirname(__FILE__) . '/autoload-php7.php';
42 42
 }
43 43
 
44 44
 /* Explicitly, always load the Compat class: */
45 45
 require_once dirname(__FILE__) . '/src/Compat.php';
46 46
 
47 47
 if (!class_exists('SodiumException', false)) {
48
-    require_once dirname(__FILE__) . '/src/SodiumException.php';
48
+	require_once dirname(__FILE__) . '/src/SodiumException.php';
49 49
 }
50 50
 if (PHP_VERSION_ID >= 50300) {
51
-    // Namespaces didn't exist before 5.3.0, so don't even try to use this
52
-    // unless PHP >= 5.3.0
53
-    require_once dirname(__FILE__) . '/lib/namespaced.php';
54
-    require_once dirname(__FILE__) . '/lib/sodium_compat.php';
51
+	// Namespaces didn't exist before 5.3.0, so don't even try to use this
52
+	// unless PHP >= 5.3.0
53
+	require_once dirname(__FILE__) . '/lib/namespaced.php';
54
+	require_once dirname(__FILE__) . '/lib/sodium_compat.php';
55 55
 } else {
56
-    require_once dirname(__FILE__) . '/src/PHP52/SplFixedArray.php';
56
+	require_once dirname(__FILE__) . '/src/PHP52/SplFixedArray.php';
57 57
 }
58 58
 if (PHP_VERSION_ID < 70200 || !extension_loaded('sodium')) {
59
-    if (PHP_VERSION_ID >= 50300 && !defined('SODIUM_CRYPTO_SCALARMULT_BYTES')) {
60
-        require_once dirname(__FILE__) . '/lib/php72compat_const.php';
61
-    }
62
-    if (PHP_VERSION_ID >= 70000) {
63
-        assert(class_exists('ParagonIE_Sodium_Compat'), 'Possible filesystem/autoloader bug?');
64
-    } else {
65
-        assert(class_exists('ParagonIE_Sodium_Compat'));
66
-    }
67
-    require_once(dirname(__FILE__) . '/lib/php72compat.php');
59
+	if (PHP_VERSION_ID >= 50300 && !defined('SODIUM_CRYPTO_SCALARMULT_BYTES')) {
60
+		require_once dirname(__FILE__) . '/lib/php72compat_const.php';
61
+	}
62
+	if (PHP_VERSION_ID >= 70000) {
63
+		assert(class_exists('ParagonIE_Sodium_Compat'), 'Possible filesystem/autoloader bug?');
64
+	} else {
65
+		assert(class_exists('ParagonIE_Sodium_Compat'));
66
+	}
67
+	require_once(dirname(__FILE__) . '/lib/php72compat.php');
68 68
 } elseif (!function_exists('sodium_crypto_stream_xchacha20_xor')) {
69
-    // Older versions of {PHP, ext/sodium} will not define these
70
-    require_once(dirname(__FILE__) . '/lib/php72compat.php');
69
+	// Older versions of {PHP, ext/sodium} will not define these
70
+	require_once(dirname(__FILE__) . '/lib/php72compat.php');
71 71
 }
72 72
 require_once(dirname(__FILE__) . '/lib/ristretto255.php');
Please login to merge, or discard this patch.
vendor/paragonie/sodium_compat/autoload-php7.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -3,29 +3,29 @@
 block discarded – undo
3 3
  This file should only ever be loaded on PHP 7+
4 4
  */
5 5
 if (PHP_VERSION_ID < 70000) {
6
-    return;
6
+	return;
7 7
 }
8 8
 
9 9
 spl_autoload_register(function ($class) {
10
-    $namespace = 'ParagonIE_Sodium_';
11
-    // Does the class use the namespace prefix?
12
-    $len = strlen($namespace);
13
-    if (strncmp($namespace, $class, $len) !== 0) {
14
-        // no, move to the next registered autoloader
15
-        return false;
16
-    }
10
+	$namespace = 'ParagonIE_Sodium_';
11
+	// Does the class use the namespace prefix?
12
+	$len = strlen($namespace);
13
+	if (strncmp($namespace, $class, $len) !== 0) {
14
+		// no, move to the next registered autoloader
15
+		return false;
16
+	}
17 17
 
18
-    // Get the relative class name
19
-    $relative_class = substr($class, $len);
18
+	// Get the relative class name
19
+	$relative_class = substr($class, $len);
20 20
 
21
-    // Replace the namespace prefix with the base directory, replace namespace
22
-    // separators with directory separators in the relative class name, append
23
-    // with .php
24
-    $file = dirname(__FILE__) . '/src/' . str_replace('_', '/', $relative_class) . '.php';
25
-    // if the file exists, require it
26
-    if (file_exists($file)) {
27
-        require_once $file;
28
-        return true;
29
-    }
30
-    return false;
21
+	// Replace the namespace prefix with the base directory, replace namespace
22
+	// separators with directory separators in the relative class name, append
23
+	// with .php
24
+	$file = dirname(__FILE__) . '/src/' . str_replace('_', '/', $relative_class) . '.php';
25
+	// if the file exists, require it
26
+	if (file_exists($file)) {
27
+		require_once $file;
28
+		return true;
29
+	}
30
+	return false;
31 31
 });
Please login to merge, or discard this patch.
vendor/paragonie/sodium_compat/autoload-phpunit.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,6 +3,6 @@
 block discarded – undo
3 3
 require_once (dirname(__FILE__) . '/vendor/autoload.php');
4 4
 
5 5
 if (PHP_VERSION_ID >= 50300) {
6
-    require_once (dirname(__FILE__) . '/tests/phpunit-shim.php');
6
+	require_once (dirname(__FILE__) . '/tests/phpunit-shim.php');
7 7
 }
8 8
 require_once (dirname(__FILE__) . '/autoload.php');
Please login to merge, or discard this patch.
vendor/paragonie/sodium_compat/src/Crypto.php 1 patch
Indentation   +1639 added lines, -1639 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if (class_exists('ParagonIE_Sodium_Crypto', false)) {
4
-    return;
4
+	return;
5 5
 }
6 6
 
7 7
 /**
@@ -14,1642 +14,1642 @@  discard block
 block discarded – undo
14 14
  */
15 15
 abstract class ParagonIE_Sodium_Crypto
16 16
 {
17
-    const aead_chacha20poly1305_KEYBYTES = 32;
18
-    const aead_chacha20poly1305_NSECBYTES = 0;
19
-    const aead_chacha20poly1305_NPUBBYTES = 8;
20
-    const aead_chacha20poly1305_ABYTES = 16;
21
-
22
-    const aead_chacha20poly1305_IETF_KEYBYTES = 32;
23
-    const aead_chacha20poly1305_IETF_NSECBYTES = 0;
24
-    const aead_chacha20poly1305_IETF_NPUBBYTES = 12;
25
-    const aead_chacha20poly1305_IETF_ABYTES = 16;
26
-
27
-    const aead_xchacha20poly1305_IETF_KEYBYTES = 32;
28
-    const aead_xchacha20poly1305_IETF_NSECBYTES = 0;
29
-    const aead_xchacha20poly1305_IETF_NPUBBYTES = 24;
30
-    const aead_xchacha20poly1305_IETF_ABYTES = 16;
31
-
32
-    const box_curve25519xsalsa20poly1305_SEEDBYTES = 32;
33
-    const box_curve25519xsalsa20poly1305_PUBLICKEYBYTES = 32;
34
-    const box_curve25519xsalsa20poly1305_SECRETKEYBYTES = 32;
35
-    const box_curve25519xsalsa20poly1305_BEFORENMBYTES = 32;
36
-    const box_curve25519xsalsa20poly1305_NONCEBYTES = 24;
37
-    const box_curve25519xsalsa20poly1305_MACBYTES = 16;
38
-    const box_curve25519xsalsa20poly1305_BOXZEROBYTES = 16;
39
-    const box_curve25519xsalsa20poly1305_ZEROBYTES = 32;
40
-
41
-    const onetimeauth_poly1305_BYTES = 16;
42
-    const onetimeauth_poly1305_KEYBYTES = 32;
43
-
44
-    const secretbox_xsalsa20poly1305_KEYBYTES = 32;
45
-    const secretbox_xsalsa20poly1305_NONCEBYTES = 24;
46
-    const secretbox_xsalsa20poly1305_MACBYTES = 16;
47
-    const secretbox_xsalsa20poly1305_BOXZEROBYTES = 16;
48
-    const secretbox_xsalsa20poly1305_ZEROBYTES = 32;
49
-
50
-    const secretbox_xchacha20poly1305_KEYBYTES = 32;
51
-    const secretbox_xchacha20poly1305_NONCEBYTES = 24;
52
-    const secretbox_xchacha20poly1305_MACBYTES = 16;
53
-    const secretbox_xchacha20poly1305_BOXZEROBYTES = 16;
54
-    const secretbox_xchacha20poly1305_ZEROBYTES = 32;
55
-
56
-    const stream_salsa20_KEYBYTES = 32;
57
-
58
-    /**
59
-     * AEAD Decryption with ChaCha20-Poly1305
60
-     *
61
-     * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
62
-     *
63
-     * @param string $message
64
-     * @param string $ad
65
-     * @param string $nonce
66
-     * @param string $key
67
-     * @return string
68
-     * @throws SodiumException
69
-     * @throws TypeError
70
-     */
71
-    public static function aead_chacha20poly1305_decrypt(
72
-        $message = '',
73
-        $ad = '',
74
-        $nonce = '',
75
-        $key = ''
76
-    ) {
77
-        /** @var int $len - Length of message (ciphertext + MAC) */
78
-        $len = ParagonIE_Sodium_Core_Util::strlen($message);
79
-
80
-        /** @var int  $clen - Length of ciphertext */
81
-        $clen = $len - self::aead_chacha20poly1305_ABYTES;
82
-
83
-        /** @var int $adlen - Length of associated data */
84
-        $adlen = ParagonIE_Sodium_Core_Util::strlen($ad);
85
-
86
-        /** @var string $mac - Message authentication code */
87
-        $mac = ParagonIE_Sodium_Core_Util::substr(
88
-            $message,
89
-            $clen,
90
-            self::aead_chacha20poly1305_ABYTES
91
-        );
92
-
93
-        /** @var string $ciphertext - The encrypted message (sans MAC) */
94
-        $ciphertext = ParagonIE_Sodium_Core_Util::substr($message, 0, $clen);
95
-
96
-        /** @var string The first block of the chacha20 keystream, used as a poly1305 key */
97
-        $block0 = ParagonIE_Sodium_Core_ChaCha20::stream(
98
-            32,
99
-            $nonce,
100
-            $key
101
-        );
102
-
103
-        /* Recalculate the Poly1305 authentication tag (MAC): */
104
-        $state = new ParagonIE_Sodium_Core_Poly1305_State($block0);
105
-        try {
106
-            ParagonIE_Sodium_Compat::memzero($block0);
107
-        } catch (SodiumException $ex) {
108
-            $block0 = null;
109
-        }
110
-        $state->update($ad);
111
-        $state->update(ParagonIE_Sodium_Core_Util::store64_le($adlen));
112
-        $state->update($ciphertext);
113
-        $state->update(ParagonIE_Sodium_Core_Util::store64_le($clen));
114
-        $computed_mac = $state->finish();
115
-
116
-        /* Compare the given MAC with the recalculated MAC: */
117
-        if (!ParagonIE_Sodium_Core_Util::verify_16($computed_mac, $mac)) {
118
-            throw new SodiumException('Invalid MAC');
119
-        }
120
-
121
-        // Here, we know that the MAC is valid, so we decrypt and return the plaintext
122
-        return ParagonIE_Sodium_Core_ChaCha20::streamXorIc(
123
-            $ciphertext,
124
-            $nonce,
125
-            $key,
126
-            ParagonIE_Sodium_Core_Util::store64_le(1)
127
-        );
128
-    }
129
-
130
-    /**
131
-     * AEAD Encryption with ChaCha20-Poly1305
132
-     *
133
-     * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
134
-     *
135
-     * @param string $message
136
-     * @param string $ad
137
-     * @param string $nonce
138
-     * @param string $key
139
-     * @return string
140
-     * @throws SodiumException
141
-     * @throws TypeError
142
-     */
143
-    public static function aead_chacha20poly1305_encrypt(
144
-        $message = '',
145
-        $ad = '',
146
-        $nonce = '',
147
-        $key = ''
148
-    ) {
149
-        /** @var int $len - Length of the plaintext message */
150
-        $len = ParagonIE_Sodium_Core_Util::strlen($message);
151
-
152
-        /** @var int $adlen - Length of the associated data */
153
-        $adlen = ParagonIE_Sodium_Core_Util::strlen($ad);
154
-
155
-        /** @var string The first block of the chacha20 keystream, used as a poly1305 key */
156
-        $block0 = ParagonIE_Sodium_Core_ChaCha20::stream(
157
-            32,
158
-            $nonce,
159
-            $key
160
-        );
161
-        $state = new ParagonIE_Sodium_Core_Poly1305_State($block0);
162
-        try {
163
-            ParagonIE_Sodium_Compat::memzero($block0);
164
-        } catch (SodiumException $ex) {
165
-            $block0 = null;
166
-        }
167
-
168
-        /** @var string $ciphertext - Raw encrypted data */
169
-        $ciphertext = ParagonIE_Sodium_Core_ChaCha20::streamXorIc(
170
-            $message,
171
-            $nonce,
172
-            $key,
173
-            ParagonIE_Sodium_Core_Util::store64_le(1)
174
-        );
175
-
176
-        $state->update($ad);
177
-        $state->update(ParagonIE_Sodium_Core_Util::store64_le($adlen));
178
-        $state->update($ciphertext);
179
-        $state->update(ParagonIE_Sodium_Core_Util::store64_le($len));
180
-        return $ciphertext . $state->finish();
181
-    }
182
-
183
-    /**
184
-     * AEAD Decryption with ChaCha20-Poly1305, IETF mode (96-bit nonce)
185
-     *
186
-     * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
187
-     *
188
-     * @param string $message
189
-     * @param string $ad
190
-     * @param string $nonce
191
-     * @param string $key
192
-     * @return string
193
-     * @throws SodiumException
194
-     * @throws TypeError
195
-     */
196
-    public static function aead_chacha20poly1305_ietf_decrypt(
197
-        $message = '',
198
-        $ad = '',
199
-        $nonce = '',
200
-        $key = ''
201
-    ) {
202
-        /** @var int $adlen - Length of associated data */
203
-        $adlen = ParagonIE_Sodium_Core_Util::strlen($ad);
204
-
205
-        /** @var int $len - Length of message (ciphertext + MAC) */
206
-        $len = ParagonIE_Sodium_Core_Util::strlen($message);
207
-
208
-        /** @var int  $clen - Length of ciphertext */
209
-        $clen = $len - self::aead_chacha20poly1305_IETF_ABYTES;
210
-
211
-        /** @var string The first block of the chacha20 keystream, used as a poly1305 key */
212
-        $block0 = ParagonIE_Sodium_Core_ChaCha20::ietfStream(
213
-            32,
214
-            $nonce,
215
-            $key
216
-        );
217
-
218
-        /** @var string $mac - Message authentication code */
219
-        $mac = ParagonIE_Sodium_Core_Util::substr(
220
-            $message,
221
-            $len - self::aead_chacha20poly1305_IETF_ABYTES,
222
-            self::aead_chacha20poly1305_IETF_ABYTES
223
-        );
224
-
225
-        /** @var string $ciphertext - The encrypted message (sans MAC) */
226
-        $ciphertext = ParagonIE_Sodium_Core_Util::substr(
227
-            $message,
228
-            0,
229
-            $len - self::aead_chacha20poly1305_IETF_ABYTES
230
-        );
231
-
232
-        /* Recalculate the Poly1305 authentication tag (MAC): */
233
-        $state = new ParagonIE_Sodium_Core_Poly1305_State($block0);
234
-        try {
235
-            ParagonIE_Sodium_Compat::memzero($block0);
236
-        } catch (SodiumException $ex) {
237
-            $block0 = null;
238
-        }
239
-        $state->update($ad);
240
-        $state->update(str_repeat("\x00", ((0x10 - $adlen) & 0xf)));
241
-        $state->update($ciphertext);
242
-        $state->update(str_repeat("\x00", (0x10 - $clen) & 0xf));
243
-        $state->update(ParagonIE_Sodium_Core_Util::store64_le($adlen));
244
-        $state->update(ParagonIE_Sodium_Core_Util::store64_le($clen));
245
-        $computed_mac = $state->finish();
246
-
247
-        /* Compare the given MAC with the recalculated MAC: */
248
-        if (!ParagonIE_Sodium_Core_Util::verify_16($computed_mac, $mac)) {
249
-            throw new SodiumException('Invalid MAC');
250
-        }
251
-
252
-        // Here, we know that the MAC is valid, so we decrypt and return the plaintext
253
-        return ParagonIE_Sodium_Core_ChaCha20::ietfStreamXorIc(
254
-            $ciphertext,
255
-            $nonce,
256
-            $key,
257
-            ParagonIE_Sodium_Core_Util::store64_le(1)
258
-        );
259
-    }
260
-
261
-    /**
262
-     * AEAD Encryption with ChaCha20-Poly1305, IETF mode (96-bit nonce)
263
-     *
264
-     * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
265
-     *
266
-     * @param string $message
267
-     * @param string $ad
268
-     * @param string $nonce
269
-     * @param string $key
270
-     * @return string
271
-     * @throws SodiumException
272
-     * @throws TypeError
273
-     */
274
-    public static function aead_chacha20poly1305_ietf_encrypt(
275
-        $message = '',
276
-        $ad = '',
277
-        $nonce = '',
278
-        $key = ''
279
-    ) {
280
-        /** @var int $len - Length of the plaintext message */
281
-        $len = ParagonIE_Sodium_Core_Util::strlen($message);
282
-
283
-        /** @var int $adlen - Length of the associated data */
284
-        $adlen = ParagonIE_Sodium_Core_Util::strlen($ad);
285
-
286
-        /** @var string The first block of the chacha20 keystream, used as a poly1305 key */
287
-        $block0 = ParagonIE_Sodium_Core_ChaCha20::ietfStream(
288
-            32,
289
-            $nonce,
290
-            $key
291
-        );
292
-        $state = new ParagonIE_Sodium_Core_Poly1305_State($block0);
293
-        try {
294
-            ParagonIE_Sodium_Compat::memzero($block0);
295
-        } catch (SodiumException $ex) {
296
-            $block0 = null;
297
-        }
298
-
299
-        /** @var string $ciphertext - Raw encrypted data */
300
-        $ciphertext = ParagonIE_Sodium_Core_ChaCha20::ietfStreamXorIc(
301
-            $message,
302
-            $nonce,
303
-            $key,
304
-            ParagonIE_Sodium_Core_Util::store64_le(1)
305
-        );
306
-
307
-        $state->update($ad);
308
-        $state->update(str_repeat("\x00", ((0x10 - $adlen) & 0xf)));
309
-        $state->update($ciphertext);
310
-        $state->update(str_repeat("\x00", ((0x10 - $len) & 0xf)));
311
-        $state->update(ParagonIE_Sodium_Core_Util::store64_le($adlen));
312
-        $state->update(ParagonIE_Sodium_Core_Util::store64_le($len));
313
-        return $ciphertext . $state->finish();
314
-    }
315
-
316
-    /**
317
-     * AEAD Decryption with ChaCha20-Poly1305, IETF mode (96-bit nonce)
318
-     *
319
-     * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
320
-     *
321
-     * @param string $message
322
-     * @param string $ad
323
-     * @param string $nonce
324
-     * @param string $key
325
-     * @return string
326
-     * @throws SodiumException
327
-     * @throws TypeError
328
-     */
329
-    public static function aead_xchacha20poly1305_ietf_decrypt(
330
-        $message = '',
331
-        $ad = '',
332
-        $nonce = '',
333
-        $key = ''
334
-    ) {
335
-        $subkey = ParagonIE_Sodium_Core_HChaCha20::hChaCha20(
336
-            ParagonIE_Sodium_Core_Util::substr($nonce, 0, 16),
337
-            $key
338
-        );
339
-        $nonceLast = "\x00\x00\x00\x00" .
340
-            ParagonIE_Sodium_Core_Util::substr($nonce, 16, 8);
341
-
342
-        return self::aead_chacha20poly1305_ietf_decrypt($message, $ad, $nonceLast, $subkey);
343
-    }
344
-
345
-    /**
346
-     * AEAD Encryption with ChaCha20-Poly1305, IETF mode (96-bit nonce)
347
-     *
348
-     * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
349
-     *
350
-     * @param string $message
351
-     * @param string $ad
352
-     * @param string $nonce
353
-     * @param string $key
354
-     * @return string
355
-     * @throws SodiumException
356
-     * @throws TypeError
357
-     */
358
-    public static function aead_xchacha20poly1305_ietf_encrypt(
359
-        $message = '',
360
-        $ad = '',
361
-        $nonce = '',
362
-        $key = ''
363
-    ) {
364
-        $subkey = ParagonIE_Sodium_Core_HChaCha20::hChaCha20(
365
-            ParagonIE_Sodium_Core_Util::substr($nonce, 0, 16),
366
-            $key
367
-        );
368
-        $nonceLast = "\x00\x00\x00\x00" .
369
-            ParagonIE_Sodium_Core_Util::substr($nonce, 16, 8);
370
-
371
-        return self::aead_chacha20poly1305_ietf_encrypt($message, $ad, $nonceLast, $subkey);
372
-    }
373
-
374
-    /**
375
-     * HMAC-SHA-512-256 (a.k.a. the leftmost 256 bits of HMAC-SHA-512)
376
-     *
377
-     * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
378
-     *
379
-     * @param string $message
380
-     * @param string $key
381
-     * @return string
382
-     * @throws TypeError
383
-     */
384
-    public static function auth($message, $key)
385
-    {
386
-        return ParagonIE_Sodium_Core_Util::substr(
387
-            hash_hmac('sha512', $message, $key, true),
388
-            0,
389
-            32
390
-        );
391
-    }
392
-
393
-    /**
394
-     * HMAC-SHA-512-256 validation. Constant-time via hash_equals().
395
-     *
396
-     * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
397
-     *
398
-     * @param string $mac
399
-     * @param string $message
400
-     * @param string $key
401
-     * @return bool
402
-     * @throws SodiumException
403
-     * @throws TypeError
404
-     */
405
-    public static function auth_verify($mac, $message, $key)
406
-    {
407
-        return ParagonIE_Sodium_Core_Util::hashEquals(
408
-            $mac,
409
-            self::auth($message, $key)
410
-        );
411
-    }
412
-
413
-    /**
414
-     * X25519 key exchange followed by XSalsa20Poly1305 symmetric encryption
415
-     *
416
-     * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
417
-     *
418
-     * @param string $plaintext
419
-     * @param string $nonce
420
-     * @param string $keypair
421
-     * @return string
422
-     * @throws SodiumException
423
-     * @throws TypeError
424
-     */
425
-    public static function box($plaintext, $nonce, $keypair)
426
-    {
427
-        $c = self::secretbox(
428
-            $plaintext,
429
-            $nonce,
430
-            self::box_beforenm(
431
-                self::box_secretkey($keypair),
432
-                self::box_publickey($keypair)
433
-            )
434
-        );
435
-        return $c;
436
-    }
437
-
438
-    /**
439
-     * X25519-XSalsa20-Poly1305 with one ephemeral X25519 keypair.
440
-     *
441
-     * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
442
-     *
443
-     * @param string $message
444
-     * @param string $publicKey
445
-     * @return string
446
-     * @throws SodiumException
447
-     * @throws TypeError
448
-     */
449
-    public static function box_seal($message, $publicKey)
450
-    {
451
-        /** @var string $ephemeralKeypair */
452
-        $ephemeralKeypair = self::box_keypair();
453
-
454
-        /** @var string $ephemeralSK */
455
-        $ephemeralSK = self::box_secretkey($ephemeralKeypair);
456
-
457
-        /** @var string $ephemeralPK */
458
-        $ephemeralPK = self::box_publickey($ephemeralKeypair);
459
-
460
-        /** @var string $nonce */
461
-        $nonce = self::generichash(
462
-            $ephemeralPK . $publicKey,
463
-            '',
464
-            24
465
-        );
466
-
467
-        /** @var string $keypair - The combined keypair used in crypto_box() */
468
-        $keypair = self::box_keypair_from_secretkey_and_publickey($ephemeralSK, $publicKey);
469
-
470
-        /** @var string $ciphertext Ciphertext + MAC from crypto_box */
471
-        $ciphertext = self::box($message, $nonce, $keypair);
472
-        try {
473
-            ParagonIE_Sodium_Compat::memzero($ephemeralKeypair);
474
-            ParagonIE_Sodium_Compat::memzero($ephemeralSK);
475
-            ParagonIE_Sodium_Compat::memzero($nonce);
476
-        } catch (SodiumException $ex) {
477
-            $ephemeralKeypair = null;
478
-            $ephemeralSK = null;
479
-            $nonce = null;
480
-        }
481
-        return $ephemeralPK . $ciphertext;
482
-    }
483
-
484
-    /**
485
-     * Opens a message encrypted via box_seal().
486
-     *
487
-     * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
488
-     *
489
-     * @param string $message
490
-     * @param string $keypair
491
-     * @return string
492
-     * @throws SodiumException
493
-     * @throws TypeError
494
-     */
495
-    public static function box_seal_open($message, $keypair)
496
-    {
497
-        /** @var string $ephemeralPK */
498
-        $ephemeralPK = ParagonIE_Sodium_Core_Util::substr($message, 0, 32);
499
-
500
-        /** @var string $ciphertext (ciphertext + MAC) */
501
-        $ciphertext = ParagonIE_Sodium_Core_Util::substr($message, 32);
502
-
503
-        /** @var string $secretKey */
504
-        $secretKey = self::box_secretkey($keypair);
505
-
506
-        /** @var string $publicKey */
507
-        $publicKey = self::box_publickey($keypair);
508
-
509
-        /** @var string $nonce */
510
-        $nonce = self::generichash(
511
-            $ephemeralPK . $publicKey,
512
-            '',
513
-            24
514
-        );
515
-
516
-        /** @var string $keypair */
517
-        $keypair = self::box_keypair_from_secretkey_and_publickey($secretKey, $ephemeralPK);
518
-
519
-        /** @var string $m */
520
-        $m = self::box_open($ciphertext, $nonce, $keypair);
521
-        try {
522
-            ParagonIE_Sodium_Compat::memzero($secretKey);
523
-            ParagonIE_Sodium_Compat::memzero($ephemeralPK);
524
-            ParagonIE_Sodium_Compat::memzero($nonce);
525
-        } catch (SodiumException $ex) {
526
-            $secretKey = null;
527
-            $ephemeralPK = null;
528
-            $nonce = null;
529
-        }
530
-        return $m;
531
-    }
532
-
533
-    /**
534
-     * Used by crypto_box() to get the crypto_secretbox() key.
535
-     *
536
-     * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
537
-     *
538
-     * @param string $sk
539
-     * @param string $pk
540
-     * @return string
541
-     * @throws SodiumException
542
-     * @throws TypeError
543
-     */
544
-    public static function box_beforenm($sk, $pk)
545
-    {
546
-        return ParagonIE_Sodium_Core_HSalsa20::hsalsa20(
547
-            str_repeat("\x00", 16),
548
-            self::scalarmult($sk, $pk)
549
-        );
550
-    }
551
-
552
-    /**
553
-     * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
554
-     *
555
-     * @return string
556
-     * @throws Exception
557
-     * @throws SodiumException
558
-     * @throws TypeError
559
-     */
560
-    public static function box_keypair()
561
-    {
562
-        $sKey = random_bytes(32);
563
-        $pKey = self::scalarmult_base($sKey);
564
-        return $sKey . $pKey;
565
-    }
566
-
567
-    /**
568
-     * @param string $seed
569
-     * @return string
570
-     * @throws SodiumException
571
-     * @throws TypeError
572
-     */
573
-    public static function box_seed_keypair($seed)
574
-    {
575
-        $sKey = ParagonIE_Sodium_Core_Util::substr(
576
-            hash('sha512', $seed, true),
577
-            0,
578
-            32
579
-        );
580
-        $pKey = self::scalarmult_base($sKey);
581
-        return $sKey . $pKey;
582
-    }
583
-
584
-    /**
585
-     * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
586
-     *
587
-     * @param string $sKey
588
-     * @param string $pKey
589
-     * @return string
590
-     * @throws TypeError
591
-     */
592
-    public static function box_keypair_from_secretkey_and_publickey($sKey, $pKey)
593
-    {
594
-        return ParagonIE_Sodium_Core_Util::substr($sKey, 0, 32) .
595
-            ParagonIE_Sodium_Core_Util::substr($pKey, 0, 32);
596
-    }
597
-
598
-    /**
599
-     * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
600
-     *
601
-     * @param string $keypair
602
-     * @return string
603
-     * @throws RangeException
604
-     * @throws TypeError
605
-     */
606
-    public static function box_secretkey($keypair)
607
-    {
608
-        if (ParagonIE_Sodium_Core_Util::strlen($keypair) !== 64) {
609
-            throw new RangeException(
610
-                'Must be ParagonIE_Sodium_Compat::CRYPTO_BOX_KEYPAIRBYTES bytes long.'
611
-            );
612
-        }
613
-        return ParagonIE_Sodium_Core_Util::substr($keypair, 0, 32);
614
-    }
615
-
616
-    /**
617
-     * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
618
-     *
619
-     * @param string $keypair
620
-     * @return string
621
-     * @throws RangeException
622
-     * @throws TypeError
623
-     */
624
-    public static function box_publickey($keypair)
625
-    {
626
-        if (ParagonIE_Sodium_Core_Util::strlen($keypair) !== ParagonIE_Sodium_Compat::CRYPTO_BOX_KEYPAIRBYTES) {
627
-            throw new RangeException(
628
-                'Must be ParagonIE_Sodium_Compat::CRYPTO_BOX_KEYPAIRBYTES bytes long.'
629
-            );
630
-        }
631
-        return ParagonIE_Sodium_Core_Util::substr($keypair, 32, 32);
632
-    }
633
-
634
-    /**
635
-     * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
636
-     *
637
-     * @param string $sKey
638
-     * @return string
639
-     * @throws RangeException
640
-     * @throws SodiumException
641
-     * @throws TypeError
642
-     */
643
-    public static function box_publickey_from_secretkey($sKey)
644
-    {
645
-        if (ParagonIE_Sodium_Core_Util::strlen($sKey) !== ParagonIE_Sodium_Compat::CRYPTO_BOX_SECRETKEYBYTES) {
646
-            throw new RangeException(
647
-                'Must be ParagonIE_Sodium_Compat::CRYPTO_BOX_SECRETKEYBYTES bytes long.'
648
-            );
649
-        }
650
-        return self::scalarmult_base($sKey);
651
-    }
652
-
653
-    /**
654
-     * Decrypt a message encrypted with box().
655
-     *
656
-     * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
657
-     *
658
-     * @param string $ciphertext
659
-     * @param string $nonce
660
-     * @param string $keypair
661
-     * @return string
662
-     * @throws SodiumException
663
-     * @throws TypeError
664
-     */
665
-    public static function box_open($ciphertext, $nonce, $keypair)
666
-    {
667
-        return self::secretbox_open(
668
-            $ciphertext,
669
-            $nonce,
670
-            self::box_beforenm(
671
-                self::box_secretkey($keypair),
672
-                self::box_publickey($keypair)
673
-            )
674
-        );
675
-    }
676
-
677
-    /**
678
-     * Calculate a BLAKE2b hash.
679
-     *
680
-     * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
681
-     *
682
-     * @param string $message
683
-     * @param string|null $key
684
-     * @param int $outlen
685
-     * @return string
686
-     * @throws RangeException
687
-     * @throws SodiumException
688
-     * @throws TypeError
689
-     */
690
-    public static function generichash($message, $key = '', $outlen = 32)
691
-    {
692
-        // This ensures that ParagonIE_Sodium_Core_BLAKE2b::$iv is initialized
693
-        ParagonIE_Sodium_Core_BLAKE2b::pseudoConstructor();
694
-
695
-        $k = null;
696
-        if (!empty($key)) {
697
-            /** @var SplFixedArray $k */
698
-            $k = ParagonIE_Sodium_Core_BLAKE2b::stringToSplFixedArray($key);
699
-            if ($k->count() > ParagonIE_Sodium_Core_BLAKE2b::KEYBYTES) {
700
-                throw new RangeException('Invalid key size');
701
-            }
702
-        }
703
-
704
-        /** @var SplFixedArray $in */
705
-        $in = ParagonIE_Sodium_Core_BLAKE2b::stringToSplFixedArray($message);
706
-
707
-        /** @var SplFixedArray $ctx */
708
-        $ctx = ParagonIE_Sodium_Core_BLAKE2b::init($k, $outlen);
709
-        ParagonIE_Sodium_Core_BLAKE2b::update($ctx, $in, $in->count());
710
-
711
-        /** @var SplFixedArray $out */
712
-        $out = new SplFixedArray($outlen);
713
-        $out = ParagonIE_Sodium_Core_BLAKE2b::finish($ctx, $out);
714
-
715
-        /** @var array<int, int> */
716
-        $outArray = $out->toArray();
717
-        return ParagonIE_Sodium_Core_Util::intArrayToString($outArray);
718
-    }
719
-
720
-    /**
721
-     * Finalize a BLAKE2b hashing context, returning the hash.
722
-     *
723
-     * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
724
-     *
725
-     * @param string $ctx
726
-     * @param int $outlen
727
-     * @return string
728
-     * @throws SodiumException
729
-     * @throws TypeError
730
-     */
731
-    public static function generichash_final($ctx, $outlen = 32)
732
-    {
733
-        if (!is_string($ctx)) {
734
-            throw new TypeError('Context must be a string');
735
-        }
736
-        $out = new SplFixedArray($outlen);
737
-
738
-        /** @var SplFixedArray $context */
739
-        $context = ParagonIE_Sodium_Core_BLAKE2b::stringToContext($ctx);
740
-
741
-        /** @var SplFixedArray $out */
742
-        $out = ParagonIE_Sodium_Core_BLAKE2b::finish($context, $out);
743
-
744
-        /** @var array<int, int> */
745
-        $outArray = $out->toArray();
746
-        return ParagonIE_Sodium_Core_Util::intArrayToString($outArray);
747
-    }
748
-
749
-    /**
750
-     * Initialize a hashing context for BLAKE2b.
751
-     *
752
-     * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
753
-     *
754
-     * @param string $key
755
-     * @param int $outputLength
756
-     * @return string
757
-     * @throws RangeException
758
-     * @throws SodiumException
759
-     * @throws TypeError
760
-     */
761
-    public static function generichash_init($key = '', $outputLength = 32)
762
-    {
763
-        // This ensures that ParagonIE_Sodium_Core_BLAKE2b::$iv is initialized
764
-        ParagonIE_Sodium_Core_BLAKE2b::pseudoConstructor();
765
-
766
-        $k = null;
767
-        if (!empty($key)) {
768
-            $k = ParagonIE_Sodium_Core_BLAKE2b::stringToSplFixedArray($key);
769
-            if ($k->count() > ParagonIE_Sodium_Core_BLAKE2b::KEYBYTES) {
770
-                throw new RangeException('Invalid key size');
771
-            }
772
-        }
773
-
774
-        /** @var SplFixedArray $ctx */
775
-        $ctx = ParagonIE_Sodium_Core_BLAKE2b::init($k, $outputLength);
776
-
777
-        return ParagonIE_Sodium_Core_BLAKE2b::contextToString($ctx);
778
-    }
779
-
780
-    /**
781
-     * Initialize a hashing context for BLAKE2b.
782
-     *
783
-     * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
784
-     *
785
-     * @param string $key
786
-     * @param int $outputLength
787
-     * @param string $salt
788
-     * @param string $personal
789
-     * @return string
790
-     * @throws RangeException
791
-     * @throws SodiumException
792
-     * @throws TypeError
793
-     */
794
-    public static function generichash_init_salt_personal(
795
-        $key = '',
796
-        $outputLength = 32,
797
-        $salt = '',
798
-        $personal = ''
799
-    ) {
800
-        // This ensures that ParagonIE_Sodium_Core_BLAKE2b::$iv is initialized
801
-        ParagonIE_Sodium_Core_BLAKE2b::pseudoConstructor();
802
-
803
-        $k = null;
804
-        if (!empty($key)) {
805
-            $k = ParagonIE_Sodium_Core_BLAKE2b::stringToSplFixedArray($key);
806
-            if ($k->count() > ParagonIE_Sodium_Core_BLAKE2b::KEYBYTES) {
807
-                throw new RangeException('Invalid key size');
808
-            }
809
-        }
810
-        if (!empty($salt)) {
811
-            $s = ParagonIE_Sodium_Core_BLAKE2b::stringToSplFixedArray($salt);
812
-        } else {
813
-            $s = null;
814
-        }
815
-        if (!empty($salt)) {
816
-            $p = ParagonIE_Sodium_Core_BLAKE2b::stringToSplFixedArray($personal);
817
-        } else {
818
-            $p = null;
819
-        }
820
-
821
-        /** @var SplFixedArray $ctx */
822
-        $ctx = ParagonIE_Sodium_Core_BLAKE2b::init($k, $outputLength, $s, $p);
823
-
824
-        return ParagonIE_Sodium_Core_BLAKE2b::contextToString($ctx);
825
-    }
826
-
827
-    /**
828
-     * Update a hashing context for BLAKE2b with $message
829
-     *
830
-     * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
831
-     *
832
-     * @param string $ctx
833
-     * @param string $message
834
-     * @return string
835
-     * @throws SodiumException
836
-     * @throws TypeError
837
-     */
838
-    public static function generichash_update($ctx, $message)
839
-    {
840
-        // This ensures that ParagonIE_Sodium_Core_BLAKE2b::$iv is initialized
841
-        ParagonIE_Sodium_Core_BLAKE2b::pseudoConstructor();
842
-
843
-        /** @var SplFixedArray $context */
844
-        $context = ParagonIE_Sodium_Core_BLAKE2b::stringToContext($ctx);
845
-
846
-        /** @var SplFixedArray $in */
847
-        $in = ParagonIE_Sodium_Core_BLAKE2b::stringToSplFixedArray($message);
848
-
849
-        ParagonIE_Sodium_Core_BLAKE2b::update($context, $in, $in->count());
850
-
851
-        return ParagonIE_Sodium_Core_BLAKE2b::contextToString($context);
852
-    }
853
-
854
-    /**
855
-     * Libsodium's crypto_kx().
856
-     *
857
-     * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
858
-     *
859
-     * @param string $my_sk
860
-     * @param string $their_pk
861
-     * @param string $client_pk
862
-     * @param string $server_pk
863
-     * @return string
864
-     * @throws SodiumException
865
-     * @throws TypeError
866
-     */
867
-    public static function keyExchange($my_sk, $their_pk, $client_pk, $server_pk)
868
-    {
869
-        return ParagonIE_Sodium_Compat::crypto_generichash(
870
-            ParagonIE_Sodium_Compat::crypto_scalarmult($my_sk, $their_pk) .
871
-            $client_pk .
872
-            $server_pk
873
-        );
874
-    }
875
-
876
-    /**
877
-     * ECDH over Curve25519
878
-     *
879
-     * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
880
-     *
881
-     * @param string $sKey
882
-     * @param string $pKey
883
-     * @return string
884
-     *
885
-     * @throws SodiumException
886
-     * @throws TypeError
887
-     */
888
-    public static function scalarmult($sKey, $pKey)
889
-    {
890
-        $q = ParagonIE_Sodium_Core_X25519::crypto_scalarmult_curve25519_ref10($sKey, $pKey);
891
-        self::scalarmult_throw_if_zero($q);
892
-        return $q;
893
-    }
894
-
895
-    /**
896
-     * ECDH over Curve25519, using the basepoint.
897
-     * Used to get a secret key from a public key.
898
-     *
899
-     * @param string $secret
900
-     * @return string
901
-     *
902
-     * @throws SodiumException
903
-     * @throws TypeError
904
-     */
905
-    public static function scalarmult_base($secret)
906
-    {
907
-        $q = ParagonIE_Sodium_Core_X25519::crypto_scalarmult_curve25519_ref10_base($secret);
908
-        self::scalarmult_throw_if_zero($q);
909
-        return $q;
910
-    }
911
-
912
-    /**
913
-     * This throws an Error if a zero public key was passed to the function.
914
-     *
915
-     * @param string $q
916
-     * @return void
917
-     * @throws SodiumException
918
-     * @throws TypeError
919
-     */
920
-    protected static function scalarmult_throw_if_zero($q)
921
-    {
922
-        $d = 0;
923
-        for ($i = 0; $i < self::box_curve25519xsalsa20poly1305_SECRETKEYBYTES; ++$i) {
924
-            $d |= ParagonIE_Sodium_Core_Util::chrToInt($q[$i]);
925
-        }
926
-
927
-        /* branch-free variant of === 0 */
928
-        if (-(1 & (($d - 1) >> 8))) {
929
-            throw new SodiumException('Zero public key is not allowed');
930
-        }
931
-    }
932
-
933
-    /**
934
-     * XSalsa20-Poly1305 authenticated symmetric-key encryption.
935
-     *
936
-     * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
937
-     *
938
-     * @param string $plaintext
939
-     * @param string $nonce
940
-     * @param string $key
941
-     * @return string
942
-     * @throws SodiumException
943
-     * @throws TypeError
944
-     */
945
-    public static function secretbox($plaintext, $nonce, $key)
946
-    {
947
-        /** @var string $subkey */
948
-        $subkey = ParagonIE_Sodium_Core_HSalsa20::hsalsa20($nonce, $key);
949
-
950
-        /** @var string $block0 */
951
-        $block0 = str_repeat("\x00", 32);
952
-
953
-        /** @var int $mlen - Length of the plaintext message */
954
-        $mlen = ParagonIE_Sodium_Core_Util::strlen($plaintext);
955
-        $mlen0 = $mlen;
956
-        if ($mlen0 > 64 - self::secretbox_xsalsa20poly1305_ZEROBYTES) {
957
-            $mlen0 = 64 - self::secretbox_xsalsa20poly1305_ZEROBYTES;
958
-        }
959
-        $block0 .= ParagonIE_Sodium_Core_Util::substr($plaintext, 0, $mlen0);
960
-
961
-        /** @var string $block0 */
962
-        $block0 = ParagonIE_Sodium_Core_Salsa20::salsa20_xor(
963
-            $block0,
964
-            ParagonIE_Sodium_Core_Util::substr($nonce, 16, 8),
965
-            $subkey
966
-        );
967
-
968
-        /** @var string $c */
969
-        $c = ParagonIE_Sodium_Core_Util::substr(
970
-            $block0,
971
-            self::secretbox_xsalsa20poly1305_ZEROBYTES
972
-        );
973
-        if ($mlen > $mlen0) {
974
-            $c .= ParagonIE_Sodium_Core_Salsa20::salsa20_xor_ic(
975
-                ParagonIE_Sodium_Core_Util::substr(
976
-                    $plaintext,
977
-                    self::secretbox_xsalsa20poly1305_ZEROBYTES
978
-                ),
979
-                ParagonIE_Sodium_Core_Util::substr($nonce, 16, 8),
980
-                1,
981
-                $subkey
982
-            );
983
-        }
984
-        $state = new ParagonIE_Sodium_Core_Poly1305_State(
985
-            ParagonIE_Sodium_Core_Util::substr(
986
-                $block0,
987
-                0,
988
-                self::onetimeauth_poly1305_KEYBYTES
989
-            )
990
-        );
991
-        try {
992
-            ParagonIE_Sodium_Compat::memzero($block0);
993
-            ParagonIE_Sodium_Compat::memzero($subkey);
994
-        } catch (SodiumException $ex) {
995
-            $block0 = null;
996
-            $subkey = null;
997
-        }
998
-
999
-        $state->update($c);
1000
-
1001
-        /** @var string $c - MAC || ciphertext */
1002
-        $c = $state->finish() . $c;
1003
-        unset($state);
1004
-
1005
-        return $c;
1006
-    }
1007
-
1008
-    /**
1009
-     * Decrypt a ciphertext generated via secretbox().
1010
-     *
1011
-     * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
1012
-     *
1013
-     * @param string $ciphertext
1014
-     * @param string $nonce
1015
-     * @param string $key
1016
-     * @return string
1017
-     * @throws SodiumException
1018
-     * @throws TypeError
1019
-     */
1020
-    public static function secretbox_open($ciphertext, $nonce, $key)
1021
-    {
1022
-        /** @var string $mac */
1023
-        $mac = ParagonIE_Sodium_Core_Util::substr(
1024
-            $ciphertext,
1025
-            0,
1026
-            self::secretbox_xsalsa20poly1305_MACBYTES
1027
-        );
1028
-
1029
-        /** @var string $c */
1030
-        $c = ParagonIE_Sodium_Core_Util::substr(
1031
-            $ciphertext,
1032
-            self::secretbox_xsalsa20poly1305_MACBYTES
1033
-        );
1034
-
1035
-        /** @var int $clen */
1036
-        $clen = ParagonIE_Sodium_Core_Util::strlen($c);
1037
-
1038
-        /** @var string $subkey */
1039
-        $subkey = ParagonIE_Sodium_Core_HSalsa20::hsalsa20($nonce, $key);
1040
-
1041
-        /** @var string $block0 */
1042
-        $block0 = ParagonIE_Sodium_Core_Salsa20::salsa20(
1043
-            64,
1044
-            ParagonIE_Sodium_Core_Util::substr($nonce, 16, 8),
1045
-            $subkey
1046
-        );
1047
-        $verified = ParagonIE_Sodium_Core_Poly1305::onetimeauth_verify(
1048
-            $mac,
1049
-            $c,
1050
-            ParagonIE_Sodium_Core_Util::substr($block0, 0, 32)
1051
-        );
1052
-        if (!$verified) {
1053
-            try {
1054
-                ParagonIE_Sodium_Compat::memzero($subkey);
1055
-            } catch (SodiumException $ex) {
1056
-                $subkey = null;
1057
-            }
1058
-            throw new SodiumException('Invalid MAC');
1059
-        }
1060
-
1061
-        /** @var string $m - Decrypted message */
1062
-        $m = ParagonIE_Sodium_Core_Util::xorStrings(
1063
-            ParagonIE_Sodium_Core_Util::substr($block0, self::secretbox_xsalsa20poly1305_ZEROBYTES),
1064
-            ParagonIE_Sodium_Core_Util::substr($c, 0, self::secretbox_xsalsa20poly1305_ZEROBYTES)
1065
-        );
1066
-        if ($clen > self::secretbox_xsalsa20poly1305_ZEROBYTES) {
1067
-            // We had more than 1 block, so let's continue to decrypt the rest.
1068
-            $m .= ParagonIE_Sodium_Core_Salsa20::salsa20_xor_ic(
1069
-                ParagonIE_Sodium_Core_Util::substr(
1070
-                    $c,
1071
-                    self::secretbox_xsalsa20poly1305_ZEROBYTES
1072
-                ),
1073
-                ParagonIE_Sodium_Core_Util::substr($nonce, 16, 8),
1074
-                1,
1075
-                (string) $subkey
1076
-            );
1077
-        }
1078
-        return $m;
1079
-    }
1080
-
1081
-    /**
1082
-     * XChaCha20-Poly1305 authenticated symmetric-key encryption.
1083
-     *
1084
-     * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
1085
-     *
1086
-     * @param string $plaintext
1087
-     * @param string $nonce
1088
-     * @param string $key
1089
-     * @return string
1090
-     * @throws SodiumException
1091
-     * @throws TypeError
1092
-     */
1093
-    public static function secretbox_xchacha20poly1305($plaintext, $nonce, $key)
1094
-    {
1095
-        /** @var string $subkey */
1096
-        $subkey = ParagonIE_Sodium_Core_HChaCha20::hChaCha20(
1097
-            ParagonIE_Sodium_Core_Util::substr($nonce, 0, 16),
1098
-            $key
1099
-        );
1100
-        $nonceLast = ParagonIE_Sodium_Core_Util::substr($nonce, 16, 8);
1101
-
1102
-        /** @var string $block0 */
1103
-        $block0 = str_repeat("\x00", 32);
1104
-
1105
-        /** @var int $mlen - Length of the plaintext message */
1106
-        $mlen = ParagonIE_Sodium_Core_Util::strlen($plaintext);
1107
-        $mlen0 = $mlen;
1108
-        if ($mlen0 > 64 - self::secretbox_xchacha20poly1305_ZEROBYTES) {
1109
-            $mlen0 = 64 - self::secretbox_xchacha20poly1305_ZEROBYTES;
1110
-        }
1111
-        $block0 .= ParagonIE_Sodium_Core_Util::substr($plaintext, 0, $mlen0);
1112
-
1113
-        /** @var string $block0 */
1114
-        $block0 = ParagonIE_Sodium_Core_ChaCha20::streamXorIc(
1115
-            $block0,
1116
-            $nonceLast,
1117
-            $subkey
1118
-        );
1119
-
1120
-        /** @var string $c */
1121
-        $c = ParagonIE_Sodium_Core_Util::substr(
1122
-            $block0,
1123
-            self::secretbox_xchacha20poly1305_ZEROBYTES
1124
-        );
1125
-        if ($mlen > $mlen0) {
1126
-            $c .= ParagonIE_Sodium_Core_ChaCha20::streamXorIc(
1127
-                ParagonIE_Sodium_Core_Util::substr(
1128
-                    $plaintext,
1129
-                    self::secretbox_xchacha20poly1305_ZEROBYTES
1130
-                ),
1131
-                $nonceLast,
1132
-                $subkey,
1133
-                ParagonIE_Sodium_Core_Util::store64_le(1)
1134
-            );
1135
-        }
1136
-        $state = new ParagonIE_Sodium_Core_Poly1305_State(
1137
-            ParagonIE_Sodium_Core_Util::substr(
1138
-                $block0,
1139
-                0,
1140
-                self::onetimeauth_poly1305_KEYBYTES
1141
-            )
1142
-        );
1143
-        try {
1144
-            ParagonIE_Sodium_Compat::memzero($block0);
1145
-            ParagonIE_Sodium_Compat::memzero($subkey);
1146
-        } catch (SodiumException $ex) {
1147
-            $block0 = null;
1148
-            $subkey = null;
1149
-        }
1150
-
1151
-        $state->update($c);
1152
-
1153
-        /** @var string $c - MAC || ciphertext */
1154
-        $c = $state->finish() . $c;
1155
-        unset($state);
1156
-
1157
-        return $c;
1158
-    }
1159
-
1160
-    /**
1161
-     * Decrypt a ciphertext generated via secretbox_xchacha20poly1305().
1162
-     *
1163
-     * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
1164
-     *
1165
-     * @param string $ciphertext
1166
-     * @param string $nonce
1167
-     * @param string $key
1168
-     * @return string
1169
-     * @throws SodiumException
1170
-     * @throws TypeError
1171
-     */
1172
-    public static function secretbox_xchacha20poly1305_open($ciphertext, $nonce, $key)
1173
-    {
1174
-        /** @var string $mac */
1175
-        $mac = ParagonIE_Sodium_Core_Util::substr(
1176
-            $ciphertext,
1177
-            0,
1178
-            self::secretbox_xchacha20poly1305_MACBYTES
1179
-        );
1180
-
1181
-        /** @var string $c */
1182
-        $c = ParagonIE_Sodium_Core_Util::substr(
1183
-            $ciphertext,
1184
-            self::secretbox_xchacha20poly1305_MACBYTES
1185
-        );
1186
-
1187
-        /** @var int $clen */
1188
-        $clen = ParagonIE_Sodium_Core_Util::strlen($c);
1189
-
1190
-        /** @var string $subkey */
1191
-        $subkey = ParagonIE_Sodium_Core_HChaCha20::hchacha20($nonce, $key);
1192
-
1193
-        /** @var string $block0 */
1194
-        $block0 = ParagonIE_Sodium_Core_ChaCha20::stream(
1195
-            64,
1196
-            ParagonIE_Sodium_Core_Util::substr($nonce, 16, 8),
1197
-            $subkey
1198
-        );
1199
-        $verified = ParagonIE_Sodium_Core_Poly1305::onetimeauth_verify(
1200
-            $mac,
1201
-            $c,
1202
-            ParagonIE_Sodium_Core_Util::substr($block0, 0, 32)
1203
-        );
1204
-
1205
-        if (!$verified) {
1206
-            try {
1207
-                ParagonIE_Sodium_Compat::memzero($subkey);
1208
-            } catch (SodiumException $ex) {
1209
-                $subkey = null;
1210
-            }
1211
-            throw new SodiumException('Invalid MAC');
1212
-        }
1213
-
1214
-        /** @var string $m - Decrypted message */
1215
-        $m = ParagonIE_Sodium_Core_Util::xorStrings(
1216
-            ParagonIE_Sodium_Core_Util::substr($block0, self::secretbox_xchacha20poly1305_ZEROBYTES),
1217
-            ParagonIE_Sodium_Core_Util::substr($c, 0, self::secretbox_xchacha20poly1305_ZEROBYTES)
1218
-        );
1219
-
1220
-        if ($clen > self::secretbox_xchacha20poly1305_ZEROBYTES) {
1221
-            // We had more than 1 block, so let's continue to decrypt the rest.
1222
-            $m .= ParagonIE_Sodium_Core_ChaCha20::streamXorIc(
1223
-                ParagonIE_Sodium_Core_Util::substr(
1224
-                    $c,
1225
-                    self::secretbox_xchacha20poly1305_ZEROBYTES
1226
-                ),
1227
-                ParagonIE_Sodium_Core_Util::substr($nonce, 16, 8),
1228
-                (string) $subkey,
1229
-                ParagonIE_Sodium_Core_Util::store64_le(1)
1230
-            );
1231
-        }
1232
-        return $m;
1233
-    }
1234
-
1235
-    /**
1236
-     * @param string $key
1237
-     * @return array<int, string> Returns a state and a header.
1238
-     * @throws Exception
1239
-     * @throws SodiumException
1240
-     */
1241
-    public static function secretstream_xchacha20poly1305_init_push($key)
1242
-    {
1243
-        # randombytes_buf(out, crypto_secretstream_xchacha20poly1305_HEADERBYTES);
1244
-        $out = random_bytes(24);
1245
-
1246
-        # crypto_core_hchacha20(state->k, out, k, NULL);
1247
-        $subkey = ParagonIE_Sodium_Core_HChaCha20::hChaCha20($out, $key);
1248
-        $state = new ParagonIE_Sodium_Core_SecretStream_State(
1249
-            $subkey,
1250
-            ParagonIE_Sodium_Core_Util::substr($out, 16, 8) . str_repeat("\0", 4)
1251
-        );
1252
-
1253
-        # _crypto_secretstream_xchacha20poly1305_counter_reset(state);
1254
-        $state->counterReset();
1255
-
1256
-        # memcpy(STATE_INONCE(state), out + crypto_core_hchacha20_INPUTBYTES,
1257
-        #        crypto_secretstream_xchacha20poly1305_INONCEBYTES);
1258
-        # memset(state->_pad, 0, sizeof state->_pad);
1259
-        return array(
1260
-            $state->toString(),
1261
-            $out
1262
-        );
1263
-    }
1264
-
1265
-    /**
1266
-     * @param string $key
1267
-     * @param string $header
1268
-     * @return string Returns a state.
1269
-     * @throws Exception
1270
-     */
1271
-    public static function secretstream_xchacha20poly1305_init_pull($key, $header)
1272
-    {
1273
-        # crypto_core_hchacha20(state->k, in, k, NULL);
1274
-        $subkey = ParagonIE_Sodium_Core_HChaCha20::hChaCha20(
1275
-            ParagonIE_Sodium_Core_Util::substr($header, 0, 16),
1276
-            $key
1277
-        );
1278
-        $state = new ParagonIE_Sodium_Core_SecretStream_State(
1279
-            $subkey,
1280
-            ParagonIE_Sodium_Core_Util::substr($header, 16)
1281
-        );
1282
-        $state->counterReset();
1283
-        # memcpy(STATE_INONCE(state), in + crypto_core_hchacha20_INPUTBYTES,
1284
-        #     crypto_secretstream_xchacha20poly1305_INONCEBYTES);
1285
-        # memset(state->_pad, 0, sizeof state->_pad);
1286
-        # return 0;
1287
-        return $state->toString();
1288
-    }
1289
-
1290
-    /**
1291
-     * @param string $state
1292
-     * @param string $msg
1293
-     * @param string $aad
1294
-     * @param int $tag
1295
-     * @return string
1296
-     * @throws SodiumException
1297
-     */
1298
-    public static function secretstream_xchacha20poly1305_push(&$state, $msg, $aad = '', $tag = 0)
1299
-    {
1300
-        $st = ParagonIE_Sodium_Core_SecretStream_State::fromString($state);
1301
-        # crypto_onetimeauth_poly1305_state poly1305_state;
1302
-        # unsigned char                     block[64U];
1303
-        # unsigned char                     slen[8U];
1304
-        # unsigned char                    *c;
1305
-        # unsigned char                    *mac;
1306
-
1307
-        $msglen = ParagonIE_Sodium_Core_Util::strlen($msg);
1308
-        $aadlen = ParagonIE_Sodium_Core_Util::strlen($aad);
1309
-
1310
-        if ((($msglen + 63) >> 6) > 0xfffffffe) {
1311
-            throw new SodiumException(
1312
-                'message cannot be larger than SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_MESSAGEBYTES_MAX bytes'
1313
-            );
1314
-        }
1315
-
1316
-        # if (outlen_p != NULL) {
1317
-        #     *outlen_p = 0U;
1318
-        # }
1319
-        # if (mlen > crypto_secretstream_xchacha20poly1305_MESSAGEBYTES_MAX) {
1320
-        #     sodium_misuse();
1321
-        # }
1322
-
1323
-        # crypto_stream_chacha20_ietf(block, sizeof block, state->nonce, state->k);
1324
-        # crypto_onetimeauth_poly1305_init(&poly1305_state, block);
1325
-        # sodium_memzero(block, sizeof block);
1326
-        $auth = new ParagonIE_Sodium_Core_Poly1305_State(
1327
-            ParagonIE_Sodium_Core_ChaCha20::ietfStream(32, $st->getCombinedNonce(), $st->getKey())
1328
-        );
1329
-
1330
-        # crypto_onetimeauth_poly1305_update(&poly1305_state, ad, adlen);
1331
-        $auth->update($aad);
1332
-
1333
-        # crypto_onetimeauth_poly1305_update(&poly1305_state, _pad0,
1334
-        #     (0x10 - adlen) & 0xf);
1335
-        $auth->update(str_repeat("\0", ((0x10 - $aadlen) & 0xf)));
1336
-
1337
-        # memset(block, 0, sizeof block);
1338
-        # block[0] = tag;
1339
-        # crypto_stream_chacha20_ietf_xor_ic(block, block, sizeof block,
1340
-        #                                    state->nonce, 1U, state->k);
1341
-        $block = ParagonIE_Sodium_Core_ChaCha20::ietfStreamXorIc(
1342
-            ParagonIE_Sodium_Core_Util::intToChr($tag) . str_repeat("\0", 63),
1343
-            $st->getCombinedNonce(),
1344
-            $st->getKey(),
1345
-            ParagonIE_Sodium_Core_Util::store64_le(1)
1346
-        );
1347
-
1348
-        # crypto_onetimeauth_poly1305_update(&poly1305_state, block, sizeof block);
1349
-        $auth->update($block);
1350
-
1351
-        # out[0] = block[0];
1352
-        $out = $block[0];
1353
-        # c = out + (sizeof tag);
1354
-        # crypto_stream_chacha20_ietf_xor_ic(c, m, mlen, state->nonce, 2U, state->k);
1355
-        $cipher = ParagonIE_Sodium_Core_ChaCha20::ietfStreamXorIc(
1356
-            $msg,
1357
-            $st->getCombinedNonce(),
1358
-            $st->getKey(),
1359
-            ParagonIE_Sodium_Core_Util::store64_le(2)
1360
-        );
1361
-
1362
-        # crypto_onetimeauth_poly1305_update(&poly1305_state, c, mlen);
1363
-        $auth->update($cipher);
1364
-
1365
-        $out .= $cipher;
1366
-        unset($cipher);
1367
-
1368
-        # crypto_onetimeauth_poly1305_update
1369
-        # (&poly1305_state, _pad0, (0x10 - (sizeof block) + mlen) & 0xf);
1370
-        $auth->update(str_repeat("\0", ((0x10 - 64 + $msglen) & 0xf)));
1371
-
1372
-        # STORE64_LE(slen, (uint64_t) adlen);
1373
-        $slen = ParagonIE_Sodium_Core_Util::store64_le($aadlen);
1374
-
1375
-        # crypto_onetimeauth_poly1305_update(&poly1305_state, slen, sizeof slen);
1376
-        $auth->update($slen);
1377
-
1378
-        # STORE64_LE(slen, (sizeof block) + mlen);
1379
-        $slen = ParagonIE_Sodium_Core_Util::store64_le(64 + $msglen);
1380
-
1381
-        # crypto_onetimeauth_poly1305_update(&poly1305_state, slen, sizeof slen);
1382
-        $auth->update($slen);
1383
-
1384
-        # mac = c + mlen;
1385
-        # crypto_onetimeauth_poly1305_final(&poly1305_state, mac);
1386
-        $mac = $auth->finish();
1387
-        $out .= $mac;
1388
-
1389
-        # sodium_memzero(&poly1305_state, sizeof poly1305_state);
1390
-        unset($auth);
1391
-
1392
-
1393
-        # XOR_BUF(STATE_INONCE(state), mac,
1394
-        #     crypto_secretstream_xchacha20poly1305_INONCEBYTES);
1395
-        $st->xorNonce($mac);
1396
-
1397
-        # sodium_increment(STATE_COUNTER(state),
1398
-        #     crypto_secretstream_xchacha20poly1305_COUNTERBYTES);
1399
-        $st->incrementCounter();
1400
-        // Overwrite by reference:
1401
-        $state = $st->toString();
1402
-
1403
-        /** @var bool $rekey */
1404
-        $rekey = ($tag & ParagonIE_Sodium_Compat::CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_REKEY) !== 0;
1405
-        # if ((tag & crypto_secretstream_xchacha20poly1305_TAG_REKEY) != 0 ||
1406
-        #     sodium_is_zero(STATE_COUNTER(state),
1407
-        #         crypto_secretstream_xchacha20poly1305_COUNTERBYTES)) {
1408
-        #     crypto_secretstream_xchacha20poly1305_rekey(state);
1409
-        # }
1410
-        if ($rekey || $st->needsRekey()) {
1411
-            // DO REKEY
1412
-            self::secretstream_xchacha20poly1305_rekey($state);
1413
-        }
1414
-        # if (outlen_p != NULL) {
1415
-        #     *outlen_p = crypto_secretstream_xchacha20poly1305_ABYTES + mlen;
1416
-        # }
1417
-        return $out;
1418
-    }
1419
-
1420
-    /**
1421
-     * @param string $state
1422
-     * @param string $cipher
1423
-     * @param string $aad
1424
-     * @return bool|array{0: string, 1: int}
1425
-     * @throws SodiumException
1426
-     */
1427
-    public static function secretstream_xchacha20poly1305_pull(&$state, $cipher, $aad = '')
1428
-    {
1429
-        $st = ParagonIE_Sodium_Core_SecretStream_State::fromString($state);
1430
-
1431
-        $cipherlen = ParagonIE_Sodium_Core_Util::strlen($cipher);
1432
-        #     mlen = inlen - crypto_secretstream_xchacha20poly1305_ABYTES;
1433
-        $msglen = $cipherlen - ParagonIE_Sodium_Compat::CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_ABYTES;
1434
-        $aadlen = ParagonIE_Sodium_Core_Util::strlen($aad);
1435
-
1436
-        #     if (mlen > crypto_secretstream_xchacha20poly1305_MESSAGEBYTES_MAX) {
1437
-        #         sodium_misuse();
1438
-        #     }
1439
-        if ((($msglen + 63) >> 6) > 0xfffffffe) {
1440
-            throw new SodiumException(
1441
-                'message cannot be larger than SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_MESSAGEBYTES_MAX bytes'
1442
-            );
1443
-        }
1444
-
1445
-        #     crypto_stream_chacha20_ietf(block, sizeof block, state->nonce, state->k);
1446
-        #     crypto_onetimeauth_poly1305_init(&poly1305_state, block);
1447
-        #     sodium_memzero(block, sizeof block);
1448
-        $auth = new ParagonIE_Sodium_Core_Poly1305_State(
1449
-            ParagonIE_Sodium_Core_ChaCha20::ietfStream(32, $st->getCombinedNonce(), $st->getKey())
1450
-        );
1451
-
1452
-        #     crypto_onetimeauth_poly1305_update(&poly1305_state, ad, adlen);
1453
-        $auth->update($aad);
1454
-
1455
-        #     crypto_onetimeauth_poly1305_update(&poly1305_state, _pad0,
1456
-        #         (0x10 - adlen) & 0xf);
1457
-        $auth->update(str_repeat("\0", ((0x10 - $aadlen) & 0xf)));
1458
-
1459
-
1460
-        #     memset(block, 0, sizeof block);
1461
-        #     block[0] = in[0];
1462
-        #     crypto_stream_chacha20_ietf_xor_ic(block, block, sizeof block,
1463
-        #                                        state->nonce, 1U, state->k);
1464
-        $block = ParagonIE_Sodium_Core_ChaCha20::ietfStreamXorIc(
1465
-            $cipher[0] . str_repeat("\0", 63),
1466
-            $st->getCombinedNonce(),
1467
-            $st->getKey(),
1468
-            ParagonIE_Sodium_Core_Util::store64_le(1)
1469
-        );
1470
-        #     tag = block[0];
1471
-        #     block[0] = in[0];
1472
-        #     crypto_onetimeauth_poly1305_update(&poly1305_state, block, sizeof block);
1473
-        $tag = ParagonIE_Sodium_Core_Util::chrToInt($block[0]);
1474
-        $block[0] = $cipher[0];
1475
-        $auth->update($block);
1476
-
1477
-
1478
-        #     c = in + (sizeof tag);
1479
-        #     crypto_onetimeauth_poly1305_update(&poly1305_state, c, mlen);
1480
-        $auth->update(ParagonIE_Sodium_Core_Util::substr($cipher, 1, $msglen));
1481
-
1482
-        #     crypto_onetimeauth_poly1305_update
1483
-        #     (&poly1305_state, _pad0, (0x10 - (sizeof block) + mlen) & 0xf);
1484
-        $auth->update(str_repeat("\0", ((0x10 - 64 + $msglen) & 0xf)));
1485
-
1486
-        #     STORE64_LE(slen, (uint64_t) adlen);
1487
-        #     crypto_onetimeauth_poly1305_update(&poly1305_state, slen, sizeof slen);
1488
-        $slen = ParagonIE_Sodium_Core_Util::store64_le($aadlen);
1489
-        $auth->update($slen);
1490
-
1491
-        #     STORE64_LE(slen, (sizeof block) + mlen);
1492
-        #     crypto_onetimeauth_poly1305_update(&poly1305_state, slen, sizeof slen);
1493
-        $slen = ParagonIE_Sodium_Core_Util::store64_le(64 + $msglen);
1494
-        $auth->update($slen);
1495
-
1496
-        #     crypto_onetimeauth_poly1305_final(&poly1305_state, mac);
1497
-        #     sodium_memzero(&poly1305_state, sizeof poly1305_state);
1498
-        $mac = $auth->finish();
1499
-
1500
-        #     stored_mac = c + mlen;
1501
-        #     if (sodium_memcmp(mac, stored_mac, sizeof mac) != 0) {
1502
-        #     sodium_memzero(mac, sizeof mac);
1503
-        #         return -1;
1504
-        #     }
1505
-
1506
-        $stored = ParagonIE_Sodium_Core_Util::substr($cipher, $msglen + 1, 16);
1507
-        if (!ParagonIE_Sodium_Core_Util::hashEquals($mac, $stored)) {
1508
-            return false;
1509
-        }
1510
-
1511
-        #     crypto_stream_chacha20_ietf_xor_ic(m, c, mlen, state->nonce, 2U, state->k);
1512
-        $out = ParagonIE_Sodium_Core_ChaCha20::ietfStreamXorIc(
1513
-            ParagonIE_Sodium_Core_Util::substr($cipher, 1, $msglen),
1514
-            $st->getCombinedNonce(),
1515
-            $st->getKey(),
1516
-            ParagonIE_Sodium_Core_Util::store64_le(2)
1517
-        );
1518
-
1519
-        #     XOR_BUF(STATE_INONCE(state), mac,
1520
-        #         crypto_secretstream_xchacha20poly1305_INONCEBYTES);
1521
-        $st->xorNonce($mac);
1522
-
1523
-        #     sodium_increment(STATE_COUNTER(state),
1524
-        #         crypto_secretstream_xchacha20poly1305_COUNTERBYTES);
1525
-        $st->incrementCounter();
1526
-
1527
-        #     if ((tag & crypto_secretstream_xchacha20poly1305_TAG_REKEY) != 0 ||
1528
-        #         sodium_is_zero(STATE_COUNTER(state),
1529
-        #             crypto_secretstream_xchacha20poly1305_COUNTERBYTES)) {
1530
-        #         crypto_secretstream_xchacha20poly1305_rekey(state);
1531
-        #     }
1532
-
1533
-        // Overwrite by reference:
1534
-        $state = $st->toString();
1535
-
1536
-        /** @var bool $rekey */
1537
-        $rekey = ($tag & ParagonIE_Sodium_Compat::CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_REKEY) !== 0;
1538
-        if ($rekey || $st->needsRekey()) {
1539
-            // DO REKEY
1540
-            self::secretstream_xchacha20poly1305_rekey($state);
1541
-        }
1542
-        return array($out, $tag);
1543
-    }
1544
-
1545
-    /**
1546
-     * @param string $state
1547
-     * @return void
1548
-     * @throws SodiumException
1549
-     */
1550
-    public static function secretstream_xchacha20poly1305_rekey(&$state)
1551
-    {
1552
-        $st = ParagonIE_Sodium_Core_SecretStream_State::fromString($state);
1553
-        # unsigned char new_key_and_inonce[crypto_stream_chacha20_ietf_KEYBYTES +
1554
-        # crypto_secretstream_xchacha20poly1305_INONCEBYTES];
1555
-        # size_t        i;
1556
-        # for (i = 0U; i < crypto_stream_chacha20_ietf_KEYBYTES; i++) {
1557
-        #     new_key_and_inonce[i] = state->k[i];
1558
-        # }
1559
-        $new_key_and_inonce = $st->getKey();
1560
-
1561
-        # for (i = 0U; i < crypto_secretstream_xchacha20poly1305_INONCEBYTES; i++) {
1562
-        #     new_key_and_inonce[crypto_stream_chacha20_ietf_KEYBYTES + i] =
1563
-        #         STATE_INONCE(state)[i];
1564
-        # }
1565
-        $new_key_and_inonce .= ParagonIE_Sodium_Core_Util::substR($st->getNonce(), 0, 8);
1566
-
1567
-        # crypto_stream_chacha20_ietf_xor(new_key_and_inonce, new_key_and_inonce,
1568
-        #                                 sizeof new_key_and_inonce,
1569
-        #                                 state->nonce, state->k);
1570
-
1571
-        $st->rekey(ParagonIE_Sodium_Core_ChaCha20::ietfStreamXorIc(
1572
-            $new_key_and_inonce,
1573
-            $st->getCombinedNonce(),
1574
-            $st->getKey(),
1575
-            ParagonIE_Sodium_Core_Util::store64_le(0)
1576
-        ));
1577
-
1578
-        # for (i = 0U; i < crypto_stream_chacha20_ietf_KEYBYTES; i++) {
1579
-        #     state->k[i] = new_key_and_inonce[i];
1580
-        # }
1581
-        # for (i = 0U; i < crypto_secretstream_xchacha20poly1305_INONCEBYTES; i++) {
1582
-        #     STATE_INONCE(state)[i] =
1583
-        #          new_key_and_inonce[crypto_stream_chacha20_ietf_KEYBYTES + i];
1584
-        # }
1585
-        # _crypto_secretstream_xchacha20poly1305_counter_reset(state);
1586
-        $st->counterReset();
1587
-
1588
-        $state = $st->toString();
1589
-    }
1590
-
1591
-    /**
1592
-     * Detached Ed25519 signature.
1593
-     *
1594
-     * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
1595
-     *
1596
-     * @param string $message
1597
-     * @param string $sk
1598
-     * @return string
1599
-     * @throws SodiumException
1600
-     * @throws TypeError
1601
-     */
1602
-    public static function sign_detached($message, $sk)
1603
-    {
1604
-        return ParagonIE_Sodium_Core_Ed25519::sign_detached($message, $sk);
1605
-    }
1606
-
1607
-    /**
1608
-     * Attached Ed25519 signature. (Returns a signed message.)
1609
-     *
1610
-     * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
1611
-     *
1612
-     * @param string $message
1613
-     * @param string $sk
1614
-     * @return string
1615
-     * @throws SodiumException
1616
-     * @throws TypeError
1617
-     */
1618
-    public static function sign($message, $sk)
1619
-    {
1620
-        return ParagonIE_Sodium_Core_Ed25519::sign($message, $sk);
1621
-    }
1622
-
1623
-    /**
1624
-     * Opens a signed message. If valid, returns the message.
1625
-     *
1626
-     * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
1627
-     *
1628
-     * @param string $signedMessage
1629
-     * @param string $pk
1630
-     * @return string
1631
-     * @throws SodiumException
1632
-     * @throws TypeError
1633
-     */
1634
-    public static function sign_open($signedMessage, $pk)
1635
-    {
1636
-        return ParagonIE_Sodium_Core_Ed25519::sign_open($signedMessage, $pk);
1637
-    }
1638
-
1639
-    /**
1640
-     * Verify a detached signature of a given message and public key.
1641
-     *
1642
-     * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
1643
-     *
1644
-     * @param string $signature
1645
-     * @param string $message
1646
-     * @param string $pk
1647
-     * @return bool
1648
-     * @throws SodiumException
1649
-     * @throws TypeError
1650
-     */
1651
-    public static function sign_verify_detached($signature, $message, $pk)
1652
-    {
1653
-        return ParagonIE_Sodium_Core_Ed25519::verify_detached($signature, $message, $pk);
1654
-    }
17
+	const aead_chacha20poly1305_KEYBYTES = 32;
18
+	const aead_chacha20poly1305_NSECBYTES = 0;
19
+	const aead_chacha20poly1305_NPUBBYTES = 8;
20
+	const aead_chacha20poly1305_ABYTES = 16;
21
+
22
+	const aead_chacha20poly1305_IETF_KEYBYTES = 32;
23
+	const aead_chacha20poly1305_IETF_NSECBYTES = 0;
24
+	const aead_chacha20poly1305_IETF_NPUBBYTES = 12;
25
+	const aead_chacha20poly1305_IETF_ABYTES = 16;
26
+
27
+	const aead_xchacha20poly1305_IETF_KEYBYTES = 32;
28
+	const aead_xchacha20poly1305_IETF_NSECBYTES = 0;
29
+	const aead_xchacha20poly1305_IETF_NPUBBYTES = 24;
30
+	const aead_xchacha20poly1305_IETF_ABYTES = 16;
31
+
32
+	const box_curve25519xsalsa20poly1305_SEEDBYTES = 32;
33
+	const box_curve25519xsalsa20poly1305_PUBLICKEYBYTES = 32;
34
+	const box_curve25519xsalsa20poly1305_SECRETKEYBYTES = 32;
35
+	const box_curve25519xsalsa20poly1305_BEFORENMBYTES = 32;
36
+	const box_curve25519xsalsa20poly1305_NONCEBYTES = 24;
37
+	const box_curve25519xsalsa20poly1305_MACBYTES = 16;
38
+	const box_curve25519xsalsa20poly1305_BOXZEROBYTES = 16;
39
+	const box_curve25519xsalsa20poly1305_ZEROBYTES = 32;
40
+
41
+	const onetimeauth_poly1305_BYTES = 16;
42
+	const onetimeauth_poly1305_KEYBYTES = 32;
43
+
44
+	const secretbox_xsalsa20poly1305_KEYBYTES = 32;
45
+	const secretbox_xsalsa20poly1305_NONCEBYTES = 24;
46
+	const secretbox_xsalsa20poly1305_MACBYTES = 16;
47
+	const secretbox_xsalsa20poly1305_BOXZEROBYTES = 16;
48
+	const secretbox_xsalsa20poly1305_ZEROBYTES = 32;
49
+
50
+	const secretbox_xchacha20poly1305_KEYBYTES = 32;
51
+	const secretbox_xchacha20poly1305_NONCEBYTES = 24;
52
+	const secretbox_xchacha20poly1305_MACBYTES = 16;
53
+	const secretbox_xchacha20poly1305_BOXZEROBYTES = 16;
54
+	const secretbox_xchacha20poly1305_ZEROBYTES = 32;
55
+
56
+	const stream_salsa20_KEYBYTES = 32;
57
+
58
+	/**
59
+	 * AEAD Decryption with ChaCha20-Poly1305
60
+	 *
61
+	 * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
62
+	 *
63
+	 * @param string $message
64
+	 * @param string $ad
65
+	 * @param string $nonce
66
+	 * @param string $key
67
+	 * @return string
68
+	 * @throws SodiumException
69
+	 * @throws TypeError
70
+	 */
71
+	public static function aead_chacha20poly1305_decrypt(
72
+		$message = '',
73
+		$ad = '',
74
+		$nonce = '',
75
+		$key = ''
76
+	) {
77
+		/** @var int $len - Length of message (ciphertext + MAC) */
78
+		$len = ParagonIE_Sodium_Core_Util::strlen($message);
79
+
80
+		/** @var int  $clen - Length of ciphertext */
81
+		$clen = $len - self::aead_chacha20poly1305_ABYTES;
82
+
83
+		/** @var int $adlen - Length of associated data */
84
+		$adlen = ParagonIE_Sodium_Core_Util::strlen($ad);
85
+
86
+		/** @var string $mac - Message authentication code */
87
+		$mac = ParagonIE_Sodium_Core_Util::substr(
88
+			$message,
89
+			$clen,
90
+			self::aead_chacha20poly1305_ABYTES
91
+		);
92
+
93
+		/** @var string $ciphertext - The encrypted message (sans MAC) */
94
+		$ciphertext = ParagonIE_Sodium_Core_Util::substr($message, 0, $clen);
95
+
96
+		/** @var string The first block of the chacha20 keystream, used as a poly1305 key */
97
+		$block0 = ParagonIE_Sodium_Core_ChaCha20::stream(
98
+			32,
99
+			$nonce,
100
+			$key
101
+		);
102
+
103
+		/* Recalculate the Poly1305 authentication tag (MAC): */
104
+		$state = new ParagonIE_Sodium_Core_Poly1305_State($block0);
105
+		try {
106
+			ParagonIE_Sodium_Compat::memzero($block0);
107
+		} catch (SodiumException $ex) {
108
+			$block0 = null;
109
+		}
110
+		$state->update($ad);
111
+		$state->update(ParagonIE_Sodium_Core_Util::store64_le($adlen));
112
+		$state->update($ciphertext);
113
+		$state->update(ParagonIE_Sodium_Core_Util::store64_le($clen));
114
+		$computed_mac = $state->finish();
115
+
116
+		/* Compare the given MAC with the recalculated MAC: */
117
+		if (!ParagonIE_Sodium_Core_Util::verify_16($computed_mac, $mac)) {
118
+			throw new SodiumException('Invalid MAC');
119
+		}
120
+
121
+		// Here, we know that the MAC is valid, so we decrypt and return the plaintext
122
+		return ParagonIE_Sodium_Core_ChaCha20::streamXorIc(
123
+			$ciphertext,
124
+			$nonce,
125
+			$key,
126
+			ParagonIE_Sodium_Core_Util::store64_le(1)
127
+		);
128
+	}
129
+
130
+	/**
131
+	 * AEAD Encryption with ChaCha20-Poly1305
132
+	 *
133
+	 * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
134
+	 *
135
+	 * @param string $message
136
+	 * @param string $ad
137
+	 * @param string $nonce
138
+	 * @param string $key
139
+	 * @return string
140
+	 * @throws SodiumException
141
+	 * @throws TypeError
142
+	 */
143
+	public static function aead_chacha20poly1305_encrypt(
144
+		$message = '',
145
+		$ad = '',
146
+		$nonce = '',
147
+		$key = ''
148
+	) {
149
+		/** @var int $len - Length of the plaintext message */
150
+		$len = ParagonIE_Sodium_Core_Util::strlen($message);
151
+
152
+		/** @var int $adlen - Length of the associated data */
153
+		$adlen = ParagonIE_Sodium_Core_Util::strlen($ad);
154
+
155
+		/** @var string The first block of the chacha20 keystream, used as a poly1305 key */
156
+		$block0 = ParagonIE_Sodium_Core_ChaCha20::stream(
157
+			32,
158
+			$nonce,
159
+			$key
160
+		);
161
+		$state = new ParagonIE_Sodium_Core_Poly1305_State($block0);
162
+		try {
163
+			ParagonIE_Sodium_Compat::memzero($block0);
164
+		} catch (SodiumException $ex) {
165
+			$block0 = null;
166
+		}
167
+
168
+		/** @var string $ciphertext - Raw encrypted data */
169
+		$ciphertext = ParagonIE_Sodium_Core_ChaCha20::streamXorIc(
170
+			$message,
171
+			$nonce,
172
+			$key,
173
+			ParagonIE_Sodium_Core_Util::store64_le(1)
174
+		);
175
+
176
+		$state->update($ad);
177
+		$state->update(ParagonIE_Sodium_Core_Util::store64_le($adlen));
178
+		$state->update($ciphertext);
179
+		$state->update(ParagonIE_Sodium_Core_Util::store64_le($len));
180
+		return $ciphertext . $state->finish();
181
+	}
182
+
183
+	/**
184
+	 * AEAD Decryption with ChaCha20-Poly1305, IETF mode (96-bit nonce)
185
+	 *
186
+	 * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
187
+	 *
188
+	 * @param string $message
189
+	 * @param string $ad
190
+	 * @param string $nonce
191
+	 * @param string $key
192
+	 * @return string
193
+	 * @throws SodiumException
194
+	 * @throws TypeError
195
+	 */
196
+	public static function aead_chacha20poly1305_ietf_decrypt(
197
+		$message = '',
198
+		$ad = '',
199
+		$nonce = '',
200
+		$key = ''
201
+	) {
202
+		/** @var int $adlen - Length of associated data */
203
+		$adlen = ParagonIE_Sodium_Core_Util::strlen($ad);
204
+
205
+		/** @var int $len - Length of message (ciphertext + MAC) */
206
+		$len = ParagonIE_Sodium_Core_Util::strlen($message);
207
+
208
+		/** @var int  $clen - Length of ciphertext */
209
+		$clen = $len - self::aead_chacha20poly1305_IETF_ABYTES;
210
+
211
+		/** @var string The first block of the chacha20 keystream, used as a poly1305 key */
212
+		$block0 = ParagonIE_Sodium_Core_ChaCha20::ietfStream(
213
+			32,
214
+			$nonce,
215
+			$key
216
+		);
217
+
218
+		/** @var string $mac - Message authentication code */
219
+		$mac = ParagonIE_Sodium_Core_Util::substr(
220
+			$message,
221
+			$len - self::aead_chacha20poly1305_IETF_ABYTES,
222
+			self::aead_chacha20poly1305_IETF_ABYTES
223
+		);
224
+
225
+		/** @var string $ciphertext - The encrypted message (sans MAC) */
226
+		$ciphertext = ParagonIE_Sodium_Core_Util::substr(
227
+			$message,
228
+			0,
229
+			$len - self::aead_chacha20poly1305_IETF_ABYTES
230
+		);
231
+
232
+		/* Recalculate the Poly1305 authentication tag (MAC): */
233
+		$state = new ParagonIE_Sodium_Core_Poly1305_State($block0);
234
+		try {
235
+			ParagonIE_Sodium_Compat::memzero($block0);
236
+		} catch (SodiumException $ex) {
237
+			$block0 = null;
238
+		}
239
+		$state->update($ad);
240
+		$state->update(str_repeat("\x00", ((0x10 - $adlen) & 0xf)));
241
+		$state->update($ciphertext);
242
+		$state->update(str_repeat("\x00", (0x10 - $clen) & 0xf));
243
+		$state->update(ParagonIE_Sodium_Core_Util::store64_le($adlen));
244
+		$state->update(ParagonIE_Sodium_Core_Util::store64_le($clen));
245
+		$computed_mac = $state->finish();
246
+
247
+		/* Compare the given MAC with the recalculated MAC: */
248
+		if (!ParagonIE_Sodium_Core_Util::verify_16($computed_mac, $mac)) {
249
+			throw new SodiumException('Invalid MAC');
250
+		}
251
+
252
+		// Here, we know that the MAC is valid, so we decrypt and return the plaintext
253
+		return ParagonIE_Sodium_Core_ChaCha20::ietfStreamXorIc(
254
+			$ciphertext,
255
+			$nonce,
256
+			$key,
257
+			ParagonIE_Sodium_Core_Util::store64_le(1)
258
+		);
259
+	}
260
+
261
+	/**
262
+	 * AEAD Encryption with ChaCha20-Poly1305, IETF mode (96-bit nonce)
263
+	 *
264
+	 * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
265
+	 *
266
+	 * @param string $message
267
+	 * @param string $ad
268
+	 * @param string $nonce
269
+	 * @param string $key
270
+	 * @return string
271
+	 * @throws SodiumException
272
+	 * @throws TypeError
273
+	 */
274
+	public static function aead_chacha20poly1305_ietf_encrypt(
275
+		$message = '',
276
+		$ad = '',
277
+		$nonce = '',
278
+		$key = ''
279
+	) {
280
+		/** @var int $len - Length of the plaintext message */
281
+		$len = ParagonIE_Sodium_Core_Util::strlen($message);
282
+
283
+		/** @var int $adlen - Length of the associated data */
284
+		$adlen = ParagonIE_Sodium_Core_Util::strlen($ad);
285
+
286
+		/** @var string The first block of the chacha20 keystream, used as a poly1305 key */
287
+		$block0 = ParagonIE_Sodium_Core_ChaCha20::ietfStream(
288
+			32,
289
+			$nonce,
290
+			$key
291
+		);
292
+		$state = new ParagonIE_Sodium_Core_Poly1305_State($block0);
293
+		try {
294
+			ParagonIE_Sodium_Compat::memzero($block0);
295
+		} catch (SodiumException $ex) {
296
+			$block0 = null;
297
+		}
298
+
299
+		/** @var string $ciphertext - Raw encrypted data */
300
+		$ciphertext = ParagonIE_Sodium_Core_ChaCha20::ietfStreamXorIc(
301
+			$message,
302
+			$nonce,
303
+			$key,
304
+			ParagonIE_Sodium_Core_Util::store64_le(1)
305
+		);
306
+
307
+		$state->update($ad);
308
+		$state->update(str_repeat("\x00", ((0x10 - $adlen) & 0xf)));
309
+		$state->update($ciphertext);
310
+		$state->update(str_repeat("\x00", ((0x10 - $len) & 0xf)));
311
+		$state->update(ParagonIE_Sodium_Core_Util::store64_le($adlen));
312
+		$state->update(ParagonIE_Sodium_Core_Util::store64_le($len));
313
+		return $ciphertext . $state->finish();
314
+	}
315
+
316
+	/**
317
+	 * AEAD Decryption with ChaCha20-Poly1305, IETF mode (96-bit nonce)
318
+	 *
319
+	 * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
320
+	 *
321
+	 * @param string $message
322
+	 * @param string $ad
323
+	 * @param string $nonce
324
+	 * @param string $key
325
+	 * @return string
326
+	 * @throws SodiumException
327
+	 * @throws TypeError
328
+	 */
329
+	public static function aead_xchacha20poly1305_ietf_decrypt(
330
+		$message = '',
331
+		$ad = '',
332
+		$nonce = '',
333
+		$key = ''
334
+	) {
335
+		$subkey = ParagonIE_Sodium_Core_HChaCha20::hChaCha20(
336
+			ParagonIE_Sodium_Core_Util::substr($nonce, 0, 16),
337
+			$key
338
+		);
339
+		$nonceLast = "\x00\x00\x00\x00" .
340
+			ParagonIE_Sodium_Core_Util::substr($nonce, 16, 8);
341
+
342
+		return self::aead_chacha20poly1305_ietf_decrypt($message, $ad, $nonceLast, $subkey);
343
+	}
344
+
345
+	/**
346
+	 * AEAD Encryption with ChaCha20-Poly1305, IETF mode (96-bit nonce)
347
+	 *
348
+	 * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
349
+	 *
350
+	 * @param string $message
351
+	 * @param string $ad
352
+	 * @param string $nonce
353
+	 * @param string $key
354
+	 * @return string
355
+	 * @throws SodiumException
356
+	 * @throws TypeError
357
+	 */
358
+	public static function aead_xchacha20poly1305_ietf_encrypt(
359
+		$message = '',
360
+		$ad = '',
361
+		$nonce = '',
362
+		$key = ''
363
+	) {
364
+		$subkey = ParagonIE_Sodium_Core_HChaCha20::hChaCha20(
365
+			ParagonIE_Sodium_Core_Util::substr($nonce, 0, 16),
366
+			$key
367
+		);
368
+		$nonceLast = "\x00\x00\x00\x00" .
369
+			ParagonIE_Sodium_Core_Util::substr($nonce, 16, 8);
370
+
371
+		return self::aead_chacha20poly1305_ietf_encrypt($message, $ad, $nonceLast, $subkey);
372
+	}
373
+
374
+	/**
375
+	 * HMAC-SHA-512-256 (a.k.a. the leftmost 256 bits of HMAC-SHA-512)
376
+	 *
377
+	 * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
378
+	 *
379
+	 * @param string $message
380
+	 * @param string $key
381
+	 * @return string
382
+	 * @throws TypeError
383
+	 */
384
+	public static function auth($message, $key)
385
+	{
386
+		return ParagonIE_Sodium_Core_Util::substr(
387
+			hash_hmac('sha512', $message, $key, true),
388
+			0,
389
+			32
390
+		);
391
+	}
392
+
393
+	/**
394
+	 * HMAC-SHA-512-256 validation. Constant-time via hash_equals().
395
+	 *
396
+	 * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
397
+	 *
398
+	 * @param string $mac
399
+	 * @param string $message
400
+	 * @param string $key
401
+	 * @return bool
402
+	 * @throws SodiumException
403
+	 * @throws TypeError
404
+	 */
405
+	public static function auth_verify($mac, $message, $key)
406
+	{
407
+		return ParagonIE_Sodium_Core_Util::hashEquals(
408
+			$mac,
409
+			self::auth($message, $key)
410
+		);
411
+	}
412
+
413
+	/**
414
+	 * X25519 key exchange followed by XSalsa20Poly1305 symmetric encryption
415
+	 *
416
+	 * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
417
+	 *
418
+	 * @param string $plaintext
419
+	 * @param string $nonce
420
+	 * @param string $keypair
421
+	 * @return string
422
+	 * @throws SodiumException
423
+	 * @throws TypeError
424
+	 */
425
+	public static function box($plaintext, $nonce, $keypair)
426
+	{
427
+		$c = self::secretbox(
428
+			$plaintext,
429
+			$nonce,
430
+			self::box_beforenm(
431
+				self::box_secretkey($keypair),
432
+				self::box_publickey($keypair)
433
+			)
434
+		);
435
+		return $c;
436
+	}
437
+
438
+	/**
439
+	 * X25519-XSalsa20-Poly1305 with one ephemeral X25519 keypair.
440
+	 *
441
+	 * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
442
+	 *
443
+	 * @param string $message
444
+	 * @param string $publicKey
445
+	 * @return string
446
+	 * @throws SodiumException
447
+	 * @throws TypeError
448
+	 */
449
+	public static function box_seal($message, $publicKey)
450
+	{
451
+		/** @var string $ephemeralKeypair */
452
+		$ephemeralKeypair = self::box_keypair();
453
+
454
+		/** @var string $ephemeralSK */
455
+		$ephemeralSK = self::box_secretkey($ephemeralKeypair);
456
+
457
+		/** @var string $ephemeralPK */
458
+		$ephemeralPK = self::box_publickey($ephemeralKeypair);
459
+
460
+		/** @var string $nonce */
461
+		$nonce = self::generichash(
462
+			$ephemeralPK . $publicKey,
463
+			'',
464
+			24
465
+		);
466
+
467
+		/** @var string $keypair - The combined keypair used in crypto_box() */
468
+		$keypair = self::box_keypair_from_secretkey_and_publickey($ephemeralSK, $publicKey);
469
+
470
+		/** @var string $ciphertext Ciphertext + MAC from crypto_box */
471
+		$ciphertext = self::box($message, $nonce, $keypair);
472
+		try {
473
+			ParagonIE_Sodium_Compat::memzero($ephemeralKeypair);
474
+			ParagonIE_Sodium_Compat::memzero($ephemeralSK);
475
+			ParagonIE_Sodium_Compat::memzero($nonce);
476
+		} catch (SodiumException $ex) {
477
+			$ephemeralKeypair = null;
478
+			$ephemeralSK = null;
479
+			$nonce = null;
480
+		}
481
+		return $ephemeralPK . $ciphertext;
482
+	}
483
+
484
+	/**
485
+	 * Opens a message encrypted via box_seal().
486
+	 *
487
+	 * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
488
+	 *
489
+	 * @param string $message
490
+	 * @param string $keypair
491
+	 * @return string
492
+	 * @throws SodiumException
493
+	 * @throws TypeError
494
+	 */
495
+	public static function box_seal_open($message, $keypair)
496
+	{
497
+		/** @var string $ephemeralPK */
498
+		$ephemeralPK = ParagonIE_Sodium_Core_Util::substr($message, 0, 32);
499
+
500
+		/** @var string $ciphertext (ciphertext + MAC) */
501
+		$ciphertext = ParagonIE_Sodium_Core_Util::substr($message, 32);
502
+
503
+		/** @var string $secretKey */
504
+		$secretKey = self::box_secretkey($keypair);
505
+
506
+		/** @var string $publicKey */
507
+		$publicKey = self::box_publickey($keypair);
508
+
509
+		/** @var string $nonce */
510
+		$nonce = self::generichash(
511
+			$ephemeralPK . $publicKey,
512
+			'',
513
+			24
514
+		);
515
+
516
+		/** @var string $keypair */
517
+		$keypair = self::box_keypair_from_secretkey_and_publickey($secretKey, $ephemeralPK);
518
+
519
+		/** @var string $m */
520
+		$m = self::box_open($ciphertext, $nonce, $keypair);
521
+		try {
522
+			ParagonIE_Sodium_Compat::memzero($secretKey);
523
+			ParagonIE_Sodium_Compat::memzero($ephemeralPK);
524
+			ParagonIE_Sodium_Compat::memzero($nonce);
525
+		} catch (SodiumException $ex) {
526
+			$secretKey = null;
527
+			$ephemeralPK = null;
528
+			$nonce = null;
529
+		}
530
+		return $m;
531
+	}
532
+
533
+	/**
534
+	 * Used by crypto_box() to get the crypto_secretbox() key.
535
+	 *
536
+	 * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
537
+	 *
538
+	 * @param string $sk
539
+	 * @param string $pk
540
+	 * @return string
541
+	 * @throws SodiumException
542
+	 * @throws TypeError
543
+	 */
544
+	public static function box_beforenm($sk, $pk)
545
+	{
546
+		return ParagonIE_Sodium_Core_HSalsa20::hsalsa20(
547
+			str_repeat("\x00", 16),
548
+			self::scalarmult($sk, $pk)
549
+		);
550
+	}
551
+
552
+	/**
553
+	 * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
554
+	 *
555
+	 * @return string
556
+	 * @throws Exception
557
+	 * @throws SodiumException
558
+	 * @throws TypeError
559
+	 */
560
+	public static function box_keypair()
561
+	{
562
+		$sKey = random_bytes(32);
563
+		$pKey = self::scalarmult_base($sKey);
564
+		return $sKey . $pKey;
565
+	}
566
+
567
+	/**
568
+	 * @param string $seed
569
+	 * @return string
570
+	 * @throws SodiumException
571
+	 * @throws TypeError
572
+	 */
573
+	public static function box_seed_keypair($seed)
574
+	{
575
+		$sKey = ParagonIE_Sodium_Core_Util::substr(
576
+			hash('sha512', $seed, true),
577
+			0,
578
+			32
579
+		);
580
+		$pKey = self::scalarmult_base($sKey);
581
+		return $sKey . $pKey;
582
+	}
583
+
584
+	/**
585
+	 * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
586
+	 *
587
+	 * @param string $sKey
588
+	 * @param string $pKey
589
+	 * @return string
590
+	 * @throws TypeError
591
+	 */
592
+	public static function box_keypair_from_secretkey_and_publickey($sKey, $pKey)
593
+	{
594
+		return ParagonIE_Sodium_Core_Util::substr($sKey, 0, 32) .
595
+			ParagonIE_Sodium_Core_Util::substr($pKey, 0, 32);
596
+	}
597
+
598
+	/**
599
+	 * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
600
+	 *
601
+	 * @param string $keypair
602
+	 * @return string
603
+	 * @throws RangeException
604
+	 * @throws TypeError
605
+	 */
606
+	public static function box_secretkey($keypair)
607
+	{
608
+		if (ParagonIE_Sodium_Core_Util::strlen($keypair) !== 64) {
609
+			throw new RangeException(
610
+				'Must be ParagonIE_Sodium_Compat::CRYPTO_BOX_KEYPAIRBYTES bytes long.'
611
+			);
612
+		}
613
+		return ParagonIE_Sodium_Core_Util::substr($keypair, 0, 32);
614
+	}
615
+
616
+	/**
617
+	 * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
618
+	 *
619
+	 * @param string $keypair
620
+	 * @return string
621
+	 * @throws RangeException
622
+	 * @throws TypeError
623
+	 */
624
+	public static function box_publickey($keypair)
625
+	{
626
+		if (ParagonIE_Sodium_Core_Util::strlen($keypair) !== ParagonIE_Sodium_Compat::CRYPTO_BOX_KEYPAIRBYTES) {
627
+			throw new RangeException(
628
+				'Must be ParagonIE_Sodium_Compat::CRYPTO_BOX_KEYPAIRBYTES bytes long.'
629
+			);
630
+		}
631
+		return ParagonIE_Sodium_Core_Util::substr($keypair, 32, 32);
632
+	}
633
+
634
+	/**
635
+	 * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
636
+	 *
637
+	 * @param string $sKey
638
+	 * @return string
639
+	 * @throws RangeException
640
+	 * @throws SodiumException
641
+	 * @throws TypeError
642
+	 */
643
+	public static function box_publickey_from_secretkey($sKey)
644
+	{
645
+		if (ParagonIE_Sodium_Core_Util::strlen($sKey) !== ParagonIE_Sodium_Compat::CRYPTO_BOX_SECRETKEYBYTES) {
646
+			throw new RangeException(
647
+				'Must be ParagonIE_Sodium_Compat::CRYPTO_BOX_SECRETKEYBYTES bytes long.'
648
+			);
649
+		}
650
+		return self::scalarmult_base($sKey);
651
+	}
652
+
653
+	/**
654
+	 * Decrypt a message encrypted with box().
655
+	 *
656
+	 * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
657
+	 *
658
+	 * @param string $ciphertext
659
+	 * @param string $nonce
660
+	 * @param string $keypair
661
+	 * @return string
662
+	 * @throws SodiumException
663
+	 * @throws TypeError
664
+	 */
665
+	public static function box_open($ciphertext, $nonce, $keypair)
666
+	{
667
+		return self::secretbox_open(
668
+			$ciphertext,
669
+			$nonce,
670
+			self::box_beforenm(
671
+				self::box_secretkey($keypair),
672
+				self::box_publickey($keypair)
673
+			)
674
+		);
675
+	}
676
+
677
+	/**
678
+	 * Calculate a BLAKE2b hash.
679
+	 *
680
+	 * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
681
+	 *
682
+	 * @param string $message
683
+	 * @param string|null $key
684
+	 * @param int $outlen
685
+	 * @return string
686
+	 * @throws RangeException
687
+	 * @throws SodiumException
688
+	 * @throws TypeError
689
+	 */
690
+	public static function generichash($message, $key = '', $outlen = 32)
691
+	{
692
+		// This ensures that ParagonIE_Sodium_Core_BLAKE2b::$iv is initialized
693
+		ParagonIE_Sodium_Core_BLAKE2b::pseudoConstructor();
694
+
695
+		$k = null;
696
+		if (!empty($key)) {
697
+			/** @var SplFixedArray $k */
698
+			$k = ParagonIE_Sodium_Core_BLAKE2b::stringToSplFixedArray($key);
699
+			if ($k->count() > ParagonIE_Sodium_Core_BLAKE2b::KEYBYTES) {
700
+				throw new RangeException('Invalid key size');
701
+			}
702
+		}
703
+
704
+		/** @var SplFixedArray $in */
705
+		$in = ParagonIE_Sodium_Core_BLAKE2b::stringToSplFixedArray($message);
706
+
707
+		/** @var SplFixedArray $ctx */
708
+		$ctx = ParagonIE_Sodium_Core_BLAKE2b::init($k, $outlen);
709
+		ParagonIE_Sodium_Core_BLAKE2b::update($ctx, $in, $in->count());
710
+
711
+		/** @var SplFixedArray $out */
712
+		$out = new SplFixedArray($outlen);
713
+		$out = ParagonIE_Sodium_Core_BLAKE2b::finish($ctx, $out);
714
+
715
+		/** @var array<int, int> */
716
+		$outArray = $out->toArray();
717
+		return ParagonIE_Sodium_Core_Util::intArrayToString($outArray);
718
+	}
719
+
720
+	/**
721
+	 * Finalize a BLAKE2b hashing context, returning the hash.
722
+	 *
723
+	 * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
724
+	 *
725
+	 * @param string $ctx
726
+	 * @param int $outlen
727
+	 * @return string
728
+	 * @throws SodiumException
729
+	 * @throws TypeError
730
+	 */
731
+	public static function generichash_final($ctx, $outlen = 32)
732
+	{
733
+		if (!is_string($ctx)) {
734
+			throw new TypeError('Context must be a string');
735
+		}
736
+		$out = new SplFixedArray($outlen);
737
+
738
+		/** @var SplFixedArray $context */
739
+		$context = ParagonIE_Sodium_Core_BLAKE2b::stringToContext($ctx);
740
+
741
+		/** @var SplFixedArray $out */
742
+		$out = ParagonIE_Sodium_Core_BLAKE2b::finish($context, $out);
743
+
744
+		/** @var array<int, int> */
745
+		$outArray = $out->toArray();
746
+		return ParagonIE_Sodium_Core_Util::intArrayToString($outArray);
747
+	}
748
+
749
+	/**
750
+	 * Initialize a hashing context for BLAKE2b.
751
+	 *
752
+	 * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
753
+	 *
754
+	 * @param string $key
755
+	 * @param int $outputLength
756
+	 * @return string
757
+	 * @throws RangeException
758
+	 * @throws SodiumException
759
+	 * @throws TypeError
760
+	 */
761
+	public static function generichash_init($key = '', $outputLength = 32)
762
+	{
763
+		// This ensures that ParagonIE_Sodium_Core_BLAKE2b::$iv is initialized
764
+		ParagonIE_Sodium_Core_BLAKE2b::pseudoConstructor();
765
+
766
+		$k = null;
767
+		if (!empty($key)) {
768
+			$k = ParagonIE_Sodium_Core_BLAKE2b::stringToSplFixedArray($key);
769
+			if ($k->count() > ParagonIE_Sodium_Core_BLAKE2b::KEYBYTES) {
770
+				throw new RangeException('Invalid key size');
771
+			}
772
+		}
773
+
774
+		/** @var SplFixedArray $ctx */
775
+		$ctx = ParagonIE_Sodium_Core_BLAKE2b::init($k, $outputLength);
776
+
777
+		return ParagonIE_Sodium_Core_BLAKE2b::contextToString($ctx);
778
+	}
779
+
780
+	/**
781
+	 * Initialize a hashing context for BLAKE2b.
782
+	 *
783
+	 * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
784
+	 *
785
+	 * @param string $key
786
+	 * @param int $outputLength
787
+	 * @param string $salt
788
+	 * @param string $personal
789
+	 * @return string
790
+	 * @throws RangeException
791
+	 * @throws SodiumException
792
+	 * @throws TypeError
793
+	 */
794
+	public static function generichash_init_salt_personal(
795
+		$key = '',
796
+		$outputLength = 32,
797
+		$salt = '',
798
+		$personal = ''
799
+	) {
800
+		// This ensures that ParagonIE_Sodium_Core_BLAKE2b::$iv is initialized
801
+		ParagonIE_Sodium_Core_BLAKE2b::pseudoConstructor();
802
+
803
+		$k = null;
804
+		if (!empty($key)) {
805
+			$k = ParagonIE_Sodium_Core_BLAKE2b::stringToSplFixedArray($key);
806
+			if ($k->count() > ParagonIE_Sodium_Core_BLAKE2b::KEYBYTES) {
807
+				throw new RangeException('Invalid key size');
808
+			}
809
+		}
810
+		if (!empty($salt)) {
811
+			$s = ParagonIE_Sodium_Core_BLAKE2b::stringToSplFixedArray($salt);
812
+		} else {
813
+			$s = null;
814
+		}
815
+		if (!empty($salt)) {
816
+			$p = ParagonIE_Sodium_Core_BLAKE2b::stringToSplFixedArray($personal);
817
+		} else {
818
+			$p = null;
819
+		}
820
+
821
+		/** @var SplFixedArray $ctx */
822
+		$ctx = ParagonIE_Sodium_Core_BLAKE2b::init($k, $outputLength, $s, $p);
823
+
824
+		return ParagonIE_Sodium_Core_BLAKE2b::contextToString($ctx);
825
+	}
826
+
827
+	/**
828
+	 * Update a hashing context for BLAKE2b with $message
829
+	 *
830
+	 * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
831
+	 *
832
+	 * @param string $ctx
833
+	 * @param string $message
834
+	 * @return string
835
+	 * @throws SodiumException
836
+	 * @throws TypeError
837
+	 */
838
+	public static function generichash_update($ctx, $message)
839
+	{
840
+		// This ensures that ParagonIE_Sodium_Core_BLAKE2b::$iv is initialized
841
+		ParagonIE_Sodium_Core_BLAKE2b::pseudoConstructor();
842
+
843
+		/** @var SplFixedArray $context */
844
+		$context = ParagonIE_Sodium_Core_BLAKE2b::stringToContext($ctx);
845
+
846
+		/** @var SplFixedArray $in */
847
+		$in = ParagonIE_Sodium_Core_BLAKE2b::stringToSplFixedArray($message);
848
+
849
+		ParagonIE_Sodium_Core_BLAKE2b::update($context, $in, $in->count());
850
+
851
+		return ParagonIE_Sodium_Core_BLAKE2b::contextToString($context);
852
+	}
853
+
854
+	/**
855
+	 * Libsodium's crypto_kx().
856
+	 *
857
+	 * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
858
+	 *
859
+	 * @param string $my_sk
860
+	 * @param string $their_pk
861
+	 * @param string $client_pk
862
+	 * @param string $server_pk
863
+	 * @return string
864
+	 * @throws SodiumException
865
+	 * @throws TypeError
866
+	 */
867
+	public static function keyExchange($my_sk, $their_pk, $client_pk, $server_pk)
868
+	{
869
+		return ParagonIE_Sodium_Compat::crypto_generichash(
870
+			ParagonIE_Sodium_Compat::crypto_scalarmult($my_sk, $their_pk) .
871
+			$client_pk .
872
+			$server_pk
873
+		);
874
+	}
875
+
876
+	/**
877
+	 * ECDH over Curve25519
878
+	 *
879
+	 * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
880
+	 *
881
+	 * @param string $sKey
882
+	 * @param string $pKey
883
+	 * @return string
884
+	 *
885
+	 * @throws SodiumException
886
+	 * @throws TypeError
887
+	 */
888
+	public static function scalarmult($sKey, $pKey)
889
+	{
890
+		$q = ParagonIE_Sodium_Core_X25519::crypto_scalarmult_curve25519_ref10($sKey, $pKey);
891
+		self::scalarmult_throw_if_zero($q);
892
+		return $q;
893
+	}
894
+
895
+	/**
896
+	 * ECDH over Curve25519, using the basepoint.
897
+	 * Used to get a secret key from a public key.
898
+	 *
899
+	 * @param string $secret
900
+	 * @return string
901
+	 *
902
+	 * @throws SodiumException
903
+	 * @throws TypeError
904
+	 */
905
+	public static function scalarmult_base($secret)
906
+	{
907
+		$q = ParagonIE_Sodium_Core_X25519::crypto_scalarmult_curve25519_ref10_base($secret);
908
+		self::scalarmult_throw_if_zero($q);
909
+		return $q;
910
+	}
911
+
912
+	/**
913
+	 * This throws an Error if a zero public key was passed to the function.
914
+	 *
915
+	 * @param string $q
916
+	 * @return void
917
+	 * @throws SodiumException
918
+	 * @throws TypeError
919
+	 */
920
+	protected static function scalarmult_throw_if_zero($q)
921
+	{
922
+		$d = 0;
923
+		for ($i = 0; $i < self::box_curve25519xsalsa20poly1305_SECRETKEYBYTES; ++$i) {
924
+			$d |= ParagonIE_Sodium_Core_Util::chrToInt($q[$i]);
925
+		}
926
+
927
+		/* branch-free variant of === 0 */
928
+		if (-(1 & (($d - 1) >> 8))) {
929
+			throw new SodiumException('Zero public key is not allowed');
930
+		}
931
+	}
932
+
933
+	/**
934
+	 * XSalsa20-Poly1305 authenticated symmetric-key encryption.
935
+	 *
936
+	 * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
937
+	 *
938
+	 * @param string $plaintext
939
+	 * @param string $nonce
940
+	 * @param string $key
941
+	 * @return string
942
+	 * @throws SodiumException
943
+	 * @throws TypeError
944
+	 */
945
+	public static function secretbox($plaintext, $nonce, $key)
946
+	{
947
+		/** @var string $subkey */
948
+		$subkey = ParagonIE_Sodium_Core_HSalsa20::hsalsa20($nonce, $key);
949
+
950
+		/** @var string $block0 */
951
+		$block0 = str_repeat("\x00", 32);
952
+
953
+		/** @var int $mlen - Length of the plaintext message */
954
+		$mlen = ParagonIE_Sodium_Core_Util::strlen($plaintext);
955
+		$mlen0 = $mlen;
956
+		if ($mlen0 > 64 - self::secretbox_xsalsa20poly1305_ZEROBYTES) {
957
+			$mlen0 = 64 - self::secretbox_xsalsa20poly1305_ZEROBYTES;
958
+		}
959
+		$block0 .= ParagonIE_Sodium_Core_Util::substr($plaintext, 0, $mlen0);
960
+
961
+		/** @var string $block0 */
962
+		$block0 = ParagonIE_Sodium_Core_Salsa20::salsa20_xor(
963
+			$block0,
964
+			ParagonIE_Sodium_Core_Util::substr($nonce, 16, 8),
965
+			$subkey
966
+		);
967
+
968
+		/** @var string $c */
969
+		$c = ParagonIE_Sodium_Core_Util::substr(
970
+			$block0,
971
+			self::secretbox_xsalsa20poly1305_ZEROBYTES
972
+		);
973
+		if ($mlen > $mlen0) {
974
+			$c .= ParagonIE_Sodium_Core_Salsa20::salsa20_xor_ic(
975
+				ParagonIE_Sodium_Core_Util::substr(
976
+					$plaintext,
977
+					self::secretbox_xsalsa20poly1305_ZEROBYTES
978
+				),
979
+				ParagonIE_Sodium_Core_Util::substr($nonce, 16, 8),
980
+				1,
981
+				$subkey
982
+			);
983
+		}
984
+		$state = new ParagonIE_Sodium_Core_Poly1305_State(
985
+			ParagonIE_Sodium_Core_Util::substr(
986
+				$block0,
987
+				0,
988
+				self::onetimeauth_poly1305_KEYBYTES
989
+			)
990
+		);
991
+		try {
992
+			ParagonIE_Sodium_Compat::memzero($block0);
993
+			ParagonIE_Sodium_Compat::memzero($subkey);
994
+		} catch (SodiumException $ex) {
995
+			$block0 = null;
996
+			$subkey = null;
997
+		}
998
+
999
+		$state->update($c);
1000
+
1001
+		/** @var string $c - MAC || ciphertext */
1002
+		$c = $state->finish() . $c;
1003
+		unset($state);
1004
+
1005
+		return $c;
1006
+	}
1007
+
1008
+	/**
1009
+	 * Decrypt a ciphertext generated via secretbox().
1010
+	 *
1011
+	 * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
1012
+	 *
1013
+	 * @param string $ciphertext
1014
+	 * @param string $nonce
1015
+	 * @param string $key
1016
+	 * @return string
1017
+	 * @throws SodiumException
1018
+	 * @throws TypeError
1019
+	 */
1020
+	public static function secretbox_open($ciphertext, $nonce, $key)
1021
+	{
1022
+		/** @var string $mac */
1023
+		$mac = ParagonIE_Sodium_Core_Util::substr(
1024
+			$ciphertext,
1025
+			0,
1026
+			self::secretbox_xsalsa20poly1305_MACBYTES
1027
+		);
1028
+
1029
+		/** @var string $c */
1030
+		$c = ParagonIE_Sodium_Core_Util::substr(
1031
+			$ciphertext,
1032
+			self::secretbox_xsalsa20poly1305_MACBYTES
1033
+		);
1034
+
1035
+		/** @var int $clen */
1036
+		$clen = ParagonIE_Sodium_Core_Util::strlen($c);
1037
+
1038
+		/** @var string $subkey */
1039
+		$subkey = ParagonIE_Sodium_Core_HSalsa20::hsalsa20($nonce, $key);
1040
+
1041
+		/** @var string $block0 */
1042
+		$block0 = ParagonIE_Sodium_Core_Salsa20::salsa20(
1043
+			64,
1044
+			ParagonIE_Sodium_Core_Util::substr($nonce, 16, 8),
1045
+			$subkey
1046
+		);
1047
+		$verified = ParagonIE_Sodium_Core_Poly1305::onetimeauth_verify(
1048
+			$mac,
1049
+			$c,
1050
+			ParagonIE_Sodium_Core_Util::substr($block0, 0, 32)
1051
+		);
1052
+		if (!$verified) {
1053
+			try {
1054
+				ParagonIE_Sodium_Compat::memzero($subkey);
1055
+			} catch (SodiumException $ex) {
1056
+				$subkey = null;
1057
+			}
1058
+			throw new SodiumException('Invalid MAC');
1059
+		}
1060
+
1061
+		/** @var string $m - Decrypted message */
1062
+		$m = ParagonIE_Sodium_Core_Util::xorStrings(
1063
+			ParagonIE_Sodium_Core_Util::substr($block0, self::secretbox_xsalsa20poly1305_ZEROBYTES),
1064
+			ParagonIE_Sodium_Core_Util::substr($c, 0, self::secretbox_xsalsa20poly1305_ZEROBYTES)
1065
+		);
1066
+		if ($clen > self::secretbox_xsalsa20poly1305_ZEROBYTES) {
1067
+			// We had more than 1 block, so let's continue to decrypt the rest.
1068
+			$m .= ParagonIE_Sodium_Core_Salsa20::salsa20_xor_ic(
1069
+				ParagonIE_Sodium_Core_Util::substr(
1070
+					$c,
1071
+					self::secretbox_xsalsa20poly1305_ZEROBYTES
1072
+				),
1073
+				ParagonIE_Sodium_Core_Util::substr($nonce, 16, 8),
1074
+				1,
1075
+				(string) $subkey
1076
+			);
1077
+		}
1078
+		return $m;
1079
+	}
1080
+
1081
+	/**
1082
+	 * XChaCha20-Poly1305 authenticated symmetric-key encryption.
1083
+	 *
1084
+	 * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
1085
+	 *
1086
+	 * @param string $plaintext
1087
+	 * @param string $nonce
1088
+	 * @param string $key
1089
+	 * @return string
1090
+	 * @throws SodiumException
1091
+	 * @throws TypeError
1092
+	 */
1093
+	public static function secretbox_xchacha20poly1305($plaintext, $nonce, $key)
1094
+	{
1095
+		/** @var string $subkey */
1096
+		$subkey = ParagonIE_Sodium_Core_HChaCha20::hChaCha20(
1097
+			ParagonIE_Sodium_Core_Util::substr($nonce, 0, 16),
1098
+			$key
1099
+		);
1100
+		$nonceLast = ParagonIE_Sodium_Core_Util::substr($nonce, 16, 8);
1101
+
1102
+		/** @var string $block0 */
1103
+		$block0 = str_repeat("\x00", 32);
1104
+
1105
+		/** @var int $mlen - Length of the plaintext message */
1106
+		$mlen = ParagonIE_Sodium_Core_Util::strlen($plaintext);
1107
+		$mlen0 = $mlen;
1108
+		if ($mlen0 > 64 - self::secretbox_xchacha20poly1305_ZEROBYTES) {
1109
+			$mlen0 = 64 - self::secretbox_xchacha20poly1305_ZEROBYTES;
1110
+		}
1111
+		$block0 .= ParagonIE_Sodium_Core_Util::substr($plaintext, 0, $mlen0);
1112
+
1113
+		/** @var string $block0 */
1114
+		$block0 = ParagonIE_Sodium_Core_ChaCha20::streamXorIc(
1115
+			$block0,
1116
+			$nonceLast,
1117
+			$subkey
1118
+		);
1119
+
1120
+		/** @var string $c */
1121
+		$c = ParagonIE_Sodium_Core_Util::substr(
1122
+			$block0,
1123
+			self::secretbox_xchacha20poly1305_ZEROBYTES
1124
+		);
1125
+		if ($mlen > $mlen0) {
1126
+			$c .= ParagonIE_Sodium_Core_ChaCha20::streamXorIc(
1127
+				ParagonIE_Sodium_Core_Util::substr(
1128
+					$plaintext,
1129
+					self::secretbox_xchacha20poly1305_ZEROBYTES
1130
+				),
1131
+				$nonceLast,
1132
+				$subkey,
1133
+				ParagonIE_Sodium_Core_Util::store64_le(1)
1134
+			);
1135
+		}
1136
+		$state = new ParagonIE_Sodium_Core_Poly1305_State(
1137
+			ParagonIE_Sodium_Core_Util::substr(
1138
+				$block0,
1139
+				0,
1140
+				self::onetimeauth_poly1305_KEYBYTES
1141
+			)
1142
+		);
1143
+		try {
1144
+			ParagonIE_Sodium_Compat::memzero($block0);
1145
+			ParagonIE_Sodium_Compat::memzero($subkey);
1146
+		} catch (SodiumException $ex) {
1147
+			$block0 = null;
1148
+			$subkey = null;
1149
+		}
1150
+
1151
+		$state->update($c);
1152
+
1153
+		/** @var string $c - MAC || ciphertext */
1154
+		$c = $state->finish() . $c;
1155
+		unset($state);
1156
+
1157
+		return $c;
1158
+	}
1159
+
1160
+	/**
1161
+	 * Decrypt a ciphertext generated via secretbox_xchacha20poly1305().
1162
+	 *
1163
+	 * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
1164
+	 *
1165
+	 * @param string $ciphertext
1166
+	 * @param string $nonce
1167
+	 * @param string $key
1168
+	 * @return string
1169
+	 * @throws SodiumException
1170
+	 * @throws TypeError
1171
+	 */
1172
+	public static function secretbox_xchacha20poly1305_open($ciphertext, $nonce, $key)
1173
+	{
1174
+		/** @var string $mac */
1175
+		$mac = ParagonIE_Sodium_Core_Util::substr(
1176
+			$ciphertext,
1177
+			0,
1178
+			self::secretbox_xchacha20poly1305_MACBYTES
1179
+		);
1180
+
1181
+		/** @var string $c */
1182
+		$c = ParagonIE_Sodium_Core_Util::substr(
1183
+			$ciphertext,
1184
+			self::secretbox_xchacha20poly1305_MACBYTES
1185
+		);
1186
+
1187
+		/** @var int $clen */
1188
+		$clen = ParagonIE_Sodium_Core_Util::strlen($c);
1189
+
1190
+		/** @var string $subkey */
1191
+		$subkey = ParagonIE_Sodium_Core_HChaCha20::hchacha20($nonce, $key);
1192
+
1193
+		/** @var string $block0 */
1194
+		$block0 = ParagonIE_Sodium_Core_ChaCha20::stream(
1195
+			64,
1196
+			ParagonIE_Sodium_Core_Util::substr($nonce, 16, 8),
1197
+			$subkey
1198
+		);
1199
+		$verified = ParagonIE_Sodium_Core_Poly1305::onetimeauth_verify(
1200
+			$mac,
1201
+			$c,
1202
+			ParagonIE_Sodium_Core_Util::substr($block0, 0, 32)
1203
+		);
1204
+
1205
+		if (!$verified) {
1206
+			try {
1207
+				ParagonIE_Sodium_Compat::memzero($subkey);
1208
+			} catch (SodiumException $ex) {
1209
+				$subkey = null;
1210
+			}
1211
+			throw new SodiumException('Invalid MAC');
1212
+		}
1213
+
1214
+		/** @var string $m - Decrypted message */
1215
+		$m = ParagonIE_Sodium_Core_Util::xorStrings(
1216
+			ParagonIE_Sodium_Core_Util::substr($block0, self::secretbox_xchacha20poly1305_ZEROBYTES),
1217
+			ParagonIE_Sodium_Core_Util::substr($c, 0, self::secretbox_xchacha20poly1305_ZEROBYTES)
1218
+		);
1219
+
1220
+		if ($clen > self::secretbox_xchacha20poly1305_ZEROBYTES) {
1221
+			// We had more than 1 block, so let's continue to decrypt the rest.
1222
+			$m .= ParagonIE_Sodium_Core_ChaCha20::streamXorIc(
1223
+				ParagonIE_Sodium_Core_Util::substr(
1224
+					$c,
1225
+					self::secretbox_xchacha20poly1305_ZEROBYTES
1226
+				),
1227
+				ParagonIE_Sodium_Core_Util::substr($nonce, 16, 8),
1228
+				(string) $subkey,
1229
+				ParagonIE_Sodium_Core_Util::store64_le(1)
1230
+			);
1231
+		}
1232
+		return $m;
1233
+	}
1234
+
1235
+	/**
1236
+	 * @param string $key
1237
+	 * @return array<int, string> Returns a state and a header.
1238
+	 * @throws Exception
1239
+	 * @throws SodiumException
1240
+	 */
1241
+	public static function secretstream_xchacha20poly1305_init_push($key)
1242
+	{
1243
+		# randombytes_buf(out, crypto_secretstream_xchacha20poly1305_HEADERBYTES);
1244
+		$out = random_bytes(24);
1245
+
1246
+		# crypto_core_hchacha20(state->k, out, k, NULL);
1247
+		$subkey = ParagonIE_Sodium_Core_HChaCha20::hChaCha20($out, $key);
1248
+		$state = new ParagonIE_Sodium_Core_SecretStream_State(
1249
+			$subkey,
1250
+			ParagonIE_Sodium_Core_Util::substr($out, 16, 8) . str_repeat("\0", 4)
1251
+		);
1252
+
1253
+		# _crypto_secretstream_xchacha20poly1305_counter_reset(state);
1254
+		$state->counterReset();
1255
+
1256
+		# memcpy(STATE_INONCE(state), out + crypto_core_hchacha20_INPUTBYTES,
1257
+		#        crypto_secretstream_xchacha20poly1305_INONCEBYTES);
1258
+		# memset(state->_pad, 0, sizeof state->_pad);
1259
+		return array(
1260
+			$state->toString(),
1261
+			$out
1262
+		);
1263
+	}
1264
+
1265
+	/**
1266
+	 * @param string $key
1267
+	 * @param string $header
1268
+	 * @return string Returns a state.
1269
+	 * @throws Exception
1270
+	 */
1271
+	public static function secretstream_xchacha20poly1305_init_pull($key, $header)
1272
+	{
1273
+		# crypto_core_hchacha20(state->k, in, k, NULL);
1274
+		$subkey = ParagonIE_Sodium_Core_HChaCha20::hChaCha20(
1275
+			ParagonIE_Sodium_Core_Util::substr($header, 0, 16),
1276
+			$key
1277
+		);
1278
+		$state = new ParagonIE_Sodium_Core_SecretStream_State(
1279
+			$subkey,
1280
+			ParagonIE_Sodium_Core_Util::substr($header, 16)
1281
+		);
1282
+		$state->counterReset();
1283
+		# memcpy(STATE_INONCE(state), in + crypto_core_hchacha20_INPUTBYTES,
1284
+		#     crypto_secretstream_xchacha20poly1305_INONCEBYTES);
1285
+		# memset(state->_pad, 0, sizeof state->_pad);
1286
+		# return 0;
1287
+		return $state->toString();
1288
+	}
1289
+
1290
+	/**
1291
+	 * @param string $state
1292
+	 * @param string $msg
1293
+	 * @param string $aad
1294
+	 * @param int $tag
1295
+	 * @return string
1296
+	 * @throws SodiumException
1297
+	 */
1298
+	public static function secretstream_xchacha20poly1305_push(&$state, $msg, $aad = '', $tag = 0)
1299
+	{
1300
+		$st = ParagonIE_Sodium_Core_SecretStream_State::fromString($state);
1301
+		# crypto_onetimeauth_poly1305_state poly1305_state;
1302
+		# unsigned char                     block[64U];
1303
+		# unsigned char                     slen[8U];
1304
+		# unsigned char                    *c;
1305
+		# unsigned char                    *mac;
1306
+
1307
+		$msglen = ParagonIE_Sodium_Core_Util::strlen($msg);
1308
+		$aadlen = ParagonIE_Sodium_Core_Util::strlen($aad);
1309
+
1310
+		if ((($msglen + 63) >> 6) > 0xfffffffe) {
1311
+			throw new SodiumException(
1312
+				'message cannot be larger than SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_MESSAGEBYTES_MAX bytes'
1313
+			);
1314
+		}
1315
+
1316
+		# if (outlen_p != NULL) {
1317
+		#     *outlen_p = 0U;
1318
+		# }
1319
+		# if (mlen > crypto_secretstream_xchacha20poly1305_MESSAGEBYTES_MAX) {
1320
+		#     sodium_misuse();
1321
+		# }
1322
+
1323
+		# crypto_stream_chacha20_ietf(block, sizeof block, state->nonce, state->k);
1324
+		# crypto_onetimeauth_poly1305_init(&poly1305_state, block);
1325
+		# sodium_memzero(block, sizeof block);
1326
+		$auth = new ParagonIE_Sodium_Core_Poly1305_State(
1327
+			ParagonIE_Sodium_Core_ChaCha20::ietfStream(32, $st->getCombinedNonce(), $st->getKey())
1328
+		);
1329
+
1330
+		# crypto_onetimeauth_poly1305_update(&poly1305_state, ad, adlen);
1331
+		$auth->update($aad);
1332
+
1333
+		# crypto_onetimeauth_poly1305_update(&poly1305_state, _pad0,
1334
+		#     (0x10 - adlen) & 0xf);
1335
+		$auth->update(str_repeat("\0", ((0x10 - $aadlen) & 0xf)));
1336
+
1337
+		# memset(block, 0, sizeof block);
1338
+		# block[0] = tag;
1339
+		# crypto_stream_chacha20_ietf_xor_ic(block, block, sizeof block,
1340
+		#                                    state->nonce, 1U, state->k);
1341
+		$block = ParagonIE_Sodium_Core_ChaCha20::ietfStreamXorIc(
1342
+			ParagonIE_Sodium_Core_Util::intToChr($tag) . str_repeat("\0", 63),
1343
+			$st->getCombinedNonce(),
1344
+			$st->getKey(),
1345
+			ParagonIE_Sodium_Core_Util::store64_le(1)
1346
+		);
1347
+
1348
+		# crypto_onetimeauth_poly1305_update(&poly1305_state, block, sizeof block);
1349
+		$auth->update($block);
1350
+
1351
+		# out[0] = block[0];
1352
+		$out = $block[0];
1353
+		# c = out + (sizeof tag);
1354
+		# crypto_stream_chacha20_ietf_xor_ic(c, m, mlen, state->nonce, 2U, state->k);
1355
+		$cipher = ParagonIE_Sodium_Core_ChaCha20::ietfStreamXorIc(
1356
+			$msg,
1357
+			$st->getCombinedNonce(),
1358
+			$st->getKey(),
1359
+			ParagonIE_Sodium_Core_Util::store64_le(2)
1360
+		);
1361
+
1362
+		# crypto_onetimeauth_poly1305_update(&poly1305_state, c, mlen);
1363
+		$auth->update($cipher);
1364
+
1365
+		$out .= $cipher;
1366
+		unset($cipher);
1367
+
1368
+		# crypto_onetimeauth_poly1305_update
1369
+		# (&poly1305_state, _pad0, (0x10 - (sizeof block) + mlen) & 0xf);
1370
+		$auth->update(str_repeat("\0", ((0x10 - 64 + $msglen) & 0xf)));
1371
+
1372
+		# STORE64_LE(slen, (uint64_t) adlen);
1373
+		$slen = ParagonIE_Sodium_Core_Util::store64_le($aadlen);
1374
+
1375
+		# crypto_onetimeauth_poly1305_update(&poly1305_state, slen, sizeof slen);
1376
+		$auth->update($slen);
1377
+
1378
+		# STORE64_LE(slen, (sizeof block) + mlen);
1379
+		$slen = ParagonIE_Sodium_Core_Util::store64_le(64 + $msglen);
1380
+
1381
+		# crypto_onetimeauth_poly1305_update(&poly1305_state, slen, sizeof slen);
1382
+		$auth->update($slen);
1383
+
1384
+		# mac = c + mlen;
1385
+		# crypto_onetimeauth_poly1305_final(&poly1305_state, mac);
1386
+		$mac = $auth->finish();
1387
+		$out .= $mac;
1388
+
1389
+		# sodium_memzero(&poly1305_state, sizeof poly1305_state);
1390
+		unset($auth);
1391
+
1392
+
1393
+		# XOR_BUF(STATE_INONCE(state), mac,
1394
+		#     crypto_secretstream_xchacha20poly1305_INONCEBYTES);
1395
+		$st->xorNonce($mac);
1396
+
1397
+		# sodium_increment(STATE_COUNTER(state),
1398
+		#     crypto_secretstream_xchacha20poly1305_COUNTERBYTES);
1399
+		$st->incrementCounter();
1400
+		// Overwrite by reference:
1401
+		$state = $st->toString();
1402
+
1403
+		/** @var bool $rekey */
1404
+		$rekey = ($tag & ParagonIE_Sodium_Compat::CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_REKEY) !== 0;
1405
+		# if ((tag & crypto_secretstream_xchacha20poly1305_TAG_REKEY) != 0 ||
1406
+		#     sodium_is_zero(STATE_COUNTER(state),
1407
+		#         crypto_secretstream_xchacha20poly1305_COUNTERBYTES)) {
1408
+		#     crypto_secretstream_xchacha20poly1305_rekey(state);
1409
+		# }
1410
+		if ($rekey || $st->needsRekey()) {
1411
+			// DO REKEY
1412
+			self::secretstream_xchacha20poly1305_rekey($state);
1413
+		}
1414
+		# if (outlen_p != NULL) {
1415
+		#     *outlen_p = crypto_secretstream_xchacha20poly1305_ABYTES + mlen;
1416
+		# }
1417
+		return $out;
1418
+	}
1419
+
1420
+	/**
1421
+	 * @param string $state
1422
+	 * @param string $cipher
1423
+	 * @param string $aad
1424
+	 * @return bool|array{0: string, 1: int}
1425
+	 * @throws SodiumException
1426
+	 */
1427
+	public static function secretstream_xchacha20poly1305_pull(&$state, $cipher, $aad = '')
1428
+	{
1429
+		$st = ParagonIE_Sodium_Core_SecretStream_State::fromString($state);
1430
+
1431
+		$cipherlen = ParagonIE_Sodium_Core_Util::strlen($cipher);
1432
+		#     mlen = inlen - crypto_secretstream_xchacha20poly1305_ABYTES;
1433
+		$msglen = $cipherlen - ParagonIE_Sodium_Compat::CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_ABYTES;
1434
+		$aadlen = ParagonIE_Sodium_Core_Util::strlen($aad);
1435
+
1436
+		#     if (mlen > crypto_secretstream_xchacha20poly1305_MESSAGEBYTES_MAX) {
1437
+		#         sodium_misuse();
1438
+		#     }
1439
+		if ((($msglen + 63) >> 6) > 0xfffffffe) {
1440
+			throw new SodiumException(
1441
+				'message cannot be larger than SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_MESSAGEBYTES_MAX bytes'
1442
+			);
1443
+		}
1444
+
1445
+		#     crypto_stream_chacha20_ietf(block, sizeof block, state->nonce, state->k);
1446
+		#     crypto_onetimeauth_poly1305_init(&poly1305_state, block);
1447
+		#     sodium_memzero(block, sizeof block);
1448
+		$auth = new ParagonIE_Sodium_Core_Poly1305_State(
1449
+			ParagonIE_Sodium_Core_ChaCha20::ietfStream(32, $st->getCombinedNonce(), $st->getKey())
1450
+		);
1451
+
1452
+		#     crypto_onetimeauth_poly1305_update(&poly1305_state, ad, adlen);
1453
+		$auth->update($aad);
1454
+
1455
+		#     crypto_onetimeauth_poly1305_update(&poly1305_state, _pad0,
1456
+		#         (0x10 - adlen) & 0xf);
1457
+		$auth->update(str_repeat("\0", ((0x10 - $aadlen) & 0xf)));
1458
+
1459
+
1460
+		#     memset(block, 0, sizeof block);
1461
+		#     block[0] = in[0];
1462
+		#     crypto_stream_chacha20_ietf_xor_ic(block, block, sizeof block,
1463
+		#                                        state->nonce, 1U, state->k);
1464
+		$block = ParagonIE_Sodium_Core_ChaCha20::ietfStreamXorIc(
1465
+			$cipher[0] . str_repeat("\0", 63),
1466
+			$st->getCombinedNonce(),
1467
+			$st->getKey(),
1468
+			ParagonIE_Sodium_Core_Util::store64_le(1)
1469
+		);
1470
+		#     tag = block[0];
1471
+		#     block[0] = in[0];
1472
+		#     crypto_onetimeauth_poly1305_update(&poly1305_state, block, sizeof block);
1473
+		$tag = ParagonIE_Sodium_Core_Util::chrToInt($block[0]);
1474
+		$block[0] = $cipher[0];
1475
+		$auth->update($block);
1476
+
1477
+
1478
+		#     c = in + (sizeof tag);
1479
+		#     crypto_onetimeauth_poly1305_update(&poly1305_state, c, mlen);
1480
+		$auth->update(ParagonIE_Sodium_Core_Util::substr($cipher, 1, $msglen));
1481
+
1482
+		#     crypto_onetimeauth_poly1305_update
1483
+		#     (&poly1305_state, _pad0, (0x10 - (sizeof block) + mlen) & 0xf);
1484
+		$auth->update(str_repeat("\0", ((0x10 - 64 + $msglen) & 0xf)));
1485
+
1486
+		#     STORE64_LE(slen, (uint64_t) adlen);
1487
+		#     crypto_onetimeauth_poly1305_update(&poly1305_state, slen, sizeof slen);
1488
+		$slen = ParagonIE_Sodium_Core_Util::store64_le($aadlen);
1489
+		$auth->update($slen);
1490
+
1491
+		#     STORE64_LE(slen, (sizeof block) + mlen);
1492
+		#     crypto_onetimeauth_poly1305_update(&poly1305_state, slen, sizeof slen);
1493
+		$slen = ParagonIE_Sodium_Core_Util::store64_le(64 + $msglen);
1494
+		$auth->update($slen);
1495
+
1496
+		#     crypto_onetimeauth_poly1305_final(&poly1305_state, mac);
1497
+		#     sodium_memzero(&poly1305_state, sizeof poly1305_state);
1498
+		$mac = $auth->finish();
1499
+
1500
+		#     stored_mac = c + mlen;
1501
+		#     if (sodium_memcmp(mac, stored_mac, sizeof mac) != 0) {
1502
+		#     sodium_memzero(mac, sizeof mac);
1503
+		#         return -1;
1504
+		#     }
1505
+
1506
+		$stored = ParagonIE_Sodium_Core_Util::substr($cipher, $msglen + 1, 16);
1507
+		if (!ParagonIE_Sodium_Core_Util::hashEquals($mac, $stored)) {
1508
+			return false;
1509
+		}
1510
+
1511
+		#     crypto_stream_chacha20_ietf_xor_ic(m, c, mlen, state->nonce, 2U, state->k);
1512
+		$out = ParagonIE_Sodium_Core_ChaCha20::ietfStreamXorIc(
1513
+			ParagonIE_Sodium_Core_Util::substr($cipher, 1, $msglen),
1514
+			$st->getCombinedNonce(),
1515
+			$st->getKey(),
1516
+			ParagonIE_Sodium_Core_Util::store64_le(2)
1517
+		);
1518
+
1519
+		#     XOR_BUF(STATE_INONCE(state), mac,
1520
+		#         crypto_secretstream_xchacha20poly1305_INONCEBYTES);
1521
+		$st->xorNonce($mac);
1522
+
1523
+		#     sodium_increment(STATE_COUNTER(state),
1524
+		#         crypto_secretstream_xchacha20poly1305_COUNTERBYTES);
1525
+		$st->incrementCounter();
1526
+
1527
+		#     if ((tag & crypto_secretstream_xchacha20poly1305_TAG_REKEY) != 0 ||
1528
+		#         sodium_is_zero(STATE_COUNTER(state),
1529
+		#             crypto_secretstream_xchacha20poly1305_COUNTERBYTES)) {
1530
+		#         crypto_secretstream_xchacha20poly1305_rekey(state);
1531
+		#     }
1532
+
1533
+		// Overwrite by reference:
1534
+		$state = $st->toString();
1535
+
1536
+		/** @var bool $rekey */
1537
+		$rekey = ($tag & ParagonIE_Sodium_Compat::CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_REKEY) !== 0;
1538
+		if ($rekey || $st->needsRekey()) {
1539
+			// DO REKEY
1540
+			self::secretstream_xchacha20poly1305_rekey($state);
1541
+		}
1542
+		return array($out, $tag);
1543
+	}
1544
+
1545
+	/**
1546
+	 * @param string $state
1547
+	 * @return void
1548
+	 * @throws SodiumException
1549
+	 */
1550
+	public static function secretstream_xchacha20poly1305_rekey(&$state)
1551
+	{
1552
+		$st = ParagonIE_Sodium_Core_SecretStream_State::fromString($state);
1553
+		# unsigned char new_key_and_inonce[crypto_stream_chacha20_ietf_KEYBYTES +
1554
+		# crypto_secretstream_xchacha20poly1305_INONCEBYTES];
1555
+		# size_t        i;
1556
+		# for (i = 0U; i < crypto_stream_chacha20_ietf_KEYBYTES; i++) {
1557
+		#     new_key_and_inonce[i] = state->k[i];
1558
+		# }
1559
+		$new_key_and_inonce = $st->getKey();
1560
+
1561
+		# for (i = 0U; i < crypto_secretstream_xchacha20poly1305_INONCEBYTES; i++) {
1562
+		#     new_key_and_inonce[crypto_stream_chacha20_ietf_KEYBYTES + i] =
1563
+		#         STATE_INONCE(state)[i];
1564
+		# }
1565
+		$new_key_and_inonce .= ParagonIE_Sodium_Core_Util::substR($st->getNonce(), 0, 8);
1566
+
1567
+		# crypto_stream_chacha20_ietf_xor(new_key_and_inonce, new_key_and_inonce,
1568
+		#                                 sizeof new_key_and_inonce,
1569
+		#                                 state->nonce, state->k);
1570
+
1571
+		$st->rekey(ParagonIE_Sodium_Core_ChaCha20::ietfStreamXorIc(
1572
+			$new_key_and_inonce,
1573
+			$st->getCombinedNonce(),
1574
+			$st->getKey(),
1575
+			ParagonIE_Sodium_Core_Util::store64_le(0)
1576
+		));
1577
+
1578
+		# for (i = 0U; i < crypto_stream_chacha20_ietf_KEYBYTES; i++) {
1579
+		#     state->k[i] = new_key_and_inonce[i];
1580
+		# }
1581
+		# for (i = 0U; i < crypto_secretstream_xchacha20poly1305_INONCEBYTES; i++) {
1582
+		#     STATE_INONCE(state)[i] =
1583
+		#          new_key_and_inonce[crypto_stream_chacha20_ietf_KEYBYTES + i];
1584
+		# }
1585
+		# _crypto_secretstream_xchacha20poly1305_counter_reset(state);
1586
+		$st->counterReset();
1587
+
1588
+		$state = $st->toString();
1589
+	}
1590
+
1591
+	/**
1592
+	 * Detached Ed25519 signature.
1593
+	 *
1594
+	 * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
1595
+	 *
1596
+	 * @param string $message
1597
+	 * @param string $sk
1598
+	 * @return string
1599
+	 * @throws SodiumException
1600
+	 * @throws TypeError
1601
+	 */
1602
+	public static function sign_detached($message, $sk)
1603
+	{
1604
+		return ParagonIE_Sodium_Core_Ed25519::sign_detached($message, $sk);
1605
+	}
1606
+
1607
+	/**
1608
+	 * Attached Ed25519 signature. (Returns a signed message.)
1609
+	 *
1610
+	 * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
1611
+	 *
1612
+	 * @param string $message
1613
+	 * @param string $sk
1614
+	 * @return string
1615
+	 * @throws SodiumException
1616
+	 * @throws TypeError
1617
+	 */
1618
+	public static function sign($message, $sk)
1619
+	{
1620
+		return ParagonIE_Sodium_Core_Ed25519::sign($message, $sk);
1621
+	}
1622
+
1623
+	/**
1624
+	 * Opens a signed message. If valid, returns the message.
1625
+	 *
1626
+	 * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
1627
+	 *
1628
+	 * @param string $signedMessage
1629
+	 * @param string $pk
1630
+	 * @return string
1631
+	 * @throws SodiumException
1632
+	 * @throws TypeError
1633
+	 */
1634
+	public static function sign_open($signedMessage, $pk)
1635
+	{
1636
+		return ParagonIE_Sodium_Core_Ed25519::sign_open($signedMessage, $pk);
1637
+	}
1638
+
1639
+	/**
1640
+	 * Verify a detached signature of a given message and public key.
1641
+	 *
1642
+	 * @internal Do not use this directly. Use ParagonIE_Sodium_Compat.
1643
+	 *
1644
+	 * @param string $signature
1645
+	 * @param string $message
1646
+	 * @param string $pk
1647
+	 * @return bool
1648
+	 * @throws SodiumException
1649
+	 * @throws TypeError
1650
+	 */
1651
+	public static function sign_verify_detached($signature, $message, $pk)
1652
+	{
1653
+		return ParagonIE_Sodium_Core_Ed25519::verify_detached($signature, $message, $pk);
1654
+	}
1655 1655
 }
Please login to merge, or discard this patch.