- Timestamp:
- 10/06/2025 03:46:40 PM (6 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/sodium_compat/src/Core/ChaCha20/Ctx.php
r51591 r60905 51 51 $this->container[11] = self::load_4(self::substr($key, 28, 4)); 52 52 53 if (empty($counter)) { 54 $this->container[12] = 0; 55 $this->container[13] = 0; 56 } else { 57 $this->container[12] = self::load_4(self::substr($counter, 0, 4)); 58 $this->container[13] = self::load_4(self::substr($counter, 4, 4)); 59 } 53 $counter = $this->initCounter($counter); 54 $this->container[12] = self::load_4(self::substr($counter, 0, 4)); 55 $this->container[13] = self::load_4(self::substr($counter, 4, 4)); 60 56 $this->container[14] = self::load_4(self::substr($iv, 0, 4)); 61 57 $this->container[15] = self::load_4(self::substr($iv, 4, 4)); … … 121 117 : null; 122 118 } 119 120 /** 121 * Initialize (pad) a counter value. 122 * @throws SodiumException 123 * 124 * @param string $ctr 125 * @return string 126 */ 127 public function initCounter( 128 #[SensitiveParameter] 129 $ctr 130 ) { 131 $len = self::strlen($ctr); 132 if ($len === 0) { 133 return str_repeat("\0", 8); 134 } 135 if ($len < 8) { 136 return $ctr . str_repeat("\0", 8 - $len); 137 } 138 if ($len > 8) { 139 throw new SodiumException("counter cannot be more than 8 bytes"); 140 } 141 return $ctr; 142 } 123 143 }
Note: See TracChangeset
for help on using the changeset viewer.