def METHOD_NAME(data, priv_key, out_file):
    """Signs the data (bytes) with the private key (file path)."""
    """Save the signed firmware to out_file (file path)."""
    sha256 = hashlib.sha256(data)
    signcmd = [ 'openssl', 'rsautl', '-sign', '-inkey', priv_key ]
    proc = subprocess.Popen(signcmd, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
    signout, signerr = proc.communicate(input=sha256.digest())
    if proc.returncode:
        sys.stderr.write("OpenSSL returned an error legacy signing the binary: " + str(proc.returncode) + "\nSTDERR: " + str(signerr))
    else:
        with open(out_file, "wb") as out:
            out.write(data)
            out.write(signout)
            out.write(struct.pack("<L", len(signout))) # u32, little-endian
            sys.stderr.write("Legacy signed binary: " + out_file + "\n")