ParagonIE_Sodium_Compat::crypto_stream_xchacha20_xor_ic() – DANGER! UNAUTHENTICATED ENCRYPTION!
You appear to be a bot. Output may be restricted
Description
DANGER! UNAUTHENTICATED ENCRYPTION!
Unless you are following expert advice, do not use this feature. Algorithm: XChaCha20 This DOES NOT provide ciphertext integrity.
Usage
$string = ParagonIE_Sodium_Compat::crypto_stream_xchacha20_xor_ic( $message, $nonce, $counter, $key, $dontFallback );
Parameters
- $message
- ( string ) required – Plaintext message
- $nonce
- ( string ) required – Number to be used Once; must be 24 bytes
- $counter
- ( int ) required –
- $key
- ( string ) required – Encryption key
- $dontFallback
- ( bool ) optional –
Returns
string Encrypted text which is vulnerable to chosen- ciphertext attacks unless you implement some other mitigation to the ciphertext (i.e. Encrypt then MAC)
Source
File name: wordpress/wp-includes/sodium_compat/src/Compat.php
Lines:
public static function crypto_stream_xchacha20_xor_ic($message, $nonce, $counter, $key, $dontFallback = false) { /* Type checks: */ ParagonIE_Sodium_Core_Util::ParagonIE_Sodium_Core_Util::declareScalarType($message, 'string', 1); ParagonIE_Sodium_Core_Util::ParagonIE_Sodium_Core_Util::declareScalarType($nonce, 'string', 2); ParagonIE_Sodium_Core_Util::ParagonIE_Sodium_Core_Util::declareScalarType($counter, 'int', 3); ParagonIE_Sodium_Core_Util::ParagonIE_Sodium_Core_Util::declareScalarType($key, 'string', 4); /* Input validation: */ if (ParagonIE_Sodium_Core_Util::ParagonIE_Sodium_Core_Util::strlen($nonce) !== self::CRYPTO_STREAM_XCHACHA20_NONCEBYTES) { throw new SodiumException('Argument 2 must be CRYPTO_SECRETBOX_XCHACHA20_NONCEBYTES long.'); } if (ParagonIE_Sodium_Core_Util::ParagonIE_Sodium_Core_Util::strlen($key) !== self::CRYPTO_STREAM_XCHACHA20_KEYBYTES) { throw new SodiumException('Argument 3 must be CRYPTO_SECRETBOX_XCHACHA20_KEYBYTES long.'); } if (is_callable('sodium_crypto_stream_xchacha20_xor_ic') && !$dontFallback) { return sodium_crypto_stream_xchacha20_xor_ic($message, $nonce, $counter, $key); } $ic = ParagonIE_Sodium_Core_Util::ParagonIE_Sodium_Core_Util::store64_le($counter); if (PHP_INT_SIZE === 4) { return ParagonIE_Sodium_Core32_XChaCha20::ParagonIE_Sodium_Core32_XChaCha20::streamXorIc($message, $nonce, $key, $ic); } return ParagonIE_Sodium_Core_XChaCha20::ParagonIE_Sodium_Core_XChaCha20::streamXorIc($message, $nonce, $key, $ic); }