/* create a new card from certs and keys  */
static VCard* vcard_emul_make_card(VReader *reader, unsigned char *const *certs, int *cert_len, VCardKey *keys[], int cert_count)
/* create a new card from certs and keys  */
static VCard* vcard_emul_make_card(VReader *reader, unsigned char *const *certs, int *cert_len, VCardKey *keys[], int cert_count)
{
    VCardEmul *vcard_emul;
    VCard *vcard;
    PK11SlotInfo *slot;
    VCardEmulType type;
    const char *params;
    type = vcard_emul_get_type(reader);
    if (type == VCARD_EMUL_NONE) {
        return NULL;
    }
    slot = vcard_emul_reader_get_slot(reader);
    if (slot == NULL) {
        return NULL;
    }
    params = vcard_emul_get_type_params(reader);
    vcard_emul = vcard_emul_new_card(slot);
    if (vcard_emul == NULL) {
        return NULL;
    }
    vcard = vcard_new(vcard_emul, vcard_emul_delete_card);
    if (vcard == NULL) {
        vcard_emul_delete_card(vcard_emul);
        return NULL;
    }
    vcard_init(reader, vcard, type, params, certs, cert_len, keys, cert_count);
    return vcard;
}