public function signStream($stream, $privateKey)
    {
        try {
            $virgilSourceStream = new VirgilStreamDataSource($stream);
            $virgilSourceStream->reset();

            return (new CryptoVirgilStreamSigner($this->hashAlgorithm))->sign(
                $virgilSourceStream,
                $privateKey
            );
        } catch (Exception $exception) {
            throw new ContentSigningException($exception->getMessage(), $exception->getCode());
        }
    }