[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/sodium_compat/src/Core32/ -> XSalsa20.php (source)

   1  <?php
   2  
   3  if (class_exists('ParagonIE_Sodium_Core32_XSalsa20', false)) {
   4      return;
   5  }
   6  
   7  /**
   8   * Class ParagonIE_Sodium_Core32_XSalsa20
   9   */
  10  abstract class ParagonIE_Sodium_Core32_XSalsa20 extends ParagonIE_Sodium_Core32_HSalsa20
  11  {
  12      /**
  13       * Expand a key and nonce into an xsalsa20 keystream.
  14       *
  15       * @internal You should not use this directly from another application
  16       *
  17       * @param int $len
  18       * @param string $nonce
  19       * @param string $key
  20       * @return string
  21       * @throws SodiumException
  22       * @throws TypeError
  23       */
  24      public static function xsalsa20($len, $nonce, $key)
  25      {
  26          $ret = self::salsa20(
  27              $len,
  28              self::substr($nonce, 16, 8),
  29              self::hsalsa20($nonce, $key)
  30          );
  31          return $ret;
  32      }
  33  
  34      /**
  35       * Encrypt a string with XSalsa20. Doesn't provide integrity.
  36       *
  37       * @internal You should not use this directly from another application
  38       *
  39       * @param string $message
  40       * @param string $nonce
  41       * @param string $key
  42       * @return string
  43       * @throws SodiumException
  44       * @throws TypeError
  45       */
  46      public static function xsalsa20_xor($message, $nonce, $key)
  47      {
  48          return self::xorStrings(
  49              $message,
  50              self::xsalsa20(
  51                  self::strlen($message),
  52                  $nonce,
  53                  $key
  54              )
  55          );
  56      }
  57  }


Generated: Thu Nov 21 01:00:03 2024 Cross-referenced by PHPXref 0.7.1