public function ParagonIE_Sodium_Core32_Poly1305_State::__construct in Automatic Updates 7
Same name and namespace in other branches
- 8 vendor/paragonie/sodium_compat/src/Core32/Poly1305/State.php \ParagonIE_Sodium_Core32_Poly1305_State::__construct()
ParagonIE_Sodium_Core32_Poly1305_State constructor.
@internal You should not use this directly from another application
Parameters
string $key:
Throws
InvalidArgumentException
SodiumException
TypeError
File
- vendor/
paragonie/ sodium_compat/ src/ Core32/ Poly1305/ State.php, line 52
Class
- ParagonIE_Sodium_Core32_Poly1305_State
- Class ParagonIE_Sodium_Core32_Poly1305_State
Code
public function __construct($key = '') {
if (self::strlen($key) < 32) {
throw new InvalidArgumentException('Poly1305 requires a 32-byte key');
}
/* r &= 0xffffffc0ffffffc0ffffffc0fffffff */
$this->r = array(
// st->r[0] = ...
ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 0, 4))
->setUnsignedInt(true)
->mask(0x3ffffff),
// st->r[1] = ...
ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 3, 4))
->setUnsignedInt(true)
->shiftRight(2)
->mask(0x3ffff03),
// st->r[2] = ...
ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 6, 4))
->setUnsignedInt(true)
->shiftRight(4)
->mask(0x3ffc0ff),
// st->r[3] = ...
ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 9, 4))
->setUnsignedInt(true)
->shiftRight(6)
->mask(0x3f03fff),
// st->r[4] = ...
ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 12, 4))
->setUnsignedInt(true)
->shiftRight(8)
->mask(0xfffff),
);
/* h = 0 */
$this->h = array(
new ParagonIE_Sodium_Core32_Int32(array(
0,
0,
), true),
new ParagonIE_Sodium_Core32_Int32(array(
0,
0,
), true),
new ParagonIE_Sodium_Core32_Int32(array(
0,
0,
), true),
new ParagonIE_Sodium_Core32_Int32(array(
0,
0,
), true),
new ParagonIE_Sodium_Core32_Int32(array(
0,
0,
), true),
);
/* save pad for later */
$this->pad = array(
ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 16, 4))
->setUnsignedInt(true)
->toInt64(),
ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 20, 4))
->setUnsignedInt(true)
->toInt64(),
ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 24, 4))
->setUnsignedInt(true)
->toInt64(),
ParagonIE_Sodium_Core32_Int32::fromReverseString(self::substr($key, 28, 4))
->setUnsignedInt(true)
->toInt64(),
);
$this->leftover = 0;
$this->final = false;
}