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
* @param int $opslimit
[2000] Fix | Delete
* @param int $memlimit
[2001] Fix | Delete
* @return bool
[2002] Fix | Delete
* @throws SodiumException
[2003] Fix | Delete
*/
[2004] Fix | Delete
public static function crypto_pwhash_str_needs_rehash($hash, $opslimit, $memlimit)
[2005] Fix | Delete
{
[2006] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($hash, 'string', 1);
[2007] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($opslimit, 'int', 2);
[2008] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($memlimit, 'int', 3);
[2009] Fix | Delete
[2010] Fix | Delete
// Just grab the first 4 pieces.
[2011] Fix | Delete
$pieces = explode('$', (string) $hash);
[2012] Fix | Delete
$prefix = implode('$', array_slice($pieces, 0, 4));
[2013] Fix | Delete
[2014] Fix | Delete
// Rebuild the expected header.
[2015] Fix | Delete
/** @var int $ops */
[2016] Fix | Delete
$ops = (int) $opslimit;
[2017] Fix | Delete
/** @var int $mem */
[2018] Fix | Delete
$mem = (int) $memlimit >> 10;
[2019] Fix | Delete
$encoded = self::CRYPTO_PWHASH_STRPREFIX . 'v=19$m=' . $mem . ',t=' . $ops . ',p=1';
[2020] Fix | Delete
[2021] Fix | Delete
// Do they match? If so, we don't need to rehash, so return false.
[2022] Fix | Delete
return !ParagonIE_Sodium_Core_Util::hashEquals($encoded, $prefix);
[2023] Fix | Delete
}
[2024] Fix | Delete
[2025] Fix | Delete
/**
[2026] Fix | Delete
* @param string $passwd
[2027] Fix | Delete
* @param string $hash
[2028] Fix | Delete
* @return bool
[2029] Fix | Delete
* @throws SodiumException
[2030] Fix | Delete
* @throws TypeError
[2031] Fix | Delete
* @psalm-suppress MixedArgument
[2032] Fix | Delete
*/
[2033] Fix | Delete
public static function crypto_pwhash_str_verify($passwd, $hash)
[2034] Fix | Delete
{
[2035] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($passwd, 'string', 1);
[2036] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($hash, 'string', 2);
[2037] Fix | Delete
[2038] Fix | Delete
if (self::useNewSodiumAPI()) {
[2039] Fix | Delete
return (bool) sodium_crypto_pwhash_str_verify($passwd, $hash);
[2040] Fix | Delete
}
[2041] Fix | Delete
if (self::use_fallback('crypto_pwhash_str_verify')) {
[2042] Fix | Delete
return (bool) call_user_func('\\Sodium\\crypto_pwhash_str_verify', $passwd, $hash);
[2043] Fix | Delete
}
[2044] Fix | Delete
// This is the best we can do.
[2045] Fix | Delete
throw new SodiumException(
[2046] Fix | Delete
'This is not implemented, as it is not possible to implement Argon2i with acceptable performance in pure-PHP'
[2047] Fix | Delete
);
[2048] Fix | Delete
}
[2049] Fix | Delete
[2050] Fix | Delete
/**
[2051] Fix | Delete
* @param int $outlen
[2052] Fix | Delete
* @param string $passwd
[2053] Fix | Delete
* @param string $salt
[2054] Fix | Delete
* @param int $opslimit
[2055] Fix | Delete
* @param int $memlimit
[2056] Fix | Delete
* @return string
[2057] Fix | Delete
* @throws SodiumException
[2058] Fix | Delete
* @throws TypeError
[2059] Fix | Delete
*/
[2060] Fix | Delete
public static function crypto_pwhash_scryptsalsa208sha256($outlen, $passwd, $salt, $opslimit, $memlimit)
[2061] Fix | Delete
{
[2062] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($outlen, 'int', 1);
[2063] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($passwd, 'string', 2);
[2064] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($salt, 'string', 3);
[2065] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($opslimit, 'int', 4);
[2066] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($memlimit, 'int', 5);
[2067] Fix | Delete
[2068] Fix | Delete
if (self::useNewSodiumAPI()) {
[2069] Fix | Delete
return (string) sodium_crypto_pwhash_scryptsalsa208sha256(
[2070] Fix | Delete
(int) $outlen,
[2071] Fix | Delete
(string) $passwd,
[2072] Fix | Delete
(string) $salt,
[2073] Fix | Delete
(int) $opslimit,
[2074] Fix | Delete
(int) $memlimit
[2075] Fix | Delete
);
[2076] Fix | Delete
}
[2077] Fix | Delete
if (self::use_fallback('crypto_pwhash_scryptsalsa208sha256')) {
[2078] Fix | Delete
return (string) call_user_func(
[2079] Fix | Delete
'\\Sodium\\crypto_pwhash_scryptsalsa208sha256',
[2080] Fix | Delete
(int) $outlen,
[2081] Fix | Delete
(string) $passwd,
[2082] Fix | Delete
(string) $salt,
[2083] Fix | Delete
(int) $opslimit,
[2084] Fix | Delete
(int) $memlimit
[2085] Fix | Delete
);
[2086] Fix | Delete
}
[2087] Fix | Delete
// This is the best we can do.
[2088] Fix | Delete
throw new SodiumException(
[2089] Fix | Delete
'This is not implemented, as it is not possible to implement Scrypt with acceptable performance in pure-PHP'
[2090] Fix | Delete
);
[2091] Fix | Delete
}
[2092] Fix | Delete
[2093] Fix | Delete
/**
[2094] Fix | Delete
* !Exclusive to sodium_compat!
[2095] Fix | Delete
*
[2096] Fix | Delete
* This returns TRUE if the native crypto_pwhash API is available by libsodium.
[2097] Fix | Delete
* This returns FALSE if only sodium_compat is available.
[2098] Fix | Delete
*
[2099] Fix | Delete
* @return bool
[2100] Fix | Delete
*/
[2101] Fix | Delete
public static function crypto_pwhash_scryptsalsa208sha256_is_available()
[2102] Fix | Delete
{
[2103] Fix | Delete
if (self::useNewSodiumAPI()) {
[2104] Fix | Delete
return true;
[2105] Fix | Delete
}
[2106] Fix | Delete
if (self::use_fallback('crypto_pwhash_scryptsalsa208sha256')) {
[2107] Fix | Delete
return true;
[2108] Fix | Delete
}
[2109] Fix | Delete
return false;
[2110] Fix | Delete
}
[2111] Fix | Delete
[2112] Fix | Delete
/**
[2113] Fix | Delete
* @param string $passwd
[2114] Fix | Delete
* @param int $opslimit
[2115] Fix | Delete
* @param int $memlimit
[2116] Fix | Delete
* @return string
[2117] Fix | Delete
* @throws SodiumException
[2118] Fix | Delete
* @throws TypeError
[2119] Fix | Delete
*/
[2120] Fix | Delete
public static function crypto_pwhash_scryptsalsa208sha256_str($passwd, $opslimit, $memlimit)
[2121] Fix | Delete
{
[2122] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($passwd, 'string', 1);
[2123] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($opslimit, 'int', 2);
[2124] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($memlimit, 'int', 3);
[2125] Fix | Delete
[2126] Fix | Delete
if (self::useNewSodiumAPI()) {
[2127] Fix | Delete
return (string) sodium_crypto_pwhash_scryptsalsa208sha256_str(
[2128] Fix | Delete
(string) $passwd,
[2129] Fix | Delete
(int) $opslimit,
[2130] Fix | Delete
(int) $memlimit
[2131] Fix | Delete
);
[2132] Fix | Delete
}
[2133] Fix | Delete
if (self::use_fallback('crypto_pwhash_scryptsalsa208sha256_str')) {
[2134] Fix | Delete
return (string) call_user_func(
[2135] Fix | Delete
'\\Sodium\\crypto_pwhash_scryptsalsa208sha256_str',
[2136] Fix | Delete
(string) $passwd,
[2137] Fix | Delete
(int) $opslimit,
[2138] Fix | Delete
(int) $memlimit
[2139] Fix | Delete
);
[2140] Fix | Delete
}
[2141] Fix | Delete
// This is the best we can do.
[2142] Fix | Delete
throw new SodiumException(
[2143] Fix | Delete
'This is not implemented, as it is not possible to implement Scrypt with acceptable performance in pure-PHP'
[2144] Fix | Delete
);
[2145] Fix | Delete
}
[2146] Fix | Delete
[2147] Fix | Delete
/**
[2148] Fix | Delete
* @param string $passwd
[2149] Fix | Delete
* @param string $hash
[2150] Fix | Delete
* @return bool
[2151] Fix | Delete
* @throws SodiumException
[2152] Fix | Delete
* @throws TypeError
[2153] Fix | Delete
*/
[2154] Fix | Delete
public static function crypto_pwhash_scryptsalsa208sha256_str_verify($passwd, $hash)
[2155] Fix | Delete
{
[2156] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($passwd, 'string', 1);
[2157] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($hash, 'string', 2);
[2158] Fix | Delete
[2159] Fix | Delete
if (self::useNewSodiumAPI()) {
[2160] Fix | Delete
return (bool) sodium_crypto_pwhash_scryptsalsa208sha256_str_verify(
[2161] Fix | Delete
(string) $passwd,
[2162] Fix | Delete
(string) $hash
[2163] Fix | Delete
);
[2164] Fix | Delete
}
[2165] Fix | Delete
if (self::use_fallback('crypto_pwhash_scryptsalsa208sha256_str_verify')) {
[2166] Fix | Delete
return (bool) call_user_func(
[2167] Fix | Delete
'\\Sodium\\crypto_pwhash_scryptsalsa208sha256_str_verify',
[2168] Fix | Delete
(string) $passwd,
[2169] Fix | Delete
(string) $hash
[2170] Fix | Delete
);
[2171] Fix | Delete
}
[2172] Fix | Delete
// This is the best we can do.
[2173] Fix | Delete
throw new SodiumException(
[2174] Fix | Delete
'This is not implemented, as it is not possible to implement Scrypt with acceptable performance in pure-PHP'
[2175] Fix | Delete
);
[2176] Fix | Delete
}
[2177] Fix | Delete
[2178] Fix | Delete
/**
[2179] Fix | Delete
* Calculate the shared secret between your secret key and your
[2180] Fix | Delete
* recipient's public key.
[2181] Fix | Delete
*
[2182] Fix | Delete
* Algorithm: X25519 (ECDH over Curve25519)
[2183] Fix | Delete
*
[2184] Fix | Delete
* @param string $secretKey
[2185] Fix | Delete
* @param string $publicKey
[2186] Fix | Delete
* @return string
[2187] Fix | Delete
* @throws SodiumException
[2188] Fix | Delete
* @throws TypeError
[2189] Fix | Delete
* @psalm-suppress MixedArgument
[2190] Fix | Delete
*/
[2191] Fix | Delete
public static function crypto_scalarmult($secretKey, $publicKey)
[2192] Fix | Delete
{
[2193] Fix | Delete
/* Type checks: */
[2194] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($secretKey, 'string', 1);
[2195] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($publicKey, 'string', 2);
[2196] Fix | Delete
[2197] Fix | Delete
/* Input validation: */
[2198] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($secretKey) !== self::CRYPTO_BOX_SECRETKEYBYTES) {
[2199] Fix | Delete
throw new SodiumException('Argument 1 must be CRYPTO_BOX_SECRETKEYBYTES long.');
[2200] Fix | Delete
}
[2201] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($publicKey) !== self::CRYPTO_BOX_PUBLICKEYBYTES) {
[2202] Fix | Delete
throw new SodiumException('Argument 2 must be CRYPTO_BOX_PUBLICKEYBYTES long.');
[2203] Fix | Delete
}
[2204] Fix | Delete
[2205] Fix | Delete
if (self::useNewSodiumAPI()) {
[2206] Fix | Delete
return sodium_crypto_scalarmult($secretKey, $publicKey);
[2207] Fix | Delete
}
[2208] Fix | Delete
if (self::use_fallback('crypto_scalarmult')) {
[2209] Fix | Delete
return (string) call_user_func('\\Sodium\\crypto_scalarmult', $secretKey, $publicKey);
[2210] Fix | Delete
}
[2211] Fix | Delete
[2212] Fix | Delete
/* Output validation: Forbid all-zero keys */
[2213] Fix | Delete
if (ParagonIE_Sodium_Core_Util::hashEquals($secretKey, str_repeat("\0", self::CRYPTO_BOX_SECRETKEYBYTES))) {
[2214] Fix | Delete
throw new SodiumException('Zero secret key is not allowed');
[2215] Fix | Delete
}
[2216] Fix | Delete
if (ParagonIE_Sodium_Core_Util::hashEquals($publicKey, str_repeat("\0", self::CRYPTO_BOX_PUBLICKEYBYTES))) {
[2217] Fix | Delete
throw new SodiumException('Zero public key is not allowed');
[2218] Fix | Delete
}
[2219] Fix | Delete
if (PHP_INT_SIZE === 4) {
[2220] Fix | Delete
return ParagonIE_Sodium_Crypto32::scalarmult($secretKey, $publicKey);
[2221] Fix | Delete
}
[2222] Fix | Delete
return ParagonIE_Sodium_Crypto::scalarmult($secretKey, $publicKey);
[2223] Fix | Delete
}
[2224] Fix | Delete
[2225] Fix | Delete
/**
[2226] Fix | Delete
* Calculate an X25519 public key from an X25519 secret key.
[2227] Fix | Delete
*
[2228] Fix | Delete
* @param string $secretKey
[2229] Fix | Delete
* @return string
[2230] Fix | Delete
* @throws SodiumException
[2231] Fix | Delete
* @throws TypeError
[2232] Fix | Delete
* @psalm-suppress TooFewArguments
[2233] Fix | Delete
* @psalm-suppress MixedArgument
[2234] Fix | Delete
*/
[2235] Fix | Delete
public static function crypto_scalarmult_base($secretKey)
[2236] Fix | Delete
{
[2237] Fix | Delete
/* Type checks: */
[2238] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($secretKey, 'string', 1);
[2239] Fix | Delete
[2240] Fix | Delete
/* Input validation: */
[2241] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($secretKey) !== self::CRYPTO_BOX_SECRETKEYBYTES) {
[2242] Fix | Delete
throw new SodiumException('Argument 1 must be CRYPTO_BOX_SECRETKEYBYTES long.');
[2243] Fix | Delete
}
[2244] Fix | Delete
[2245] Fix | Delete
if (self::useNewSodiumAPI()) {
[2246] Fix | Delete
return sodium_crypto_scalarmult_base($secretKey);
[2247] Fix | Delete
}
[2248] Fix | Delete
if (self::use_fallback('crypto_scalarmult_base')) {
[2249] Fix | Delete
return (string) call_user_func('\\Sodium\\crypto_scalarmult_base', $secretKey);
[2250] Fix | Delete
}
[2251] Fix | Delete
if (ParagonIE_Sodium_Core_Util::hashEquals($secretKey, str_repeat("\0", self::CRYPTO_BOX_SECRETKEYBYTES))) {
[2252] Fix | Delete
throw new SodiumException('Zero secret key is not allowed');
[2253] Fix | Delete
}
[2254] Fix | Delete
if (PHP_INT_SIZE === 4) {
[2255] Fix | Delete
return ParagonIE_Sodium_Crypto32::scalarmult_base($secretKey);
[2256] Fix | Delete
}
[2257] Fix | Delete
return ParagonIE_Sodium_Crypto::scalarmult_base($secretKey);
[2258] Fix | Delete
}
[2259] Fix | Delete
[2260] Fix | Delete
/**
[2261] Fix | Delete
* Authenticated symmetric-key encryption.
[2262] Fix | Delete
*
[2263] Fix | Delete
* Algorithm: XSalsa20-Poly1305
[2264] Fix | Delete
*
[2265] Fix | Delete
* @param string $plaintext The message you're encrypting
[2266] Fix | Delete
* @param string $nonce A Number to be used Once; must be 24 bytes
[2267] Fix | Delete
* @param string $key Symmetric encryption key
[2268] Fix | Delete
* @return string Ciphertext with Poly1305 MAC
[2269] Fix | Delete
* @throws SodiumException
[2270] Fix | Delete
* @throws TypeError
[2271] Fix | Delete
* @psalm-suppress MixedArgument
[2272] Fix | Delete
*/
[2273] Fix | Delete
public static function crypto_secretbox($plaintext, $nonce, $key)
[2274] Fix | Delete
{
[2275] Fix | Delete
/* Type checks: */
[2276] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($plaintext, 'string', 1);
[2277] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($nonce, 'string', 2);
[2278] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($key, 'string', 3);
[2279] Fix | Delete
[2280] Fix | Delete
/* Input validation: */
[2281] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($nonce) !== self::CRYPTO_SECRETBOX_NONCEBYTES) {
[2282] Fix | Delete
throw new SodiumException('Argument 2 must be CRYPTO_SECRETBOX_NONCEBYTES long.');
[2283] Fix | Delete
}
[2284] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($key) !== self::CRYPTO_SECRETBOX_KEYBYTES) {
[2285] Fix | Delete
throw new SodiumException('Argument 3 must be CRYPTO_SECRETBOX_KEYBYTES long.');
[2286] Fix | Delete
}
[2287] Fix | Delete
[2288] Fix | Delete
if (self::useNewSodiumAPI()) {
[2289] Fix | Delete
return sodium_crypto_secretbox($plaintext, $nonce, $key);
[2290] Fix | Delete
}
[2291] Fix | Delete
if (self::use_fallback('crypto_secretbox')) {
[2292] Fix | Delete
return (string) call_user_func('\\Sodium\\crypto_secretbox', $plaintext, $nonce, $key);
[2293] Fix | Delete
}
[2294] Fix | Delete
if (PHP_INT_SIZE === 4) {
[2295] Fix | Delete
return ParagonIE_Sodium_Crypto32::secretbox($plaintext, $nonce, $key);
[2296] Fix | Delete
}
[2297] Fix | Delete
return ParagonIE_Sodium_Crypto::secretbox($plaintext, $nonce, $key);
[2298] Fix | Delete
}
[2299] Fix | Delete
[2300] Fix | Delete
/**
[2301] Fix | Delete
* Decrypts a message previously encrypted with crypto_secretbox().
[2302] Fix | Delete
*
[2303] Fix | Delete
* @param string $ciphertext Ciphertext with Poly1305 MAC
[2304] Fix | Delete
* @param string $nonce A Number to be used Once; must be 24 bytes
[2305] Fix | Delete
* @param string $key Symmetric encryption key
[2306] Fix | Delete
* @return string Original plaintext message
[2307] Fix | Delete
* @throws SodiumException
[2308] Fix | Delete
* @throws TypeError
[2309] Fix | Delete
* @psalm-suppress MixedArgument
[2310] Fix | Delete
* @psalm-suppress MixedInferredReturnType
[2311] Fix | Delete
* @psalm-suppress MixedReturnStatement
[2312] Fix | Delete
*/
[2313] Fix | Delete
public static function crypto_secretbox_open($ciphertext, $nonce, $key)
[2314] Fix | Delete
{
[2315] Fix | Delete
/* Type checks: */
[2316] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($ciphertext, 'string', 1);
[2317] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($nonce, 'string', 2);
[2318] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($key, 'string', 3);
[2319] Fix | Delete
[2320] Fix | Delete
/* Input validation: */
[2321] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($nonce) !== self::CRYPTO_SECRETBOX_NONCEBYTES) {
[2322] Fix | Delete
throw new SodiumException('Argument 2 must be CRYPTO_SECRETBOX_NONCEBYTES long.');
[2323] Fix | Delete
}
[2324] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($key) !== self::CRYPTO_SECRETBOX_KEYBYTES) {
[2325] Fix | Delete
throw new SodiumException('Argument 3 must be CRYPTO_SECRETBOX_KEYBYTES long.');
[2326] Fix | Delete
}
[2327] Fix | Delete
[2328] Fix | Delete
if (self::useNewSodiumAPI()) {
[2329] Fix | Delete
/**
[2330] Fix | Delete
* @psalm-suppress InvalidReturnStatement
[2331] Fix | Delete
* @psalm-suppress FalsableReturnStatement
[2332] Fix | Delete
*/
[2333] Fix | Delete
return sodium_crypto_secretbox_open($ciphertext, $nonce, $key);
[2334] Fix | Delete
}
[2335] Fix | Delete
if (self::use_fallback('crypto_secretbox_open')) {
[2336] Fix | Delete
return call_user_func('\\Sodium\\crypto_secretbox_open', $ciphertext, $nonce, $key);
[2337] Fix | Delete
}
[2338] Fix | Delete
if (PHP_INT_SIZE === 4) {
[2339] Fix | Delete
return ParagonIE_Sodium_Crypto32::secretbox_open($ciphertext, $nonce, $key);
[2340] Fix | Delete
}
[2341] Fix | Delete
return ParagonIE_Sodium_Crypto::secretbox_open($ciphertext, $nonce, $key);
[2342] Fix | Delete
}
[2343] Fix | Delete
[2344] Fix | Delete
/**
[2345] Fix | Delete
* Return a secure random key for use with crypto_secretbox
[2346] Fix | Delete
*
[2347] Fix | Delete
* @return string
[2348] Fix | Delete
* @throws Exception
[2349] Fix | Delete
* @throws Error
[2350] Fix | Delete
*/
[2351] Fix | Delete
public static function crypto_secretbox_keygen()
[2352] Fix | Delete
{
[2353] Fix | Delete
return random_bytes(self::CRYPTO_SECRETBOX_KEYBYTES);
[2354] Fix | Delete
}
[2355] Fix | Delete
[2356] Fix | Delete
/**
[2357] Fix | Delete
* Authenticated symmetric-key encryption.
[2358] Fix | Delete
*
[2359] Fix | Delete
* Algorithm: XChaCha20-Poly1305
[2360] Fix | Delete
*
[2361] Fix | Delete
* @param string $plaintext The message you're encrypting
[2362] Fix | Delete
* @param string $nonce A Number to be used Once; must be 24 bytes
[2363] Fix | Delete
* @param string $key Symmetric encryption key
[2364] Fix | Delete
* @return string Ciphertext with Poly1305 MAC
[2365] Fix | Delete
* @throws SodiumException
[2366] Fix | Delete
* @throws TypeError
[2367] Fix | Delete
* @psalm-suppress MixedArgument
[2368] Fix | Delete
*/
[2369] Fix | Delete
public static function crypto_secretbox_xchacha20poly1305($plaintext, $nonce, $key)
[2370] Fix | Delete
{
[2371] Fix | Delete
/* Type checks: */
[2372] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($plaintext, 'string', 1);
[2373] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($nonce, 'string', 2);
[2374] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($key, 'string', 3);
[2375] Fix | Delete
[2376] Fix | Delete
/* Input validation: */
[2377] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($nonce) !== self::CRYPTO_SECRETBOX_NONCEBYTES) {
[2378] Fix | Delete
throw new SodiumException('Argument 2 must be CRYPTO_SECRETBOX_NONCEBYTES long.');
[2379] Fix | Delete
}
[2380] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($key) !== self::CRYPTO_SECRETBOX_KEYBYTES) {
[2381] Fix | Delete
throw new SodiumException('Argument 3 must be CRYPTO_SECRETBOX_KEYBYTES long.');
[2382] Fix | Delete
}
[2383] Fix | Delete
if (PHP_INT_SIZE === 4) {
[2384] Fix | Delete
return ParagonIE_Sodium_Crypto32::secretbox_xchacha20poly1305($plaintext, $nonce, $key);
[2385] Fix | Delete
}
[2386] Fix | Delete
return ParagonIE_Sodium_Crypto::secretbox_xchacha20poly1305($plaintext, $nonce, $key);
[2387] Fix | Delete
}
[2388] Fix | Delete
/**
[2389] Fix | Delete
* Decrypts a message previously encrypted with crypto_secretbox_xchacha20poly1305().
[2390] Fix | Delete
*
[2391] Fix | Delete
* @param string $ciphertext Ciphertext with Poly1305 MAC
[2392] Fix | Delete
* @param string $nonce A Number to be used Once; must be 24 bytes
[2393] Fix | Delete
* @param string $key Symmetric encryption key
[2394] Fix | Delete
* @return string Original plaintext message
[2395] Fix | Delete
* @throws SodiumException
[2396] Fix | Delete
* @throws TypeError
[2397] Fix | Delete
* @psalm-suppress MixedArgument
[2398] Fix | Delete
*/
[2399] Fix | Delete
public static function crypto_secretbox_xchacha20poly1305_open($ciphertext, $nonce, $key)
[2400] Fix | Delete
{
[2401] Fix | Delete
/* Type checks: */
[2402] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($ciphertext, 'string', 1);
[2403] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($nonce, 'string', 2);
[2404] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($key, 'string', 3);
[2405] Fix | Delete
[2406] Fix | Delete
/* Input validation: */
[2407] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($nonce) !== self::CRYPTO_SECRETBOX_NONCEBYTES) {
[2408] Fix | Delete
throw new SodiumException('Argument 2 must be CRYPTO_SECRETBOX_NONCEBYTES long.');
[2409] Fix | Delete
}
[2410] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($key) !== self::CRYPTO_SECRETBOX_KEYBYTES) {
[2411] Fix | Delete
throw new SodiumException('Argument 3 must be CRYPTO_SECRETBOX_KEYBYTES long.');
[2412] Fix | Delete
}
[2413] Fix | Delete
[2414] Fix | Delete
if (PHP_INT_SIZE === 4) {
[2415] Fix | Delete
return ParagonIE_Sodium_Crypto32::secretbox_xchacha20poly1305_open($ciphertext, $nonce, $key);
[2416] Fix | Delete
}
[2417] Fix | Delete
return ParagonIE_Sodium_Crypto::secretbox_xchacha20poly1305_open($ciphertext, $nonce, $key);
[2418] Fix | Delete
}
[2419] Fix | Delete
[2420] Fix | Delete
/**
[2421] Fix | Delete
* @param string $key
[2422] Fix | Delete
* @return array<int, string> Returns a state and a header.
[2423] Fix | Delete
* @throws Exception
[2424] Fix | Delete
* @throws SodiumException
[2425] Fix | Delete
*/
[2426] Fix | Delete
public static function crypto_secretstream_xchacha20poly1305_init_push($key)
[2427] Fix | Delete
{
[2428] Fix | Delete
if (PHP_INT_SIZE === 4) {
[2429] Fix | Delete
return ParagonIE_Sodium_Crypto32::secretstream_xchacha20poly1305_init_push($key);
[2430] Fix | Delete
}
[2431] Fix | Delete
return ParagonIE_Sodium_Crypto::secretstream_xchacha20poly1305_init_push($key);
[2432] Fix | Delete
}
[2433] Fix | Delete
[2434] Fix | Delete
/**
[2435] Fix | Delete
* @param string $header
[2436] Fix | Delete
* @param string $key
[2437] Fix | Delete
* @return string Returns a state.
[2438] Fix | Delete
* @throws Exception
[2439] Fix | Delete
*/
[2440] Fix | Delete
public static function crypto_secretstream_xchacha20poly1305_init_pull($header, $key)
[2441] Fix | Delete
{
[2442] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($header) < self::CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_HEADERBYTES) {
[2443] Fix | Delete
throw new SodiumException(
[2444] Fix | Delete
'header size should be SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_HEADERBYTES bytes'
[2445] Fix | Delete
);
[2446] Fix | Delete
}
[2447] Fix | Delete
if (PHP_INT_SIZE === 4) {
[2448] Fix | Delete
return ParagonIE_Sodium_Crypto32::secretstream_xchacha20poly1305_init_pull($key, $header);
[2449] Fix | Delete
}
[2450] Fix | Delete
return ParagonIE_Sodium_Crypto::secretstream_xchacha20poly1305_init_pull($key, $header);
[2451] Fix | Delete
}
[2452] Fix | Delete
[2453] Fix | Delete
/**
[2454] Fix | Delete
* @param string $state
[2455] Fix | Delete
* @param string $msg
[2456] Fix | Delete
* @param string $aad
[2457] Fix | Delete
* @param int $tag
[2458] Fix | Delete
* @return string
[2459] Fix | Delete
* @throws SodiumException
[2460] Fix | Delete
*/
[2461] Fix | Delete
public static function crypto_secretstream_xchacha20poly1305_push(&$state, $msg, $aad = '', $tag = 0)
[2462] Fix | Delete
{
[2463] Fix | Delete
if (PHP_INT_SIZE === 4) {
[2464] Fix | Delete
return ParagonIE_Sodium_Crypto32::secretstream_xchacha20poly1305_push(
[2465] Fix | Delete
$state,
[2466] Fix | Delete
$msg,
[2467] Fix | Delete
$aad,
[2468] Fix | Delete
$tag
[2469] Fix | Delete
);
[2470] Fix | Delete
}
[2471] Fix | Delete
return ParagonIE_Sodium_Crypto::secretstream_xchacha20poly1305_push(
[2472] Fix | Delete
$state,
[2473] Fix | Delete
$msg,
[2474] Fix | Delete
$aad,
[2475] Fix | Delete
$tag
[2476] Fix | Delete
);
[2477] Fix | Delete
}
[2478] Fix | Delete
[2479] Fix | Delete
/**
[2480] Fix | Delete
* @param string $state
[2481] Fix | Delete
* @param string $msg
[2482] Fix | Delete
* @param string $aad
[2483] Fix | Delete
* @return bool|array{0: string, 1: int}
[2484] Fix | Delete
* @throws SodiumException
[2485] Fix | Delete
*/
[2486] Fix | Delete
public static function crypto_secretstream_xchacha20poly1305_pull(&$state, $msg, $aad = '')
[2487] Fix | Delete
{
[2488] Fix | Delete
if (PHP_INT_SIZE === 4) {
[2489] Fix | Delete
return ParagonIE_Sodium_Crypto32::secretstream_xchacha20poly1305_pull(
[2490] Fix | Delete
$state,
[2491] Fix | Delete
$msg,
[2492] Fix | Delete
$aad
[2493] Fix | Delete
);
[2494] Fix | Delete
}
[2495] Fix | Delete
return ParagonIE_Sodium_Crypto::secretstream_xchacha20poly1305_pull(
[2496] Fix | Delete
$state,
[2497] Fix | Delete
$msg,
[2498] Fix | Delete
$aad
[2499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function