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
);
[2500] Fix | Delete
}
[2501] Fix | Delete
[2502] Fix | Delete
/**
[2503] Fix | Delete
* @return string
[2504] Fix | Delete
* @throws Exception
[2505] Fix | Delete
*/
[2506] Fix | Delete
public static function crypto_secretstream_xchacha20poly1305_keygen()
[2507] Fix | Delete
{
[2508] Fix | Delete
return random_bytes(self::CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_KEYBYTES);
[2509] Fix | Delete
}
[2510] Fix | Delete
[2511] Fix | Delete
/**
[2512] Fix | Delete
* @param string $state
[2513] Fix | Delete
* @return void
[2514] Fix | Delete
* @throws SodiumException
[2515] Fix | Delete
*/
[2516] Fix | Delete
public static function crypto_secretstream_xchacha20poly1305_rekey(&$state)
[2517] Fix | Delete
{
[2518] Fix | Delete
if (PHP_INT_SIZE === 4) {
[2519] Fix | Delete
ParagonIE_Sodium_Crypto32::secretstream_xchacha20poly1305_rekey($state);
[2520] Fix | Delete
} else {
[2521] Fix | Delete
ParagonIE_Sodium_Crypto::secretstream_xchacha20poly1305_rekey($state);
[2522] Fix | Delete
}
[2523] Fix | Delete
}
[2524] Fix | Delete
[2525] Fix | Delete
/**
[2526] Fix | Delete
* Calculates a SipHash-2-4 hash of a message for a given key.
[2527] Fix | Delete
*
[2528] Fix | Delete
* @param string $message Input message
[2529] Fix | Delete
* @param string $key SipHash-2-4 key
[2530] Fix | Delete
* @return string Hash
[2531] Fix | Delete
* @throws SodiumException
[2532] Fix | Delete
* @throws TypeError
[2533] Fix | Delete
* @psalm-suppress MixedArgument
[2534] Fix | Delete
* @psalm-suppress MixedInferredReturnType
[2535] Fix | Delete
* @psalm-suppress MixedReturnStatement
[2536] Fix | Delete
*/
[2537] Fix | Delete
public static function crypto_shorthash($message, $key)
[2538] Fix | Delete
{
[2539] Fix | Delete
/* Type checks: */
[2540] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($message, 'string', 1);
[2541] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($key, 'string', 2);
[2542] Fix | Delete
[2543] Fix | Delete
/* Input validation: */
[2544] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($key) !== self::CRYPTO_SHORTHASH_KEYBYTES) {
[2545] Fix | Delete
throw new SodiumException('Argument 2 must be CRYPTO_SHORTHASH_KEYBYTES long.');
[2546] Fix | Delete
}
[2547] Fix | Delete
[2548] Fix | Delete
if (self::useNewSodiumAPI()) {
[2549] Fix | Delete
return sodium_crypto_shorthash($message, $key);
[2550] Fix | Delete
}
[2551] Fix | Delete
if (self::use_fallback('crypto_shorthash')) {
[2552] Fix | Delete
return (string) call_user_func('\\Sodium\\crypto_shorthash', $message, $key);
[2553] Fix | Delete
}
[2554] Fix | Delete
if (PHP_INT_SIZE === 4) {
[2555] Fix | Delete
return ParagonIE_Sodium_Core32_SipHash::sipHash24($message, $key);
[2556] Fix | Delete
}
[2557] Fix | Delete
return ParagonIE_Sodium_Core_SipHash::sipHash24($message, $key);
[2558] Fix | Delete
}
[2559] Fix | Delete
[2560] Fix | Delete
/**
[2561] Fix | Delete
* Return a secure random key for use with crypto_shorthash
[2562] Fix | Delete
*
[2563] Fix | Delete
* @return string
[2564] Fix | Delete
* @throws Exception
[2565] Fix | Delete
* @throws Error
[2566] Fix | Delete
*/
[2567] Fix | Delete
public static function crypto_shorthash_keygen()
[2568] Fix | Delete
{
[2569] Fix | Delete
return random_bytes(self::CRYPTO_SHORTHASH_KEYBYTES);
[2570] Fix | Delete
}
[2571] Fix | Delete
[2572] Fix | Delete
/**
[2573] Fix | Delete
* Returns a signed message. You probably want crypto_sign_detached()
[2574] Fix | Delete
* instead, which only returns the signature.
[2575] Fix | Delete
*
[2576] Fix | Delete
* Algorithm: Ed25519 (EdDSA over Curve25519)
[2577] Fix | Delete
*
[2578] Fix | Delete
* @param string $message Message to be signed.
[2579] Fix | Delete
* @param string $secretKey Secret signing key.
[2580] Fix | Delete
* @return string Signed message (signature is prefixed).
[2581] Fix | Delete
* @throws SodiumException
[2582] Fix | Delete
* @throws TypeError
[2583] Fix | Delete
* @psalm-suppress MixedArgument
[2584] Fix | Delete
* @psalm-suppress MixedInferredReturnType
[2585] Fix | Delete
* @psalm-suppress MixedReturnStatement
[2586] Fix | Delete
*/
[2587] Fix | Delete
public static function crypto_sign($message, $secretKey)
[2588] Fix | Delete
{
[2589] Fix | Delete
/* Type checks: */
[2590] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($message, 'string', 1);
[2591] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($secretKey, 'string', 2);
[2592] Fix | Delete
[2593] Fix | Delete
/* Input validation: */
[2594] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($secretKey) !== self::CRYPTO_SIGN_SECRETKEYBYTES) {
[2595] Fix | Delete
throw new SodiumException('Argument 2 must be CRYPTO_SIGN_SECRETKEYBYTES long.');
[2596] Fix | Delete
}
[2597] Fix | Delete
[2598] Fix | Delete
if (self::useNewSodiumAPI()) {
[2599] Fix | Delete
return sodium_crypto_sign($message, $secretKey);
[2600] Fix | Delete
}
[2601] Fix | Delete
if (self::use_fallback('crypto_sign')) {
[2602] Fix | Delete
return (string) call_user_func('\\Sodium\\crypto_sign', $message, $secretKey);
[2603] Fix | Delete
}
[2604] Fix | Delete
if (PHP_INT_SIZE === 4) {
[2605] Fix | Delete
return ParagonIE_Sodium_Crypto32::sign($message, $secretKey);
[2606] Fix | Delete
}
[2607] Fix | Delete
return ParagonIE_Sodium_Crypto::sign($message, $secretKey);
[2608] Fix | Delete
}
[2609] Fix | Delete
[2610] Fix | Delete
/**
[2611] Fix | Delete
* Validates a signed message then returns the message.
[2612] Fix | Delete
*
[2613] Fix | Delete
* @param string $signedMessage A signed message
[2614] Fix | Delete
* @param string $publicKey A public key
[2615] Fix | Delete
* @return string The original message (if the signature is
[2616] Fix | Delete
* valid for this public key)
[2617] Fix | Delete
* @throws SodiumException
[2618] Fix | Delete
* @throws TypeError
[2619] Fix | Delete
* @psalm-suppress MixedArgument
[2620] Fix | Delete
* @psalm-suppress MixedInferredReturnType
[2621] Fix | Delete
* @psalm-suppress MixedReturnStatement
[2622] Fix | Delete
*/
[2623] Fix | Delete
public static function crypto_sign_open($signedMessage, $publicKey)
[2624] Fix | Delete
{
[2625] Fix | Delete
/* Type checks: */
[2626] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($signedMessage, 'string', 1);
[2627] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($publicKey, 'string', 2);
[2628] Fix | Delete
[2629] Fix | Delete
/* Input validation: */
[2630] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($signedMessage) < self::CRYPTO_SIGN_BYTES) {
[2631] Fix | Delete
throw new SodiumException('Argument 1 must be at least CRYPTO_SIGN_BYTES long.');
[2632] Fix | Delete
}
[2633] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($publicKey) !== self::CRYPTO_SIGN_PUBLICKEYBYTES) {
[2634] Fix | Delete
throw new SodiumException('Argument 2 must be CRYPTO_SIGN_PUBLICKEYBYTES long.');
[2635] Fix | Delete
}
[2636] Fix | Delete
[2637] Fix | Delete
if (self::useNewSodiumAPI()) {
[2638] Fix | Delete
/**
[2639] Fix | Delete
* @psalm-suppress InvalidReturnStatement
[2640] Fix | Delete
* @psalm-suppress FalsableReturnStatement
[2641] Fix | Delete
*/
[2642] Fix | Delete
return sodium_crypto_sign_open($signedMessage, $publicKey);
[2643] Fix | Delete
}
[2644] Fix | Delete
if (self::use_fallback('crypto_sign_open')) {
[2645] Fix | Delete
return call_user_func('\\Sodium\\crypto_sign_open', $signedMessage, $publicKey);
[2646] Fix | Delete
}
[2647] Fix | Delete
if (PHP_INT_SIZE === 4) {
[2648] Fix | Delete
return ParagonIE_Sodium_Crypto32::sign_open($signedMessage, $publicKey);
[2649] Fix | Delete
}
[2650] Fix | Delete
return ParagonIE_Sodium_Crypto::sign_open($signedMessage, $publicKey);
[2651] Fix | Delete
}
[2652] Fix | Delete
[2653] Fix | Delete
/**
[2654] Fix | Delete
* Generate a new random Ed25519 keypair.
[2655] Fix | Delete
*
[2656] Fix | Delete
* @return string
[2657] Fix | Delete
* @throws SodiumException
[2658] Fix | Delete
* @throws TypeError
[2659] Fix | Delete
*/
[2660] Fix | Delete
public static function crypto_sign_keypair()
[2661] Fix | Delete
{
[2662] Fix | Delete
if (self::useNewSodiumAPI()) {
[2663] Fix | Delete
return sodium_crypto_sign_keypair();
[2664] Fix | Delete
}
[2665] Fix | Delete
if (self::use_fallback('crypto_sign_keypair')) {
[2666] Fix | Delete
return (string) call_user_func('\\Sodium\\crypto_sign_keypair');
[2667] Fix | Delete
}
[2668] Fix | Delete
if (PHP_INT_SIZE === 4) {
[2669] Fix | Delete
return ParagonIE_Sodium_Core32_Ed25519::keypair();
[2670] Fix | Delete
}
[2671] Fix | Delete
return ParagonIE_Sodium_Core_Ed25519::keypair();
[2672] Fix | Delete
}
[2673] Fix | Delete
[2674] Fix | Delete
/**
[2675] Fix | Delete
* @param string $sk
[2676] Fix | Delete
* @param string $pk
[2677] Fix | Delete
* @return string
[2678] Fix | Delete
* @throws SodiumException
[2679] Fix | Delete
*/
[2680] Fix | Delete
public static function crypto_sign_keypair_from_secretkey_and_publickey($sk, $pk)
[2681] Fix | Delete
{
[2682] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($sk, 'string', 1);
[2683] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($pk, 'string', 1);
[2684] Fix | Delete
$sk = (string) $sk;
[2685] Fix | Delete
$pk = (string) $pk;
[2686] Fix | Delete
[2687] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($sk) !== self::CRYPTO_SIGN_SECRETKEYBYTES) {
[2688] Fix | Delete
throw new SodiumException('secretkey should be SODIUM_CRYPTO_SIGN_SECRETKEYBYTES bytes');
[2689] Fix | Delete
}
[2690] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($pk) !== self::CRYPTO_SIGN_PUBLICKEYBYTES) {
[2691] Fix | Delete
throw new SodiumException('publickey should be SODIUM_CRYPTO_SIGN_PUBLICKEYBYTES bytes');
[2692] Fix | Delete
}
[2693] Fix | Delete
[2694] Fix | Delete
if (self::useNewSodiumAPI()) {
[2695] Fix | Delete
return sodium_crypto_sign_keypair_from_secretkey_and_publickey($sk, $pk);
[2696] Fix | Delete
}
[2697] Fix | Delete
return $sk . $pk;
[2698] Fix | Delete
}
[2699] Fix | Delete
[2700] Fix | Delete
/**
[2701] Fix | Delete
* Generate an Ed25519 keypair from a seed.
[2702] Fix | Delete
*
[2703] Fix | Delete
* @param string $seed Input seed
[2704] Fix | Delete
* @return string Keypair
[2705] Fix | Delete
* @throws SodiumException
[2706] Fix | Delete
* @throws TypeError
[2707] Fix | Delete
* @psalm-suppress MixedArgument
[2708] Fix | Delete
*/
[2709] Fix | Delete
public static function crypto_sign_seed_keypair($seed)
[2710] Fix | Delete
{
[2711] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($seed, 'string', 1);
[2712] Fix | Delete
[2713] Fix | Delete
if (self::useNewSodiumAPI()) {
[2714] Fix | Delete
return sodium_crypto_sign_seed_keypair($seed);
[2715] Fix | Delete
}
[2716] Fix | Delete
if (self::use_fallback('crypto_sign_keypair')) {
[2717] Fix | Delete
return (string) call_user_func('\\Sodium\\crypto_sign_seed_keypair', $seed);
[2718] Fix | Delete
}
[2719] Fix | Delete
$publicKey = '';
[2720] Fix | Delete
$secretKey = '';
[2721] Fix | Delete
if (PHP_INT_SIZE === 4) {
[2722] Fix | Delete
ParagonIE_Sodium_Core32_Ed25519::seed_keypair($publicKey, $secretKey, $seed);
[2723] Fix | Delete
} else {
[2724] Fix | Delete
ParagonIE_Sodium_Core_Ed25519::seed_keypair($publicKey, $secretKey, $seed);
[2725] Fix | Delete
}
[2726] Fix | Delete
return $secretKey . $publicKey;
[2727] Fix | Delete
}
[2728] Fix | Delete
[2729] Fix | Delete
/**
[2730] Fix | Delete
* Extract an Ed25519 public key from an Ed25519 keypair.
[2731] Fix | Delete
*
[2732] Fix | Delete
* @param string $keypair Keypair
[2733] Fix | Delete
* @return string Public key
[2734] Fix | Delete
* @throws SodiumException
[2735] Fix | Delete
* @throws TypeError
[2736] Fix | Delete
* @psalm-suppress MixedArgument
[2737] Fix | Delete
*/
[2738] Fix | Delete
public static function crypto_sign_publickey($keypair)
[2739] Fix | Delete
{
[2740] Fix | Delete
/* Type checks: */
[2741] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($keypair, 'string', 1);
[2742] Fix | Delete
[2743] Fix | Delete
/* Input validation: */
[2744] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($keypair) !== self::CRYPTO_SIGN_KEYPAIRBYTES) {
[2745] Fix | Delete
throw new SodiumException('Argument 1 must be CRYPTO_SIGN_KEYPAIRBYTES long.');
[2746] Fix | Delete
}
[2747] Fix | Delete
[2748] Fix | Delete
if (self::useNewSodiumAPI()) {
[2749] Fix | Delete
return sodium_crypto_sign_publickey($keypair);
[2750] Fix | Delete
}
[2751] Fix | Delete
if (self::use_fallback('crypto_sign_publickey')) {
[2752] Fix | Delete
return (string) call_user_func('\\Sodium\\crypto_sign_publickey', $keypair);
[2753] Fix | Delete
}
[2754] Fix | Delete
if (PHP_INT_SIZE === 4) {
[2755] Fix | Delete
return ParagonIE_Sodium_Core32_Ed25519::publickey($keypair);
[2756] Fix | Delete
}
[2757] Fix | Delete
return ParagonIE_Sodium_Core_Ed25519::publickey($keypair);
[2758] Fix | Delete
}
[2759] Fix | Delete
[2760] Fix | Delete
/**
[2761] Fix | Delete
* Calculate an Ed25519 public key from an Ed25519 secret key.
[2762] Fix | Delete
*
[2763] Fix | Delete
* @param string $secretKey Your Ed25519 secret key
[2764] Fix | Delete
* @return string The corresponding Ed25519 public key
[2765] Fix | Delete
* @throws SodiumException
[2766] Fix | Delete
* @throws TypeError
[2767] Fix | Delete
* @psalm-suppress MixedArgument
[2768] Fix | Delete
*/
[2769] Fix | Delete
public static function crypto_sign_publickey_from_secretkey($secretKey)
[2770] Fix | Delete
{
[2771] Fix | Delete
/* Type checks: */
[2772] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($secretKey, 'string', 1);
[2773] Fix | Delete
[2774] Fix | Delete
/* Input validation: */
[2775] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($secretKey) !== self::CRYPTO_SIGN_SECRETKEYBYTES) {
[2776] Fix | Delete
throw new SodiumException('Argument 1 must be CRYPTO_SIGN_SECRETKEYBYTES long.');
[2777] Fix | Delete
}
[2778] Fix | Delete
[2779] Fix | Delete
if (self::useNewSodiumAPI()) {
[2780] Fix | Delete
return sodium_crypto_sign_publickey_from_secretkey($secretKey);
[2781] Fix | Delete
}
[2782] Fix | Delete
if (self::use_fallback('crypto_sign_publickey_from_secretkey')) {
[2783] Fix | Delete
return (string) call_user_func('\\Sodium\\crypto_sign_publickey_from_secretkey', $secretKey);
[2784] Fix | Delete
}
[2785] Fix | Delete
if (PHP_INT_SIZE === 4) {
[2786] Fix | Delete
return ParagonIE_Sodium_Core32_Ed25519::publickey_from_secretkey($secretKey);
[2787] Fix | Delete
}
[2788] Fix | Delete
return ParagonIE_Sodium_Core_Ed25519::publickey_from_secretkey($secretKey);
[2789] Fix | Delete
}
[2790] Fix | Delete
[2791] Fix | Delete
/**
[2792] Fix | Delete
* Extract an Ed25519 secret key from an Ed25519 keypair.
[2793] Fix | Delete
*
[2794] Fix | Delete
* @param string $keypair Keypair
[2795] Fix | Delete
* @return string Secret key
[2796] Fix | Delete
* @throws SodiumException
[2797] Fix | Delete
* @throws TypeError
[2798] Fix | Delete
* @psalm-suppress MixedArgument
[2799] Fix | Delete
*/
[2800] Fix | Delete
public static function crypto_sign_secretkey($keypair)
[2801] Fix | Delete
{
[2802] Fix | Delete
/* Type checks: */
[2803] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($keypair, 'string', 1);
[2804] Fix | Delete
[2805] Fix | Delete
/* Input validation: */
[2806] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($keypair) !== self::CRYPTO_SIGN_KEYPAIRBYTES) {
[2807] Fix | Delete
throw new SodiumException('Argument 1 must be CRYPTO_SIGN_KEYPAIRBYTES long.');
[2808] Fix | Delete
}
[2809] Fix | Delete
[2810] Fix | Delete
if (self::useNewSodiumAPI()) {
[2811] Fix | Delete
return sodium_crypto_sign_secretkey($keypair);
[2812] Fix | Delete
}
[2813] Fix | Delete
if (self::use_fallback('crypto_sign_secretkey')) {
[2814] Fix | Delete
return (string) call_user_func('\\Sodium\\crypto_sign_secretkey', $keypair);
[2815] Fix | Delete
}
[2816] Fix | Delete
if (PHP_INT_SIZE === 4) {
[2817] Fix | Delete
return ParagonIE_Sodium_Core32_Ed25519::secretkey($keypair);
[2818] Fix | Delete
}
[2819] Fix | Delete
return ParagonIE_Sodium_Core_Ed25519::secretkey($keypair);
[2820] Fix | Delete
}
[2821] Fix | Delete
[2822] Fix | Delete
/**
[2823] Fix | Delete
* Calculate the Ed25519 signature of a message and return ONLY the signature.
[2824] Fix | Delete
*
[2825] Fix | Delete
* Algorithm: Ed25519 (EdDSA over Curve25519)
[2826] Fix | Delete
*
[2827] Fix | Delete
* @param string $message Message to be signed
[2828] Fix | Delete
* @param string $secretKey Secret signing key
[2829] Fix | Delete
* @return string Digital signature
[2830] Fix | Delete
* @throws SodiumException
[2831] Fix | Delete
* @throws TypeError
[2832] Fix | Delete
* @psalm-suppress MixedArgument
[2833] Fix | Delete
*/
[2834] Fix | Delete
public static function crypto_sign_detached($message, $secretKey)
[2835] Fix | Delete
{
[2836] Fix | Delete
/* Type checks: */
[2837] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($message, 'string', 1);
[2838] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($secretKey, 'string', 2);
[2839] Fix | Delete
[2840] Fix | Delete
/* Input validation: */
[2841] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($secretKey) !== self::CRYPTO_SIGN_SECRETKEYBYTES) {
[2842] Fix | Delete
throw new SodiumException('Argument 2 must be CRYPTO_SIGN_SECRETKEYBYTES long.');
[2843] Fix | Delete
}
[2844] Fix | Delete
[2845] Fix | Delete
if (self::useNewSodiumAPI()) {
[2846] Fix | Delete
return sodium_crypto_sign_detached($message, $secretKey);
[2847] Fix | Delete
}
[2848] Fix | Delete
if (self::use_fallback('crypto_sign_detached')) {
[2849] Fix | Delete
return (string) call_user_func('\\Sodium\\crypto_sign_detached', $message, $secretKey);
[2850] Fix | Delete
}
[2851] Fix | Delete
if (PHP_INT_SIZE === 4) {
[2852] Fix | Delete
return ParagonIE_Sodium_Crypto32::sign_detached($message, $secretKey);
[2853] Fix | Delete
}
[2854] Fix | Delete
return ParagonIE_Sodium_Crypto::sign_detached($message, $secretKey);
[2855] Fix | Delete
}
[2856] Fix | Delete
[2857] Fix | Delete
/**
[2858] Fix | Delete
* Verify the Ed25519 signature of a message.
[2859] Fix | Delete
*
[2860] Fix | Delete
* @param string $signature Digital sginature
[2861] Fix | Delete
* @param string $message Message to be verified
[2862] Fix | Delete
* @param string $publicKey Public key
[2863] Fix | Delete
* @return bool TRUE if this signature is good for this public key;
[2864] Fix | Delete
* FALSE otherwise
[2865] Fix | Delete
* @throws SodiumException
[2866] Fix | Delete
* @throws TypeError
[2867] Fix | Delete
* @psalm-suppress MixedArgument
[2868] Fix | Delete
*/
[2869] Fix | Delete
public static function crypto_sign_verify_detached($signature, $message, $publicKey)
[2870] Fix | Delete
{
[2871] Fix | Delete
/* Type checks: */
[2872] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($signature, 'string', 1);
[2873] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($message, 'string', 2);
[2874] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($publicKey, 'string', 3);
[2875] Fix | Delete
[2876] Fix | Delete
/* Input validation: */
[2877] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($signature) !== self::CRYPTO_SIGN_BYTES) {
[2878] Fix | Delete
throw new SodiumException('Argument 1 must be CRYPTO_SIGN_BYTES long.');
[2879] Fix | Delete
}
[2880] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($publicKey) !== self::CRYPTO_SIGN_PUBLICKEYBYTES) {
[2881] Fix | Delete
throw new SodiumException('Argument 3 must be CRYPTO_SIGN_PUBLICKEYBYTES long.');
[2882] Fix | Delete
}
[2883] Fix | Delete
[2884] Fix | Delete
if (self::useNewSodiumAPI()) {
[2885] Fix | Delete
return sodium_crypto_sign_verify_detached($signature, $message, $publicKey);
[2886] Fix | Delete
}
[2887] Fix | Delete
if (self::use_fallback('crypto_sign_verify_detached')) {
[2888] Fix | Delete
return (bool) call_user_func(
[2889] Fix | Delete
'\\Sodium\\crypto_sign_verify_detached',
[2890] Fix | Delete
$signature,
[2891] Fix | Delete
$message,
[2892] Fix | Delete
$publicKey
[2893] Fix | Delete
);
[2894] Fix | Delete
}
[2895] Fix | Delete
if (PHP_INT_SIZE === 4) {
[2896] Fix | Delete
return ParagonIE_Sodium_Crypto32::sign_verify_detached($signature, $message, $publicKey);
[2897] Fix | Delete
}
[2898] Fix | Delete
return ParagonIE_Sodium_Crypto::sign_verify_detached($signature, $message, $publicKey);
[2899] Fix | Delete
}
[2900] Fix | Delete
[2901] Fix | Delete
/**
[2902] Fix | Delete
* Convert an Ed25519 public key to a Curve25519 public key
[2903] Fix | Delete
*
[2904] Fix | Delete
* @param string $pk
[2905] Fix | Delete
* @return string
[2906] Fix | Delete
* @throws SodiumException
[2907] Fix | Delete
* @throws TypeError
[2908] Fix | Delete
* @psalm-suppress MixedArgument
[2909] Fix | Delete
*/
[2910] Fix | Delete
public static function crypto_sign_ed25519_pk_to_curve25519($pk)
[2911] Fix | Delete
{
[2912] Fix | Delete
/* Type checks: */
[2913] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($pk, 'string', 1);
[2914] Fix | Delete
[2915] Fix | Delete
/* Input validation: */
[2916] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($pk) < self::CRYPTO_SIGN_PUBLICKEYBYTES) {
[2917] Fix | Delete
throw new SodiumException('Argument 1 must be at least CRYPTO_SIGN_PUBLICKEYBYTES long.');
[2918] Fix | Delete
}
[2919] Fix | Delete
if (self::useNewSodiumAPI()) {
[2920] Fix | Delete
if (is_callable('crypto_sign_ed25519_pk_to_curve25519')) {
[2921] Fix | Delete
return (string) sodium_crypto_sign_ed25519_pk_to_curve25519($pk);
[2922] Fix | Delete
}
[2923] Fix | Delete
}
[2924] Fix | Delete
if (self::use_fallback('crypto_sign_ed25519_pk_to_curve25519')) {
[2925] Fix | Delete
return (string) call_user_func('\\Sodium\\crypto_sign_ed25519_pk_to_curve25519', $pk);
[2926] Fix | Delete
}
[2927] Fix | Delete
if (PHP_INT_SIZE === 4) {
[2928] Fix | Delete
return ParagonIE_Sodium_Core32_Ed25519::pk_to_curve25519($pk);
[2929] Fix | Delete
}
[2930] Fix | Delete
return ParagonIE_Sodium_Core_Ed25519::pk_to_curve25519($pk);
[2931] Fix | Delete
}
[2932] Fix | Delete
[2933] Fix | Delete
/**
[2934] Fix | Delete
* Convert an Ed25519 secret key to a Curve25519 secret key
[2935] Fix | Delete
*
[2936] Fix | Delete
* @param string $sk
[2937] Fix | Delete
* @return string
[2938] Fix | Delete
* @throws SodiumException
[2939] Fix | Delete
* @throws TypeError
[2940] Fix | Delete
* @psalm-suppress MixedArgument
[2941] Fix | Delete
*/
[2942] Fix | Delete
public static function crypto_sign_ed25519_sk_to_curve25519($sk)
[2943] Fix | Delete
{
[2944] Fix | Delete
/* Type checks: */
[2945] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($sk, 'string', 1);
[2946] Fix | Delete
[2947] Fix | Delete
/* Input validation: */
[2948] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($sk) < self::CRYPTO_SIGN_SEEDBYTES) {
[2949] Fix | Delete
throw new SodiumException('Argument 1 must be at least CRYPTO_SIGN_SEEDBYTES long.');
[2950] Fix | Delete
}
[2951] Fix | Delete
if (self::useNewSodiumAPI()) {
[2952] Fix | Delete
if (is_callable('crypto_sign_ed25519_sk_to_curve25519')) {
[2953] Fix | Delete
return sodium_crypto_sign_ed25519_sk_to_curve25519($sk);
[2954] Fix | Delete
}
[2955] Fix | Delete
}
[2956] Fix | Delete
if (self::use_fallback('crypto_sign_ed25519_sk_to_curve25519')) {
[2957] Fix | Delete
return (string) call_user_func('\\Sodium\\crypto_sign_ed25519_sk_to_curve25519', $sk);
[2958] Fix | Delete
}
[2959] Fix | Delete
[2960] Fix | Delete
$h = hash('sha512', ParagonIE_Sodium_Core_Util::substr($sk, 0, 32), true);
[2961] Fix | Delete
$h[0] = ParagonIE_Sodium_Core_Util::intToChr(
[2962] Fix | Delete
ParagonIE_Sodium_Core_Util::chrToInt($h[0]) & 248
[2963] Fix | Delete
);
[2964] Fix | Delete
$h[31] = ParagonIE_Sodium_Core_Util::intToChr(
[2965] Fix | Delete
(ParagonIE_Sodium_Core_Util::chrToInt($h[31]) & 127) | 64
[2966] Fix | Delete
);
[2967] Fix | Delete
return ParagonIE_Sodium_Core_Util::substr($h, 0, 32);
[2968] Fix | Delete
}
[2969] Fix | Delete
[2970] Fix | Delete
/**
[2971] Fix | Delete
* Expand a key and nonce into a keystream of pseudorandom bytes.
[2972] Fix | Delete
*
[2973] Fix | Delete
* @param int $len Number of bytes desired
[2974] Fix | Delete
* @param string $nonce Number to be used Once; must be 24 bytes
[2975] Fix | Delete
* @param string $key XSalsa20 key
[2976] Fix | Delete
* @return string Pseudorandom stream that can be XORed with messages
[2977] Fix | Delete
* to provide encryption (but not authentication; see
[2978] Fix | Delete
* Poly1305 or crypto_auth() for that, which is not
[2979] Fix | Delete
* optional for security)
[2980] Fix | Delete
* @throws SodiumException
[2981] Fix | Delete
* @throws TypeError
[2982] Fix | Delete
* @psalm-suppress MixedArgument
[2983] Fix | Delete
*/
[2984] Fix | Delete
public static function crypto_stream($len, $nonce, $key)
[2985] Fix | Delete
{
[2986] Fix | Delete
/* Type checks: */
[2987] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($len, 'int', 1);
[2988] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($nonce, 'string', 2);
[2989] Fix | Delete
ParagonIE_Sodium_Core_Util::declareScalarType($key, 'string', 3);
[2990] Fix | Delete
[2991] Fix | Delete
/* Input validation: */
[2992] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($nonce) !== self::CRYPTO_STREAM_NONCEBYTES) {
[2993] Fix | Delete
throw new SodiumException('Argument 2 must be CRYPTO_SECRETBOX_NONCEBYTES long.');
[2994] Fix | Delete
}
[2995] Fix | Delete
if (ParagonIE_Sodium_Core_Util::strlen($key) !== self::CRYPTO_STREAM_KEYBYTES) {
[2996] Fix | Delete
throw new SodiumException('Argument 3 must be CRYPTO_STREAM_KEYBYTES long.');
[2997] Fix | Delete
}
[2998] Fix | Delete
[2999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function