'Sign the ``msg`` using ``key``.'

def sign(self, key, msg):

    try:
        signer = key.signer(self.padding, self.hash)
    except AttributeError as error:
        logger.debug(error, exc_info=True)
        raise errors.Error('Public    key    cannot    be    used    for    signing')
    except ValueError as error:
        logger.debug(error, exc_info=True)
        raise errors.Error(str(error))
    signer.update(msg)
    try:
        return signer.finalize()
    except ValueError as error:
        logger.debug(error, exc_info=True)
        raise errors.Error(str(error))
