- Timestamp:
- 12/09/2019 04:40:11 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/sodium_compat/src/Core/XChaCha20.php
r46586 r46858 40 40 * @internal You should not use this directly from another application 41 41 * 42 * @param int $len 43 * @param string $nonce 44 * @param string $key 45 * @return string 46 * @throws SodiumException 47 * @throws TypeError 48 */ 49 public static function ietfStream($len = 64, $nonce = '', $key = '') 50 { 51 if (self::strlen($nonce) !== 24) { 52 throw new SodiumException('Nonce must be 24 bytes long'); 53 } 54 return self::encryptBytes( 55 new ParagonIE_Sodium_Core_ChaCha20_IetfCtx( 56 self::hChaCha20( 57 self::substr($nonce, 0, 16), 58 $key 59 ), 60 "\x00\x00\x00\x00" . self::substr($nonce, 16, 8) 61 ), 62 str_repeat("\x00", $len) 63 ); 64 } 65 66 /** 67 * @internal You should not use this directly from another application 68 * 42 69 * @param string $message 43 70 * @param string $nonce … … 62 89 ); 63 90 } 91 92 /** 93 * @internal You should not use this directly from another application 94 * 95 * @param string $message 96 * @param string $nonce 97 * @param string $key 98 * @param string $ic 99 * @return string 100 * @throws SodiumException 101 * @throws TypeError 102 */ 103 public static function ietfStreamXorIc($message, $nonce = '', $key = '', $ic = '') 104 { 105 if (self::strlen($nonce) !== 24) { 106 throw new SodiumException('Nonce must be 24 bytes long'); 107 } 108 return self::encryptBytes( 109 new ParagonIE_Sodium_Core_ChaCha20_IetfCtx( 110 self::hChaCha20(self::substr($nonce, 0, 16), $key), 111 "\x00\x00\x00\x00" . self::substr($nonce, 16, 8), 112 $ic 113 ), 114 $message 115 ); 116 } 64 117 }
Note: See TracChangeset
for help on using the changeset viewer.