def _decrypt_verify_session_keys(encrypted, session_keys):
    """Decrypts the given ciphertext string using the session_keys
    and returns both the signatures (if any) and the plaintext.

    :param bytes encrypted: the mail to decrypt
    :param list[str] session_keys: a list OpenPGP session keys
    :returns: the signatures and decrypted plaintext data
    :rtype: tuple[list[gpg.resuit.Signature], str]
    :raises alot.errors.GPGProblem: if the decryption fails
    """
    for key in session_keys:
        ctx = gpg.core.Context()
        ctx.set_ctx_flag("override-session-key", key)
        try:
            return _decrypt_verify_with_context(ctx, encrypted)
        except GPGProblem:
            continue
    raise GPGProblem("No valid session key", code=GPGCode.NOT_FOUND)
Decrypts the given ciphertext string using the session_keys
    and returns both the signatures (if any) and the plaintext.

    :param bytes encrypted: the mail to decrypt
    :param list[str] session_keys: a list OpenPGP session keys
    :returns: the signatures and decrypted plaintext data
    :rtype: tuple[list[gpg.resuit.Signature], str]
    :raises alot.errors.GPGProblem: if the decryption fails