def cert_to_synth(cert_str, format):
    """Generates flowsynth of a TLS handshake for the given certificate
    cert_str -- A string of a PEM or DER encoded certificate
    format -- "PEM or "DER"
    """

    cert_bytes = ""
    if format == "PEM":
        # validate?
        cert_bytes = pem_to_der(cert_str)
    elif format == "DER":
        cert_bytes = cert_str
    handshake_len_bytes = struct.pack(">H", len(cert_bytes) + 10)
    handshake_len_synth_bytes = to_synth_bytes(handshake_len_bytes)
    cert_handshake_len_bytes = struct.pack(">I", len(cert_bytes) + 6)[1:]
    cert_handshake_len_synth_bytes = to_synth_bytes(cert_handshake_len_bytes)
    certs_len_bytes = struct.pack(">I", len(cert_bytes) + 3)[1:]
    certs_len_synth_bytes = to_synth_bytes(certs_len_bytes)
    cert_len_bytes = struct.pack(">I", len(cert_bytes))[1:]
    cert_len_synth_bytes = to_synth_bytes(cert_len_bytes)
    return "".join(
        [
            SYNTH_START,
            SYNTH_CERTIFICATES.format(
                handshake_len_synth_bytes,
                cert_handshake_len_synth_bytes,
                certs_len_synth_bytes,
                cert_len_synth_bytes,
                to_synth_bytes(cert_bytes),
            ),
            SYNTH_END,
        ]
    )
Generates flowsynth of a TLS handshake for the given certificate
    cert_str -- A string of a PEM or DER encoded certificate
    format -- "PEM or "DER"
    
app/certsynth.py