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