/** * @param string $keyMaterial - The actual key data */ public function __construct(string $keyMaterial = '', ...$args) { if (CryptoUtil::safeStrlen($keyMaterial) !== \Sodium\CRYPTO_AUTH_KEYBYTES) { throw new InvalidKey('Authentication key must be CRYPTO_AUTH_KEYBYTES bytes long'); } parent::__construct($keyMaterial, true); }
/** * @param HiddenString $keyMaterial - The actual key data * @throws InvalidKey */ public function __construct(HiddenString $keyMaterial) { if (CryptoUtil::safeStrlen($keyMaterial->getString()) !== \Sodium\CRYPTO_STREAM_KEYBYTES) { throw new InvalidKey('Encryption key must be CRYPTO_STREAM_KEYBYTES bytes long'); } parent::__construct($keyMaterial); }
/** * @param HiddenString $keyMaterial - The actual key data * @throws InvalidKey */ public function __construct(HiddenString $keyMaterial) { if (CryptoUtil::safeStrlen($keyMaterial->getString()) !== \Sodium\CRYPTO_AUTH_KEYBYTES) { throw new InvalidKey('Authentication key must be CRYPTO_AUTH_KEYBYTES bytes long'); } parent::__construct($keyMaterial); $this->isSigningKey = true; }