def sign(self, msg, key):
        """
        Create a signature over a message as defined in RFC7515 using an
        RSA key

        :param msg: the message.
        :type msg: bytes
        :returns: bytes, the signature of data.
        :rtype: bytes
        """

        if not isinstance(key, rsa.RSAPrivateKey):
            raise TypeError(
                "The key must be an instance of rsa.RSAPrivateKey")
        sig = key.sign(msg, self.padding, self.hash)
        return sig
Create a signature over a message as defined in RFC7515 using an
        RSA key

        :param msg: the message.
        :type msg: bytes
        :returns: bytes, the signature of data.
        :rtype: bytes