private function _validateIv($iv = null)
    {
        if (self::$allowedCiphers[$this->cipher]['iv']) {
            $this->blockSize = openssl_cipher_iv_length($this->cipher);

            $ivLength = mb_strlen($iv, '8bit');
            if ($ivLength !== $this->blockSize) {
                throw new InvalidArgumentException(sprintf(
                    'Initialization vector of %d bytes is required for cipher "%s", %d given.',
                    $this->blockSize,
                    $this->cipher,
                    $ivLength
                ));
            }
        }
    }