Diff: STRATO-apps/wordpress_03/app/wp-includes/sodium_compat/src/Core/ChaCha20/IetfCtx.php

Keine Baseline-Datei – Diff nur gegen leer.
Zur Liste
1 -
1 + <?php
2 +
3 + if (class_exists('ParagonIE_Sodium_Core_ChaCha20_IetfCtx', false)) {
4 + return;
5 + }
6 +
7 + /**
8 + * Class ParagonIE_Sodium_Core_ChaCha20_IetfCtx
9 + */
10 + class ParagonIE_Sodium_Core_ChaCha20_IetfCtx extends ParagonIE_Sodium_Core_ChaCha20_Ctx
11 + {
12 + /**
13 + * ParagonIE_Sodium_Core_ChaCha20_IetfCtx constructor.
14 + *
15 + * @internal You should not use this directly from another application
16 + *
17 + * @param string $key ChaCha20 key.
18 + * @param string $iv Initialization Vector (a.k.a. nonce).
19 + * @param string $counter The initial counter value.
20 + * Defaults to 4 0x00 bytes.
21 + * @throws InvalidArgumentException
22 + * @throws TypeError
23 + */
24 + public function __construct($key = '', $iv = '', $counter = '')
25 + {
26 + if (self::strlen($iv) !== 12) {
27 + throw new InvalidArgumentException('ChaCha20 expects a 96-bit nonce in IETF mode.');
28 + }
29 + $counter = $this->initCounter($counter);
30 + parent::__construct($key, self::substr($iv, 0, 8), $counter);
31 + $this->container[12] = self::load_4(self::substr($counter, 0, 4));
32 + $this->container[13] = self::load_4(self::substr($iv, 0, 4));
33 + $this->container[14] = self::load_4(self::substr($iv, 4, 4));
34 + $this->container[15] = self::load_4(self::substr($iv, 8, 4));
35 + }
36 + }
37 +