<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def gen_signature(priv_path, pub_path, sign_path, passphrase=None):
    '''
    creates a signature for the given public-key with
    the given private key and writes it to sign_path
    '''

    with salt.utils.files.fopen(pub_path) as fp_:
        mpub_64 = fp_.read()

    mpub_sig = sign_message(priv_path, mpub_64, passphrase)
    mpub_sig_64 = binascii.b2a_base64(mpub_sig)
    if os.path.isfile(sign_path):
        return False
    log.trace(
        'Calculating signature for %s with %s',
        os.path.basename(pub_path), os.path.basename(priv_path)
    )

    if os.path.isfile(sign_path):
        log.trace(
            'Signature file %s already exists, please remove it first and '
            'try again', sign_path
        )
    else:
        with salt.utils.files.fopen(sign_path, 'wb+') as sig_f:
            sig_f.write(salt.utils.stringutils.to_bytes(mpub_sig_64))
        log.trace('Wrote signature to %s', sign_path)
    return True