Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-inclu.../sodium_c.../src
File: Compat.php
}
[500] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($ciphertext) < self::CRYPTO_AEAD_CHACHA20POLY1305_ABYTES) {
[501] Fix | Delete
throw new SodiumException('Message must be at least CRYPTO_AEAD_CHACHA20POLY1305_ABYTES long');
[502] Fix | Delete
}
[503] Fix | Delete
[504] Fix | Delete
if (self::useNewSodiumAPI()) {
[505] Fix | Delete
/**
[506] Fix | Delete
* @psalm-suppress InvalidReturnStatement
[507] Fix | Delete
* @psalm-suppress FalsableReturnStatement
[508] Fix | Delete
*/
[509] Fix | Delete
return sodium_crypto_aead_chacha20poly1305_decrypt(
[510] Fix | Delete
$ciphertext,
[511] Fix | Delete
$assocData,
[512] Fix | Delete
$nonce,
[513] Fix | Delete
$key
[514] Fix | Delete
);
[515] Fix | Delete
}
[516] Fix | Delete
if (self::use_fallback('crypto_aead_chacha20poly1305_decrypt')) {
[517] Fix | Delete
return call_user_func(
[518] Fix | Delete
'\\Sodium\\crypto_aead_chacha20poly1305_decrypt',
[519] Fix | Delete
$ciphertext,
[520] Fix | Delete
$assocData,
[521] Fix | Delete
$nonce,
[522] Fix | Delete
$key
[523] Fix | Delete
);
[524] Fix | Delete
}
[525] Fix | Delete
if (PHP_INT_SIZE === 4) {
[526] Fix | Delete
return ParagonIE_Sodium_Crypto32::aead_chacha20poly1305_decrypt(
[527] Fix | Delete
$ciphertext,
[528] Fix | Delete
$assocData,
[529] Fix | Delete
$nonce,
[530] Fix | Delete
$key
[531] Fix | Delete
);
[532] Fix | Delete
}
[533] Fix | Delete
return ParagonIE_Sodium_Crypto::aead_chacha20poly1305_decrypt(
[534] Fix | Delete
$ciphertext,
[535] Fix | Delete
$assocData,
[536] Fix | Delete
$nonce,
[537] Fix | Delete
$key
[538] Fix | Delete
);
[539] Fix | Delete
}
[540] Fix | Delete
[541] Fix | Delete
/**
[542] Fix | Delete
* Authenticated Encryption with Associated Data
[543] Fix | Delete
*
[544] Fix | Delete
* Algorithm:
[545] Fix | Delete
* ChaCha20-Poly1305
[546] Fix | Delete
*
[547] Fix | Delete
* This mode uses a 64-bit random nonce with a 64-bit counter.
[548] Fix | Delete
* IETF mode uses a 96-bit random nonce with a 32-bit counter.
[549] Fix | Delete
*
[550] Fix | Delete
* @param string $plaintext Message to be encrypted
[551] Fix | Delete
* @param string $assocData Authenticated Associated Data (unencrypted)
[552] Fix | Delete
* @param string $nonce Number to be used only Once; must be 8 bytes
[553] Fix | Delete
* @param string $key Encryption key
[554] Fix | Delete
*
[555] Fix | Delete
* @return string Ciphertext with a 16-byte Poly1305 message
[556] Fix | Delete
* authentication code appended
[557] Fix | Delete
* @throws SodiumException
[558] Fix | Delete
* @throws TypeError
[559] Fix | Delete
* @psalm-suppress MixedArgument
[560] Fix | Delete
*/
[561] Fix | Delete
public static function crypto_aead_chacha20poly1305_encrypt(
[562] Fix | Delete
$plaintext = '',
[563] Fix | Delete
$assocData = '',
[564] Fix | Delete
$nonce = '',
[565] Fix | Delete
$key = ''
[566] Fix | Delete
) {
[567] Fix | Delete
/* Type checks: */
[568] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($plaintext, 'string', 1);
[569] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($assocData, 'string', 2);
[570] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($nonce, 'string', 3);
[571] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($key, 'string', 4);
[572] Fix | Delete
[573] Fix | Delete
/* Input validation: */
[574] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($nonce) !== self::CRYPTO_AEAD_CHACHA20POLY1305_NPUBBYTES) {
[575] Fix | Delete
throw new SodiumException('Nonce must be CRYPTO_AEAD_CHACHA20POLY1305_NPUBBYTES long');
[576] Fix | Delete
}
[577] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($key) !== self::CRYPTO_AEAD_CHACHA20POLY1305_KEYBYTES) {
[578] Fix | Delete
throw new SodiumException('Key must be CRYPTO_AEAD_CHACHA20POLY1305_KEYBYTES long');
[579] Fix | Delete
}
[580] Fix | Delete
[581] Fix | Delete
if (self::useNewSodiumAPI()) {
[582] Fix | Delete
return (string) sodium_crypto_aead_chacha20poly1305_encrypt(
[583] Fix | Delete
$plaintext,
[584] Fix | Delete
$assocData,
[585] Fix | Delete
$nonce,
[586] Fix | Delete
$key
[587] Fix | Delete
);
[588] Fix | Delete
}
[589] Fix | Delete
if (self::use_fallback('crypto_aead_chacha20poly1305_encrypt')) {
[590] Fix | Delete
return (string) call_user_func(
[591] Fix | Delete
'\\Sodium\\crypto_aead_chacha20poly1305_encrypt',
[592] Fix | Delete
$plaintext,
[593] Fix | Delete
$assocData,
[594] Fix | Delete
$nonce,
[595] Fix | Delete
$key
[596] Fix | Delete
);
[597] Fix | Delete
}
[598] Fix | Delete
if (PHP_INT_SIZE === 4) {
[599] Fix | Delete
return ParagonIE_Sodium_Crypto32::aead_chacha20poly1305_encrypt(
[600] Fix | Delete
$plaintext,
[601] Fix | Delete
$assocData,
[602] Fix | Delete
$nonce,
[603] Fix | Delete
$key
[604] Fix | Delete
);
[605] Fix | Delete
}
[606] Fix | Delete
return ParagonIE_Sodium_Crypto::aead_chacha20poly1305_encrypt(
[607] Fix | Delete
$plaintext,
[608] Fix | Delete
$assocData,
[609] Fix | Delete
$nonce,
[610] Fix | Delete
$key
[611] Fix | Delete
);
[612] Fix | Delete
}
[613] Fix | Delete
[614] Fix | Delete
/**
[615] Fix | Delete
* Authenticated Encryption with Associated Data: Decryption
[616] Fix | Delete
*
[617] Fix | Delete
* Algorithm:
[618] Fix | Delete
* ChaCha20-Poly1305
[619] Fix | Delete
*
[620] Fix | Delete
* IETF mode uses a 96-bit random nonce with a 32-bit counter.
[621] Fix | Delete
* Regular mode uses a 64-bit random nonce with a 64-bit counter.
[622] Fix | Delete
*
[623] Fix | Delete
* @param string $ciphertext Encrypted message (with Poly1305 MAC appended)
[624] Fix | Delete
* @param string $assocData Authenticated Associated Data (unencrypted)
[625] Fix | Delete
* @param string $nonce Number to be used only Once; must be 12 bytes
[626] Fix | Delete
* @param string $key Encryption key
[627] Fix | Delete
*
[628] Fix | Delete
* @return string The original plaintext message
[629] Fix | Delete
* @throws SodiumException
[630] Fix | Delete
* @throws TypeError
[631] Fix | Delete
* @psalm-suppress MixedArgument
[632] Fix | Delete
* @psalm-suppress MixedInferredReturnType
[633] Fix | Delete
* @psalm-suppress MixedReturnStatement
[634] Fix | Delete
*/
[635] Fix | Delete
public static function crypto_aead_chacha20poly1305_ietf_decrypt(
[636] Fix | Delete
$ciphertext = '',
[637] Fix | Delete
$assocData = '',
[638] Fix | Delete
$nonce = '',
[639] Fix | Delete
$key = ''
[640] Fix | Delete
) {
[641] Fix | Delete
/* Type checks: */
[642] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($ciphertext, 'string', 1);
[643] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($assocData, 'string', 2);
[644] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($nonce, 'string', 3);
[645] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($key, 'string', 4);
[646] Fix | Delete
[647] Fix | Delete
/* Input validation: */
[648] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($nonce) !== self::CRYPTO_AEAD_CHACHA20POLY1305_IETF_NPUBBYTES) {
[649] Fix | Delete
throw new SodiumException('Nonce must be CRYPTO_AEAD_CHACHA20POLY1305_IETF_NPUBBYTES long');
[650] Fix | Delete
}
[651] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($key) !== self::CRYPTO_AEAD_CHACHA20POLY1305_KEYBYTES) {
[652] Fix | Delete
throw new SodiumException('Key must be CRYPTO_AEAD_CHACHA20POLY1305_KEYBYTES long');
[653] Fix | Delete
}
[654] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($ciphertext) < self::CRYPTO_AEAD_CHACHA20POLY1305_ABYTES) {
[655] Fix | Delete
throw new SodiumException('Message must be at least CRYPTO_AEAD_CHACHA20POLY1305_ABYTES long');
[656] Fix | Delete
}
[657] Fix | Delete
[658] Fix | Delete
if (self::useNewSodiumAPI()) {
[659] Fix | Delete
/**
[660] Fix | Delete
* @psalm-suppress InvalidReturnStatement
[661] Fix | Delete
* @psalm-suppress FalsableReturnStatement
[662] Fix | Delete
*/
[663] Fix | Delete
return sodium_crypto_aead_chacha20poly1305_ietf_decrypt(
[664] Fix | Delete
$ciphertext,
[665] Fix | Delete
$assocData,
[666] Fix | Delete
$nonce,
[667] Fix | Delete
$key
[668] Fix | Delete
);
[669] Fix | Delete
}
[670] Fix | Delete
if (self::use_fallback('crypto_aead_chacha20poly1305_ietf_decrypt')) {
[671] Fix | Delete
return call_user_func(
[672] Fix | Delete
'\\Sodium\\crypto_aead_chacha20poly1305_ietf_decrypt',
[673] Fix | Delete
$ciphertext,
[674] Fix | Delete
$assocData,
[675] Fix | Delete
$nonce,
[676] Fix | Delete
$key
[677] Fix | Delete
);
[678] Fix | Delete
}
[679] Fix | Delete
if (PHP_INT_SIZE === 4) {
[680] Fix | Delete
return ParagonIE_Sodium_Crypto32::aead_chacha20poly1305_ietf_decrypt(
[681] Fix | Delete
$ciphertext,
[682] Fix | Delete
$assocData,
[683] Fix | Delete
$nonce,
[684] Fix | Delete
$key
[685] Fix | Delete
);
[686] Fix | Delete
}
[687] Fix | Delete
return ParagonIE_Sodium_Crypto::aead_chacha20poly1305_ietf_decrypt(
[688] Fix | Delete
$ciphertext,
[689] Fix | Delete
$assocData,
[690] Fix | Delete
$nonce,
[691] Fix | Delete
$key
[692] Fix | Delete
);
[693] Fix | Delete
}
[694] Fix | Delete
[695] Fix | Delete
/**
[696] Fix | Delete
* Return a secure random key for use with the ChaCha20-Poly1305
[697] Fix | Delete
* symmetric AEAD interface.
[698] Fix | Delete
*
[699] Fix | Delete
* @return string
[700] Fix | Delete
* @throws Exception
[701] Fix | Delete
* @throws Error
[702] Fix | Delete
*/
[703] Fix | Delete
public static function crypto_aead_chacha20poly1305_keygen()
[704] Fix | Delete
{
[705] Fix | Delete
return random_bytes(self::CRYPTO_AEAD_CHACHA20POLY1305_KEYBYTES);
[706] Fix | Delete
}
[707] Fix | Delete
[708] Fix | Delete
/**
[709] Fix | Delete
* Authenticated Encryption with Associated Data
[710] Fix | Delete
*
[711] Fix | Delete
* Algorithm:
[712] Fix | Delete
* ChaCha20-Poly1305
[713] Fix | Delete
*
[714] Fix | Delete
* IETF mode uses a 96-bit random nonce with a 32-bit counter.
[715] Fix | Delete
* Regular mode uses a 64-bit random nonce with a 64-bit counter.
[716] Fix | Delete
*
[717] Fix | Delete
* @param string $plaintext Message to be encrypted
[718] Fix | Delete
* @param string $assocData Authenticated Associated Data (unencrypted)
[719] Fix | Delete
* @param string $nonce Number to be used only Once; must be 8 bytes
[720] Fix | Delete
* @param string $key Encryption key
[721] Fix | Delete
*
[722] Fix | Delete
* @return string Ciphertext with a 16-byte Poly1305 message
[723] Fix | Delete
* authentication code appended
[724] Fix | Delete
* @throws SodiumException
[725] Fix | Delete
* @throws TypeError
[726] Fix | Delete
* @psalm-suppress MixedArgument
[727] Fix | Delete
*/
[728] Fix | Delete
public static function crypto_aead_chacha20poly1305_ietf_encrypt(
[729] Fix | Delete
$plaintext = '',
[730] Fix | Delete
$assocData = '',
[731] Fix | Delete
$nonce = '',
[732] Fix | Delete
$key = ''
[733] Fix | Delete
) {
[734] Fix | Delete
/* Type checks: */
[735] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($plaintext, 'string', 1);
[736] Fix | Delete
if (!is_null($assocData)) {
[737] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($assocData, 'string', 2);
[738] Fix | Delete
}
[739] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($nonce, 'string', 3);
[740] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($key, 'string', 4);
[741] Fix | Delete
[742] Fix | Delete
/* Input validation: */
[743] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($nonce) !== self::CRYPTO_AEAD_CHACHA20POLY1305_IETF_NPUBBYTES) {
[744] Fix | Delete
throw new SodiumException('Nonce must be CRYPTO_AEAD_CHACHA20POLY1305_IETF_NPUBBYTES long');
[745] Fix | Delete
}
[746] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($key) !== self::CRYPTO_AEAD_CHACHA20POLY1305_KEYBYTES) {
[747] Fix | Delete
throw new SodiumException('Key must be CRYPTO_AEAD_CHACHA20POLY1305_KEYBYTES long');
[748] Fix | Delete
}
[749] Fix | Delete
[750] Fix | Delete
if (self::useNewSodiumAPI()) {
[751] Fix | Delete
return (string) sodium_crypto_aead_chacha20poly1305_ietf_encrypt(
[752] Fix | Delete
$plaintext,
[753] Fix | Delete
$assocData,
[754] Fix | Delete
$nonce,
[755] Fix | Delete
$key
[756] Fix | Delete
);
[757] Fix | Delete
}
[758] Fix | Delete
if (self::use_fallback('crypto_aead_chacha20poly1305_ietf_encrypt')) {
[759] Fix | Delete
return (string) call_user_func(
[760] Fix | Delete
'\\Sodium\\crypto_aead_chacha20poly1305_ietf_encrypt',
[761] Fix | Delete
$plaintext,
[762] Fix | Delete
$assocData,
[763] Fix | Delete
$nonce,
[764] Fix | Delete
$key
[765] Fix | Delete
);
[766] Fix | Delete
}
[767] Fix | Delete
if (PHP_INT_SIZE === 4) {
[768] Fix | Delete
return ParagonIE_Sodium_Crypto32::aead_chacha20poly1305_ietf_encrypt(
[769] Fix | Delete
$plaintext,
[770] Fix | Delete
$assocData,
[771] Fix | Delete
$nonce,
[772] Fix | Delete
$key
[773] Fix | Delete
);
[774] Fix | Delete
}
[775] Fix | Delete
return ParagonIE_Sodium_Crypto::aead_chacha20poly1305_ietf_encrypt(
[776] Fix | Delete
$plaintext,
[777] Fix | Delete
$assocData,
[778] Fix | Delete
$nonce,
[779] Fix | Delete
$key
[780] Fix | Delete
);
[781] Fix | Delete
}
[782] Fix | Delete
[783] Fix | Delete
/**
[784] Fix | Delete
* Return a secure random key for use with the ChaCha20-Poly1305
[785] Fix | Delete
* symmetric AEAD interface. (IETF version)
[786] Fix | Delete
*
[787] Fix | Delete
* @return string
[788] Fix | Delete
* @throws Exception
[789] Fix | Delete
* @throws Error
[790] Fix | Delete
*/
[791] Fix | Delete
public static function crypto_aead_chacha20poly1305_ietf_keygen()
[792] Fix | Delete
{
[793] Fix | Delete
return random_bytes(self::CRYPTO_AEAD_CHACHA20POLY1305_IETF_KEYBYTES);
[794] Fix | Delete
}
[795] Fix | Delete
[796] Fix | Delete
/**
[797] Fix | Delete
* Authenticated Encryption with Associated Data: Decryption
[798] Fix | Delete
*
[799] Fix | Delete
* Algorithm:
[800] Fix | Delete
* XChaCha20-Poly1305
[801] Fix | Delete
*
[802] Fix | Delete
* This mode uses a 64-bit random nonce with a 64-bit counter.
[803] Fix | Delete
* IETF mode uses a 96-bit random nonce with a 32-bit counter.
[804] Fix | Delete
*
[805] Fix | Delete
* @param string $ciphertext Encrypted message (with Poly1305 MAC appended)
[806] Fix | Delete
* @param string $assocData Authenticated Associated Data (unencrypted)
[807] Fix | Delete
* @param string $nonce Number to be used only Once; must be 8 bytes
[808] Fix | Delete
* @param string $key Encryption key
[809] Fix | Delete
* @param bool $dontFallback Don't fallback to ext/sodium
[810] Fix | Delete
*
[811] Fix | Delete
* @return string|bool The original plaintext message
[812] Fix | Delete
* @throws SodiumException
[813] Fix | Delete
* @throws TypeError
[814] Fix | Delete
* @psalm-suppress MixedArgument
[815] Fix | Delete
*/
[816] Fix | Delete
public static function crypto_aead_xchacha20poly1305_ietf_decrypt(
[817] Fix | Delete
$ciphertext = '',
[818] Fix | Delete
$assocData = '',
[819] Fix | Delete
$nonce = '',
[820] Fix | Delete
$key = '',
[821] Fix | Delete
$dontFallback = false
[822] Fix | Delete
) {
[823] Fix | Delete
/* Type checks: */
[824] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($ciphertext, 'string', 1);
[825] Fix | Delete
if (!is_null($assocData)) {
[826] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($assocData, 'string', 2);
[827] Fix | Delete
} else {
[828] Fix | Delete
$assocData = '';
[829] Fix | Delete
}
[830] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($nonce, 'string', 3);
[831] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($key, 'string', 4);
[832] Fix | Delete
[833] Fix | Delete
/* Input validation: */
[834] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($nonce) !== self::CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES) {
[835] Fix | Delete
throw new SodiumException('Nonce must be CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES long');
[836] Fix | Delete
}
[837] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($key) !== self::CRYPTO_AEAD_XCHACHA20POLY1305_IETF_KEYBYTES) {
[838] Fix | Delete
throw new SodiumException('Key must be CRYPTO_AEAD_XCHACHA20POLY1305_IETF_KEYBYTES long');
[839] Fix | Delete
}
[840] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($ciphertext) < self::CRYPTO_AEAD_XCHACHA20POLY1305_IETF_ABYTES) {
[841] Fix | Delete
throw new SodiumException('Message must be at least CRYPTO_AEAD_XCHACHA20POLY1305_IETF_ABYTES long');
[842] Fix | Delete
}
[843] Fix | Delete
if (self::useNewSodiumAPI() && !$dontFallback) {
[844] Fix | Delete
if (is_callable('sodium_crypto_aead_xchacha20poly1305_ietf_decrypt')) {
[845] Fix | Delete
return sodium_crypto_aead_xchacha20poly1305_ietf_decrypt(
[846] Fix | Delete
$ciphertext,
[847] Fix | Delete
$assocData,
[848] Fix | Delete
$nonce,
[849] Fix | Delete
$key
[850] Fix | Delete
);
[851] Fix | Delete
}
[852] Fix | Delete
}
[853] Fix | Delete
[854] Fix | Delete
if (PHP_INT_SIZE === 4) {
[855] Fix | Delete
return ParagonIE_Sodium_Crypto32::aead_xchacha20poly1305_ietf_decrypt(
[856] Fix | Delete
$ciphertext,
[857] Fix | Delete
$assocData,
[858] Fix | Delete
$nonce,
[859] Fix | Delete
$key
[860] Fix | Delete
);
[861] Fix | Delete
}
[862] Fix | Delete
return ParagonIE_Sodium_Crypto::aead_xchacha20poly1305_ietf_decrypt(
[863] Fix | Delete
$ciphertext,
[864] Fix | Delete
$assocData,
[865] Fix | Delete
$nonce,
[866] Fix | Delete
$key
[867] Fix | Delete
);
[868] Fix | Delete
}
[869] Fix | Delete
[870] Fix | Delete
/**
[871] Fix | Delete
* Authenticated Encryption with Associated Data
[872] Fix | Delete
*
[873] Fix | Delete
* Algorithm:
[874] Fix | Delete
* XChaCha20-Poly1305
[875] Fix | Delete
*
[876] Fix | Delete
* This mode uses a 64-bit random nonce with a 64-bit counter.
[877] Fix | Delete
* IETF mode uses a 96-bit random nonce with a 32-bit counter.
[878] Fix | Delete
*
[879] Fix | Delete
* @param string $plaintext Message to be encrypted
[880] Fix | Delete
* @param string $assocData Authenticated Associated Data (unencrypted)
[881] Fix | Delete
* @param string $nonce Number to be used only Once; must be 8 bytes
[882] Fix | Delete
* @param string $key Encryption key
[883] Fix | Delete
* @param bool $dontFallback Don't fallback to ext/sodium
[884] Fix | Delete
*
[885] Fix | Delete
* @return string Ciphertext with a 16-byte Poly1305 message
[886] Fix | Delete
* authentication code appended
[887] Fix | Delete
* @throws SodiumException
[888] Fix | Delete
* @throws TypeError
[889] Fix | Delete
* @psalm-suppress MixedArgument
[890] Fix | Delete
*/
[891] Fix | Delete
public static function crypto_aead_xchacha20poly1305_ietf_encrypt(
[892] Fix | Delete
$plaintext = '',
[893] Fix | Delete
$assocData = '',
[894] Fix | Delete
$nonce = '',
[895] Fix | Delete
$key = '',
[896] Fix | Delete
$dontFallback = false
[897] Fix | Delete
) {
[898] Fix | Delete
/* Type checks: */
[899] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($plaintext, 'string', 1);
[900] Fix | Delete
if (!is_null($assocData)) {
[901] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($assocData, 'string', 2);
[902] Fix | Delete
} else {
[903] Fix | Delete
$assocData = '';
[904] Fix | Delete
}
[905] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($nonce, 'string', 3);
[906] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($key, 'string', 4);
[907] Fix | Delete
[908] Fix | Delete
/* Input validation: */
[909] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($nonce) !== self::CRYPTO_AEAD_XCHACHA20POLY1305_IETF_NPUBBYTES) {
[910] Fix | Delete
throw new SodiumException('Nonce must be CRYPTO_AEAD_XCHACHA20POLY1305_NPUBBYTES long');
[911] Fix | Delete
}
[912] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($key) !== self::CRYPTO_AEAD_XCHACHA20POLY1305_IETF_KEYBYTES) {
[913] Fix | Delete
throw new SodiumException('Key must be CRYPTO_AEAD_XCHACHA20POLY1305_KEYBYTES long');
[914] Fix | Delete
}
[915] Fix | Delete
if (self::useNewSodiumAPI() && !$dontFallback) {
[916] Fix | Delete
if (is_callable('sodium_crypto_aead_xchacha20poly1305_ietf_encrypt')) {
[917] Fix | Delete
return sodium_crypto_aead_xchacha20poly1305_ietf_encrypt(
[918] Fix | Delete
$plaintext,
[919] Fix | Delete
$assocData,
[920] Fix | Delete
$nonce,
[921] Fix | Delete
$key
[922] Fix | Delete
);
[923] Fix | Delete
}
[924] Fix | Delete
}
[925] Fix | Delete
[926] Fix | Delete
if (PHP_INT_SIZE === 4) {
[927] Fix | Delete
return ParagonIE_Sodium_Crypto32::aead_xchacha20poly1305_ietf_encrypt(
[928] Fix | Delete
$plaintext,
[929] Fix | Delete
$assocData,
[930] Fix | Delete
$nonce,
[931] Fix | Delete
$key
[932] Fix | Delete
);
[933] Fix | Delete
}
[934] Fix | Delete
return ParagonIE_Sodium_Crypto::aead_xchacha20poly1305_ietf_encrypt(
[935] Fix | Delete
$plaintext,
[936] Fix | Delete
$assocData,
[937] Fix | Delete
$nonce,
[938] Fix | Delete
$key
[939] Fix | Delete
);
[940] Fix | Delete
}
[941] Fix | Delete
[942] Fix | Delete
/**
[943] Fix | Delete
* Return a secure random key for use with the XChaCha20-Poly1305
[944] Fix | Delete
* symmetric AEAD interface.
[945] Fix | Delete
*
[946] Fix | Delete
* @return string
[947] Fix | Delete
* @throws Exception
[948] Fix | Delete
* @throws Error
[949] Fix | Delete
*/
[950] Fix | Delete
public static function crypto_aead_xchacha20poly1305_ietf_keygen()
[951] Fix | Delete
{
[952] Fix | Delete
return random_bytes(self::CRYPTO_AEAD_XCHACHA20POLY1305_IETF_KEYBYTES);
[953] Fix | Delete
}
[954] Fix | Delete
[955] Fix | Delete
/**
[956] Fix | Delete
* Authenticate a message. Uses symmetric-key cryptography.
[957] Fix | Delete
*
[958] Fix | Delete
* Algorithm:
[959] Fix | Delete
* HMAC-SHA512-256. Which is HMAC-SHA-512 truncated to 256 bits.
[960] Fix | Delete
* Not to be confused with HMAC-SHA-512/256 which would use the
[961] Fix | Delete
* SHA-512/256 hash function (uses different initial parameters
[962] Fix | Delete
* but still truncates to 256 bits to sidestep length-extension
[963] Fix | Delete
* attacks).
[964] Fix | Delete
*
[965] Fix | Delete
* @param string $message Message to be authenticated
[966] Fix | Delete
* @param string $key Symmetric authentication key
[967] Fix | Delete
* @return string Message authentication code
[968] Fix | Delete
* @throws SodiumException
[969] Fix | Delete
* @throws TypeError
[970] Fix | Delete
* @psalm-suppress MixedArgument
[971] Fix | Delete
*/
[972] Fix | Delete
public static function crypto_auth($message, $key)
[973] Fix | Delete
{
[974] Fix | Delete
/* Type checks: */
[975] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($message, 'string', 1);
[976] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($key, 'string', 2);
[977] Fix | Delete
[978] Fix | Delete
/* Input validation: */
[979] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($key) !== self::CRYPTO_AUTH_KEYBYTES) {
[980] Fix | Delete
throw new SodiumException('Argument 2 must be CRYPTO_AUTH_KEYBYTES long.');
[981] Fix | Delete
}
[982] Fix | Delete
[983] Fix | Delete
if (self::useNewSodiumAPI()) {
[984] Fix | Delete
return (string) sodium_crypto_auth($message, $key);
[985] Fix | Delete
}
[986] Fix | Delete
if (self::use_fallback('crypto_auth')) {
[987] Fix | Delete
return (string) call_user_func('\\Sodium\\crypto_auth', $message, $key);
[988] Fix | Delete
}
[989] Fix | Delete
if (PHP_INT_SIZE === 4) {
[990] Fix | Delete
return ParagonIE_Sodium_Crypto32::auth($message, $key);
[991] Fix | Delete
}
[992] Fix | Delete
return ParagonIE_Sodium_Crypto::auth($message, $key);
[993] Fix | Delete
}
[994] Fix | Delete
[995] Fix | Delete
/**
[996] Fix | Delete
* @return string
[997] Fix | Delete
* @throws Exception
[998] Fix | Delete
* @throws Error
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function