Diff: STRATO-apps/wordpress_03/app/wp-includes/sodium_compat/lib/php72compat.php

Keine Baseline-Datei – Diff nur gegen leer.
Zur Liste
1 -
1 + <?php
2 +
3 + require_once dirname(dirname(__FILE__)) . '/autoload.php';
4 +
5 + /**
6 + * This file will monkey patch the pure-PHP implementation in place of the
7 + * PECL functions and constants, but only if they do not already exist.
8 + *
9 + * Thus, the functions or constants just proxy to the appropriate
10 + * ParagonIE_Sodium_Compat method or class constant, respectively.
11 + */
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_AES256GCM_KEYBYTES',
18 + 'CRYPTO_AEAD_AES256GCM_NSECBYTES',
19 + 'CRYPTO_AEAD_AES256GCM_NPUBBYTES',
20 + 'CRYPTO_AEAD_AES256GCM_ABYTES',
21 + 'CRYPTO_AEAD_CHACHA20POLY1305_KEYBYTES',
22 + 'CRYPTO_AEAD_CHACHA20POLY1305_NSECBYTES',
23 + 'CRYPTO_AEAD_CHACHA20POLY1305_NPUBBYTES',
24 + 'CRYPTO_AEAD_CHACHA20POLY1305_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 + ) {
106 + if (!defined("SODIUM_$constant") && defined("ParagonIE_Sodium_Compat::$constant")) {
107 + define("SODIUM_$constant", constant("ParagonIE_Sodium_Compat::$constant"));
108 + }
109 + }
110 + if (!is_callable('sodium_add')) {
111 + /**
112 + * @see ParagonIE_Sodium_Compat::add()
113 + * @param string $string1
114 + * @param string $string2
115 + * @return void
116 + * @throws SodiumException
117 + */
118 + function sodium_add(
119 + #[\SensitiveParameter]
120 + &$string1,
121 + #[\SensitiveParameter]
122 + $string2
123 + ) {
124 + ParagonIE_Sodium_Compat::add($string1, $string2);
125 + }
126 + }
127 + if (!is_callable('sodium_base642bin')) {
128 + /**
129 + * @see ParagonIE_Sodium_Compat::bin2base64()
130 + * @param string $string
131 + * @param int $variant
132 + * @param string $ignore
133 + * @return string
134 + * @throws SodiumException
135 + * @throws TypeError
136 + */
137 + function sodium_base642bin(
138 + #[\SensitiveParameter]
139 + $string,
140 + $variant,
141 + $ignore =''
142 + ) {
143 + return ParagonIE_Sodium_Compat::base642bin($string, $variant, $ignore);
144 + }
145 + }
146 + if (!is_callable('sodium_bin2base64')) {
147 + /**
148 + * @see ParagonIE_Sodium_Compat::bin2base64()
149 + * @param string $string
150 + * @param int $variant
151 + * @return string
152 + * @throws SodiumException
153 + * @throws TypeError
154 + */
155 + function sodium_bin2base64(
156 + #[\SensitiveParameter]
157 + $string,
158 + $variant
159 + ) {
160 + return ParagonIE_Sodium_Compat::bin2base64($string, $variant);
161 + }
162 + }
163 + if (!is_callable('sodium_bin2hex')) {
164 + /**
165 + * @see ParagonIE_Sodium_Compat::hex2bin()
166 + * @param string $string
167 + * @return string
168 + * @throws SodiumException
169 + * @throws TypeError
170 + */
171 + function sodium_bin2hex(
172 + #[\SensitiveParameter]
173 + $string
174 + ) {
175 + return ParagonIE_Sodium_Compat::bin2hex($string);
176 + }
177 + }
178 + if (!is_callable('sodium_compare')) {
179 + /**
180 + * @see ParagonIE_Sodium_Compat::compare()
181 + * @param string $string1
182 + * @param string $string2
183 + * @return int
184 + * @throws SodiumException
185 + * @throws TypeError
186 + */
187 + function sodium_compare(
188 + #[\SensitiveParameter]
189 + $string1,
190 + #[\SensitiveParameter]
191 + $string2
192 + ) {
193 + return ParagonIE_Sodium_Compat::compare($string1, $string2);
194 + }
195 + }
196 + if (!is_callable('sodium_crypto_aead_aes256gcm_decrypt')) {
197 + /**
198 + * @see ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_decrypt()
199 + * @param string $ciphertext
200 + * @param string $additional_data
201 + * @param string $nonce
202 + * @param string $key
203 + * @return string|bool
204 + */
205 + function sodium_crypto_aead_aes256gcm_decrypt(
206 + $ciphertext,
207 + $additional_data,
208 + $nonce,
209 + #[\SensitiveParameter]
210 + $key
211 + ) {
212 + try {
213 + return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_decrypt(
214 + $ciphertext,
215 + $additional_data,
216 + $nonce,
217 + $key
218 + );
219 + } catch (Error $ex) {
220 + return false;
221 + } catch (Exception $ex) {
222 + if (($ex instanceof SodiumException) && ($ex->getMessage() === 'AES-256-GCM is not available')) {
223 + throw $ex;
224 + }
225 + return false;
226 + }
227 + }
228 + }
229 + if (!is_callable('sodium_crypto_aead_aes256gcm_encrypt')) {
230 + /**
231 + * @see ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_encrypt()
232 + * @param string $message
233 + * @param string $additional_data
234 + * @param string $nonce
235 + * @param string $key
236 + * @return string
237 + * @throws SodiumException
238 + * @throws TypeError
239 + */
240 + function sodium_crypto_aead_aes256gcm_encrypt(
241 + #[\SensitiveParameter]
242 + $message,
243 + $additional_data,
244 + $nonce,
245 + #[\SensitiveParameter]
246 + $key
247 + ) {
248 + return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_encrypt($message, $additional_data, $nonce, $key);
249 + }
250 + }
251 + if (!is_callable('sodium_crypto_aead_aes256gcm_is_available')) {
252 + /**
253 + * @see ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_is_available()
254 + * @return bool
255 + */
256 + function sodium_crypto_aead_aes256gcm_is_available()
257 + {
258 + return ParagonIE_Sodium_Compat::crypto_aead_aes256gcm_is_available();
259 + }
260 + }
261 + if (!is_callable('sodium_crypto_aead_chacha20poly1305_decrypt')) {
262 + /**
263 + * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_decrypt()
264 + * @param string $ciphertext
265 + * @param string $additional_data
266 + * @param string $nonce
267 + * @param string $key
268 + * @return string|bool
269 + */
270 + function sodium_crypto_aead_chacha20poly1305_decrypt(
271 + $ciphertext,
272 + $additional_data,
273 + $nonce,
274 + #[\SensitiveParameter]
275 + $key
276 + ) {
277 + try {
278 + return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_decrypt(
279 + $ciphertext,
280 + $additional_data,
281 + $nonce,
282 + $key
283 + );
284 + } catch (Error $ex) {
285 + return false;
286 + } catch (Exception $ex) {
287 + return false;
288 + }
289 + }
290 + }
291 + if (!is_callable('sodium_crypto_aead_chacha20poly1305_encrypt')) {
292 + /**
293 + * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_encrypt()
294 + * @param string $message
295 + * @param string $additional_data
296 + * @param string $nonce
297 + * @param string $key
298 + * @return string
299 + * @throws SodiumException
300 + * @throws TypeError
301 + */
302 + function sodium_crypto_aead_chacha20poly1305_encrypt(
303 + #[\SensitiveParameter]
304 + $message,
305 + $additional_data,
306 + $nonce,
307 + #[\SensitiveParameter]
308 + $key
309 + ) {
310 + return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_encrypt(
311 + $message,
312 + $additional_data,
313 + $nonce,
314 + $key
315 + );
316 + }
317 + }
318 + if (!is_callable('sodium_crypto_aead_chacha20poly1305_keygen')) {
319 + /**
320 + * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_keygen()
321 + * @return string
322 + * @throws Exception
323 + */
324 + function sodium_crypto_aead_chacha20poly1305_keygen()
325 + {
326 + return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_keygen();
327 + }
328 + }
329 + if (!is_callable('sodium_crypto_aead_chacha20poly1305_ietf_decrypt')) {
330 + /**
331 + * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_decrypt()
332 + * @param string $message
333 + * @param string $additional_data
334 + * @param string $nonce
335 + * @param string $key
336 + * @return string|bool
337 + */
338 + function sodium_crypto_aead_chacha20poly1305_ietf_decrypt(
339 + $message,
340 + $additional_data,
341 + $nonce,
342 + #[\SensitiveParameter]
343 + $key
344 + ) {
345 + try {
346 + return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_decrypt(
347 + $message,
348 + $additional_data,
349 + $nonce,
350 + $key
351 + );
352 + } catch (Error $ex) {
353 + return false;
354 + } catch (Exception $ex) {
355 + return false;
356 + }
357 + }
358 + }
359 + if (!is_callable('sodium_crypto_aead_chacha20poly1305_ietf_encrypt')) {
360 + /**
361 + * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_encrypt()
362 + * @param string $message
363 + * @param string $additional_data
364 + * @param string $nonce
365 + * @param string $key
366 + * @return string
367 + * @throws SodiumException
368 + * @throws TypeError
369 + */
370 + function sodium_crypto_aead_chacha20poly1305_ietf_encrypt(
371 + #[\SensitiveParameter]
372 + $message,
373 + $additional_data,
374 + $nonce,
375 + #[\SensitiveParameter]
376 + $key
377 + ) {
378 + return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_encrypt(
379 + $message,
380 + $additional_data,
381 + $nonce,
382 + $key
383 + );
384 + }
385 + }
386 + if (!is_callable('sodium_crypto_aead_chacha20poly1305_ietf_keygen')) {
387 + /**
388 + * @see ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_keygen()
389 + * @return string
390 + * @throws Exception
391 + */
392 + function sodium_crypto_aead_chacha20poly1305_ietf_keygen()
393 + {
394 + return ParagonIE_Sodium_Compat::crypto_aead_chacha20poly1305_ietf_keygen();
395 + }
396 + }
397 + if (!is_callable('sodium_crypto_aead_xchacha20poly1305_ietf_decrypt')) {
398 + /**
399 + * @see ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_decrypt()
400 + * @param string $ciphertext
401 + * @param string $additional_data
402 + * @param string $nonce
403 + * @param string $key
404 + * @return string|bool
405 + */
406 + function sodium_crypto_aead_xchacha20poly1305_ietf_decrypt(
407 + $ciphertext,
408 + $additional_data,
409 + $nonce,
410 + #[\SensitiveParameter]
411 + $key
412 + ) {
413 + try {
414 + return ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_decrypt(
415 + $ciphertext,
416 + $additional_data,
417 + $nonce,
418 + $key,
419 + true
420 + );
421 + } catch (Error $ex) {
422 + return false;
423 + } catch (Exception $ex) {
424 + return false;
425 + }
426 + }
427 + }
428 + if (!is_callable('sodium_crypto_aead_xchacha20poly1305_ietf_encrypt')) {
429 + /**
430 + * @see ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_encrypt()
431 + * @param string $message
432 + * @param string $additional_data
433 + * @param string $nonce
434 + * @param string $key
435 + * @return string
436 + * @throws SodiumException
437 + * @throws TypeError
438 + */
439 + function sodium_crypto_aead_xchacha20poly1305_ietf_encrypt(
440 + #[\SensitiveParameter]
441 + $message,
442 + $additional_data,
443 + $nonce,
444 + #[\SensitiveParameter]
445 + $key
446 + ) {
447 + return ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_encrypt(
448 + $message,
449 + $additional_data,
450 + $nonce,
451 + $key,
452 + true
453 + );
454 + }
455 + }
456 + if (!is_callable('sodium_crypto_aead_xchacha20poly1305_ietf_keygen')) {
457 + /**
458 + * @see ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_keygen()
459 + * @return string
460 + * @throws Exception
461 + */
462 + function sodium_crypto_aead_xchacha20poly1305_ietf_keygen()
463 + {
464 + return ParagonIE_Sodium_Compat::crypto_aead_xchacha20poly1305_ietf_keygen();
465 + }
466 + }
467 + if (!is_callable('sodium_crypto_auth')) {
468 + /**
469 + * @see ParagonIE_Sodium_Compat::crypto_auth()
470 + * @param string $message
471 + * @param string $key
472 + * @return string
473 + * @throws SodiumException
474 + * @throws TypeError
475 + */
476 + function sodium_crypto_auth(
477 + $message,
478 + #[\SensitiveParameter]
479 + $key
480 + ) {
481 + return ParagonIE_Sodium_Compat::crypto_auth($message, $key);
482 + }
483 + }
484 + if (!is_callable('sodium_crypto_auth_keygen')) {
485 + /**
486 + * @see ParagonIE_Sodium_Compat::crypto_auth_keygen()
487 + * @return string
488 + * @throws Exception
489 + */
490 + function sodium_crypto_auth_keygen()
491 + {
492 + return ParagonIE_Sodium_Compat::crypto_auth_keygen();
493 + }
494 + }
495 + if (!is_callable('sodium_crypto_auth_verify')) {
496 + /**
497 + * @see ParagonIE_Sodium_Compat::crypto_auth_verify()
498 + * @param string $mac
499 + * @param string $message
500 + * @param string $key
501 + * @return bool
502 + * @throws SodiumException
503 + * @throws TypeError
504 + */
505 + function sodium_crypto_auth_verify(
506 + $mac,
507 + $message,
508 + #[\SensitiveParameter]
509 + $key
510 + ) {
511 + return ParagonIE_Sodium_Compat::crypto_auth_verify($mac, $message, $key);
512 + }
513 + }
514 + if (!is_callable('sodium_crypto_box')) {
515 + /**
516 + * @see ParagonIE_Sodium_Compat::crypto_box()
517 + * @param string $message
518 + * @param string $nonce
519 + * @param string $key_pair
520 + * @return string
521 + * @throws SodiumException
522 + * @throws TypeError
523 + */
524 + function sodium_crypto_box(
525 + #[\SensitiveParameter]
526 + $message,
527 + $nonce,
528 + #[\SensitiveParameter]
529 + $key_pair
530 + ) {
531 + return ParagonIE_Sodium_Compat::crypto_box($message, $nonce, $key_pair);
532 + }
533 + }
534 + if (!is_callable('sodium_crypto_box_keypair')) {
535 + /**
536 + * @see ParagonIE_Sodium_Compat::crypto_box_keypair()
537 + * @return string
538 + * @throws SodiumException
539 + * @throws TypeError
540 + */
541 + function sodium_crypto_box_keypair()
542 + {
543 + return ParagonIE_Sodium_Compat::crypto_box_keypair();
544 + }
545 + }
546 + if (!is_callable('sodium_crypto_box_keypair_from_secretkey_and_publickey')) {
547 + /**
548 + * @see ParagonIE_Sodium_Compat::crypto_box_keypair_from_secretkey_and_publickey()
549 + * @param string $secret_key
550 + * @param string $public_key
551 + * @return string
552 + * @throws SodiumException
553 + * @throws TypeError
554 + */
555 + function sodium_crypto_box_keypair_from_secretkey_and_publickey(
556 + #[\SensitiveParameter]
557 + $secret_key,
558 + $public_key
559 + ) {
560 + return ParagonIE_Sodium_Compat::crypto_box_keypair_from_secretkey_and_publickey($secret_key, $public_key);
561 + }
562 + }
563 + if (!is_callable('sodium_crypto_box_open')) {
564 + /**
565 + * @see ParagonIE_Sodium_Compat::crypto_box_open()
566 + * @param string $ciphertext
567 + * @param string $nonce
568 + * @param string $key_pair
569 + * @return string|bool
570 + */
571 + function sodium_crypto_box_open(
572 + $ciphertext,
573 + $nonce,
574 + #[\SensitiveParameter]
575 + $key_pair
576 + ) {
577 + try {
578 + return ParagonIE_Sodium_Compat::crypto_box_open($ciphertext, $nonce, $key_pair);
579 + } catch (Error $ex) {
580 + return false;
581 + } catch (Exception $ex) {
582 + return false;
583 + }
584 + }
585 + }
586 + if (!is_callable('sodium_crypto_box_publickey')) {
587 + /**
588 + * @see ParagonIE_Sodium_Compat::crypto_box_publickey()
589 + * @param string $key_pair
590 + * @return string
591 + * @throws SodiumException
592 + * @throws TypeError
593 + */
594 + function sodium_crypto_box_publickey(
595 + #[\SensitiveParameter]
596 + $key_pair
597 + ) {
598 + return ParagonIE_Sodium_Compat::crypto_box_publickey($key_pair);
599 + }
600 + }
601 + if (!is_callable('sodium_crypto_box_publickey_from_secretkey')) {
602 + /**
603 + * @see ParagonIE_Sodium_Compat::crypto_box_publickey_from_secretkey()
604 + * @param string $secret_key
605 + * @return string
606 + * @throws SodiumException
607 + * @throws TypeError
608 + */
609 + function sodium_crypto_box_publickey_from_secretkey(
610 + #[\SensitiveParameter]
611 + $secret_key
612 + ) {
613 + return ParagonIE_Sodium_Compat::crypto_box_publickey_from_secretkey($secret_key);
614 + }
615 + }
616 + if (!is_callable('sodium_crypto_box_seal')) {
617 + /**
618 + * @see ParagonIE_Sodium_Compat::crypto_box_seal()
619 + * @param string $message
620 + * @param string $public_key
621 + * @return string
622 + * @throws SodiumException
623 + * @throws TypeError
624 + */
625 + function sodium_crypto_box_seal(
626 + #[\SensitiveParameter]
627 + $message,
628 + $public_key
629 + ) {
630 + return ParagonIE_Sodium_Compat::crypto_box_seal($message, $public_key);
631 + }
632 + }
633 + if (!is_callable('sodium_crypto_box_seal_open')) {
634 + /**
635 + * @see ParagonIE_Sodium_Compat::crypto_box_seal_open()
636 + * @param string $message
637 + * @param string $key_pair
638 + * @return string|bool
639 + * @throws SodiumException
640 + */
641 + function sodium_crypto_box_seal_open(
642 + $message,
643 + #[\SensitiveParameter]
644 + $key_pair
645 + ) {
646 + try {
647 + return ParagonIE_Sodium_Compat::crypto_box_seal_open($message, $key_pair);
648 + } catch (SodiumException $ex) {
649 + if ($ex->getMessage() === 'Argument 2 must be CRYPTO_BOX_KEYPAIRBYTES long.') {
650 + throw $ex;
651 + }
652 + return false;
653 + }
654 + }
655 + }
656 + if (!is_callable('sodium_crypto_box_secretkey')) {
657 + /**
658 + * @see ParagonIE_Sodium_Compat::crypto_box_secretkey()
659 + * @param string $key_pair
660 + * @return string
661 + * @throws SodiumException
662 + * @throws TypeError
663 + */
664 + function sodium_crypto_box_secretkey(
665 + #[\SensitiveParameter]
666 + $key_pair
667 + ) {
668 + return ParagonIE_Sodium_Compat::crypto_box_secretkey($key_pair);
669 + }
670 + }
671 + if (!is_callable('sodium_crypto_box_seed_keypair')) {
672 + /**
673 + * @see ParagonIE_Sodium_Compat::crypto_box_seed_keypair()
674 + * @param string $seed
675 + * @return string
676 + * @throws SodiumException
677 + * @throws TypeError
678 + */
679 + function sodium_crypto_box_seed_keypair(
680 + #[\SensitiveParameter]
681 + $seed
682 + ) {
683 + return ParagonIE_Sodium_Compat::crypto_box_seed_keypair($seed);
684 + }
685 + }
686 + if (!is_callable('sodium_crypto_generichash')) {
687 + /**
688 + * @see ParagonIE_Sodium_Compat::crypto_generichash()
689 + * @param string $message
690 + * @param string|null $key
691 + * @param int $length
692 + * @return string
693 + * @throws SodiumException
694 + * @throws TypeError
695 + */
696 + function sodium_crypto_generichash(
697 + $message,
698 + #[\SensitiveParameter]
699 + $key = null,
700 + $length = 32
701 + ) {
702 + return ParagonIE_Sodium_Compat::crypto_generichash($message, $key, $length);
703 + }
704 + }
705 + if (!is_callable('sodium_crypto_generichash_final')) {
706 + /**
707 + * @see ParagonIE_Sodium_Compat::crypto_generichash_final()
708 + * @param string|null $state
709 + * @param int $outputLength
710 + * @return string
711 + * @throws SodiumException
712 + * @throws TypeError
713 + */
714 + function sodium_crypto_generichash_final(&$state, $outputLength = 32)
715 + {
716 + return ParagonIE_Sodium_Compat::crypto_generichash_final($state, $outputLength);
717 + }
718 + }
719 + if (!is_callable('sodium_crypto_generichash_init')) {
720 + /**
721 + * @see ParagonIE_Sodium_Compat::crypto_generichash_init()
722 + * @param string|null $key
723 + * @param int $length
724 + * @return string
725 + * @throws SodiumException
726 + * @throws TypeError
727 + */
728 + function sodium_crypto_generichash_init(
729 + #[\SensitiveParameter]
730 + $key = null,
731 + $length = 32
732 + ) {
733 + return ParagonIE_Sodium_Compat::crypto_generichash_init($key, $length);
734 + }
735 + }
736 + if (!is_callable('sodium_crypto_generichash_keygen')) {
737 + /**
738 + * @see ParagonIE_Sodium_Compat::crypto_generichash_keygen()
739 + * @return string
740 + * @throws Exception
741 + */
742 + function sodium_crypto_generichash_keygen()
743 + {
744 + return ParagonIE_Sodium_Compat::crypto_generichash_keygen();
745 + }
746 + }
747 + if (!is_callable('sodium_crypto_generichash_update')) {
748 + /**
749 + * @see ParagonIE_Sodium_Compat::crypto_generichash_update()
750 + * @param string|null $state
751 + * @param string $message
752 + * @return void
753 + * @throws SodiumException
754 + * @throws TypeError
755 + */
756 + function sodium_crypto_generichash_update(
757 + #[\SensitiveParameter]
758 + &$state,
759 + $message = ''
760 + ) {
761 + ParagonIE_Sodium_Compat::crypto_generichash_update($state, $message);
762 + }
763 + }
764 + if (!is_callable('sodium_crypto_kdf_keygen')) {
765 + /**
766 + * @see ParagonIE_Sodium_Compat::crypto_kdf_keygen()
767 + * @return string
768 + * @throws Exception
769 + */
770 + function sodium_crypto_kdf_keygen()
771 + {
772 + return ParagonIE_Sodium_Compat::crypto_kdf_keygen();
773 + }
774 + }
775 + if (!is_callable('sodium_crypto_kdf_derive_from_key')) {
776 + /**
777 + * @see ParagonIE_Sodium_Compat::crypto_kdf_derive_from_key()
778 + * @param int $subkey_length
779 + * @param int $subkey_id
780 + * @param string $context
781 + * @param string $key
782 + * @return string
783 + * @throws Exception
784 + */
785 + function sodium_crypto_kdf_derive_from_key(
786 + $subkey_length,
787 + $subkey_id,
788 + $context,
789 + #[\SensitiveParameter]
790 + $key
791 + ) {
792 + return ParagonIE_Sodium_Compat::crypto_kdf_derive_from_key(
793 + $subkey_length,
794 + $subkey_id,
795 + $context,
796 + $key
797 + );
798 + }
799 + }
800 + if (!is_callable('sodium_crypto_kx')) {
801 + /**
802 + * @see ParagonIE_Sodium_Compat::crypto_kx()
803 + * @param string $my_secret
804 + * @param string $their_public
805 + * @param string $client_public
806 + * @param string $server_public
807 + * @return string
808 + * @throws SodiumException
809 + * @throws TypeError
810 + */
811 + function sodium_crypto_kx(
812 + #[\SensitiveParameter]
813 + $my_secret,
814 + $their_public,
815 + $client_public,
816 + $server_public
817 + ) {
818 + return ParagonIE_Sodium_Compat::crypto_kx(
819 + $my_secret,
820 + $their_public,
821 + $client_public,
822 + $server_public
823 + );
824 + }
825 + }
826 + if (!is_callable('sodium_crypto_kx_seed_keypair')) {
827 + /**
828 + * @param string $seed
829 + * @return string
830 + * @throws Exception
831 + */
832 + function sodium_crypto_kx_seed_keypair(
833 + #[\SensitiveParameter]
834 + $seed
835 + ) {
836 + return ParagonIE_Sodium_Compat::crypto_kx_seed_keypair($seed);
837 + }
838 + }
839 + if (!is_callable('sodium_crypto_kx_keypair')) {
840 + /**
841 + * @return string
842 + * @throws Exception
843 + */
844 + function sodium_crypto_kx_keypair()
845 + {
846 + return ParagonIE_Sodium_Compat::crypto_kx_keypair();
847 + }
848 + }
849 + if (!is_callable('sodium_crypto_kx_client_session_keys')) {
850 + /**
851 + * @param string $client_key_pair
852 + * @param string $server_key
853 + * @return array{0: string, 1: string}
854 + * @throws SodiumException
855 + */
856 + function sodium_crypto_kx_client_session_keys(
857 + #[\SensitiveParameter]
858 + $client_key_pair,
859 + $server_key
860 + ) {
861 + return ParagonIE_Sodium_Compat::crypto_kx_client_session_keys($client_key_pair, $server_key);
862 + }
863 + }
864 + if (!is_callable('sodium_crypto_kx_server_session_keys')) {
865 + /**
866 + * @param string $server_key_pair
867 + * @param string $client_key
868 + * @return array{0: string, 1: string}
869 + * @throws SodiumException
870 + */
871 + function sodium_crypto_kx_server_session_keys(
872 + #[\SensitiveParameter]
873 + $server_key_pair,
874 + $client_key
875 + ) {
876 + return ParagonIE_Sodium_Compat::crypto_kx_server_session_keys($server_key_pair, $client_key);
877 + }
878 + }
879 + if (!is_callable('sodium_crypto_kx_secretkey')) {
880 + /**
881 + * @param string $key_pair
882 + * @return string
883 + * @throws Exception
884 + */
885 + function sodium_crypto_kx_secretkey(
886 + #[\SensitiveParameter]
887 + $key_pair
888 + ) {
889 + return ParagonIE_Sodium_Compat::crypto_kx_secretkey($key_pair);
890 + }
891 + }
892 + if (!is_callable('sodium_crypto_kx_publickey')) {
893 + /**
894 + * @param string $key_pair
895 + * @return string
896 + * @throws Exception
897 + */
898 + function sodium_crypto_kx_publickey(
899 + #[\SensitiveParameter]
900 + $key_pair
901 + ) {
902 + return ParagonIE_Sodium_Compat::crypto_kx_publickey($key_pair);
903 + }
904 + }
905 + if (!is_callable('sodium_crypto_pwhash')) {
906 + /**
907 + * @see ParagonIE_Sodium_Compat::crypto_pwhash()
908 + * @param int $length
909 + * @param string $passwd
910 + * @param string $salt
911 + * @param int $opslimit
912 + * @param int $memlimit
913 + * @param int|null $algo
914 + * @return string
915 + * @throws SodiumException
916 + * @throws TypeError
917 + */
918 + function sodium_crypto_pwhash(
919 + $length,
920 + #[\SensitiveParameter]
921 + $passwd,
922 + $salt,
923 + $opslimit,
924 + $memlimit,
925 + $algo = null
926 + ) {
927 + return ParagonIE_Sodium_Compat::crypto_pwhash($length, $passwd, $salt, $opslimit, $memlimit, $algo);
928 + }
929 + }
930 + if (!is_callable('sodium_crypto_pwhash_str')) {
931 + /**
932 + * @see ParagonIE_Sodium_Compat::crypto_pwhash_str()
933 + * @param string $passwd
934 + * @param int $opslimit
935 + * @param int $memlimit
936 + * @return string
937 + * @throws SodiumException
938 + * @throws TypeError
939 + */
940 + function sodium_crypto_pwhash_str(
941 + #[\SensitiveParameter]
942 + $passwd,
943 + $opslimit,
944 + $memlimit
945 + ) {
946 + return ParagonIE_Sodium_Compat::crypto_pwhash_str($passwd, $opslimit, $memlimit);
947 + }
948 + }
949 + if (!is_callable('sodium_crypto_pwhash_str_needs_rehash')) {
950 + /**
951 + * @see ParagonIE_Sodium_Compat::crypto_pwhash_str_needs_rehash()
952 + * @param string $hash
953 + * @param int $opslimit
954 + * @param int $memlimit
955 + * @return bool
956 + *
957 + * @throws SodiumException
958 + */
959 + function sodium_crypto_pwhash_str_needs_rehash(
960 + #[\SensitiveParameter]
961 + $hash,
962 + $opslimit,
963 + $memlimit
964 + ) {
965 + return ParagonIE_Sodium_Compat::crypto_pwhash_str_needs_rehash($hash, $opslimit, $memlimit);
966 + }
967 + }
968 + if (!is_callable('sodium_crypto_pwhash_str_verify')) {
969 + /**
970 + * @see ParagonIE_Sodium_Compat::crypto_pwhash_str_verify()
971 + * @param string $passwd
972 + * @param string $hash
973 + * @return bool
974 + * @throws SodiumException
975 + * @throws TypeError
976 + */
977 + function sodium_crypto_pwhash_str_verify(
978 + #[\SensitiveParameter]
979 + $passwd,
980 + #[\SensitiveParameter]
981 + $hash
982 + ) {
983 + return ParagonIE_Sodium_Compat::crypto_pwhash_str_verify($passwd, $hash);
984 + }
985 + }
986 + if (!is_callable('sodium_crypto_pwhash_scryptsalsa208sha256')) {
987 + /**
988 + * @see ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256()
989 + * @param int $length
990 + * @param string $passwd
991 + * @param string $salt
992 + * @param int $opslimit
993 + * @param int $memlimit
994 + * @return string
995 + * @throws SodiumException
996 + * @throws TypeError
997 + */
998 + function sodium_crypto_pwhash_scryptsalsa208sha256(
999 + $length,
1000 + #[\SensitiveParameter]
1001 + $passwd,
1002 + $salt,
1003 + $opslimit,
1004 + $memlimit
1005 + ) {
1006 + return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256(
1007 + $length,
1008 + $passwd,
1009 + $salt,
1010 + $opslimit,
1011 + $memlimit
1012 + );
1013 + }
1014 + }
1015 + if (!is_callable('sodium_crypto_pwhash_scryptsalsa208sha256_str')) {
1016 + /**
1017 + * @see ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str()
1018 + * @param string $passwd
1019 + * @param int $opslimit
1020 + * @param int $memlimit
1021 + * @return string
1022 + * @throws SodiumException
1023 + * @throws TypeError
1024 + */
1025 + function sodium_crypto_pwhash_scryptsalsa208sha256_str(
1026 + #[\SensitiveParameter]
1027 + $passwd,
1028 + $opslimit,
1029 + $memlimit
1030 + ) {
1031 + return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str($passwd, $opslimit, $memlimit);
1032 + }
1033 + }
1034 + if (!is_callable('sodium_crypto_pwhash_scryptsalsa208sha256_str_verify')) {
1035 + /**
1036 + * @see ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str_verify()
1037 + * @param string $passwd
1038 + * @param string $hash
1039 + * @return bool
1040 + * @throws SodiumException
1041 + * @throws TypeError
1042 + */
1043 + function sodium_crypto_pwhash_scryptsalsa208sha256_str_verify(
1044 + #[\SensitiveParameter]
1045 + $passwd,
1046 + #[\SensitiveParameter]
1047 + $hash
1048 + ) {
1049 + return ParagonIE_Sodium_Compat::crypto_pwhash_scryptsalsa208sha256_str_verify($passwd, $hash);
1050 + }
1051 + }
1052 + if (!is_callable('sodium_crypto_scalarmult')) {
1053 + /**
1054 + * @see ParagonIE_Sodium_Compat::crypto_scalarmult()
1055 + * @param string $n
1056 + * @param string $p
1057 + * @return string
1058 + * @throws SodiumException
1059 + * @throws TypeError
1060 + */
1061 + function sodium_crypto_scalarmult(
1062 + #[\SensitiveParameter]
1063 + $n,
1064 + $p
1065 + ) {
1066 + return ParagonIE_Sodium_Compat::crypto_scalarmult($n, $p);
1067 + }
1068 + }
1069 + if (!is_callable('sodium_crypto_scalarmult_base')) {
1070 + /**
1071 + * @see ParagonIE_Sodium_Compat::crypto_scalarmult_base()
1072 + * @param string $n
1073 + * @return string
1074 + * @throws SodiumException
1075 + * @throws TypeError
1076 + */
1077 + function sodium_crypto_scalarmult_base(
1078 + #[\SensitiveParameter]
1079 + $n
1080 + ) {
1081 + return ParagonIE_Sodium_Compat::crypto_scalarmult_base($n);
1082 + }
1083 + }
1084 + if (!is_callable('sodium_crypto_secretbox')) {
1085 + /**
1086 + * @see ParagonIE_Sodium_Compat::crypto_secretbox()
1087 + * @param string $message
1088 + * @param string $nonce
1089 + * @param string $key
1090 + * @return string
1091 + * @throws SodiumException
1092 + * @throws TypeError
1093 + */
1094 + function sodium_crypto_secretbox(
1095 + #[\SensitiveParameter]
1096 + $message,
1097 + $nonce,
1098 + #[\SensitiveParameter]
1099 + $key
1100 + ) {
1101 + return ParagonIE_Sodium_Compat::crypto_secretbox($message, $nonce, $key);
1102 + }
1103 + }
1104 + if (!is_callable('sodium_crypto_secretbox_keygen')) {
1105 + /**
1106 + * @see ParagonIE_Sodium_Compat::crypto_secretbox_keygen()
1107 + * @return string
1108 + * @throws Exception
1109 + */
1110 + function sodium_crypto_secretbox_keygen()
1111 + {
1112 + return ParagonIE_Sodium_Compat::crypto_secretbox_keygen();
1113 + }
1114 + }
1115 + if (!is_callable('sodium_crypto_secretbox_open')) {
1116 + /**
1117 + * @see ParagonIE_Sodium_Compat::crypto_secretbox_open()
1118 + * @param string $ciphertext
1119 + * @param string $nonce
1120 + * @param string $key
1121 + * @return string|bool
1122 + */
1123 + function sodium_crypto_secretbox_open(
1124 + $ciphertext,
1125 + $nonce,
1126 + #[\SensitiveParameter]
1127 + $key
1128 + ) {
1129 + try {
1130 + return ParagonIE_Sodium_Compat::crypto_secretbox_open($ciphertext, $nonce, $key);
1131 + } catch (Error $ex) {
1132 + return false;
1133 + } catch (Exception $ex) {
1134 + return false;
1135 + }
1136 + }
1137 + }
1138 + if (!is_callable('sodium_crypto_secretstream_xchacha20poly1305_init_push')) {
1139 + /**
1140 + * @param string $key
1141 + * @return array<int, string>
1142 + * @throws SodiumException
1143 + */
1144 + function sodium_crypto_secretstream_xchacha20poly1305_init_push(
1145 + #[\SensitiveParameter]
1146 + $key
1147 + ) {
1148 + return ParagonIE_Sodium_Compat::crypto_secretstream_xchacha20poly1305_init_push($key);
1149 + }
1150 + }
1151 + if (!is_callable('sodium_crypto_secretstream_xchacha20poly1305_push')) {
1152 + /**
1153 + * @param string $state
1154 + * @param string $message
1155 + * @param string $additional_data
1156 + * @param int $tag
1157 + * @return string
1158 + * @throws SodiumException
1159 + */
1160 + function sodium_crypto_secretstream_xchacha20poly1305_push(
1161 + #[\SensitiveParameter]
1162 + &$state,
1163 + #[\SensitiveParameter]
1164 + $message,
1165 + $additional_data = '',
1166 + $tag = 0
1167 + ) {
1168 + return ParagonIE_Sodium_Compat::crypto_secretstream_xchacha20poly1305_push(
1169 + $state,
1170 + $message,
1171 + $additional_data,
1172 + $tag
1173 + );
1174 + }
1175 + }
1176 + if (!is_callable('sodium_crypto_secretstream_xchacha20poly1305_init_pull')) {
1177 + /**
1178 + * @param string $header
1179 + * @param string $key
1180 + * @return string
1181 + * @throws Exception
1182 + */
1183 + function sodium_crypto_secretstream_xchacha20poly1305_init_pull(
1184 + $header,
1185 + #[\SensitiveParameter]
1186 + $key
1187 + ) {
1188 + return ParagonIE_Sodium_Compat::crypto_secretstream_xchacha20poly1305_init_pull($header, $key);
1189 + }
1190 + }
1191 + if (!is_callable('sodium_crypto_secretstream_xchacha20poly1305_pull')) {
1192 + /**
1193 + * @param string $state
1194 + * @param string $ciphertext
1195 + * @param string $additional_data
1196 + * @return bool|array{0: string, 1: int}
1197 + * @throws SodiumException
1198 + */
1199 + function sodium_crypto_secretstream_xchacha20poly1305_pull(
1200 + #[\SensitiveParameter]
1201 + &$state,
1202 + $ciphertext,
1203 + $additional_data = ''
1204 + ) {
1205 + return ParagonIE_Sodium_Compat::crypto_secretstream_xchacha20poly1305_pull(
1206 + $state,
1207 + $ciphertext,
1208 + $additional_data
1209 + );
1210 + }
1211 + }
1212 + if (!is_callable('sodium_crypto_secretstream_xchacha20poly1305_rekey')) {
1213 + /**
1214 + * @param string $state
1215 + * @return void
1216 + * @throws SodiumException
1217 + */
1218 + function sodium_crypto_secretstream_xchacha20poly1305_rekey(
1219 + #[\SensitiveParameter]
1220 + &$state
1221 + ) {
1222 + ParagonIE_Sodium_Compat::crypto_secretstream_xchacha20poly1305_rekey($state);
1223 + }
1224 + }
1225 + if (!is_callable('sodium_crypto_secretstream_xchacha20poly1305_keygen')) {
1226 + /**
1227 + * @return string
1228 + * @throws Exception
1229 + */
1230 + function sodium_crypto_secretstream_xchacha20poly1305_keygen()
1231 + {
1232 + return ParagonIE_Sodium_Compat::crypto_secretstream_xchacha20poly1305_keygen();
1233 + }
1234 + }
1235 + if (!is_callable('sodium_crypto_shorthash')) {
1236 + /**
1237 + * @see ParagonIE_Sodium_Compat::crypto_shorthash()
1238 + * @param string $message
1239 + * @param string $key
1240 + * @return string
1241 + * @throws SodiumException
1242 + * @throws TypeError
1243 + */
1244 + function sodium_crypto_shorthash(
1245 + $message,
1246 + #[\SensitiveParameter]
1247 + $key = ''
1248 + ) {
1249 + return ParagonIE_Sodium_Compat::crypto_shorthash($message, $key);
1250 + }
1251 + }
1252 + if (!is_callable('sodium_crypto_shorthash_keygen')) {
1253 + /**
1254 + * @see ParagonIE_Sodium_Compat::crypto_shorthash_keygen()
1255 + * @return string
1256 + * @throws Exception
1257 + */
1258 + function sodium_crypto_shorthash_keygen()
1259 + {
1260 + return ParagonIE_Sodium_Compat::crypto_shorthash_keygen();
1261 + }
1262 + }
1263 + if (!is_callable('sodium_crypto_sign')) {
1264 + /**
1265 + * @see ParagonIE_Sodium_Compat::crypto_sign()
1266 + * @param string $message
1267 + * @param string $secret_key
1268 + * @return string
1269 + * @throws SodiumException
1270 + * @throws TypeError
1271 + */
1272 + function sodium_crypto_sign(
1273 + $message,
1274 + #[\SensitiveParameter]
1275 + $secret_key
1276 + ) {
1277 + return ParagonIE_Sodium_Compat::crypto_sign($message, $secret_key);
1278 + }
1279 + }
1280 + if (!is_callable('sodium_crypto_sign_detached')) {
1281 + /**
1282 + * @see ParagonIE_Sodium_Compat::crypto_sign_detached()
1283 + * @param string $message
1284 + * @param string $secret_key
1285 + * @return string
1286 + * @throws SodiumException
1287 + * @throws TypeError
1288 + */
1289 + function sodium_crypto_sign_detached(
1290 + $message,
1291 + #[\SensitiveParameter]
1292 + $secret_key
1293 + ) {
1294 + return ParagonIE_Sodium_Compat::crypto_sign_detached($message, $secret_key);
1295 + }
1296 + }
1297 + if (!is_callable('sodium_crypto_sign_keypair_from_secretkey_and_publickey')) {
1298 + /**
1299 + * @see ParagonIE_Sodium_Compat::crypto_sign_keypair_from_secretkey_and_publickey()
1300 + * @param string $secret_key
1301 + * @param string $public_key
1302 + * @return string
1303 + * @throws SodiumException
1304 + * @throws TypeError
1305 + */
1306 + function sodium_crypto_sign_keypair_from_secretkey_and_publickey(
1307 + #[\SensitiveParameter]
1308 + $secret_key,
1309 + $public_key
1310 + ) {
1311 + return ParagonIE_Sodium_Compat::crypto_sign_keypair_from_secretkey_and_publickey($secret_key, $public_key);
1312 + }
1313 + }
1314 + if (!is_callable('sodium_crypto_sign_keypair')) {
1315 + /**
1316 + * @see ParagonIE_Sodium_Compat::crypto_sign_keypair()
1317 + * @return string
1318 + * @throws SodiumException
1319 + * @throws TypeError
1320 + */
1321 + function sodium_crypto_sign_keypair()
1322 + {
1323 + return ParagonIE_Sodium_Compat::crypto_sign_keypair();
1324 + }
1325 + }
1326 + if (!is_callable('sodium_crypto_sign_open')) {
1327 + /**
1328 + * @see ParagonIE_Sodium_Compat::crypto_sign_open()
1329 + * @param string $signedMessage
1330 + * @param string $public_key
1331 + * @return string|bool
1332 + */
1333 + function sodium_crypto_sign_open($signedMessage, $public_key)
1334 + {
1335 + try {
1336 + return ParagonIE_Sodium_Compat::crypto_sign_open($signedMessage, $public_key);
1337 + } catch (Error $ex) {
1338 + return false;
1339 + } catch (Exception $ex) {
1340 + return false;
1341 + }
1342 + }
1343 + }
1344 + if (!is_callable('sodium_crypto_sign_publickey')) {
1345 + /**
1346 + * @see ParagonIE_Sodium_Compat::crypto_sign_publickey()
1347 + * @param string $key_pair
1348 + * @return string
1349 + * @throws SodiumException
1350 + * @throws TypeError
1351 + */
1352 + function sodium_crypto_sign_publickey(
1353 + #[\SensitiveParameter]
1354 + $key_pair
1355 + ) {
1356 + return ParagonIE_Sodium_Compat::crypto_sign_publickey($key_pair);
1357 + }
1358 + }
1359 + if (!is_callable('sodium_crypto_sign_publickey_from_secretkey')) {
1360 + /**
1361 + * @see ParagonIE_Sodium_Compat::crypto_sign_publickey_from_secretkey()
1362 + * @param string $secret_key
1363 + * @return string
1364 + * @throws SodiumException
1365 + * @throws TypeError
1366 + */
1367 + function sodium_crypto_sign_publickey_from_secretkey(
1368 + #[\SensitiveParameter]
1369 + $secret_key
1370 + ) {
1371 + return ParagonIE_Sodium_Compat::crypto_sign_publickey_from_secretkey($secret_key);
1372 + }
1373 + }
1374 + if (!is_callable('sodium_crypto_sign_secretkey')) {
1375 + /**
1376 + * @see ParagonIE_Sodium_Compat::crypto_sign_secretkey()
1377 + * @param string $key_pair
1378 + * @return string
1379 + * @throws SodiumException
1380 + * @throws TypeError
1381 + */
1382 + function sodium_crypto_sign_secretkey(
1383 + #[\SensitiveParameter]
1384 + $key_pair
1385 + ) {
1386 + return ParagonIE_Sodium_Compat::crypto_sign_secretkey($key_pair);
1387 + }
1388 + }
1389 + if (!is_callable('sodium_crypto_sign_seed_keypair')) {
1390 + /**
1391 + * @see ParagonIE_Sodium_Compat::crypto_sign_seed_keypair()
1392 + * @param string $seed
1393 + * @return string
1394 + * @throws SodiumException
1395 + * @throws TypeError
1396 + */
1397 + function sodium_crypto_sign_seed_keypair(
1398 + #[\SensitiveParameter]
1399 + $seed
1400 + ) {
1401 + return ParagonIE_Sodium_Compat::crypto_sign_seed_keypair($seed);
1402 + }
1403 + }
1404 + if (!is_callable('sodium_crypto_sign_verify_detached')) {
1405 + /**
1406 + * @see ParagonIE_Sodium_Compat::crypto_sign_verify_detached()
1407 + * @param string $signature
1408 + * @param string $message
1409 + * @param string $public_key
1410 + * @return bool
1411 + * @throws SodiumException
1412 + * @throws TypeError
1413 + */
1414 + function sodium_crypto_sign_verify_detached($signature, $message, $public_key)
1415 + {
1416 + return ParagonIE_Sodium_Compat::crypto_sign_verify_detached($signature, $message, $public_key);
1417 + }
1418 + }
1419 + if (!is_callable('sodium_crypto_sign_ed25519_pk_to_curve25519')) {
1420 + /**
1421 + * @see ParagonIE_Sodium_Compat::crypto_sign_ed25519_pk_to_curve25519()
1422 + * @param string $public_key
1423 + * @return string
1424 + * @throws SodiumException
1425 + * @throws TypeError
1426 + */
1427 + function sodium_crypto_sign_ed25519_pk_to_curve25519($public_key)
1428 + {
1429 + return ParagonIE_Sodium_Compat::crypto_sign_ed25519_pk_to_curve25519($public_key);
1430 + }
1431 + }
1432 + if (!is_callable('sodium_crypto_sign_ed25519_sk_to_curve25519')) {
1433 + /**
1434 + * @see ParagonIE_Sodium_Compat::crypto_sign_ed25519_sk_to_curve25519()
1435 + * @param string $secret_key
1436 + * @return string
1437 + * @throws SodiumException
1438 + * @throws TypeError
1439 + */
1440 + function sodium_crypto_sign_ed25519_sk_to_curve25519(
1441 + #[\SensitiveParameter]
1442 + $secret_key
1443 + ) {
1444 + return ParagonIE_Sodium_Compat::crypto_sign_ed25519_sk_to_curve25519($secret_key);
1445 + }
1446 + }
1447 + if (!is_callable('sodium_crypto_stream')) {
1448 + /**
1449 + * @see ParagonIE_Sodium_Compat::crypto_stream()
1450 + * @param int $length
1451 + * @param string $nonce
1452 + * @param string $key
1453 + * @return string
1454 + * @throws SodiumException
1455 + * @throws TypeError
1456 + */
1457 + function sodium_crypto_stream(
1458 + $length,
1459 + $nonce,
1460 + #[\SensitiveParameter]
1461 + $key
1462 + ) {
1463 + return ParagonIE_Sodium_Compat::crypto_stream($length, $nonce, $key);
1464 + }
1465 + }
1466 + if (!is_callable('sodium_crypto_stream_keygen')) {
1467 + /**
1468 + * @see ParagonIE_Sodium_Compat::crypto_stream_keygen()
1469 + * @return string
1470 + * @throws Exception
1471 + */
1472 + function sodium_crypto_stream_keygen()
1473 + {
1474 + return ParagonIE_Sodium_Compat::crypto_stream_keygen();
1475 + }
1476 + }
1477 + if (!is_callable('sodium_crypto_stream_xor')) {
1478 + /**
1479 + * @see ParagonIE_Sodium_Compat::crypto_stream_xor()
1480 + * @param string $message
1481 + * @param string $nonce
1482 + * @param string $key
1483 + * @return string
1484 + * @throws SodiumException
1485 + * @throws TypeError
1486 + */
1487 + function sodium_crypto_stream_xor(
1488 + #[\SensitiveParameter]
1489 + $message,
1490 + $nonce,
1491 + #[\SensitiveParameter]
1492 + $key
1493 + ) {
1494 + return ParagonIE_Sodium_Compat::crypto_stream_xor($message, $nonce, $key);
1495 + }
1496 + }
1497 + require_once dirname(__FILE__) . '/stream-xchacha20.php';
1498 + if (!is_callable('sodium_hex2bin')) {
1499 + /**
1500 + * @see ParagonIE_Sodium_Compat::hex2bin()
1501 + * @param string $string
1502 + * @param string $ignore
1503 + * @return string
1504 + * @throws SodiumException
1505 + * @throws TypeError
1506 + */
1507 + function sodium_hex2bin(
1508 + #[\SensitiveParameter]
1509 + $string,
1510 + $ignore = ''
1511 + ) {
1512 + return ParagonIE_Sodium_Compat::hex2bin($string, $ignore);
1513 + }
1514 + }
1515 + if (!is_callable('sodium_increment')) {
1516 + /**
1517 + * @see ParagonIE_Sodium_Compat::increment()
1518 + * @param string $string
1519 + * @return void
1520 + * @throws SodiumException
1521 + * @throws TypeError
1522 + */
1523 + function sodium_increment(
1524 + #[\SensitiveParameter]
1525 + &$string
1526 + ) {
1527 + ParagonIE_Sodium_Compat::increment($string);
1528 + }
1529 + }
1530 + if (!is_callable('sodium_library_version_major')) {
1531 + /**
1532 + * @see ParagonIE_Sodium_Compat::library_version_major()
1533 + * @return int
1534 + */
1535 + function sodium_library_version_major()
1536 + {
1537 + return ParagonIE_Sodium_Compat::library_version_major();
1538 + }
1539 + }
1540 + if (!is_callable('sodium_library_version_minor')) {
1541 + /**
1542 + * @see ParagonIE_Sodium_Compat::library_version_minor()
1543 + * @return int
1544 + */
1545 + function sodium_library_version_minor()
1546 + {
1547 + return ParagonIE_Sodium_Compat::library_version_minor();
1548 + }
1549 + }
1550 + if (!is_callable('sodium_version_string')) {
1551 + /**
1552 + * @see ParagonIE_Sodium_Compat::version_string()
1553 + * @return string
1554 + */
1555 + function sodium_version_string()
1556 + {
1557 + return ParagonIE_Sodium_Compat::version_string();
1558 + }
1559 + }
1560 + if (!is_callable('sodium_memcmp')) {
1561 + /**
1562 + * @see ParagonIE_Sodium_Compat::memcmp()
1563 + * @param string $string1
1564 + * @param string $string2
1565 + * @return int
1566 + * @throws SodiumException
1567 + * @throws TypeError
1568 + */
1569 + function sodium_memcmp(
1570 + #[\SensitiveParameter]
1571 + $string1,
1572 + #[\SensitiveParameter]
1573 + $string2
1574 + ) {
1575 + return ParagonIE_Sodium_Compat::memcmp($string1, $string2);
1576 + }
1577 + }
1578 + if (!is_callable('sodium_memzero')) {
1579 + /**
1580 + * @see ParagonIE_Sodium_Compat::memzero()
1581 + * @param string $string
1582 + * @return void
1583 + * @throws SodiumException
1584 + * @throws TypeError
1585 + *
1586 + * @psalm-suppress ReferenceConstraintViolation
1587 + */
1588 + function sodium_memzero(
1589 + #[\SensitiveParameter]
1590 + &$string
1591 + ) {
1592 + ParagonIE_Sodium_Compat::memzero($string);
1593 + }
1594 + }
1595 + if (!is_callable('sodium_pad')) {
1596 + /**
1597 + * @see ParagonIE_Sodium_Compat::pad()
1598 + * @param string $unpadded
1599 + * @param int $block_size
1600 + * @return string
1601 + * @throws SodiumException
1602 + * @throws TypeError
1603 + */
1604 + function sodium_pad(
1605 + #[\SensitiveParameter]
1606 + $unpadded,
1607 + $block_size
1608 + ) {
1609 + return ParagonIE_Sodium_Compat::pad($unpadded, $block_size, true);
1610 + }
1611 + }
1612 + if (!is_callable('sodium_unpad')) {
1613 + /**
1614 + * @see ParagonIE_Sodium_Compat::pad()
1615 + * @param string $padded
1616 + * @param int $block_size
1617 + * @return string
1618 + * @throws SodiumException
1619 + * @throws TypeError
1620 + */
1621 + function sodium_unpad(
1622 + #[\SensitiveParameter]
1623 + $padded,
1624 + $block_size
1625 + ) {
1626 + return ParagonIE_Sodium_Compat::unpad($padded, $block_size, true);
1627 + }
1628 + }
1629 + if (!is_callable('sodium_randombytes_buf')) {
1630 + /**
1631 + * @see ParagonIE_Sodium_Compat::randombytes_buf()
1632 + * @param int $amount
1633 + * @return string
1634 + * @throws Exception
1635 + */
1636 + function sodium_randombytes_buf($amount)
1637 + {
1638 + return ParagonIE_Sodium_Compat::randombytes_buf($amount);
1639 + }
1640 + }
1641 +
1642 + if (!is_callable('sodium_randombytes_uniform')) {
1643 + /**
1644 + * @see ParagonIE_Sodium_Compat::randombytes_uniform()
1645 + * @param int $upperLimit
1646 + * @return int
1647 + * @throws Exception
1648 + */
1649 + function sodium_randombytes_uniform($upperLimit)
1650 + {
1651 + return ParagonIE_Sodium_Compat::randombytes_uniform($upperLimit);
1652 + }
1653 + }
1654 +
1655 + if (!is_callable('sodium_randombytes_random16')) {
1656 + /**
1657 + * @see ParagonIE_Sodium_Compat::randombytes_random16()
1658 + * @return int
1659 + * @throws Exception
1660 + */
1661 + function sodium_randombytes_random16()
1662 + {
1663 + return ParagonIE_Sodium_Compat::randombytes_random16();
1664 + }
1665 + }
1666 +