diff --git a/src/libopensc/asn1.c b/src/libopensc/asn1.c index 8ae29c59..432e1251 100644 --- a/src/libopensc/asn1.c +++ b/src/libopensc/asn1.c @@ -26,10 +26,10 @@ #include #include -static int asn1_decode(struct sc_context *ctx, struct sc_asn1_entry *asn1, +static int asn1_decode(sc_context_t *ctx, struct sc_asn1_entry *asn1, const u8 *in, size_t len, const u8 **newp, size_t *len_left, int choice, int depth); -static int asn1_encode(struct sc_context *ctx, const struct sc_asn1_entry *asn1, +static int asn1_encode(sc_context_t *ctx, const struct sc_asn1_entry *asn1, u8 **ptr, size_t *size, int depth); static const char *tag2str(unsigned int tag) @@ -303,7 +303,7 @@ void sc_asn1_print_tags(const u8 * buf, size_t buflen) print_tags_recursive(buf, buf, buflen, 0); } -const u8 *sc_asn1_find_tag(struct sc_context *ctx, const u8 * buf, +const u8 *sc_asn1_find_tag(sc_context_t *ctx, const u8 * buf, size_t buflen, unsigned int tag_in, size_t *taglen_in) { size_t left = buflen, taglen; @@ -330,7 +330,7 @@ const u8 *sc_asn1_find_tag(struct sc_context *ctx, const u8 * buf, return NULL; } -const u8 *sc_asn1_skip_tag(struct sc_context *ctx, const u8 ** buf, size_t *buflen, +const u8 *sc_asn1_skip_tag(sc_context_t *ctx, const u8 ** buf, size_t *buflen, unsigned int tag_in, size_t *taglen_out) { const u8 *p = *buf; @@ -377,7 +377,7 @@ const u8 *sc_asn1_skip_tag(struct sc_context *ctx, const u8 ** buf, size_t *bufl return p; } -const u8 *sc_asn1_verify_tag(struct sc_context *ctx, const u8 * buf, size_t buflen, +const u8 *sc_asn1_verify_tag(sc_context_t *ctx, const u8 * buf, size_t buflen, unsigned int tag_in, size_t *taglen_out) { return sc_asn1_skip_tag(ctx, &buf, &buflen, tag_in, taglen_out); @@ -670,7 +670,7 @@ int sc_asn1_put_tag(int tag, const u8 * data, int datalen, u8 * out, int outlen, return 0; } -static int asn1_write_element(struct sc_context *ctx, unsigned int tag, +static int asn1_write_element(sc_context_t *ctx, unsigned int tag, const u8 * data, size_t datalen, u8 ** out, size_t * outlen) { u8 t; @@ -726,8 +726,8 @@ static const struct sc_asn1_entry c_asn1_path[4] = { { NULL } }; -static int asn1_decode_path(struct sc_context *ctx, const u8 *in, size_t len, - struct sc_path *path, int depth) +static int asn1_decode_path(sc_context_t *ctx, const u8 *in, size_t len, + sc_path_t *path, int depth) { int idx, count, r; struct sc_asn1_entry asn1_path[4]; @@ -755,12 +755,12 @@ static int asn1_decode_path(struct sc_context *ctx, const u8 *in, size_t len, return 0; } -static int asn1_encode_path(struct sc_context *ctx, const struct sc_path *path, +static int asn1_encode_path(sc_context_t *ctx, const sc_path_t *path, u8 **buf, size_t *bufsize, int depth) { int r; struct sc_asn1_entry asn1_path[4]; - struct sc_path tpath = *path; + sc_path_t tpath = *path; sc_copy_asn1_entry(c_asn1_path, asn1_path); sc_format_asn1_entry(asn1_path + 0, (void *) &tpath.value, (void *) &tpath.len, 1); @@ -789,7 +789,7 @@ static const struct sc_asn1_entry c_asn1_p15_obj[5] = { { NULL } }; -static int asn1_decode_p15_object(struct sc_context *ctx, const u8 *in, +static int asn1_decode_p15_object(sc_context_t *ctx, const u8 *in, size_t len, struct sc_asn1_pkcs15_object *obj, int depth) { @@ -816,7 +816,7 @@ static int asn1_decode_p15_object(struct sc_context *ctx, const u8 *in, return r; } -static int asn1_encode_p15_object(struct sc_context *ctx, const struct sc_asn1_pkcs15_object *obj, +static int asn1_encode_p15_object(sc_context_t *ctx, const struct sc_asn1_pkcs15_object *obj, u8 **buf, size_t *bufsize, int depth) { int r; @@ -848,13 +848,13 @@ static int asn1_encode_p15_object(struct sc_context *ctx, const struct sc_asn1_p return r; } -static int asn1_decode_entry(struct sc_context *ctx,struct sc_asn1_entry *entry, +static int asn1_decode_entry(sc_context_t *ctx,struct sc_asn1_entry *entry, const u8 *obj, size_t objlen, int depth) { void *parm = entry->parm; - int (*callback_func)(struct sc_context *nctx, void *arg, const u8 *nobj, + int (*callback_func)(sc_context_t *nctx, void *arg, const u8 *nobj, size_t nobjlen, int ndepth) = - (int (*)(struct sc_context *, void *, const u8 *, size_t, int)) parm; + (int (*)(sc_context_t *, void *, const u8 *, size_t, int)) parm; size_t *len = (size_t *) entry->arg; int r = 0; @@ -986,7 +986,7 @@ static int asn1_decode_entry(struct sc_context *ctx,struct sc_asn1_entry *entry, break; case SC_ASN1_PATH: if (entry->parm != NULL) - r = asn1_decode_path(ctx, obj, objlen, (struct sc_path *) parm, depth); + r = asn1_decode_path(ctx, obj, objlen, (sc_path_t *) parm, depth); break; case SC_ASN1_PKCS15_ID: if (entry->parm != NULL) { @@ -1022,7 +1022,7 @@ static int asn1_decode_entry(struct sc_context *ctx,struct sc_asn1_entry *entry, return 0; } -static int asn1_decode(struct sc_context *ctx, struct sc_asn1_entry *asn1, +static int asn1_decode(sc_context_t *ctx, struct sc_asn1_entry *asn1, const u8 *in, size_t len, const u8 **newp, size_t *len_left, int choice, int depth) { @@ -1114,25 +1114,25 @@ decode_ok: SC_FUNC_RETURN(ctx, 3, 0); } -int sc_asn1_decode(struct sc_context *ctx, struct sc_asn1_entry *asn1, +int sc_asn1_decode(sc_context_t *ctx, struct sc_asn1_entry *asn1, const u8 *in, size_t len, const u8 **newp, size_t *len_left) { return asn1_decode(ctx, asn1, in, len, newp, len_left, 0, 0); } -int sc_asn1_decode_choice(struct sc_context *ctx, struct sc_asn1_entry *asn1, +int sc_asn1_decode_choice(sc_context_t *ctx, struct sc_asn1_entry *asn1, const u8 *in, size_t len, const u8 **newp, size_t *len_left) { return asn1_decode(ctx, asn1, in, len, newp, len_left, 1, 0); } -static int asn1_encode_entry(struct sc_context *ctx, const struct sc_asn1_entry *entry, +static int asn1_encode_entry(sc_context_t *ctx, const struct sc_asn1_entry *entry, u8 **obj, size_t *objlen, int depth) { void *parm = entry->parm; - int (*callback_func)(struct sc_context *nctx, void *arg, u8 **nobj, + int (*callback_func)(sc_context_t *nctx, void *arg, u8 **nobj, size_t *nobjlen, int ndepth) = - (int (*)(struct sc_context *, void *, u8 **, size_t *, int)) parm; + (int (*)(sc_context_t *, void *, u8 **, size_t *, int)) parm; const size_t *len = (const size_t *) entry->arg; int r = 0; u8 * buf = NULL; @@ -1233,7 +1233,7 @@ static int asn1_encode_entry(struct sc_context *ctx, const struct sc_asn1_entry r = sc_asn1_encode_object_id(&buf, &buflen, (struct sc_object_id *) parm); break; case SC_ASN1_PATH: - r = asn1_encode_path(ctx, (const struct sc_path *) parm, &buf, &buflen, depth); + r = asn1_encode_path(ctx, (const sc_path_t *) parm, &buf, &buflen, depth); break; case SC_ASN1_PKCS15_ID: if (entry->parm != NULL) { @@ -1308,7 +1308,7 @@ no_object: return r; } -static int asn1_encode(struct sc_context *ctx, const struct sc_asn1_entry *asn1, +static int asn1_encode(sc_context_t *ctx, const struct sc_asn1_entry *asn1, u8 **ptr, size_t *size, int depth) { int r, idx = 0; @@ -1346,20 +1346,20 @@ static int asn1_encode(struct sc_context *ctx, const struct sc_asn1_entry *asn1, return 0; } -int sc_asn1_encode(struct sc_context *ctx, const struct sc_asn1_entry *asn1, +int sc_asn1_encode(sc_context_t *ctx, const struct sc_asn1_entry *asn1, u8 **ptr, size_t *size) { return asn1_encode(ctx, asn1, ptr, size, 0); } -int _sc_asn1_encode(struct sc_context *ctx, const struct sc_asn1_entry *asn1, +int _sc_asn1_encode(sc_context_t *ctx, const struct sc_asn1_entry *asn1, u8 **ptr, size_t *size, int depth) { return asn1_encode(ctx, asn1, ptr, size, depth); } int -_sc_asn1_decode(struct sc_context *ctx, struct sc_asn1_entry *asn1, +_sc_asn1_decode(sc_context_t *ctx, struct sc_asn1_entry *asn1, const u8 *in, size_t len, const u8 **newp, size_t *left, int choice, int depth) { diff --git a/src/libopensc/card-belpic.c b/src/libopensc/card-belpic.c index 8ad59c52..5ef1228b 100644 --- a/src/libopensc/card-belpic.c +++ b/src/libopensc/card-belpic.c @@ -591,7 +591,7 @@ static LONG SCR_SCardChangePIN(LPCTSTR szPinPadDll, const SCR_Card * pCard, BYTE #if defined(HAVE_GUI) ||defined(BELPIC_PIN_PAD) -static int belpic_calculate_lang(struct sc_card *card) +static int belpic_calculate_lang(sc_card_t *card) { struct belpic_priv_data *priv = DRVDATA(card); int lang = priv->lang; @@ -662,7 +662,7 @@ int belpic_set_language(const char *reader, int lang) #endif /* BELPIC_SET_LANG */ -static int str2lang(struct sc_context *ctx, char *lang) +static int str2lang(sc_context_t *ctx, char *lang) { if (memcmp(lang, "en", 2) == 0) return LNG_ENG; @@ -737,9 +737,9 @@ static int get_pref(const char *prefs, int prefs_len, const char *title, const c return -1; } -static int get_language(struct sc_card *card) +static int get_language(sc_card_t *card) { - struct sc_apdu apdu; + sc_apdu_t apdu; u8 prefs[240], *lg_value; u8 path[] = { 0x3F, 0x00, 0xDF, 0x01, 0x40, 0x39 }; int r, i, len; @@ -817,7 +817,7 @@ static int get_language(struct sc_card *card) #endif /* GET_LANG_FROM_CARD */ -static scconf_block *get_belpic_conf(struct sc_context *ctx, char *name) +static scconf_block *get_belpic_conf(sc_context_t *ctx, char *name) { scconf_block *conf_block = NULL, **blocks; int i; @@ -849,7 +849,7 @@ static void load_pin_pad_err(const char *reader_name, const char *pp_reader_lib, reader_name); } -static int belpic_load_pin_pad_lib(struct sc_card *card, struct belpic_priv_data *priv_data, +static int belpic_load_pin_pad_lib(sc_card_t *card, struct belpic_priv_data *priv_data, const char *reader_name, const char *pp_reader_lib) { LONG r; @@ -920,7 +920,7 @@ static int belpic_load_pin_pad_lib(struct sc_card *card, struct belpic_priv_data return 1; } -static int belpic_detect_pin_pad(struct sc_card *card, struct belpic_priv_data *priv_data) +static int belpic_detect_pin_pad(sc_card_t *card, struct belpic_priv_data *priv_data) { int i = 0; char *reader_name = card->reader->name, *conf_reader, *conf_lib; @@ -958,13 +958,13 @@ static int belpic_detect_pin_pad(struct sc_card *card, struct belpic_priv_data * } #endif /* BELPIC_PIN_PAD */ -static int belpic_finish(struct sc_card *card) +static int belpic_finish(sc_card_t *card) { free(DRVDATA(card)); return 0; } -static int belpic_match_card(struct sc_card *card) +static int belpic_match_card(sc_card_t *card) { int i; @@ -974,7 +974,7 @@ static int belpic_match_card(struct sc_card *card) return 1; } -static int belpic_init(struct sc_card *card) +static int belpic_init(sc_card_t *card) { struct belpic_priv_data *priv = NULL; scconf_block *conf_block; @@ -1058,14 +1058,14 @@ static int belpic_init(struct sc_card *card) return 0; } -static int belpic_select_file(struct sc_card *card, - const struct sc_path *in_path, struct sc_file **file_out) +static int belpic_select_file(sc_card_t *card, + const sc_path_t *in_path, sc_file_t **file_out) { - struct sc_context *ctx; - struct sc_apdu apdu; + sc_context_t *ctx; + sc_apdu_t apdu; u8 pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf; int r, pathlen; - struct sc_file *file = NULL; + sc_file_t *file = NULL; assert(card != NULL && in_path != NULL); ctx = card->ctx; @@ -1109,7 +1109,7 @@ static int belpic_select_file(struct sc_card *card, return 0; } -static int belpic_read_binary(struct sc_card *card, +static int belpic_read_binary(sc_card_t *card, unsigned int idx, u8 * buf, size_t count, unsigned long flags) { int r; @@ -1142,7 +1142,7 @@ static int belpic_read_binary(struct sc_card *card, #ifdef BELPIC_PIN_PAD /* Test the result code of the pin pad reader + the card's status bytes */ -static int belpic_pp_test_res(struct sc_card *card, int r, const u8 * card_status, int *tries_left) +static int belpic_pp_test_res(sc_card_t *card, int r, const u8 * card_status, int *tries_left) { #if 0 printf("PP res: 0x%0x (%d), SW1-SW2 = %02x %02x\n", r, r, card_status[0], card_status[1]); @@ -1172,7 +1172,7 @@ static int belpic_pp_test_res(struct sc_card *card, int r, const u8 * card_statu } /* Send the verify pin command to the pin pad reader + optionally show message */ -static int belpic_pp_verify(struct sc_card *card, SCR_Card * scr_card, +static int belpic_pp_verify(sc_card_t *card, SCR_Card * scr_card, struct belpic_priv_data *priv, int pin_ref, int pin_usage, int *tries_left) { @@ -1236,7 +1236,7 @@ static int belpic_pp_verify(struct sc_card *card, SCR_Card * scr_card, } /* Send the change pin command to the pin pad reader + show message */ -static int belpic_pp_change(struct sc_card *card, SCR_Card * scr_card, +static int belpic_pp_change(sc_card_t *card, SCR_Card * scr_card, struct belpic_priv_data *priv, int pin_ref, int *tries_left) { BYTE card_status[2]; @@ -1291,7 +1291,7 @@ static int belpic_pp_change(struct sc_card *card, SCR_Card * scr_card, #endif /* BELPIC_PIN_PAD */ -static int belpic_pin_cmd_usage(struct sc_card *card, struct sc_pin_cmd_data *data, +static int belpic_pin_cmd_usage(sc_card_t *card, struct sc_pin_cmd_data *data, int *tries_left, int pin_usage) { #ifdef BELPIC_PIN_PAD @@ -1341,7 +1341,7 @@ static int belpic_pin_cmd_usage(struct sc_card *card, struct sc_pin_cmd_data *da return iso_ops->pin_cmd(card, data, tries_left); } -static int belpic_pin_cmd(struct sc_card *card, struct sc_pin_cmd_data *data, int *tries_left) +static int belpic_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *data, int *tries_left) { if (SSO_OK(card->ctx) && data->cmd == SC_PIN_CMD_VERIFY) return 0; /* Don't log in right now, just say it's OK */ @@ -1355,10 +1355,10 @@ static int belpic_pin_cmd(struct sc_card *card, struct sc_pin_cmd_data *data, in * or by belpic-compute_signature the first fime an auth signature is done * and the allow_sso is true */ -static int belpic_askpin_verify(struct sc_card *card, int pin_usage) +static int belpic_askpin_verify(sc_card_t *card, int pin_usage) { struct sc_pin_cmd_data data; - struct sc_apdu apdu; + sc_apdu_t apdu; u8 pin_data[BELPIC_MAX_USER_PIN_LEN + 1]; int pin_len; int tries_left; @@ -1442,10 +1442,10 @@ static int belpic_askpin_verify(struct sc_card *card, int pin_usage) } #endif /* HAVE_GUI */ -static int belpic_set_security_env(struct sc_card *card, - const struct sc_security_env *env, int se_num) +static int belpic_set_security_env(sc_card_t *card, + const sc_security_env_t *env, int se_num) { - struct sc_apdu apdu; + sc_apdu_t apdu; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; int r; @@ -1515,7 +1515,7 @@ static int belpic_set_security_env(struct sc_card *card, return r; } -static int belpic_compute_signature(struct sc_card *card, const u8 * data, +static int belpic_compute_signature(sc_card_t *card, const u8 * data, size_t data_len, u8 * out, size_t outlen) { int r; @@ -1533,10 +1533,10 @@ static int belpic_compute_signature(struct sc_card *card, const u8 * data, return r; } -static int belpic_logout(struct sc_card *card) +static int belpic_logout(sc_card_t *card) { #if 0 - struct sc_apdu apdu; + sc_apdu_t apdu; int r; sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0xE6, 0x00, 0x00); diff --git a/src/libopensc/card-default.c b/src/libopensc/card-default.c index 4f24488a..bf40c62e 100644 --- a/src/libopensc/card-default.c +++ b/src/libopensc/card-default.c @@ -28,22 +28,22 @@ static struct sc_card_driver default_drv = { &default_ops }; -static int default_finish(struct sc_card *card) +static int default_finish(sc_card_t *card) { return 0; } -static int default_match_card(struct sc_card *card) +static int default_match_card(sc_card_t *card) { return 1; /* always match */ } -static int autodetect_class(struct sc_card *card) +static int autodetect_class(sc_card_t *card) { int classes[] = { 0x00, 0xC0, 0xB0, 0xA0 }; int class_count = sizeof(classes)/sizeof(int); u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; - struct sc_apdu apdu; + sc_apdu_t apdu; int i, r; if (card->ctx->debug >= 2) @@ -101,7 +101,7 @@ static int autodetect_class(struct sc_card *card) return 0; } -static int default_init(struct sc_card *card) +static int default_init(sc_card_t *card) { int r; diff --git a/src/libopensc/card-emv.c b/src/libopensc/card-emv.c index 9868b008..da1d9635 100644 --- a/src/libopensc/card-emv.c +++ b/src/libopensc/card-emv.c @@ -28,7 +28,7 @@ static struct sc_card_driver emv_drv = { &emv_ops }; -static int emv_finish(struct sc_card *card) +static int emv_finish(sc_card_t *card) { return 0; } @@ -78,7 +78,7 @@ static int parse_atr(const u8 *atr, size_t atr_len, int *t0_out, int *tx1, int * return 0; } -static int emv_match_card(struct sc_card *card) +static int emv_match_card(sc_card_t *card) { int i, r, hbcount = 0, match = 1; int tx1[4], tx2[4], t0; @@ -114,7 +114,7 @@ static int emv_match_card(struct sc_card *card) return match; } -static int emv_init(struct sc_card *card) +static int emv_init(sc_card_t *card) { card->drv_data = NULL; card->cla = 0x00; @@ -122,8 +122,8 @@ static int emv_init(struct sc_card *card) return 0; } -static int emv_select_file(struct sc_card *card, const struct sc_path *path, - struct sc_file **file) +static int emv_select_file(sc_card_t *card, const sc_path_t *path, + sc_file_t **file) { int r; struct sc_card_driver *iso_drv = sc_get_iso7816_driver(); diff --git a/src/libopensc/card-etoken.c b/src/libopensc/card-etoken.c index 3918f3b2..7becb335 100644 --- a/src/libopensc/card-etoken.c +++ b/src/libopensc/card-etoken.c @@ -54,12 +54,12 @@ static struct sc_atr_table etoken_atrs[] = { { NULL } }; -static int etoken_finish(struct sc_card *card) +static int etoken_finish(sc_card_t *card) { return 0; } -static int etoken_match_card(struct sc_card *card) +static int etoken_match_card(sc_card_t *card) { int i; @@ -69,7 +69,7 @@ static int etoken_match_card(struct sc_card *card) return 1; } -static int etoken_init(struct sc_card *card) +static int etoken_init(sc_card_t *card) { unsigned long flags; @@ -150,7 +150,7 @@ const static struct sc_card_error etoken_errors[] = { { 0x9850, SC_NO_ERROR, "over/underflow useing in/decrease"} }; -static int etoken_check_sw(struct sc_card *card, int sw1, int sw2) +static int etoken_check_sw(sc_card_t *card, int sw1, int sw2) { const int err_count = sizeof(etoken_errors)/sizeof(etoken_errors[0]); int i; @@ -238,9 +238,9 @@ static u8* etoken_extract_fid(u8 *buf, int buflen) { return NULL; } -static int etoken_list_files(struct sc_card *card, u8 *buf, size_t buflen) +static int etoken_list_files(sc_card_t *card, u8 *buf, size_t buflen) { - struct sc_apdu apdu; + sc_apdu_t apdu; u8 rbuf[256]; int r; int len; @@ -307,7 +307,7 @@ get_next_part: SC_FUNC_RETURN(card->ctx, 1, r); } -static void add_acl_entry(struct sc_file *file, int op, u8 byte) +static void add_acl_entry(sc_file_t *file, int op, u8 byte) { unsigned int method, key_ref = SC_AC_KEY_REF_NONE; @@ -330,7 +330,7 @@ static void add_acl_entry(struct sc_file *file, int op, u8 byte) sc_file_add_acl_entry(file, op, method, key_ref); } -static int acl_to_byte(const struct sc_acl_entry *e) +static int acl_to_byte(const sc_acl_entry_t *e) { if (e != NULL) { switch (e->method) { @@ -380,7 +380,7 @@ static const int ef_acl[9] = { -1 /* DEC */ }; -static void parse_sec_attr(struct sc_file *file, const u8 *buf, size_t len) +static void parse_sec_attr(sc_file_t *file, const u8 *buf, size_t len) { size_t i; const int *idx; @@ -393,9 +393,9 @@ static void parse_sec_attr(struct sc_file *file, const u8 *buf, size_t len) add_acl_entry(file, idx[i], (u8)((i < len) ? buf[i] : 0xFF)); } -static int etoken_select_file(struct sc_card *card, - const struct sc_path *in_path, - struct sc_file **file) +static int etoken_select_file(sc_card_t *card, + const sc_path_t *in_path, + sc_file_t **file) { int r; @@ -406,7 +406,7 @@ static int etoken_select_file(struct sc_card *card, SC_FUNC_RETURN(card->ctx, 1, r); } -static int etoken_create_file(struct sc_card *card, struct sc_file *file) +static int etoken_create_file(sc_card_t *card, sc_file_t *file) { int r, i, byte; const int *idx; @@ -504,9 +504,9 @@ out: SC_FUNC_RETURN(card->ctx, 1, r); * Restore the indicated SE */ static int -etoken_restore_security_env(struct sc_card *card, int se_num) +etoken_restore_security_env(sc_card_t *card, int se_num) { - struct sc_apdu apdu; + sc_apdu_t apdu; int r; SC_FUNC_CALLED(card->ctx, 1); @@ -533,11 +533,11 @@ etoken_restore_security_env(struct sc_card *card, int se_num) * XXX Need to find out how the Aladdin drivers do it. */ static int -etoken_set_security_env(struct sc_card *card, - const struct sc_security_env *env, +etoken_set_security_env(sc_card_t *card, + const sc_security_env_t *env, int se_num) { - struct sc_apdu apdu; + sc_apdu_t apdu; u8 data[3]; int key_id, r; @@ -583,11 +583,11 @@ etoken_set_security_env(struct sc_card *card, /* internal function to do the actual signature computation */ static int -do_compute_signature(struct sc_card *card, const u8 *data, size_t datalen, +do_compute_signature(sc_card_t *card, const u8 *data, size_t datalen, u8 *out, size_t outlen) { int r; - struct sc_apdu apdu; + sc_apdu_t apdu; u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; @@ -619,13 +619,13 @@ do_compute_signature(struct sc_card *card, const u8 *data, size_t datalen, } static int -etoken_compute_signature(struct sc_card *card, const u8 *data, size_t datalen, +etoken_compute_signature(sc_card_t *card, const u8 *data, size_t datalen, u8 *out, size_t outlen) { int r; u8 buf[SC_MAX_APDU_BUFFER_SIZE]; size_t buf_len = sizeof(buf), tmp_len = buf_len; - struct sc_context *ctx; + sc_context_t *ctx; assert(card != NULL && data != NULL && out != NULL); ctx = card->ctx; @@ -674,9 +674,9 @@ etoken_compute_signature(struct sc_card *card, const u8 *data, size_t datalen, } static int -etoken_lifecycle_get(struct sc_card *card, int *mode) +etoken_lifecycle_get(sc_card_t *card, int *mode) { - struct sc_apdu apdu; + sc_apdu_t apdu; u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; int r; @@ -718,9 +718,9 @@ etoken_lifecycle_get(struct sc_card *card, int *mode) } static int -etoken_lifecycle_set(struct sc_card *card, int *mode) +etoken_lifecycle_set(sc_card_t *card, int *mode) { - struct sc_apdu apdu; + sc_apdu_t apdu; int r; int current; @@ -754,10 +754,10 @@ etoken_lifecycle_set(struct sc_card *card, int *mode) } static int -etoken_put_data_oci(struct sc_card *card, +etoken_put_data_oci(sc_card_t *card, struct sc_cardctl_etoken_obj_info *args) { - struct sc_apdu apdu; + sc_apdu_t apdu; int r; SC_FUNC_CALLED(card->ctx, 1); @@ -782,10 +782,10 @@ etoken_put_data_oci(struct sc_card *card, } static int -etoken_put_data_seci(struct sc_card *card, +etoken_put_data_seci(sc_card_t *card, struct sc_cardctl_etoken_obj_info *args) { - struct sc_apdu apdu; + sc_apdu_t apdu; int r; memset(&apdu, 0, sizeof(apdu)); @@ -808,10 +808,10 @@ etoken_put_data_seci(struct sc_card *card, } static int -etoken_generate_key(struct sc_card *card, +etoken_generate_key(sc_card_t *card, struct sc_cardctl_etoken_genkey_info *args) { - struct sc_apdu apdu; + sc_apdu_t apdu; u8 data[8]; int r; @@ -853,7 +853,7 @@ etoken_generate_key(struct sc_card *card, static int etoken_get_serialnr(sc_card_t *card, sc_serial_number_t *serial) { int r; - struct sc_apdu apdu; + sc_apdu_t apdu; u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xca, 0x01, 0x81); @@ -878,7 +878,7 @@ static int etoken_get_serialnr(sc_card_t *card, sc_serial_number_t *serial) } static int -etoken_card_ctl(struct sc_card *card, unsigned long cmd, void *ptr) +etoken_card_ctl(sc_card_t *card, unsigned long cmd, void *ptr) { switch (cmd) { case SC_CARDCTL_ETOKEN_PUT_DATA_FCI: @@ -910,7 +910,7 @@ etoken_card_ctl(struct sc_card *card, unsigned long cmd, void *ptr) * Unfortunately, it doesn't seem to work without this flag :-/ */ static int -etoken_pin_cmd(struct sc_card *card, struct sc_pin_cmd_data *data, +etoken_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *data, int *tries_left) { data->flags |= SC_PIN_CMD_NEED_PADDING; diff --git a/src/libopensc/card-flex.c b/src/libopensc/card-flex.c index c1bacbea..97237012 100644 --- a/src/libopensc/card-flex.c +++ b/src/libopensc/card-flex.c @@ -97,13 +97,13 @@ static struct sc_card_driver cyberflex_drv = { &cyberflex_ops }; -static int flex_finish(struct sc_card *card) +static int flex_finish(sc_card_t *card) { free(card->drv_data); return 0; } -static int cryptoflex_match_card(struct sc_card *card) +static int cryptoflex_match_card(sc_card_t *card) { int i; @@ -121,7 +121,7 @@ static int cryptoflex_match_card(struct sc_card *card) return 0; } -static int cyberflex_match_card(struct sc_card *card) +static int cyberflex_match_card(sc_card_t *card) { int i; @@ -138,7 +138,7 @@ static int cyberflex_match_card(struct sc_card *card) return 0; } -static int flex_init(struct sc_card *card) +static int flex_init(sc_card_t *card) { struct flex_private_data *data; @@ -228,10 +228,10 @@ add_acl_entry(sc_card_t *card, sc_file_t *file, unsigned int op, u8 nibble) } static int -cryptoflex_get_ac_keys(struct sc_card *card, struct sc_file *file) +cryptoflex_get_ac_keys(sc_card_t *card, sc_file_t *file) { #if 0 - struct sc_apdu apdu; + sc_apdu_t apdu; u8 rbuf[3]; int r; @@ -430,7 +430,7 @@ cyberflex_process_file_attrs(sc_card_t *card, sc_file_t *file, return 0; } -static int check_path(struct sc_card *card, const u8 **pathptr, size_t *pathlen, +static int check_path(sc_card_t *card, const u8 **pathptr, size_t *pathlen, int need_info) { const u8 *curptr = card->cache.current_path.value; @@ -463,10 +463,10 @@ static int check_path(struct sc_card *card, const u8 **pathptr, size_t *pathlen, return 0; } -static void cache_path(struct sc_card *card, const struct sc_path *path, +static void cache_path(sc_card_t *card, const sc_path_t *path, int result) { - struct sc_path *curpath = &card->cache.current_path; + sc_path_t *curpath = &card->cache.current_path; if (result < 0) { curpath->len = 0; @@ -504,13 +504,13 @@ static void cache_path(struct sc_card *card, const struct sc_path *path, } } -static int select_file_id(struct sc_card *card, const u8 *buf, size_t buflen, - u8 p1, struct sc_file **file_out) +static int select_file_id(sc_card_t *card, const u8 *buf, size_t buflen, + u8 p1, sc_file_t **file_out) { int r; - struct sc_apdu apdu; - u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; - struct sc_file *file; + sc_apdu_t apdu; + u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; + sc_file_t *file; if (card->ctx->debug >= 4) { char string[32]; @@ -561,8 +561,8 @@ static int select_file_id(struct sc_card *card, const u8 *buf, size_t buflen, return 0; } -static int flex_select_file(struct sc_card *card, const struct sc_path *path, - struct sc_file **file_out) +static int flex_select_file(sc_card_t *card, const sc_path_t *path, + sc_file_t **file_out) { int r; const u8 *pathptr = path->value; @@ -615,9 +615,9 @@ static int flex_select_file(struct sc_card *card, const struct sc_path *path, SC_FUNC_RETURN(card->ctx, 2, r); } -static int cryptoflex_list_files(struct sc_card *card, u8 *buf, size_t buflen) +static int cryptoflex_list_files(sc_card_t *card, u8 *buf, size_t buflen) { - struct sc_apdu apdu; + sc_apdu_t apdu; u8 rbuf[4]; int r; size_t count = 0; @@ -651,9 +651,9 @@ static int cryptoflex_list_files(struct sc_card *card, u8 *buf, size_t buflen) /* * The Cyberflex LIST FILES command is slightly different... */ -static int cyberflex_list_files(struct sc_card *card, u8 *buf, size_t buflen) +static int cyberflex_list_files(sc_card_t *card, u8 *buf, size_t buflen) { - struct sc_apdu apdu; + sc_apdu_t apdu; u8 rbuf[6]; int r; size_t count = 0, p2 = 0; @@ -683,9 +683,9 @@ static int cyberflex_list_files(struct sc_card *card, u8 *buf, size_t buflen) return count; } -static int flex_delete_file(struct sc_card *card, const struct sc_path *path) +static int flex_delete_file(sc_card_t *card, const sc_path_t *path) { - struct sc_apdu apdu; + sc_apdu_t apdu; int r; SC_FUNC_CALLED(card->ctx, 1); @@ -705,7 +705,7 @@ static int flex_delete_file(struct sc_card *card, const struct sc_path *path) return sc_check_sw(card, apdu.sw1, apdu.sw2); } -static int acl_to_ac_nibble(const struct sc_acl_entry *e) +static int acl_to_ac_nibble(const sc_acl_entry_t *e) { if (e == NULL) return -1; @@ -734,7 +734,7 @@ static int acl_to_ac_nibble(const struct sc_acl_entry *e) return -1; } -static int acl_to_keynum_nibble(const struct sc_acl_entry *e) +static int acl_to_keynum_nibble(const sc_acl_entry_t *e) { while (e != NULL && e->method != SC_AC_AUT) e = e->next; @@ -796,7 +796,7 @@ cryptoflex_construct_file_attrs(sc_card_t *card, const sc_file_t *file, p[8] = p[9] = p[10] = 0; p[13] = p[14] = p[15] = 0; /* Key numbers */ for (i = 0; i < 6; i++) { - const struct sc_acl_entry *entry; + const sc_acl_entry_t *entry; if (ops[i] == -1) continue; entry = sc_file_get_acl_entry(file, ops[i]); @@ -898,12 +898,12 @@ cyberflex_construct_file_attrs(sc_card_t *card, const sc_file_t *file, return 0; } -static int flex_create_file(struct sc_card *card, struct sc_file *file) +static int flex_create_file(sc_card_t *card, sc_file_t *file) { u8 sbuf[18]; size_t sendlen; int r, rec_nr; - struct sc_apdu apdu; + sc_apdu_t apdu; /* Build the file attrs. These are not the real FCI bytes * in the standard sense, but its a convenient way of @@ -939,9 +939,9 @@ static int flex_create_file(struct sc_card *card, struct sc_file *file) return 0; } -static int flex_set_security_env(struct sc_card *card, - const struct sc_security_env *env, - int se_num) +static int flex_set_security_env(sc_card_t *card, + const sc_security_env_t *env, + int se_num) { struct flex_private_data *prv = (struct flex_private_data *) card->drv_data; @@ -979,7 +979,7 @@ static int flex_set_security_env(struct sc_card *card, return 0; } -static int flex_restore_security_env(struct sc_card *card, int se_num) +static int flex_restore_security_env(sc_card_t *card, int se_num) { return 0; } @@ -989,7 +989,7 @@ cryptoflex_compute_signature(sc_card_t *card, const u8 *data, size_t data_len, u8 * out, size_t outlen) { struct flex_private_data *prv = (struct flex_private_data *) card->drv_data; - struct sc_apdu apdu; + sc_apdu_t apdu; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; int r; size_t i; @@ -1043,7 +1043,7 @@ cyberflex_compute_signature(sc_card_t *card, const u8 *data, size_t data_len, u8 * out, size_t outlen) { struct flex_private_data *prv = DRV_DATA(card); - struct sc_apdu apdu; + sc_apdu_t apdu; u8 alg_id, key_id; int r; @@ -1076,7 +1076,7 @@ cyberflex_compute_signature(sc_card_t *card, const u8 *data, return apdu.resplen; } -static int flex_decipher(struct sc_card *card, +static int flex_decipher(sc_card_t *card, const u8 * crgram, size_t crgram_len, u8 * out, size_t outlen) { @@ -1088,7 +1088,7 @@ static int flex_decipher(struct sc_card *card, } /* Return the default AAK for this type of card */ -static int flex_get_default_key(struct sc_card *card, +static int flex_get_default_key(sc_card_t *card, struct sc_cardctl_default_key *data) { struct flex_private_data *prv = DRV_DATA(card); @@ -1115,7 +1115,7 @@ static int flex_get_default_key(struct sc_card *card, /* Generate key on-card */ static int flex_generate_key(sc_card_t *card, struct sc_cardctl_cryptoflex_genkey_info *data) { - struct sc_apdu apdu; + sc_apdu_t apdu; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; int r, p1, p2; @@ -1191,7 +1191,7 @@ static int flex_get_serialnr(sc_card_t *card, sc_serial_number_t *serial) return SC_SUCCESS; } -static int flex_card_ctl(struct sc_card *card, unsigned long cmd, void *ptr) +static int flex_card_ctl(sc_card_t *card, unsigned long cmd, void *ptr) { switch (cmd) { case SC_CARDCTL_GET_DEFAULT_KEY: @@ -1207,7 +1207,7 @@ static int flex_card_ctl(struct sc_card *card, unsigned long cmd, void *ptr) return SC_ERROR_NOT_SUPPORTED; } -static int flex_build_verify_apdu(struct sc_card *card, struct sc_apdu *apdu, +static int flex_build_verify_apdu(sc_card_t *card, sc_apdu_t *apdu, struct sc_pin_cmd_data *data) { static u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; @@ -1253,7 +1253,7 @@ static void flex_init_pin_info(struct sc_pin_cmd_pin *pin, unsigned int num) pin->offset = 5 + num * 8; } -static int flex_pin_cmd(struct sc_card *card, struct sc_pin_cmd_data *data, +static int flex_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *data, int *tries_left) { sc_apdu_t apdu; @@ -1288,9 +1288,9 @@ static int flex_pin_cmd(struct sc_card *card, struct sc_pin_cmd_data *data, return r; } -static int flex_logout(struct sc_card *card) +static int flex_logout(sc_card_t *card) { - struct sc_apdu apdu; + sc_apdu_t apdu; int r; sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0x22, 0x07, 0x00); diff --git a/src/libopensc/card-gpk.c b/src/libopensc/card-gpk.c index 48b0cd19..385a7c0f 100644 --- a/src/libopensc/card-gpk.c +++ b/src/libopensc/card-gpk.c @@ -84,7 +84,7 @@ struct gpk_private_data { }; #define DRVDATA(card) ((struct gpk_private_data *) ((card)->drv_data)) -static int gpk_get_info(struct sc_card *, u8, u8, u8 *, size_t); +static int gpk_get_info(sc_card_t *, u8, u8, u8 *, size_t); /* * ATRs of GPK4000 cards courtesy of libscez @@ -114,7 +114,7 @@ static struct sc_card_driver gpk_drv = { * return 1 if this driver can handle the card */ static int -gpk_match_card(struct sc_card *card) +gpk_match_card(sc_card_t *card) { int i; @@ -151,7 +151,7 @@ gpk_match_card(struct sc_card *card) * Initialize the card struct */ static int -gpk_init(struct sc_card *card) +gpk_init(sc_card_t *card) { struct gpk_private_data *priv; unsigned long exponent, flags, kg; @@ -216,7 +216,7 @@ gpk_init(struct sc_card *card) * Card is being closed; discard any private data etc */ static int -gpk_finish(struct sc_card *card) +gpk_finish(sc_card_t *card) { if (card->drv_data) free(card->drv_data); @@ -231,7 +231,7 @@ gpk_finish(struct sc_card *card) */ #if 0 static int -gpk_check_sw(struct sc_card *card, u8 sw1, u8 sw2) +gpk_check_sw(sc_card_t *card, u8 sw1, u8 sw2) { unsigned short int sw = (sw1 << 8) | sw2; @@ -269,7 +269,7 @@ gpk_check_sw(struct sc_card *card, u8 sw1, u8 sw2) * Select a DF/EF */ static int -match_path(struct sc_card *card, unsigned short int **pathptr, size_t *pathlen, +match_path(sc_card_t *card, unsigned short int **pathptr, size_t *pathlen, int need_info) { unsigned short int *curptr, *ptr; @@ -326,7 +326,7 @@ okay: } static void -ac_to_acl(unsigned short int ac, struct sc_file *file, unsigned int op) +ac_to_acl(unsigned short int ac, sc_file_t *file, unsigned int op) { unsigned int npins, pin; @@ -355,9 +355,9 @@ ac_to_acl(unsigned short int ac, struct sc_file *file, unsigned int op) * some fuzz involved. */ static void -acl_to_ac(struct sc_file *file, unsigned int op, u8 *ac) +acl_to_ac(sc_file_t *file, unsigned int op, u8 *ac) { - const struct sc_acl_entry *acl; + const sc_acl_entry_t *acl; unsigned int npins = 0; ac[0] = ac[1] = 0; @@ -391,9 +391,9 @@ acl_to_ac(struct sc_file *file, unsigned int op, u8 *ac) } static int -gpk_parse_fci(struct sc_card *card, +gpk_parse_fci(sc_card_t *card, const u8 *buf, size_t buflen, - struct sc_file *file) + sc_file_t *file) { const u8 *end, *next; unsigned int tag, len; @@ -427,9 +427,9 @@ gpk_parse_fci(struct sc_card *card, } static int -gpk_parse_fileinfo(struct sc_card *card, +gpk_parse_fileinfo(sc_card_t *card, const u8 *buf, size_t buflen, - struct sc_file *file) + sc_file_t *file) { const u8 *sp, *end, *next; int i, rc; @@ -511,12 +511,12 @@ gpk_parse_fileinfo(struct sc_card *card, } static int -gpk_select(struct sc_card *card, u8 kind, +gpk_select(sc_card_t *card, u8 kind, const u8 *buf, size_t buflen, - struct sc_file **file) + sc_file_t **file) { struct gpk_private_data *priv = DRVDATA(card); - struct sc_apdu apdu; + sc_apdu_t apdu; u8 resbuf[256]; int r; @@ -568,10 +568,10 @@ gpk_select(struct sc_card *card, u8 kind, } static int -gpk_select_id(struct sc_card *card, u8 kind, unsigned short int fid, - struct sc_file **file) +gpk_select_id(sc_card_t *card, u8 kind, unsigned short int fid, + sc_file_t **file) { - struct sc_path *cp = &card->cache.current_path; + sc_path_t *cp = &card->cache.current_path; u8 fbuf[2]; int r; @@ -606,8 +606,8 @@ gpk_select_id(struct sc_card *card, u8 kind, unsigned short int fid, } static int -gpk_select_file(struct sc_card *card, const struct sc_path *path, - struct sc_file **file) +gpk_select_file(sc_card_t *card, const sc_path_t *path, + sc_file_t **file) { unsigned short int pathtmp[SC_MAX_PATH_SIZE/2]; unsigned short int *pathptr; @@ -722,7 +722,7 @@ done: * Required because by default the GPKs do word offsets */ static int -gpk_read_binary(struct sc_card *card, unsigned int offset, +gpk_read_binary(sc_card_t *card, unsigned int offset, u8 *buf, size_t count, unsigned long flags) { struct gpk_private_data *priv = DRVDATA(card); @@ -737,7 +737,7 @@ gpk_read_binary(struct sc_card *card, unsigned int offset, } static int -gpk_write_binary(struct sc_card *card, unsigned int offset, +gpk_write_binary(sc_card_t *card, unsigned int offset, const u8 *buf, size_t count, unsigned long flags) { struct gpk_private_data *priv = DRVDATA(card); @@ -752,7 +752,7 @@ gpk_write_binary(struct sc_card *card, unsigned int offset, } static int -gpk_update_binary(struct sc_card *card, unsigned int offset, +gpk_update_binary(sc_card_t *card, unsigned int offset, const u8 *buf, size_t count, unsigned long flags) { struct gpk_private_data *priv = DRVDATA(card); @@ -770,7 +770,7 @@ gpk_update_binary(struct sc_card *card, unsigned int offset, * Secure messaging */ static int -gpk_compute_crycks(struct sc_card *card, struct sc_apdu *apdu, +gpk_compute_crycks(sc_card_t *card, sc_apdu_t *apdu, u8 *crycks1) { struct gpk_private_data *priv = DRVDATA(card); @@ -824,7 +824,7 @@ gpk_compute_crycks(struct sc_card *card, struct sc_apdu *apdu, * Verify secure messaging response */ static int -gpk_verify_crycks(struct sc_card *card, struct sc_apdu *apdu, u8 *crycks) +gpk_verify_crycks(sc_card_t *card, sc_apdu_t *apdu, u8 *crycks) { if (apdu->resplen < 3 || memcmp(apdu->resp + apdu->resplen - 3, crycks, 3)) { @@ -843,10 +843,10 @@ gpk_verify_crycks(struct sc_card *card, struct sc_apdu *apdu, u8 *crycks) * (the GPK4000 has lots of bizarre file types). */ static int -gpk_create_file(struct sc_card *card, struct sc_file *file) +gpk_create_file(sc_card_t *card, sc_file_t *file) { struct gpk_private_data *priv = DRVDATA(card); - struct sc_apdu apdu; + sc_apdu_t apdu; u8 data[28+3], crycks[3], resp[3]; size_t datalen, namelen; int r; @@ -965,10 +965,10 @@ gpk_set_filekey(const u8 *key, const u8 *challenge, * Verify a key presented by the user for secure messaging */ static int -gpk_select_key(struct sc_card *card, int key_sfi, const u8 *buf, size_t buflen) +gpk_select_key(sc_card_t *card, int key_sfi, const u8 *buf, size_t buflen) { struct gpk_private_data *priv = DRVDATA(card); - struct sc_apdu apdu; + sc_apdu_t apdu; u8 rnd[8], resp[258]; int r; @@ -1023,12 +1023,12 @@ gpk_select_key(struct sc_card *card, int key_sfi, const u8 *buf, size_t buflen) * and other flags? */ static int -gpk_set_security_env(struct sc_card *card, - const struct sc_security_env *env, +gpk_set_security_env(sc_card_t *card, + const sc_security_env_t *env, int se_num) { struct gpk_private_data *priv = DRVDATA(card); - struct sc_apdu apdu; + sc_apdu_t apdu; unsigned int context, algorithm; unsigned int file_id; u8 sysrec[7]; @@ -1157,7 +1157,7 @@ gpk_set_security_env(struct sc_card *card, * Not sure what this is supposed to do. */ static int -gpk_restore_security_env(struct sc_card *card, int se_num) +gpk_restore_security_env(sc_card_t *card, int se_num) { return 0; } @@ -1182,9 +1182,9 @@ reverse(u8 *out, size_t outlen, const u8 *in, size_t inlen) */ #ifdef dontuse static int -gpk_hash(struct sc_card *card, const u8 *data, size_t datalen) +gpk_hash(sc_card_t *card, const u8 *data, size_t datalen) { - struct sc_apdu apdu; + sc_apdu_t apdu; unsigned int count, chain, len; int r; @@ -1225,9 +1225,9 @@ gpk_hash(struct sc_card *card, const u8 *data, size_t datalen) * Send the hashed data to the card. */ static int -gpk_init_hashed(struct sc_card *card, const u8 *digest, unsigned int len) +gpk_init_hashed(sc_card_t *card, const u8 *digest, unsigned int len) { - struct sc_apdu apdu; + sc_apdu_t apdu; u8 tsegid[64]; int r; @@ -1255,11 +1255,11 @@ gpk_init_hashed(struct sc_card *card, const u8 *digest, unsigned int len) * Note we hash everything manually and send it to the card. */ static int -gpk_compute_signature(struct sc_card *card, const u8 *data, +gpk_compute_signature(sc_card_t *card, const u8 *data, size_t data_len, u8 * out, size_t outlen) { struct gpk_private_data *priv = DRVDATA(card); - struct sc_apdu apdu; + sc_apdu_t apdu; u8 cardsig[1024/8]; int r; @@ -1316,11 +1316,11 @@ gpk_compute_signature(struct sc_card *card, const u8 *data, * SSL session key you will be able to decrypt using this card. */ static int -gpk_decipher(struct sc_card *card, const u8 *in, size_t inlen, +gpk_decipher(sc_card_t *card, const u8 *in, size_t inlen, u8 *out, size_t outlen) { struct gpk_private_data *priv = DRVDATA(card); - struct sc_apdu apdu; + sc_apdu_t apdu; u8 buffer[256]; int r; @@ -1364,10 +1364,10 @@ gpk_decipher(struct sc_card *card, const u8 *in, size_t inlen, * Erase card */ static int -gpk_erase_card(struct sc_card *card) +gpk_erase_card(sc_card_t *card) { struct gpk_private_data *priv = DRVDATA(card); - struct sc_apdu apdu; + sc_apdu_t apdu; u8 offset; int r; @@ -1417,11 +1417,11 @@ gpk_erase_card(struct sc_card *card) * AC2 for normal files). */ static int -gpk_lock(struct sc_card *card, struct sc_cardctl_gpk_lock *args) +gpk_lock(sc_card_t *card, struct sc_cardctl_gpk_lock *args) { struct gpk_private_data *priv = DRVDATA(card); - struct sc_file *file = args->file; - struct sc_apdu apdu; + sc_file_t *file = args->file; + sc_apdu_t apdu; u8 data[8], crycks[3], resp[3]; int r; @@ -1478,9 +1478,9 @@ gpk_lock(struct sc_card *card, struct sc_cardctl_gpk_lock *args) * Initialize the private portion of a public key file */ static int -gpk_pkfile_init(struct sc_card *card, struct sc_cardctl_gpk_pkinit *args) +gpk_pkfile_init(sc_card_t *card, struct sc_cardctl_gpk_pkinit *args) { - struct sc_apdu apdu; + sc_apdu_t apdu; int r; if (card->ctx->debug) @@ -1505,9 +1505,9 @@ gpk_pkfile_init(struct sc_card *card, struct sc_cardctl_gpk_pkinit *args) * Initialize the private portion of a public key file */ static int -gpk_generate_key(struct sc_card *card, struct sc_cardctl_gpk_genkey *args) +gpk_generate_key(sc_card_t *card, struct sc_cardctl_gpk_genkey *args) { - struct sc_apdu apdu; + sc_apdu_t apdu; int r; u8 buffer[256]; @@ -1551,11 +1551,11 @@ gpk_generate_key(struct sc_card *card, struct sc_cardctl_gpk_genkey *args) * Store a privat key component */ static int -gpk_pkfile_load(struct sc_card *card, struct sc_cardctl_gpk_pkload *args) +gpk_pkfile_load(sc_card_t *card, struct sc_cardctl_gpk_pkload *args) { struct gpk_private_data *priv = DRVDATA(card); des_key_schedule k1, k2; - struct sc_apdu apdu; + sc_apdu_t apdu; unsigned int n; u8 temp[256]; int r; @@ -1614,7 +1614,7 @@ gpk_pkfile_load(struct sc_card *card, struct sc_cardctl_gpk_pkload *args) * This function lets pkcs15init query for the transport key */ static int -gpk_get_default_key(struct sc_card *card, struct sc_cardctl_default_key *data) +gpk_get_default_key(sc_card_t *card, struct sc_cardctl_default_key *data) { if (data->method == SC_AC_PRO && data->key_ref == 1) { if (data->len < 16) @@ -1632,10 +1632,10 @@ gpk_get_default_key(struct sc_card *card, struct sc_cardctl_default_key *data) */ #if 0 static int -gpk_max_session_key(struct sc_card *card) +gpk_max_session_key(sc_card_t *card) { struct gpk_private_data *priv = DRVDATA(card); - struct sc_path path; + sc_path_t path; u8 value; int r; @@ -1657,9 +1657,9 @@ gpk_max_session_key(struct sc_card *card) * GetInfo call */ int -gpk_get_info(struct sc_card *card, u8 p1, u8 p2, u8 *buf, size_t buflen) +gpk_get_info(sc_card_t *card, u8 p1, u8 p2, u8 *buf, size_t buflen) { - struct sc_apdu apdu; + sc_apdu_t apdu; int r, retry = 0; /* We may have to retry the get info command. It @@ -1704,7 +1704,7 @@ static int gpk_get_serialnr(sc_card_t *card, sc_serial_number_t *serial) { int r; u8 rbuf[10]; - struct sc_apdu apdu; + sc_apdu_t apdu; if (card->type != SC_CARD_TYPE_GPK_GPK16000) return SC_ERROR_NOT_SUPPORTED; @@ -1740,7 +1740,7 @@ static int gpk_get_serialnr(sc_card_t *card, sc_serial_number_t *serial) * Dispatch card_ctl calls */ static int -gpk_card_ctl(struct sc_card *card, unsigned long cmd, void *ptr) +gpk_card_ctl(sc_card_t *card, unsigned long cmd, void *ptr) { switch (cmd) { case SC_CARDCTL_ERASE_CARD: @@ -1838,7 +1838,7 @@ gpk_build_pin_apdu(sc_card_t *card, sc_apdu_t *apdu, struct sc_pin_cmd_data *dat static int gpk_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *data, int *tries_left) { - struct sc_apdu apdu; + sc_apdu_t apdu; int r; /* Special case - External Authenticate */ diff --git a/src/libopensc/card-jcop.c b/src/libopensc/card-jcop.c index 419948bb..df32fcfd 100644 --- a/src/libopensc/card-jcop.c +++ b/src/libopensc/card-jcop.c @@ -50,9 +50,9 @@ static struct sc_card_driver jcop_drv = { struct jcop_private_data { - struct sc_file *virtmf; - struct sc_file *virtdir; - struct sc_path aid; + sc_file_t *virtmf; + sc_file_t *virtdir; + sc_path_t aid; int selected; int invalid_senv; int nfiles; @@ -60,7 +60,7 @@ struct jcop_private_data }; #define DRVDATA(card) ((struct jcop_private_data *) ((card)->drv_data)) -static int jcop_finish(struct sc_card *card) +static int jcop_finish(sc_card_t *card) { struct jcop_private_data *drvdata=DRVDATA(card); if (drvdata) { @@ -73,7 +73,7 @@ static int jcop_finish(struct sc_card *card) return 0; } -static int jcop_match_card(struct sc_card *card) +static int jcop_match_card(sc_card_t *card) { int i; @@ -91,10 +91,10 @@ static unsigned char ef_dir_contents[128] = { }; -static int jcop_init(struct sc_card *card) +static int jcop_init(sc_card_t *card) { struct jcop_private_data *drvdata; - struct sc_file *f; + sc_file_t *f; int flags; drvdata=(struct jcop_private_data *) malloc(sizeof(struct jcop_private_data)); @@ -173,7 +173,7 @@ static int jcop_init(struct sc_card *card) return 0; } -static int jcop_get_default_key(struct sc_card *card, +static int jcop_get_default_key(sc_card_t *card, struct sc_cardctl_default_key *data) { const char *key; @@ -191,15 +191,15 @@ static int jcop_get_default_key(struct sc_card *card, that, I fake an MF containing the AppDF and a fixed DIR pointing at the fake AppDF. This has the added advantage of allowing opensc-explorer to be used with this driver */ -static int jcop_select_file(struct sc_card *card, const struct sc_path *path, - struct sc_file **file) +static int jcop_select_file(sc_card_t *card, const sc_path_t *path, + sc_file_t **file) { struct jcop_private_data *drvdata=DRVDATA(card); int r,selecting; struct sc_card_driver *iso_drv = sc_get_iso7816_driver(); const struct sc_card_operations *iso_ops = iso_drv->ops; sc_path_t shortpath; - struct sc_file *tfile, **fileptr; + sc_file_t *tfile, **fileptr; if (!drvdata) return SC_ERROR_FILE_NOT_FOUND; @@ -305,12 +305,12 @@ static int jcop_select_file(struct sc_card *card, const struct sc_path *path, return 0; } -static int jcop_read_binary(struct sc_card *card, unsigned int idx, +static int jcop_read_binary(sc_card_t *card, unsigned int idx, u8 * buf, size_t count, unsigned long flags) { struct jcop_private_data *drvdata=DRVDATA(card); struct sc_card_driver *iso_drv = sc_get_iso7816_driver(); const struct sc_card_operations *iso_ops = iso_drv->ops; - struct sc_file *tfile; + sc_file_t *tfile; int r; if (drvdata->selected == SELECT_MF) { @@ -337,11 +337,11 @@ static int jcop_read_binary(struct sc_card *card, unsigned int idx, return iso_ops->read_binary(card, idx, buf, count, flags); } -static int jcop_list_files(struct sc_card *card, u8 *buf, size_t buflen) { +static int jcop_list_files(sc_card_t *card, u8 *buf, size_t buflen) { struct jcop_private_data *drvdata=DRVDATA(card); struct sc_card_driver *iso_drv = sc_get_iso7816_driver(); const struct sc_card_operations *iso_ops = iso_drv->ops; - struct sc_file *tfile; + sc_file_t *tfile; int r; if (drvdata->selected == SELECT_MF) { @@ -373,7 +373,7 @@ static int jcop_list_files(struct sc_card *card, u8 *buf, size_t buflen) { return buflen; } -static int sa_to_acl(struct sc_file *file, unsigned int operation, +static int sa_to_acl(sc_file_t *file, unsigned int operation, int nibble) { switch (nibble & 0x7) { case 0: @@ -404,7 +404,7 @@ static int sa_to_acl(struct sc_file *file, unsigned int operation, } -static int jcop_process_fci(struct sc_card *card, struct sc_file *file, +static int jcop_process_fci(sc_card_t *card, sc_file_t *file, const u8 *buf, size_t buflen) { struct jcop_private_data *drvdata=DRVDATA(card); struct sc_card_driver *iso_drv = sc_get_iso7816_driver(); @@ -480,7 +480,7 @@ static int jcop_process_fci(struct sc_card *card, struct sc_file *file, return r; } -static int acl_to_ac_nibble(const struct sc_acl_entry *e) +static int acl_to_ac_nibble(const sc_acl_entry_t *e) { if (e == NULL) return -1; @@ -510,7 +510,7 @@ static int acl_to_ac_nibble(const struct sc_acl_entry *e) } -static int jcop_create_file(struct sc_card *card, struct sc_file *file) { +static int jcop_create_file(sc_card_t *card, sc_file_t *file) { struct jcop_private_data *drvdata=DRVDATA(card); unsigned char sec_attr_data[3]; int ops[6]; @@ -533,7 +533,7 @@ static int jcop_create_file(struct sc_card *card, struct sc_file *file) { ops[5] = SC_AC_OP_ERASE; /* delete */ memset(sec_attr_data, 0, 3); for (i = 0; i < 6; i++) { - const struct sc_acl_entry *entry; + const sc_acl_entry_t *entry; if (ops[i] == -1) { sec_attr_data[i/2] |= 1 << ((i % 2) ? 0 : 4); continue; @@ -553,19 +553,19 @@ static int jcop_create_file(struct sc_card *card, struct sc_file *file) { } /* no record oriented file services */ -static int jcop_read_record_unsupp(struct sc_card *card, +static int jcop_read_record_unsupp(sc_card_t *card, unsigned int rec_nr, u8 *buf, size_t count, unsigned long flags) { return SC_ERROR_NOT_SUPPORTED; } -static int jcop_wrupd_record_unsupp(struct sc_card *card, +static int jcop_wrupd_record_unsupp(sc_card_t *card, unsigned int rec_nr, const u8 *buf, size_t count, unsigned long flags) { return SC_ERROR_NOT_SUPPORTED; } -static int jcop_append_record_unsupp(struct sc_card *card, +static int jcop_append_record_unsupp(sc_card_t *card, const u8 *buf, size_t count, unsigned long flags) { return SC_ERROR_NOT_SUPPORTED; @@ -574,7 +574,7 @@ static int jcop_append_record_unsupp(struct sc_card *card, /* We need to trap these functions so that proper errors can be returned when one of the virtual files is selected */ -static int jcop_write_binary(struct sc_card *card, +static int jcop_write_binary(sc_card_t *card, unsigned int idx, const u8 *buf, size_t count, unsigned long flags) { struct jcop_private_data *drvdata=DRVDATA(card); @@ -590,7 +590,7 @@ static int jcop_write_binary(struct sc_card *card, } -static int jcop_update_binary(struct sc_card *card, +static int jcop_update_binary(sc_card_t *card, unsigned int idx, const u8 *buf, size_t count, unsigned long flags) { @@ -605,7 +605,7 @@ static int jcop_update_binary(struct sc_card *card, return iso_ops->update_binary(card, idx, buf, count, flags); } -static int jcop_delete_file(struct sc_card *card, const struct sc_path *path) { +static int jcop_delete_file(sc_card_t *card, const sc_path_t *path) { struct jcop_private_data *drvdata=DRVDATA(card); struct sc_card_driver *iso_drv = sc_get_iso7816_driver(); const struct sc_card_operations *iso_ops = iso_drv->ops; @@ -619,11 +619,11 @@ static int jcop_delete_file(struct sc_card *card, const struct sc_path *path) { /* BlueZ doesn't support stored security environments. you have to construct one with SET every time */ -static int jcop_set_security_env(struct sc_card *card, - const struct sc_security_env *env, +static int jcop_set_security_env(sc_card_t *card, + const sc_security_env_t *env, int se_num) { - struct sc_apdu apdu; + sc_apdu_t apdu; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 *p; int r; @@ -639,7 +639,7 @@ static int jcop_set_security_env(struct sc_card *card, } if (env->flags & SC_SEC_ENV_ALG_PRESENT) { - struct sc_security_env tmp; + sc_security_env_t tmp; tmp = *env; tmp.flags &= ~SC_SEC_ENV_ALG_PRESENT; @@ -712,13 +712,13 @@ static int jcop_set_security_env(struct sc_card *card, drvdata->invalid_senv=0; return 0; } -static int jcop_compute_signature(struct sc_card *card, +static int jcop_compute_signature(sc_card_t *card, const u8 * data, size_t datalen, u8 * out, size_t outlen) { int r; - struct sc_apdu apdu; + sc_apdu_t apdu; u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; struct jcop_private_data *drvdata=DRVDATA(card); @@ -764,12 +764,12 @@ static int jcop_compute_signature(struct sc_card *card, -static int jcop_decipher(struct sc_card *card, +static int jcop_decipher(sc_card_t *card, const u8 * crgram, size_t crgram_len, u8 * out, size_t outlen) { int r; - struct sc_apdu apdu; + sc_apdu_t apdu; u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; struct jcop_private_data *drvdata=DRVDATA(card); @@ -814,10 +814,10 @@ static int jcop_decipher(struct sc_card *card, SC_FUNC_RETURN(card->ctx, 2, sc_check_sw(card, apdu.sw1, apdu.sw2)); } -static int jcop_generate_key(struct sc_card *card, struct sc_cardctl_jcop_genkey *a) { +static int jcop_generate_key(sc_card_t *card, struct sc_cardctl_jcop_genkey *a) { int modlen; int r; - struct sc_apdu apdu; + sc_apdu_t apdu; u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 *p; @@ -899,7 +899,7 @@ static int jcop_generate_key(struct sc_card *card, struct sc_cardctl_jcop_genkey return 0; } -static int jcop_card_ctl(struct sc_card *card, unsigned long cmd, void *ptr) +static int jcop_card_ctl(sc_card_t *card, unsigned long cmd, void *ptr) { switch (cmd) { case SC_CARDCTL_GET_DEFAULT_KEY: @@ -922,7 +922,7 @@ static int jcop_card_ctl(struct sc_card *card, unsigned long cmd, void *ptr) * you need to reset the card." - javacard@zurich.ibm.com, when asked about * how to invalidate logged in pins. */ -static int jcop_logout(struct sc_card *card) +static int jcop_logout(sc_card_t *card) { return 0; /* Can't */ } diff --git a/src/libopensc/card-mcrd.c b/src/libopensc/card-mcrd.c index 478bec8d..6ffbf467 100644 --- a/src/libopensc/card-mcrd.c +++ b/src/libopensc/card-mcrd.c @@ -91,15 +91,15 @@ struct mcrd_priv_data { #define DRVDATA(card) ((struct mcrd_priv_data *) ((card)->drv_data)) -static int load_special_files(struct sc_card *card); -static int select_part (struct sc_card *card, u8 kind, unsigned short int fid, - struct sc_file **file); +static int load_special_files(sc_card_t *card); +static int select_part (sc_card_t *card, u8 kind, unsigned short int fid, + sc_file_t **file); /* Return the DF_info for the current path. If does not yet exist, create it. Returns NULL on error. */ -static struct df_info_s *get_df_info (struct sc_card *card) +static struct df_info_s *get_df_info (sc_card_t *card) { - struct sc_context *ctx = card->ctx; + sc_context_t *ctx = card->ctx; struct mcrd_priv_data *priv = DRVDATA (card); struct df_info_s *dfi; @@ -151,9 +151,9 @@ static void clear_special_files (struct df_info_s *dfi) */ static int -mcrd_delete_ref_to_authkey (struct sc_card *card) +mcrd_delete_ref_to_authkey (sc_card_t *card) { - struct sc_apdu apdu; + sc_apdu_t apdu; int r; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; @@ -171,9 +171,9 @@ mcrd_delete_ref_to_authkey (struct sc_card *card) } static int -mcrd_delete_ref_to_signkey (struct sc_card *card) +mcrd_delete_ref_to_signkey (sc_card_t *card) { - struct sc_apdu apdu; + sc_apdu_t apdu; int r; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; assert (card != NULL); @@ -192,10 +192,10 @@ mcrd_delete_ref_to_signkey (struct sc_card *card) } static int -mcrd_set_decipher_key_ref (struct sc_card *card, int key_reference) +mcrd_set_decipher_key_ref (sc_card_t *card, int key_reference) { - struct sc_apdu apdu; - struct sc_path path; + sc_apdu_t apdu; + sc_path_t path; int r; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 keyref_data[SC_ESTEID_KEYREF_FILE_RECLEN]; @@ -243,7 +243,7 @@ mcrd_set_decipher_key_ref (struct sc_card *card, int key_reference) SC_FUNC_RETURN (card->ctx, 2, sc_check_sw (card, apdu.sw1, apdu.sw2)); } -static int mcrd_match_card(struct sc_card *card) +static int mcrd_match_card(sc_card_t *card) { int i; @@ -253,7 +253,7 @@ static int mcrd_match_card(struct sc_card *card) return 1; } -static int mcrd_init(struct sc_card *card) +static int mcrd_init(sc_card_t *card) { unsigned long flags; struct mcrd_priv_data *priv; @@ -280,7 +280,7 @@ static int mcrd_init(struct sc_card *card) return 0; } -static int mcrd_finish(struct sc_card *card) +static int mcrd_finish(sc_card_t *card) { struct mcrd_priv_data *priv; @@ -299,9 +299,9 @@ static int mcrd_finish(struct sc_card *card) /* Load the rule and keyd file into our private data. Return 0 on success */ -static int load_special_files (struct sc_card *card) +static int load_special_files (sc_card_t *card) { - struct sc_context *ctx = card->ctx; + sc_context_t *ctx = card->ctx; struct mcrd_priv_data *priv = DRVDATA (card); int r, recno; struct df_info_s *dfi; @@ -321,7 +321,7 @@ static int load_special_files (struct sc_card *card) SC_TEST_RET(ctx, r, "selecting EF_Rule failed"); for (recno=1;; recno++) { - struct sc_apdu apdu; + sc_apdu_t apdu; u8 recvbuf[200]; sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, @@ -358,7 +358,7 @@ static int load_special_files (struct sc_card *card) SC_TEST_RET(ctx, r, "selecting EF_KeyD failed"); for (recno=1;; recno++) { - struct sc_apdu apdu; + sc_apdu_t apdu; u8 recvbuf[200]; sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, @@ -395,10 +395,10 @@ static int load_special_files (struct sc_card *card) /* Return the SE number from the keyD for the FID. If ref_data is not NULL the reference data is returned; this shoudl be an array of at least 2 bytes. Returns -1 on error. */ -static int get_se_num_from_keyd (struct sc_card *card, unsigned short fid, +static int get_se_num_from_keyd (sc_card_t *card, unsigned short fid, u8 *ref_data) { - struct sc_context *ctx = card->ctx; + sc_context_t *ctx = card->ctx; struct df_info_s *dfi; struct keyd_record_s *keyd; size_t len, taglen; @@ -448,10 +448,10 @@ static int get_se_num_from_keyd (struct sc_card *card, unsigned short fid, } /* Process an ARR (7816-9/8.5.4) and setup the ACL. */ -static void process_arr(struct sc_card *card, struct sc_file *file, +static void process_arr(sc_card_t *card, sc_file_t *file, const u8 *buf, size_t buflen) { - struct sc_context *ctx = card->ctx; + sc_context_t *ctx = card->ctx; struct df_info_s *dfi; struct rule_record_s *rule; size_t left, taglen; @@ -548,10 +548,10 @@ static void process_arr(struct sc_card *card, struct sc_file *file, } -static void process_fcp(struct sc_card *card, struct sc_file *file, +static void process_fcp(sc_card_t *card, sc_file_t *file, const u8 *buf, size_t buflen) { - struct sc_context *ctx = card->ctx; + sc_context_t *ctx = card->ctx; size_t taglen, len = buflen; const u8 *tag = NULL, *p = buf; int bad_fde = 0; @@ -689,11 +689,11 @@ static void process_fcp(struct sc_card *card, struct sc_file *file, /* Send a select command and parse the response. */ static int -do_select(struct sc_card *card, u8 kind, +do_select(sc_card_t *card, u8 kind, const u8 *buf, size_t buflen, - struct sc_file **file) + sc_file_t **file) { - struct sc_apdu apdu; + sc_apdu_t apdu; u8 resbuf[SC_MAX_APDU_BUFFER_SIZE]; int r; @@ -743,8 +743,8 @@ do_select(struct sc_card *card, u8 kind, /* Wrapper around do_select to be used when multiple selects are required. */ static int -select_part (struct sc_card *card, u8 kind, unsigned short int fid, - struct sc_file **file) +select_part (sc_card_t *card, u8 kind, unsigned short int fid, + sc_file_t **file) { u8 fbuf[2]; int r; @@ -771,10 +771,10 @@ select_part (struct sc_card *card, u8 kind, unsigned short int fid, passed as true only DF are selected, otherwise the function tries to figure out whether the last path item is a DF or EF. */ static int -select_down (struct sc_card *card, +select_down (sc_card_t *card, unsigned short *pathptr, size_t pathlen, int df_only, - struct sc_file **file) + sc_file_t **file) { struct mcrd_priv_data *priv = DRVDATA (card); int r; @@ -817,9 +817,9 @@ select_down (struct sc_card *card, usual sc_path structure. */ static int -select_file_by_path (struct sc_card *card, unsigned short *pathptr, +select_file_by_path (sc_card_t *card, unsigned short *pathptr, size_t pathlen, - struct sc_file **file) + sc_file_t **file) { struct mcrd_priv_data *priv = DRVDATA (card); int r; @@ -902,8 +902,8 @@ select_file_by_path (struct sc_card *card, unsigned short *pathptr, } static int -select_file_by_fid (struct sc_card *card, unsigned short *pathptr, - size_t pathlen, struct sc_file **file) +select_file_by_fid (sc_card_t *card, unsigned short *pathptr, + size_t pathlen, sc_file_t **file) { struct mcrd_priv_data *priv = DRVDATA (card); int r; @@ -966,8 +966,8 @@ select_file_by_fid (struct sc_card *card, unsigned short *pathptr, /* This drivers select command handler. */ static int -mcrd_select_file(struct sc_card *card, const struct sc_path *path, - struct sc_file **file) +mcrd_select_file(sc_card_t *card, const sc_path_t *path, + sc_file_t **file) { struct mcrd_priv_data *priv = DRVDATA (card); int r = 0; @@ -1038,9 +1038,9 @@ mcrd_select_file(struct sc_card *card, const struct sc_path *path, /* Crypto operations */ -static int mcrd_enable_se (struct sc_card *card, int se_num) +static int mcrd_enable_se (sc_card_t *card, int se_num) { - struct sc_apdu apdu; + sc_apdu_t apdu; int r; sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0x22, 0xF3, se_num); @@ -1057,12 +1057,12 @@ static int mcrd_enable_se (struct sc_card *card, int se_num) It has been generalized [?] and modified by information coming from openpgp card implementation, EstEID 'manual' and some other sources. -mp */ -static int mcrd_set_security_env(struct sc_card *card, - const struct sc_security_env *env, +static int mcrd_set_security_env(sc_card_t *card, + const sc_security_env_t *env, int se_num) { struct mcrd_priv_data *priv = DRVDATA(card); - struct sc_apdu apdu; + sc_apdu_t apdu; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 *p; int r, locked = 0; @@ -1177,14 +1177,14 @@ err: } /* heavily modified by -mp */ -static int mcrd_compute_signature(struct sc_card *card, +static int mcrd_compute_signature(sc_card_t *card, const u8 * data, size_t datalen, u8 * out, size_t outlen) { struct mcrd_priv_data *priv = DRVDATA(card); sc_security_env_t *env = &priv->sec_env; int r; - struct sc_apdu apdu; + sc_apdu_t apdu; assert(card != NULL && data != NULL && out != NULL); SC_FUNC_CALLED(card->ctx, 2); @@ -1223,13 +1223,13 @@ static int mcrd_compute_signature(struct sc_card *card, } /* added by -mp */ -static int mcrd_decipher(struct sc_card *card, +static int mcrd_decipher(sc_card_t *card, const u8 * crgram, size_t crgram_len, u8 * out, size_t out_len) { int r; - struct sc_apdu apdu; + sc_apdu_t apdu; struct mcrd_priv_data *priv = DRVDATA(card); sc_security_env_t *env = &priv->sec_env; u8 *temp; @@ -1269,7 +1269,7 @@ static int mcrd_decipher(struct sc_card *card, } /* added by -mp, to give pin information in the card driver (pkcs15emu->driver needed) */ -static int mcrd_pin_cmd(struct sc_card *card, struct sc_pin_cmd_data *data, +static int mcrd_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *data, int *tries_left) { SC_FUNC_CALLED(card->ctx, 3); diff --git a/src/libopensc/card-miocos.c b/src/libopensc/card-miocos.c index c69bb0e1..2828a161 100644 --- a/src/libopensc/card-miocos.c +++ b/src/libopensc/card-miocos.c @@ -39,12 +39,12 @@ static struct sc_card_driver miocos_drv = { &miocos_ops }; -static int miocos_finish(struct sc_card *card) +static int miocos_finish(sc_card_t *card) { return 0; } -static int miocos_match_card(struct sc_card *card) +static int miocos_match_card(sc_card_t *card) { int i; @@ -54,7 +54,7 @@ static int miocos_match_card(struct sc_card *card) return 1; } -static int miocos_init(struct sc_card *card) +static int miocos_init(sc_card_t *card) { card->name = "MioCOS"; card->cla = 0x00; @@ -80,7 +80,7 @@ static int miocos_init(struct sc_card *card) static const struct sc_card_operations *iso_ops = NULL; -static int acl_to_byte(const struct sc_acl_entry *e) +static int acl_to_byte(const sc_acl_entry_t *e) { switch (e->method) { case SC_AC_NONE: @@ -99,7 +99,7 @@ static int acl_to_byte(const struct sc_acl_entry *e) return 0x00; } -static int encode_file_structure(struct sc_card *card, const struct sc_file *file, +static int encode_file_structure(sc_card_t *card, const sc_file_t *file, u8 *buf, size_t *buflen) { u8 *p = buf; @@ -202,9 +202,9 @@ static int encode_file_structure(struct sc_card *card, const struct sc_file *fil return 0; } -static int miocos_create_file(struct sc_card *card, struct sc_file *file) +static int miocos_create_file(sc_card_t *card, sc_file_t *file) { - struct sc_apdu apdu; + sc_apdu_t apdu; u8 sbuf[32]; size_t buflen; int r; @@ -227,12 +227,12 @@ static int miocos_create_file(struct sc_card *card, struct sc_file *file) return 0; } -static int miocos_set_security_env(struct sc_card *card, - const struct sc_security_env *env, +static int miocos_set_security_env(sc_card_t *card, + const sc_security_env_t *env, int se_num) { if (env->flags & SC_SEC_ENV_ALG_PRESENT) { - struct sc_security_env tmp; + sc_security_env_t tmp; tmp = *env; tmp.flags &= ~SC_SEC_ENV_ALG_PRESENT; @@ -254,7 +254,7 @@ static int miocos_set_security_env(struct sc_card *card, return iso_ops->set_security_env(card, env, se_num); } -static void add_acl_entry(struct sc_file *file, int op, u8 byte) +static void add_acl_entry(sc_file_t *file, int op, u8 byte) { unsigned int method, key_ref = SC_AC_KEY_REF_NONE; @@ -273,7 +273,7 @@ static void add_acl_entry(struct sc_file *file, int op, u8 byte) sc_file_add_acl_entry(file, op, method, key_ref); } -static void parse_sec_attr(struct sc_file *file, const u8 *buf, size_t len) +static void parse_sec_attr(sc_file_t *file, const u8 *buf, size_t len) { int i; const int df_ops[8] = { @@ -317,9 +317,9 @@ static void parse_sec_attr(struct sc_file *file, const u8 *buf, size_t len) } } -static int miocos_get_acl(struct sc_card *card, struct sc_file *file) +static int miocos_get_acl(sc_card_t *card, sc_file_t *file) { - struct sc_apdu apdu; + sc_apdu_t apdu; u8 rbuf[256]; const u8 *seq = rbuf; size_t left; @@ -352,9 +352,9 @@ static int miocos_get_acl(struct sc_card *card, struct sc_file *file) if (tag == NULL || taglen == 0) continue; for (j = 0; j < SC_MAX_AC_OPS; j++) { - struct sc_acl_entry *e; + sc_acl_entry_t *e; - e = (struct sc_acl_entry *) sc_file_get_acl_entry(file, j); + e = (sc_acl_entry_t *) sc_file_get_acl_entry(file, j); if (e == NULL) continue; if (e->method != SC_AC_CHV) @@ -377,9 +377,9 @@ static int miocos_get_acl(struct sc_card *card, struct sc_file *file) return 0; } -static int miocos_select_file(struct sc_card *card, - const struct sc_path *in_path, - struct sc_file **file) +static int miocos_select_file(sc_card_t *card, + const sc_path_t *in_path, + sc_file_t **file) { int r; @@ -394,9 +394,9 @@ static int miocos_select_file(struct sc_card *card, return 0; } -static int miocos_list_files(struct sc_card *card, u8 *buf, size_t buflen) +static int miocos_list_files(sc_card_t *card, u8 *buf, size_t buflen) { - struct sc_apdu apdu; + sc_apdu_t apdu; int r; sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xCA, 0x01, 0); @@ -410,10 +410,10 @@ static int miocos_list_files(struct sc_card *card, u8 *buf, size_t buflen) return apdu.resplen; } -static int miocos_delete_file(struct sc_card *card, const struct sc_path *path) +static int miocos_delete_file(sc_card_t *card, const sc_path_t *path) { int r; - struct sc_apdu apdu; + sc_apdu_t apdu; SC_FUNC_CALLED(card->ctx, 1); if (path->type != SC_PATH_TYPE_FILE_ID && path->len != 2) { @@ -434,7 +434,7 @@ static int miocos_delete_file(struct sc_card *card, const struct sc_path *path) static int miocos_create_ac(sc_card_t *card, struct sc_cardctl_miocos_ac_info *ac) { - struct sc_apdu apdu; + sc_apdu_t apdu; u8 sbuf[20]; int miocos_type, r; size_t sendsize; @@ -468,7 +468,7 @@ static int miocos_create_ac(sc_card_t *card, return sc_check_sw(card, apdu.sw1, apdu.sw2); } -static int miocos_card_ctl(struct sc_card *card, unsigned long cmd, +static int miocos_card_ctl(sc_card_t *card, unsigned long cmd, void *arg) { switch (cmd) { diff --git a/src/libopensc/card-oberthur.c b/src/libopensc/card-oberthur.c index e3dafafe..d1f4dfa5 100644 --- a/src/libopensc/card-oberthur.c +++ b/src/libopensc/card-oberthur.c @@ -113,7 +113,7 @@ static NTLV_t oberthur_aids[] = { static unsigned char rsa_der[PUBKEY_2048_ASN1_SIZE]; static int rsa_der_len = 0; -static struct sc_file last_selected_file; +static sc_file_t last_selected_file; static struct sc_card_operations auth_ops; static struct sc_card_operations *iso_ops; static struct sc_card_driver auth_drv = { @@ -122,19 +122,19 @@ static struct sc_card_driver auth_drv = { &auth_ops }; -static int auth_get_pin_reference (struct sc_card *card, +static int auth_get_pin_reference (sc_card_t *card, int type, int reference, int cmd, int *out_ref); static int auth_read_component(sc_card_t *card, enum SC_CARDCTL_OBERTHUR_KEY_TYPE type, int num, unsigned char *out, size_t outlen); -static int auth_verify(struct sc_card *card, unsigned int type, +static int auth_verify(sc_card_t *card, unsigned int type, int ref, const u8 *data, size_t data_len, int *tries_left); -static int auth_create_reference_data (struct sc_card *card, +static int auth_create_reference_data (sc_card_t *card, struct sc_cardctl_oberthur_createpin_info *args); static int -auth_finish(struct sc_card *card) +auth_finish(sc_card_t *card) { free(card->drv_data); return 0; @@ -142,9 +142,9 @@ auth_finish(struct sc_card *card) static int -auth_select_aid(struct sc_card *card) +auth_select_aid(sc_card_t *card) { - struct sc_apdu apdu; + sc_apdu_t apdu; unsigned char apdu_resp[SC_MAX_APDU_BUFFER_SIZE]; struct auth_private_data *data = (struct auth_private_data *) card->drv_data; int rv, ii; @@ -206,7 +206,7 @@ auth_select_aid(struct sc_card *card) } static int -auth_match_card(struct sc_card *card) +auth_match_card(sc_card_t *card) { int i; @@ -217,7 +217,7 @@ auth_match_card(struct sc_card *card) } static int -auth_init(struct sc_card *card) +auth_init(sc_card_t *card) { unsigned long flags; struct auth_private_data *data; @@ -265,7 +265,7 @@ auth_init(struct sc_card *card) static void -add_acl_entry(struct sc_card *card, struct sc_file *file, unsigned int op, +add_acl_entry(sc_card_t *card, sc_file_t *file, unsigned int op, u8 acl_byte) { struct auth_private_data *data = (struct auth_private_data *) card->drv_data; @@ -332,8 +332,8 @@ tlv_get(unsigned char *msg, unsigned char tag, unsigned char *ret, int *ret_len) static int -decode_file_structure_V5 (struct sc_card *card, unsigned char *buf, int buflen, - struct sc_file *file) +decode_file_structure_V5 (sc_card_t *card, unsigned char *buf, int buflen, + sc_file_t *file) { u8 type, attr[SC_OBERTHUR_MAX_ATTR_SIZE]; int attr_len = sizeof(attr); @@ -483,7 +483,7 @@ decode_file_structure_V5 (struct sc_card *card, unsigned char *buf, int buflen, static int -check_path(struct sc_card *card, const u8 **pathptr, size_t *pathlen, +check_path(sc_card_t *card, const u8 **pathptr, size_t *pathlen, int need_info) { const u8 *curptr = card->cache.current_path.value; @@ -516,9 +516,9 @@ check_path(struct sc_card *card, const u8 **pathptr, size_t *pathlen, #if 0 static void -auth_cache_path(struct sc_card *card, const struct sc_path *path) +auth_cache_path(sc_card_t *card, const sc_path_t *path) { - struct sc_path *curpath = &card->cache.current_path; + sc_path_t *curpath = &card->cache.current_path; switch (path->type) { case SC_PATH_TYPE_FILE_ID: @@ -553,13 +553,13 @@ auth_cache_path(struct sc_card *card, const struct sc_path *path) #endif static int -select_parent(struct sc_card *card, struct sc_file **file_out) +select_parent(sc_card_t *card, sc_file_t **file_out) { int rv; - struct sc_apdu apdu; + sc_apdu_t apdu; u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; - struct sc_file *file; - struct sc_path *cache_path = &card->cache.current_path; + sc_file_t *file; + sc_path_t *cache_path = &card->cache.current_path; struct auth_private_data *prv = (struct auth_private_data *) card->drv_data; last_selected_file.magic = 0; @@ -598,7 +598,7 @@ select_parent(struct sc_card *card, struct sc_file **file_out) return rv; } - memcpy(&last_selected_file, file, sizeof(struct sc_file)); + memcpy(&last_selected_file, file, sizeof(sc_file_t)); if (file_out) *file_out = file; @@ -610,11 +610,11 @@ select_parent(struct sc_card *card, struct sc_file **file_out) static int -select_mf(struct sc_card *card, struct sc_file **file_out) +select_mf(sc_card_t *card, sc_file_t **file_out) { int ii,rv; - struct sc_file *file = NULL; - struct sc_path *cache_path = &card->cache.current_path; + sc_file_t *file = NULL; + sc_path_t *cache_path = &card->cache.current_path; last_selected_file.magic = 0; for(ii=0;;ii++) { @@ -633,7 +633,7 @@ select_mf(struct sc_card *card, struct sc_file **file_out) memcpy(cache_path->value, "\x3F\x00", 2); cache_path->len = 2; - memcpy(&last_selected_file, file, sizeof(struct sc_file)); + memcpy(&last_selected_file, file, sizeof(sc_file_t)); if (file && file_out) *file_out = file; else if (file) @@ -644,13 +644,13 @@ select_mf(struct sc_card *card, struct sc_file **file_out) static int -select_file_id(struct sc_card *card, const u8 *buf, size_t buflen, - u8 p1, struct sc_file **file_out) +select_file_id(sc_card_t *card, const u8 *buf, size_t buflen, + u8 p1, sc_file_t **file_out) { int rv; - struct sc_apdu apdu; + sc_apdu_t apdu; u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; - struct sc_file *file; + sc_file_t *file; struct auth_private_data *prv = (struct auth_private_data *) card->drv_data; last_selected_file.magic = 0; @@ -697,10 +697,10 @@ select_file_id(struct sc_card *card, const u8 *buf, size_t buflen, return rv; } - memcpy(&last_selected_file, file, sizeof(struct sc_file)); + memcpy(&last_selected_file, file, sizeof(sc_file_t)); if (file->type == SC_FILE_TYPE_DF) { - struct sc_path *cache_path = &card->cache.current_path; + sc_path_t *cache_path = &card->cache.current_path; size_t len = cache_path->len; if (len < sizeof(cache_path->value)) { @@ -720,8 +720,8 @@ select_file_id(struct sc_card *card, const u8 *buf, size_t buflen, static int -auth_select_file(struct sc_card *card, const struct sc_path *path, - struct sc_file **file_out) +auth_select_file(sc_card_t *card, const sc_path_t *path, + sc_file_t **file_out) { int rv; const u8 *pathptr = path->value; @@ -789,9 +789,9 @@ auth_select_file(struct sc_card *card, const struct sc_path *path, static int -auth_list_files(struct sc_card *card, u8 *buf, size_t buflen) +auth_list_files(sc_card_t *card, u8 *buf, size_t buflen) { - struct sc_apdu apdu; + sc_apdu_t apdu; u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; int rv; @@ -815,11 +815,11 @@ auth_list_files(struct sc_card *card, u8 *buf, size_t buflen) static int -auth_delete_file(struct sc_card *card, const struct sc_path *path) +auth_delete_file(sc_card_t *card, const sc_path_t *path) { int rv; u8 sbuf[2]; - struct sc_apdu apdu; + sc_apdu_t apdu; sc_debug(card->ctx, "path; type=%d, path=%s\n", path->type, sc_print_path(path)); SC_FUNC_CALLED(card->ctx, 1); @@ -829,7 +829,7 @@ auth_delete_file(struct sc_card *card, const struct sc_path *path) } if (path->len > 2) { - struct sc_path parent = *path; + sc_path_t parent = *path; parent.len -= 2; parent.type = SC_PATH_TYPE_PATH; @@ -856,7 +856,7 @@ auth_delete_file(struct sc_card *card, const struct sc_path *path) u8 lbuf[SC_MAX_APDU_BUFFER_SIZE]; int ii, len; #if 0 - struct sc_file *file; + sc_file_t *file; if (!(file = sc_file_new())) SC_FUNC_RETURN(card->ctx, 0, SC_ERROR_OUT_OF_MEMORY); @@ -899,7 +899,7 @@ auth_delete_file(struct sc_card *card, const struct sc_path *path) static int -acl_to_ac_byte(struct sc_card *card, const struct sc_acl_entry *e) +acl_to_ac_byte(sc_card_t *card, const sc_acl_entry_t *e) { struct auth_private_data *data = (struct auth_private_data *) card->drv_data; @@ -933,7 +933,7 @@ acl_to_ac_byte(struct sc_card *card, const struct sc_acl_entry *e) static int -encode_file_structure_V5(struct sc_card *card, const struct sc_file *file, +encode_file_structure_V5(sc_card_t *card, const sc_file_t *file, u8 *buf, size_t *buflen) { u8 *p = buf; @@ -1099,7 +1099,7 @@ encode_file_structure_V5(struct sc_card *card, const struct sc_file *file, } for (ii = 0; ii < sizeof(ops); ii++) { - const struct sc_acl_entry *entry; + const sc_acl_entry_t *entry; p[16+ii] = 0xFF; if (ops[ii]==0xFF) @@ -1117,13 +1117,13 @@ encode_file_structure_V5(struct sc_card *card, const struct sc_file *file, static int -auth_create_file(struct sc_card *card, struct sc_file *file) +auth_create_file(sc_card_t *card, sc_file_t *file) { u8 sbuf[0x18]; size_t sendlen = sizeof(sbuf); int rv, rec_nr; - struct sc_apdu apdu; - struct sc_path path; + sc_apdu_t apdu; + sc_path_t path; struct auth_private_data *prv = (struct auth_private_data *) card->drv_data; sc_debug(card->ctx, " create path=%s\n", sc_print_path(&file->path)); @@ -1191,15 +1191,15 @@ auth_create_file(struct sc_card *card, struct sc_file *file) static int -auth_set_security_env(struct sc_card *card, - const struct sc_security_env *env, int se_num) +auth_set_security_env(sc_card_t *card, + const sc_security_env_t *env, int se_num) { auth_senv_t *senv = &((struct auth_private_data *) card->drv_data)->senv; long unsigned pads = env->algorithm_flags & SC_ALGORITHM_RSA_PADS; long unsigned supported_pads = SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_PAD_ISO9796; - struct sc_file *key_file = NULL; - struct sc_apdu apdu; + sc_file_t *key_file = NULL; + sc_apdu_t apdu; u8 rsa_sbuf[7] = {0x80, 0x01, 0xFF, 0x81, 0x02, 0xFF, 0xFF}; int des_buf_len; u8 des_sbuf[17] = {0x80, 0x01, 0x01, 0x81, 0x02, 0xFF, 0xFF, @@ -1306,18 +1306,18 @@ auth_set_security_env(struct sc_card *card, static int -auth_restore_security_env(struct sc_card *card, int se_num) +auth_restore_security_env(sc_card_t *card, int se_num) { return 0; } static int -auth_compute_signature(struct sc_card *card, +auth_compute_signature(sc_card_t *card, const u8 *in, size_t ilen, u8 * out, size_t olen) { auth_senv_t *senv = &((struct auth_private_data *) card->drv_data)->senv; - struct sc_apdu apdu; + sc_apdu_t apdu; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; int rv; @@ -1390,12 +1390,12 @@ auth_compute_signature(struct sc_card *card, } static int -auth_decipher(struct sc_card *card, const u8 * crgram, size_t crgram_len, +auth_decipher(sc_card_t *card, const u8 * crgram, size_t crgram_len, u8 * out, size_t outlen) { auth_senv_t *senv = &((struct auth_private_data *) card->drv_data)->senv; struct auth_private_data *prv = (struct auth_private_data *) card->drv_data; - struct sc_apdu apdu; + sc_apdu_t apdu; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; int rv; @@ -1498,7 +1498,7 @@ done: /* Return the default AAK for this type of card */ static int -auth_get_default_key(struct sc_card *card, struct sc_cardctl_default_key *data) +auth_get_default_key(sc_card_t *card, struct sc_cardctl_default_key *data) { return SC_ERROR_NO_DEFAULT_KEY; } @@ -1527,7 +1527,7 @@ auth_encode_exponent(unsigned long exponent, u8 *buff, size_t buff_len) static int auth_generate_key(sc_card_t *card, struct sc_cardctl_oberthur_genkey_info *data) { - struct sc_apdu apdu; + sc_apdu_t apdu; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; int rv = 0; @@ -1596,7 +1596,7 @@ auth_generate_key(sc_card_t *card, struct sc_cardctl_oberthur_genkey_info *data) static int auth_update_component(sc_card_t *card, struct sc_cardctl_oberthur_updatekey_info *args) { - struct sc_apdu apdu; + sc_apdu_t apdu; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE + 0x10]; u8 ins, p1, p2; int rv, len; @@ -1715,7 +1715,7 @@ auth_update_component(sc_card_t *card, struct sc_cardctl_oberthur_updatekey_info static int -auth_card_ctl(struct sc_card *card, unsigned long cmd, void *ptr) +auth_card_ctl(sc_card_t *card, unsigned long cmd, void *ptr) { switch (cmd) { case SC_CARDCTL_GET_DEFAULT_KEY: @@ -1741,7 +1741,7 @@ auth_read_component(sc_card_t *card, enum SC_CARDCTL_OBERTHUR_KEY_TYPE type, int num, unsigned char *out, size_t outlen) { int rv; - struct sc_apdu apdu; + sc_apdu_t apdu; struct auth_private_data *prv = (struct auth_private_data *) card->drv_data; unsigned char resp[SC_MAX_APDU_BUFFER_SIZE]; @@ -1790,7 +1790,7 @@ auth_read_component(sc_card_t *card, enum SC_CARDCTL_OBERTHUR_KEY_TYPE type, } -static int auth_get_pin_reference (struct sc_card *card, +static int auth_get_pin_reference (sc_card_t *card, int type, int reference, int cmd, int *out_ref) { struct auth_private_data *prv = (struct auth_private_data *) card->drv_data; @@ -1827,7 +1827,7 @@ static int auth_get_pin_reference (struct sc_card *card, static void -auth_init_pin_info(struct sc_card *card, struct sc_pin_cmd_pin *pin, +auth_init_pin_info(sc_card_t *card, struct sc_pin_cmd_pin *pin, unsigned int type) { struct auth_private_data *data = (struct auth_private_data *) card->drv_data; @@ -1852,7 +1852,7 @@ auth_init_pin_info(struct sc_card *card, struct sc_pin_cmd_pin *pin, static int -auth_verify(struct sc_card *card, unsigned int type, +auth_verify(sc_card_t *card, unsigned int type, int ref, const u8 *data, size_t data_len, int *tries_left) { sc_apdu_t apdu; @@ -1925,7 +1925,7 @@ auth_verify(struct sc_card *card, unsigned int type, static int -auth_change_reference_data (struct sc_card *card, unsigned int type, +auth_change_reference_data (sc_card_t *card, unsigned int type, int ref, const u8 *old, size_t oldlen, const u8 *_new, size_t newlen, int *tries_left) { @@ -1968,7 +1968,7 @@ auth_change_reference_data (struct sc_card *card, unsigned int type, static int -auth_reset_retry_counter(struct sc_card *card, unsigned int type, +auth_reset_retry_counter(sc_card_t *card, unsigned int type, int ref, const u8 *puk, size_t puklen, const u8 *pin, size_t pinlen) { @@ -2016,7 +2016,7 @@ auth_reset_retry_counter(struct sc_card *card, unsigned int type, static int -auth_create_reference_data (struct sc_card *card, +auth_create_reference_data (sc_card_t *card, struct sc_cardctl_oberthur_createpin_info *args) { sc_apdu_t apdu; @@ -2079,7 +2079,7 @@ auth_create_reference_data (struct sc_card *card, static int -auth_logout(struct sc_card *card) +auth_logout(sc_card_t *card) { sc_apdu_t apdu; int rv, pin_ref; @@ -2110,7 +2110,7 @@ auth_logout(struct sc_card *card) } static int -write_publickey (struct sc_card *card, unsigned int offset, +write_publickey (sc_card_t *card, unsigned int offset, const u8 *buf, size_t count) { int ii, rv; @@ -2179,7 +2179,7 @@ end: static int -auth_update_binary(struct sc_card *card, unsigned int offset, +auth_update_binary(sc_card_t *card, unsigned int offset, const u8 *buf, size_t count, unsigned long flags) { int rv = 0; @@ -2217,7 +2217,7 @@ auth_update_binary(struct sc_card *card, unsigned int offset, static int -auth_read_binary(struct sc_card *card, unsigned int offset, +auth_read_binary(sc_card_t *card, unsigned int offset, u8 *buf, size_t count, unsigned long flags) { int rv; @@ -2296,10 +2296,10 @@ auth_read_binary(struct sc_card *card, unsigned int offset, static int -auth_delete_record(struct sc_card *card, unsigned int nr_rec) +auth_delete_record(sc_card_t *card, unsigned int nr_rec) { int rv = 0; - struct sc_apdu apdu; + sc_apdu_t apdu; sc_debug(card->ctx, "auth_delete_record(): nr_rec %i\n", nr_rec); sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0x32, nr_rec, 0x04); diff --git a/src/libopensc/card-setcos.c b/src/libopensc/card-setcos.c index 034237a0..d6052bc3 100644 --- a/src/libopensc/card-setcos.c +++ b/src/libopensc/card-setcos.c @@ -51,12 +51,12 @@ static struct sc_card_driver setcos_drv = { &setcos_ops }; -static int setcos_finish(struct sc_card *card) +static int setcos_finish(sc_card_t *card) { return 0; } -static int match_hist_bytes(struct sc_card *card, const char *str, size_t len) +static int match_hist_bytes(sc_card_t *card, const char *str, size_t len) { const char *src = (const char *) card->slot->atr_info.hist_bytes; size_t srclen = card->slot->atr_info.hist_bytes_len; @@ -75,7 +75,7 @@ static int match_hist_bytes(struct sc_card *card, const char *str, size_t len) return 0; } -static int setcos_match_card(struct sc_card *card) +static int setcos_match_card(sc_card_t *card) { int i; @@ -110,7 +110,7 @@ static int select_fineid_app(sc_card_t * card) return r; } -static int setcos_init(struct sc_card *card) +static int setcos_init(sc_card_t *card) { card->name = "SetCOS"; @@ -159,7 +159,7 @@ static int setcos_init(struct sc_card *card) static const struct sc_card_operations *iso_ops = NULL; -static u8 acl_to_byte(const struct sc_acl_entry *e) +static u8 acl_to_byte(const sc_acl_entry_t *e) { switch (e->method) { case SC_AC_NONE: @@ -184,7 +184,7 @@ static u8 acl_to_byte(const struct sc_acl_entry *e) return 0x00; } -static int setcos_create_file(struct sc_card *card, struct sc_file *file) +static int setcos_create_file(sc_card_t *card, sc_file_t *file) { if (file->prop_attr_len == 0) sc_file_set_prop_attr(file, (const u8 *) "\x03\x00\x00", 3); @@ -218,10 +218,10 @@ static int setcos_create_file(struct sc_card *card, struct sc_file *file) return iso_ops->create_file(card, file); } -static int setcos_set_security_env2(struct sc_card *card, - const struct sc_security_env *env, int se_num) +static int setcos_set_security_env2(sc_card_t *card, + const sc_security_env_t *env, int se_num) { - struct sc_apdu apdu; + sc_apdu_t apdu; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 *p; int r, locked = 0; @@ -299,11 +299,11 @@ err: return r; } -static int setcos_set_security_env(struct sc_card *card, - const struct sc_security_env *env, int se_num) +static int setcos_set_security_env(sc_card_t *card, + const sc_security_env_t *env, int se_num) { if (env->flags & SC_SEC_ENV_ALG_PRESENT) { - struct sc_security_env tmp; + sc_security_env_t tmp; tmp = *env; tmp.flags &= ~SC_SEC_ENV_ALG_PRESENT; @@ -335,7 +335,7 @@ static int setcos_set_security_env(struct sc_card *card, return setcos_set_security_env2(card, env, se_num); } -static void add_acl_entry(struct sc_file *file, int op, u8 byte) +static void add_acl_entry(sc_file_t *file, int op, u8 byte) { unsigned int method, key_ref = SC_AC_KEY_REF_NONE; @@ -364,7 +364,7 @@ static void add_acl_entry(struct sc_file *file, int op, u8 byte) sc_file_add_acl_entry(file, op, method, key_ref); } -static void parse_sec_attr(struct sc_file *file, const u8 * buf, size_t len) +static void parse_sec_attr(sc_file_t *file, const u8 * buf, size_t len) { int i; int idx[6]; @@ -392,8 +392,8 @@ static void parse_sec_attr(struct sc_file *file, const u8 * buf, size_t len) add_acl_entry(file, idx[i], buf[i]); } -static int setcos_select_file(struct sc_card *card, - const struct sc_path *in_path, struct sc_file **file) +static int setcos_select_file(sc_card_t *card, + const sc_path_t *in_path, sc_file_t **file) { int r; @@ -405,9 +405,9 @@ static int setcos_select_file(struct sc_card *card, return 0; } -static int setcos_list_files(struct sc_card *card, u8 * buf, size_t buflen) +static int setcos_list_files(sc_card_t *card, u8 * buf, size_t buflen) { - struct sc_apdu apdu; + sc_apdu_t apdu; int r; sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xAA, 0, 0); @@ -422,7 +422,7 @@ static int setcos_list_files(struct sc_card *card, u8 * buf, size_t buflen) } #if 0 -static int setcos_logout(struct sc_card *card) +static int setcos_logout(sc_card_t *card) { return 0; } diff --git a/src/libopensc/card-starcos.c b/src/libopensc/card-starcos.c index c2f2ce7b..48a430af 100644 --- a/src/libopensc/card-starcos.c +++ b/src/libopensc/card-starcos.c @@ -66,7 +66,7 @@ typedef struct starcos_ex_data_st { } starcos_ex_data; /* the starcos part */ -static int starcos_match_card(struct sc_card *card) +static int starcos_match_card(sc_card_t *card) { int i; @@ -76,7 +76,7 @@ static int starcos_match_card(struct sc_card *card) return 1; } -static int starcos_init(struct sc_card *card) +static int starcos_init(sc_card_t *card) { int flags; starcos_ex_data *ex_data; @@ -112,14 +112,14 @@ static int starcos_init(struct sc_card *card) return 0; } -static int starcos_finish(struct sc_card *card) +static int starcos_finish(sc_card_t *card) { if (card->drv_data) free((starcos_ex_data *)card->drv_data); return 0; } -static int process_fci(struct sc_context *ctx, struct sc_file *file, +static int process_fci(sc_context_t *ctx, sc_file_t *file, const u8 *buf, size_t buflen) { /* NOTE: According to the Starcos S 2.1 manual it's possible @@ -212,9 +212,9 @@ static int process_fci(struct sc_context *ctx, struct sc_file *file, return SC_SUCCESS; } -static int starcos_select_aid(struct sc_card *card, +static int starcos_select_aid(sc_card_t *card, u8 aid[16], size_t len, - struct sc_file **file_out) + sc_file_t **file_out) { sc_apdu_t apdu; int r; @@ -260,9 +260,9 @@ static int starcos_select_aid(struct sc_card *card, SC_FUNC_RETURN(card->ctx, 2, SC_SUCCESS); } -static int starcos_select_fid(struct sc_card *card, +static int starcos_select_fid(sc_card_t *card, u8 id_hi, u8 id_lo, - struct sc_file **file_out) + sc_file_t **file_out) { sc_apdu_t apdu; u8 data[] = {id_hi, id_lo}; @@ -358,9 +358,9 @@ static int starcos_select_fid(struct sc_card *card, SC_FUNC_RETURN(card->ctx, 2, SC_SUCCESS); } -static int starcos_select_file(struct sc_card *card, - const struct sc_path *in_path, - struct sc_file **file_out) +static int starcos_select_file(sc_card_t *card, + const sc_path_t *in_path, + sc_file_t **file_out) { u8 pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf; int r; @@ -526,9 +526,9 @@ static int starcos_select_file(struct sc_card *card, #define STARCOS_AC_NEVER 0x5f #define STARCOS_PINID2STATE(a) ((((a) & 0x0f) == 0x01) ? ((a) & 0x0f) : (0x0f - ((0x0f & (a)) >> 1))) -static u8 process_acl_entry(struct sc_file *in, unsigned int method, u8 def) +static u8 process_acl_entry(sc_file_t *in, unsigned int method, u8 def) { - const struct sc_acl_entry *entry = sc_file_get_acl_entry(in, method); + const sc_acl_entry_t *entry = sc_file_get_acl_entry(in, method); if (!entry) return def; else if (entry->method & SC_AC_CHV) { @@ -556,7 +556,7 @@ static u8 process_acl_entry(struct sc_file *in, unsigned int method, u8 def) * from the OpenSC internal acl (storing the result in the supplied * sc_starcos_create_data structure). */ -static int starcos_process_acl(struct sc_card *card, struct sc_file *file, +static int starcos_process_acl(sc_card_t *card, sc_file_t *file, sc_starcos_create_data *data) { int r; @@ -691,11 +691,11 @@ static int starcos_process_acl(struct sc_card *card, struct sc_file *file, * in the sc_starcos_create_data.mf structure. Note: CREATE END must be * called separately to activate the ACs. */ -static int starcos_create_mf(struct sc_card *card, sc_starcos_create_data *data) +static int starcos_create_mf(sc_card_t *card, sc_starcos_create_data *data) { int r; - struct sc_apdu apdu; - struct sc_context *ctx = card->ctx; + sc_apdu_t apdu; + sc_context_t *ctx = card->ctx; if (ctx->debug >= 3) sc_debug(ctx, "creating MF \n"); @@ -720,12 +720,12 @@ static int starcos_create_mf(struct sc_card *card, sc_starcos_create_data *data) * stored in a sc_starcos_create_data.df data structure. Note: CREATE END must * be called separately to activate the ACs. */ -static int starcos_create_df(struct sc_card *card, sc_starcos_create_data *data) +static int starcos_create_df(sc_card_t *card, sc_starcos_create_data *data) { int r; size_t len; - struct sc_apdu apdu; - struct sc_context *ctx = card->ctx; + sc_apdu_t apdu; + sc_context_t *ctx = card->ctx; if (ctx->debug >= 3) sc_debug(ctx, "creating DF\n"); @@ -767,11 +767,11 @@ static int starcos_create_df(struct sc_card *card, sc_starcos_create_data *data) * This function creates a EF based on the information stored in * the sc_starcos_create_data.ef data structure. */ -static int starcos_create_ef(struct sc_card *card, sc_starcos_create_data *data) +static int starcos_create_ef(sc_card_t *card, sc_starcos_create_data *data) { int r; - struct sc_apdu apdu; - struct sc_context *ctx = card->ctx; + sc_apdu_t apdu; + sc_context_t *ctx = card->ctx; if (ctx->debug >= 3) sc_debug(ctx, "creating EF\n"); @@ -796,11 +796,11 @@ static int starcos_create_ef(struct sc_card *card, sc_starcos_create_data *data) * This function finishs the creation of a DF (or MF) and activates * the ACs. */ -static int starcos_create_end(struct sc_card *card, struct sc_file *file) +static int starcos_create_end(sc_card_t *card, sc_file_t *file) { int r; u8 fid[2]; - struct sc_apdu apdu; + sc_apdu_t apdu; if (file->type != SC_FILE_TYPE_DF) return SC_ERROR_INVALID_ARGUMENTS; @@ -825,7 +825,7 @@ static int starcos_create_end(struct sc_card *card, struct sc_file *file) * This function creates MF, DF or EF based on the supplied * information in the sc_file structure (using starcos_process_acl). */ -static int starcos_create_file(struct sc_card *card, struct sc_file *file) +static int starcos_create_file(sc_card_t *card, sc_file_t *file) { int r; sc_starcos_create_data data; @@ -863,11 +863,11 @@ static int starcos_create_file(struct sc_card *card, struct sc_file *file) * * This function deletes the MF (for 'test cards' only). */ -static int starcos_erase_card(struct sc_card *card) +static int starcos_erase_card(sc_card_t *card) { /* restore the delivery state */ int r; u8 sbuf[2]; - struct sc_apdu apdu; + sc_apdu_t apdu; sbuf[0] = 0x3f; sbuf[1] = 0x00; @@ -899,13 +899,13 @@ static int starcos_erase_card(struct sc_card *card) * information supplied in the sc_starcos_wkey_data structure) * and set a supplied key (depending on the mode). */ -static int starcos_write_key(struct sc_card *card, sc_starcos_wkey_data *data) +static int starcos_write_key(sc_card_t *card, sc_starcos_wkey_data *data) { int r; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; const u8 *p; size_t len = sizeof(sbuf), tlen, offset = 0; - struct sc_apdu apdu; + sc_apdu_t apdu; if (!data->mode) /* mode == 0 => install */ { /* install key header */ @@ -967,11 +967,11 @@ static int starcos_write_key(struct sc_card *card, sc_starcos_wkey_data *data) * This function generates a public key pair and stores the created * private key in the ISF (specified by the KID). */ -static int starcos_gen_key(struct sc_card *card, sc_starcos_gen_key_data *data) +static int starcos_gen_key(sc_card_t *card, sc_starcos_gen_key_data *data) { int r; size_t i, len = data->key_length >> 3; - struct sc_apdu apdu; + sc_apdu_t apdu; u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 sbuf[2], *p, *q; /* generate key */ @@ -1028,13 +1028,13 @@ static int starcos_gen_key(struct sc_card *card, sc_starcos_gen_key_data *data) * COMPUTE SIGNATURE or INTERNAL AUTHENTICATE must be used for signature * calculation. */ -static int starcos_set_security_env(struct sc_card *card, - const struct sc_security_env *env, +static int starcos_set_security_env(sc_card_t *card, + const sc_security_env_t *env, int se_num) { u8 *p, *pp, keyID; int r, operation = env->operation; - struct sc_apdu apdu; + sc_apdu_t apdu; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; starcos_ex_data *ex_data = (starcos_ex_data *)card->drv_data; @@ -1154,12 +1154,12 @@ try_authenticate: return SC_ERROR_INVALID_ARGUMENTS; } -static int starcos_compute_signature(struct sc_card *card, +static int starcos_compute_signature(sc_card_t *card, const u8 * data, size_t datalen, u8 * out, size_t outlen) { int r; - struct sc_apdu apdu; + sc_apdu_t apdu; u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; starcos_ex_data *ex_data = (starcos_ex_data *)card->drv_data; @@ -1246,7 +1246,7 @@ static int starcos_compute_signature(struct sc_card *card, SC_FUNC_RETURN(card->ctx, 4, sc_check_sw(card, apdu.sw1, apdu.sw2)); } -static int starcos_check_sw(struct sc_card *card, int sw1, int sw2) +static int starcos_check_sw(sc_card_t *card, int sw1, int sw2) { const int err_count = sizeof(starcos_errors)/sizeof(starcos_errors[0]); int i; @@ -1279,7 +1279,7 @@ static int starcos_get_serialnr(sc_card_t *card, sc_serial_number_t *serial) { int r; u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; - struct sc_apdu apdu; + sc_apdu_t apdu; if (!serial) return SC_ERROR_INVALID_ARGUMENTS; @@ -1308,7 +1308,7 @@ static int starcos_get_serialnr(sc_card_t *card, sc_serial_number_t *serial) return SC_SUCCESS; } -static int starcos_card_ctl(struct sc_card *card, unsigned long cmd, void *ptr) +static int starcos_card_ctl(sc_card_t *card, unsigned long cmd, void *ptr) { sc_starcos_create_data *tmp; @@ -1339,10 +1339,10 @@ static int starcos_card_ctl(struct sc_card *card, unsigned long cmd, void *ptr) } } -static int starcos_logout(struct sc_card *card) +static int starcos_logout(sc_card_t *card) { int r; - struct sc_apdu apdu; + sc_apdu_t apdu; const u8 mf_buf[2] = {0x3f, 0x00}; sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xA4, 0x00, 0x0C); diff --git a/src/libopensc/card-tcos.c b/src/libopensc/card-tcos.c index 5f8a78a5..45cee403 100644 --- a/src/libopensc/card-tcos.c +++ b/src/libopensc/card-tcos.c @@ -50,13 +50,13 @@ typedef struct tcos_data_st { unsigned int pad_flags; } tcos_data; -static int tcos_finish(struct sc_card *card) +static int tcos_finish(sc_card_t *card) { free(card->drv_data); return 0; } -static int tcos_match_card(struct sc_card *card) +static int tcos_match_card(sc_card_t *card) { int i; @@ -66,7 +66,7 @@ static int tcos_match_card(struct sc_card *card) return 1; } -static int tcos_init(struct sc_card *card) +static int tcos_init(sc_card_t *card) { unsigned long flags; @@ -94,7 +94,7 @@ static int tcos_init(struct sc_card *card) OpenSC should be enhanced to allow for the command based security attributes of TCOS. FIXME: This just allows to create a very basic file. */ -static int tcos_construct_fci(const struct sc_file *file, +static int tcos_construct_fci(const sc_file_t *file, u8 *out, size_t *outlen) { u8 *p = out; @@ -189,12 +189,12 @@ static int tcos_construct_fci(const struct sc_file *file, } -static int tcos_create_file(struct sc_card *card, struct sc_file *file) +static int tcos_create_file(sc_card_t *card, sc_file_t *file) { int r; size_t len; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; - struct sc_apdu apdu; + sc_apdu_t apdu; len = SC_MAX_APDU_BUFFER_SIZE; r = tcos_construct_fci(file, sbuf, &len); @@ -250,8 +250,8 @@ static int map_operations (int commandbyte ) OpenSC should be enhanced to allow for the command based security attributes of TCOS. FIXME: This just allows to create a very basic file. */ -static void parse_sec_attr(struct sc_card *card, - struct sc_file *file, const u8 *buf, size_t len) +static void parse_sec_attr(sc_card_t *card, + sc_file_t *file, const u8 *buf, size_t len) { int op; @@ -316,7 +316,7 @@ static void parse_sec_attr(struct sc_card *card, } /* Arghh. duplicated from iso7816.c */ -static void tcos_process_fci(struct sc_context *ctx, struct sc_file *file, +static void tcos_process_fci(sc_context_t *ctx, sc_file_t *file, const u8 *buf, size_t buflen) { size_t taglen, len = buflen; @@ -422,16 +422,16 @@ static void tcos_process_fci(struct sc_context *ctx, struct sc_file *file, needed to cope with some starngeness in APDU construction. It is probably better to have this specfic for TCOS, so that support for other cards does not break. */ -static int hacked_iso7816_select_file(struct sc_card *card, - const struct sc_path *in_path, - struct sc_file **file_out) +static int hacked_iso7816_select_file(sc_card_t *card, + const sc_path_t *in_path, + sc_file_t **file_out) { - struct sc_context *ctx; - struct sc_apdu apdu; + sc_context_t *ctx; + sc_apdu_t apdu; u8 buf[SC_MAX_APDU_BUFFER_SIZE]; u8 pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf; int r, pathlen; - struct sc_file *file = NULL; + sc_file_t *file = NULL; assert(card != NULL && in_path != NULL); ctx = card->ctx; @@ -515,9 +515,9 @@ static int hacked_iso7816_select_file(struct sc_card *card, -static int tcos_select_file(struct sc_card *card, - const struct sc_path *in_path, - struct sc_file **file) +static int tcos_select_file(sc_card_t *card, + const sc_path_t *in_path, + sc_file_t **file) { int r; @@ -534,9 +534,9 @@ static int tcos_select_file(struct sc_card *card, return 0; } -static int tcos_list_files(struct sc_card *card, u8 *buf, size_t buflen) +static int tcos_list_files(sc_card_t *card, u8 *buf, size_t buflen) { - struct sc_apdu apdu; + sc_apdu_t apdu; u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 p1s[2] = { 0x01, 0x02 }; int r, i, count = 0; @@ -565,11 +565,11 @@ static int tcos_list_files(struct sc_card *card, u8 *buf, size_t buflen) -static int tcos_delete_file(struct sc_card *card, const struct sc_path *path) +static int tcos_delete_file(sc_card_t *card, const sc_path_t *path) { int r; u8 sbuf[2]; - struct sc_apdu apdu; + sc_apdu_t apdu; SC_FUNC_CALLED(card->ctx, 1); if (path->type != SC_PATH_TYPE_FILE_ID && path->len != 2) { @@ -597,11 +597,11 @@ static int tcos_delete_file(struct sc_card *card, const struct sc_path *path) The problem is that I don't have the ISO specs and Juha's 7816 code uses parameters which are not described in the TCOS specs. [wk] */ -static int tcos_set_security_env(struct sc_card *card, - const struct sc_security_env *env, +static int tcos_set_security_env(sc_card_t *card, + const sc_security_env_t *env, int se_num) { - struct sc_apdu apdu; + sc_apdu_t apdu; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 *p; int r, locked = 0; @@ -678,7 +678,7 @@ err: /* See tcos_set_security_env() for comments. So we always return success */ -static int tcos_restore_security_env(struct sc_card *card, int se_num) +static int tcos_restore_security_env(sc_card_t *card, int se_num) { return 0; } @@ -687,12 +687,12 @@ static int tcos_restore_security_env(struct sc_card *card, int se_num) * TCOS decipher command (same as iso7816_decipher besides setting * the padding byte). */ -static int tcos_decipher(struct sc_card *card, +static int tcos_decipher(sc_card_t *card, const u8 * crgram, size_t crgram_len, u8 * out, size_t outlen) { int r; - struct sc_apdu apdu; + sc_apdu_t apdu; tcos_data *xdata; u8 pad_byte; u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; @@ -742,10 +742,10 @@ static int tcos_decipher(struct sc_card *card, /* Issue the SET PERMANENT command. With ENABLE_NULLPIN set the NullPIN method will be activated, otherwise the permanent operation will be done on the active file. */ -static int tcos_setperm(struct sc_card *card, int enable_nullpin) +static int tcos_setperm(sc_card_t *card, int enable_nullpin) { int r; - struct sc_apdu apdu; + sc_apdu_t apdu; SC_FUNC_CALLED(card->ctx, 1); sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0xEE, 0x00, 0x00); @@ -797,7 +797,7 @@ static int tcos_get_serialnr(sc_card_t *card, sc_serial_number_t *serial) return SC_SUCCESS; } -static int tcos_card_ctl(struct sc_card *card, unsigned long cmd, void *ptr) +static int tcos_card_ctl(sc_card_t *card, unsigned long cmd, void *ptr) { switch (cmd) { case SC_CARDCTL_TCOS_SETPERM: diff --git a/src/libopensc/card.c b/src/libopensc/card.c index 197dc9bb..3d8ea347 100644 --- a/src/libopensc/card.c +++ b/src/libopensc/card.c @@ -27,13 +27,13 @@ #endif #include -int sc_check_sw(struct sc_card *card, int sw1, int sw2) +int sc_check_sw(sc_card_t *card, int sw1, int sw2) { assert(card->ops->check_sw != NULL); return card->ops->check_sw(card, sw1, sw2); } -static int sc_check_apdu(struct sc_context *ctx, const struct sc_apdu *apdu) +static int sc_check_apdu(sc_context_t *ctx, const sc_apdu_t *apdu) { if (apdu->le > 256) { sc_error(ctx, "Value of Le too big (maximum 256 bytes)\n"); @@ -126,7 +126,7 @@ sc_masquerade_apdu(sc_card_t *card, sc_apdu_t *apdu) return 0; } -static int sc_transceive(struct sc_card *card, struct sc_apdu *apdu) +static int sc_transceive(sc_card_t *card, sc_apdu_t *apdu) { u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; @@ -238,7 +238,7 @@ static int sc_transceive(struct sc_card *card, struct sc_apdu *apdu) return 0; } -int sc_transmit_apdu(struct sc_card *card, struct sc_apdu *apdu) +int sc_transmit_apdu(sc_card_t *card, sc_apdu_t *apdu) { int r; size_t orig_resplen; @@ -304,7 +304,7 @@ int sc_transmit_apdu(struct sc_card *card, struct sc_apdu *apdu) return 0; } -void sc_format_apdu(struct sc_card *card, struct sc_apdu *apdu, +void sc_format_apdu(sc_card_t *card, sc_apdu_t *apdu, int cse, int ins, int p1, int p2) { assert(card != NULL && apdu != NULL); @@ -318,11 +318,11 @@ void sc_format_apdu(struct sc_card *card, struct sc_apdu *apdu, return; } -static struct sc_card * sc_card_new(void) +static sc_card_t * sc_card_new(void) { - struct sc_card *card; + sc_card_t *card; - card = (struct sc_card *) calloc(1, sizeof(struct sc_card)); + card = (sc_card_t *) calloc(1, sizeof(struct sc_card)); if (card == NULL) return NULL; card->ops = (struct sc_card_operations *) malloc(sizeof(struct sc_card_operations)); @@ -338,7 +338,7 @@ static struct sc_card * sc_card_new(void) return card; } -static void sc_card_free(struct sc_card *card) +static void sc_card_free(sc_card_t *card) { assert(sc_card_valid(card)); sc_free_apps(card); @@ -352,12 +352,12 @@ static void sc_card_free(struct sc_card *card) free(card); } -int sc_connect_card(struct sc_reader *reader, int slot_id, - struct sc_card **card_out) +int sc_connect_card(sc_reader_t *reader, int slot_id, + sc_card_t **card_out) { - struct sc_card *card; - struct sc_context *ctx = reader->ctx; - struct sc_slot_info *slot = _sc_get_slot_info(reader, slot_id); + sc_card_t *card; + sc_context_t *ctx = reader->ctx; + sc_slot_info_t *slot = _sc_get_slot_info(reader, slot_id); struct sc_card_driver *driver; int i, r = 0, idx; @@ -478,9 +478,9 @@ err: SC_FUNC_RETURN(ctx, 1, r); } -int sc_disconnect_card(struct sc_card *card, int action) +int sc_disconnect_card(sc_card_t *card, int action) { - struct sc_context *ctx; + sc_context_t *ctx; assert(sc_card_valid(card)); ctx = card->ctx; SC_FUNC_CALLED(ctx, 1); @@ -501,7 +501,7 @@ int sc_disconnect_card(struct sc_card *card, int action) SC_FUNC_RETURN(ctx, 1, 0); } -int sc_lock(struct sc_card *card) +int sc_lock(sc_card_t *card) { int r = 0; @@ -520,7 +520,7 @@ int sc_lock(struct sc_card *card) return r; } -int sc_unlock(struct sc_card *card) +int sc_unlock(sc_card_t *card) { int r = 0; @@ -549,7 +549,7 @@ int sc_unlock(struct sc_card *card) return r; } -int sc_list_files(struct sc_card *card, u8 *buf, size_t buflen) +int sc_list_files(sc_card_t *card, u8 *buf, size_t buflen) { int r; @@ -561,7 +561,7 @@ int sc_list_files(struct sc_card *card, u8 *buf, size_t buflen) SC_FUNC_RETURN(card->ctx, 1, r); } -int sc_create_file(struct sc_card *card, struct sc_file *file) +int sc_create_file(sc_card_t *card, sc_file_t *file) { int r; @@ -579,7 +579,7 @@ int sc_create_file(struct sc_card *card, struct sc_file *file) SC_FUNC_RETURN(card->ctx, 1, r); } -int sc_delete_file(struct sc_card *card, const struct sc_path *path) +int sc_delete_file(sc_card_t *card, const sc_path_t *path) { int r; @@ -595,7 +595,7 @@ int sc_delete_file(struct sc_card *card, const struct sc_path *path) SC_FUNC_RETURN(card->ctx, 1, r); } -int sc_read_binary(struct sc_card *card, unsigned int idx, +int sc_read_binary(sc_card_t *card, unsigned int idx, unsigned char *buf, size_t count, unsigned long flags) { size_t max_le = card->max_recv_size; @@ -637,7 +637,7 @@ int sc_read_binary(struct sc_card *card, unsigned int idx, SC_FUNC_RETURN(card->ctx, 2, r); } -int sc_write_binary(struct sc_card *card, unsigned int idx, +int sc_write_binary(sc_card_t *card, unsigned int idx, const u8 *buf, size_t count, unsigned long flags) { size_t max_lc = card->max_send_size; @@ -679,7 +679,7 @@ int sc_write_binary(struct sc_card *card, unsigned int idx, SC_FUNC_RETURN(card->ctx, 2, r); } -int sc_update_binary(struct sc_card *card, unsigned int idx, +int sc_update_binary(sc_card_t *card, unsigned int idx, const u8 *buf, size_t count, unsigned long flags) { size_t max_lc = card->max_send_size; @@ -721,9 +721,9 @@ int sc_update_binary(struct sc_card *card, unsigned int idx, SC_FUNC_RETURN(card->ctx, 2, r); } -int sc_select_file(struct sc_card *card, - const struct sc_path *in_path, - struct sc_file **file) +int sc_select_file(sc_card_t *card, + const sc_path_t *in_path, + sc_file_t **file) { int r; @@ -778,7 +778,7 @@ int sc_put_data(sc_card_t *card, unsigned int tag, const u8 *buf, size_t len) SC_FUNC_RETURN(card->ctx, 1, r); } -int sc_get_challenge(struct sc_card *card, u8 *rnd, size_t len) +int sc_get_challenge(sc_card_t *card, u8 *rnd, size_t len) { int r; @@ -790,7 +790,7 @@ int sc_get_challenge(struct sc_card *card, u8 *rnd, size_t len) SC_FUNC_RETURN(card->ctx, 2, r); } -int sc_read_record(struct sc_card *card, unsigned int rec_nr, u8 *buf, +int sc_read_record(sc_card_t *card, unsigned int rec_nr, u8 *buf, size_t count, unsigned long flags) { int r; @@ -803,7 +803,7 @@ int sc_read_record(struct sc_card *card, unsigned int rec_nr, u8 *buf, SC_FUNC_RETURN(card->ctx, 2, r); } -int sc_write_record(struct sc_card *card, unsigned int rec_nr, const u8 * buf, +int sc_write_record(sc_card_t *card, unsigned int rec_nr, const u8 * buf, size_t count, unsigned long flags) { int r; @@ -816,7 +816,7 @@ int sc_write_record(struct sc_card *card, unsigned int rec_nr, const u8 * buf, SC_FUNC_RETURN(card->ctx, 2, r); } -int sc_append_record(struct sc_card *card, const u8 * buf, size_t count, +int sc_append_record(sc_card_t *card, const u8 * buf, size_t count, unsigned long flags) { int r; @@ -829,7 +829,7 @@ int sc_append_record(struct sc_card *card, const u8 * buf, size_t count, SC_FUNC_RETURN(card->ctx, 2, r); } -int sc_update_record(struct sc_card *card, unsigned int rec_nr, const u8 * buf, +int sc_update_record(sc_card_t *card, unsigned int rec_nr, const u8 * buf, size_t count, unsigned long flags) { int r; @@ -842,7 +842,7 @@ int sc_update_record(struct sc_card *card, unsigned int rec_nr, const u8 * buf, SC_FUNC_RETURN(card->ctx, 2, r); } -int sc_delete_record(struct sc_card *card, unsigned int rec_nr) +int sc_delete_record(sc_card_t *card, unsigned int rec_nr) { int r; @@ -854,7 +854,7 @@ int sc_delete_record(struct sc_card *card, unsigned int rec_nr) SC_FUNC_RETURN(card->ctx, 2, r); } -inline int sc_card_valid(const struct sc_card *card) { +inline int sc_card_valid(const sc_card_t *card) { #ifndef NDEBUG assert(card != NULL); #endif @@ -862,7 +862,7 @@ inline int sc_card_valid(const struct sc_card *card) { } int -sc_card_ctl(struct sc_card *card, unsigned long cmd, void *args) +sc_card_ctl(sc_card_t *card, unsigned long cmd, void *args) { int r = SC_ERROR_NOT_SUPPORTED; @@ -879,12 +879,12 @@ sc_card_ctl(struct sc_card *card, unsigned long cmd, void *args) SC_FUNC_RETURN(card->ctx, 2, r); } -int _sc_card_add_algorithm(struct sc_card *card, const struct sc_algorithm_info *info) +int _sc_card_add_algorithm(sc_card_t *card, const sc_algorithm_info_t *info) { - struct sc_algorithm_info *p; + sc_algorithm_info_t *p; assert(sc_card_valid(card) && info != NULL); - p = (struct sc_algorithm_info *) realloc(card->algorithms, (card->algorithm_count + 1) * sizeof(*info)); + p = (sc_algorithm_info_t *) realloc(card->algorithms, (card->algorithm_count + 1) * sizeof(*info)); if (!p) { if (card->algorithms) free(card->algorithms); @@ -899,10 +899,10 @@ int _sc_card_add_algorithm(struct sc_card *card, const struct sc_algorithm_info return 0; } -int _sc_card_add_rsa_alg(struct sc_card *card, unsigned int key_length, +int _sc_card_add_rsa_alg(sc_card_t *card, unsigned int key_length, unsigned long flags, unsigned long exponent) { - struct sc_algorithm_info info; + sc_algorithm_info_t info; memset(&info, 0, sizeof(info)); info.algorithm = SC_ALGORITHM_RSA; @@ -913,13 +913,13 @@ int _sc_card_add_rsa_alg(struct sc_card *card, unsigned int key_length, return _sc_card_add_algorithm(card, &info); } -struct sc_algorithm_info * _sc_card_find_rsa_alg(struct sc_card *card, +sc_algorithm_info_t * _sc_card_find_rsa_alg(sc_card_t *card, unsigned int key_length) { int i; for (i = 0; i < card->algorithm_count; i++) { - struct sc_algorithm_info *info = &card->algorithms[i]; + sc_algorithm_info_t *info = &card->algorithms[i]; if (info->algorithm != SC_ALGORITHM_RSA) continue; @@ -930,7 +930,7 @@ struct sc_algorithm_info * _sc_card_find_rsa_alg(struct sc_card *card, return NULL; } -static int match_atr_table(struct sc_context *ctx, struct sc_atr_table *table, u8 *atr, size_t atr_len) +static int match_atr_table(sc_context_t *ctx, struct sc_atr_table *table, u8 *atr, size_t atr_len) { u8 *card_atr_bin = atr; size_t card_atr_bin_len = atr_len; @@ -985,7 +985,7 @@ static int match_atr_table(struct sc_context *ctx, struct sc_atr_table *table, u return -1; } -int _sc_match_atr(struct sc_card *card, struct sc_atr_table *table, int *type_out) +int _sc_match_atr(sc_card_t *card, struct sc_atr_table *table, int *type_out) { int res; @@ -1029,7 +1029,7 @@ scconf_block *_sc_match_atr_block(sc_context_t *ctx, struct sc_card_driver *driv return NULL; } -int _sc_add_atr(struct sc_context *ctx, struct sc_card_driver *driver, struct sc_atr_table *src) +int _sc_add_atr(sc_context_t *ctx, struct sc_card_driver *driver, struct sc_atr_table *src) { struct sc_atr_table *map, *dst; @@ -1063,7 +1063,7 @@ int _sc_add_atr(struct sc_context *ctx, struct sc_card_driver *driver, struct sc return SC_SUCCESS; } -int _sc_free_atr(struct sc_context *ctx, struct sc_card_driver *driver) +int _sc_free_atr(sc_context_t *ctx, struct sc_card_driver *driver) { unsigned int i; @@ -1087,7 +1087,7 @@ int _sc_free_atr(struct sc_context *ctx, struct sc_card_driver *driver) return SC_SUCCESS; } -int _sc_check_forced_protocol(struct sc_context *ctx, u8 *atr, size_t atr_len, unsigned int *protocol) +int _sc_check_forced_protocol(sc_context_t *ctx, u8 *atr, size_t atr_len, unsigned int *protocol) { scconf_block *atrblock = NULL; int ok = 0; diff --git a/src/libopensc/ctbcs.c b/src/libopensc/ctbcs.c index da9d93a0..c43e5d5e 100644 --- a/src/libopensc/ctbcs.c +++ b/src/libopensc/ctbcs.c @@ -152,11 +152,11 @@ ctbcs_build_modify_verification_apdu(sc_apdu_t *apdu, struct sc_pin_cmd_data *da } int -ctbcs_pin_cmd(struct sc_reader *reader, sc_slot_info_t *slot, +ctbcs_pin_cmd(sc_reader_t *reader, sc_slot_info_t *slot, struct sc_pin_cmd_data *data) { - struct sc_card dummy_card, *card; - struct sc_apdu apdu; + sc_card_t dummy_card, *card; + sc_apdu_t apdu; struct sc_card_operations ops; int r; diff --git a/src/libopensc/ctx.c b/src/libopensc/ctx.c index 3c929b87..09e2dda6 100644 --- a/src/libopensc/ctx.c +++ b/src/libopensc/ctx.c @@ -35,7 +35,7 @@ # define DEF_APDU_MASQ SC_APDU_MASQUERADE_4AS3 #endif -int _sc_add_reader(struct sc_context *ctx, struct sc_reader *reader) +int _sc_add_reader(sc_context_t *ctx, sc_reader_t *reader) { assert(reader != NULL); reader->ctx = ctx; @@ -156,7 +156,7 @@ static void add_internal_drvs(struct _sc_ctx_options *opts, int type) } } -static void set_defaults(struct sc_context *ctx, struct _sc_ctx_options *opts) +static void set_defaults(sc_context_t *ctx, struct _sc_ctx_options *opts) { ctx->debug = 0; if (ctx->debug_file && ctx->debug_file != stdout) @@ -171,7 +171,7 @@ static void set_defaults(struct sc_context *ctx, struct _sc_ctx_options *opts) add_internal_drvs(opts, 1); } -static int load_parameters(struct sc_context *ctx, scconf_block *block, +static int load_parameters(sc_context_t *ctx, scconf_block *block, struct _sc_ctx_options *opts) { int err = 0; @@ -290,7 +290,7 @@ static void load_reader_driver_options(sc_context_t *ctx, * find library module for provided driver in configuration file * if not found assume library name equals to module name */ -static const char *find_library(struct sc_context *ctx, const char *name, int type) +static const char *find_library(sc_context_t *ctx, const char *name, int type) { int i; const char *libname = NULL; @@ -328,7 +328,7 @@ static const char *find_library(struct sc_context *ctx, const char *name, int ty * type == 0 -> reader driver * type == 1 -> card driver */ -static void *load_dynamic_driver(struct sc_context *ctx, void **dll, +static void *load_dynamic_driver(sc_context_t *ctx, void **dll, const char *name, int type) { const char *version, *libname; @@ -370,7 +370,7 @@ static void *load_dynamic_driver(struct sc_context *ctx, void **dll, return modinit(name); } -static int load_reader_drivers(struct sc_context *ctx, +static int load_reader_drivers(sc_context_t *ctx, struct _sc_ctx_options *opts) { const struct _sc_driver_entry *ent; @@ -410,7 +410,7 @@ static int load_reader_drivers(struct sc_context *ctx, return SC_SUCCESS; } -static int load_card_driver_options(struct sc_context *ctx, +static int load_card_driver_options(sc_context_t *ctx, struct sc_card_driver *driver) { scconf_block **blocks, *blk; @@ -431,7 +431,7 @@ static int load_card_driver_options(struct sc_context *ctx, return SC_SUCCESS; } -static int load_card_drivers(struct sc_context *ctx, +static int load_card_drivers(sc_context_t *ctx, struct _sc_ctx_options *opts) { const struct _sc_driver_entry *ent; @@ -472,7 +472,7 @@ static int load_card_drivers(struct sc_context *ctx, return SC_SUCCESS; } -static int load_card_atrs(struct sc_context *ctx, +static int load_card_atrs(sc_context_t *ctx, struct _sc_ctx_options *opts) { struct sc_card_driver *driver; @@ -550,7 +550,7 @@ static int load_card_atrs(struct sc_context *ctx, return SC_SUCCESS; } -static void process_config_file(struct sc_context *ctx, struct _sc_ctx_options *opts) +static void process_config_file(sc_context_t *ctx, struct _sc_ctx_options *opts) { int i, r, count = 0; scconf_block **blocks; @@ -637,14 +637,14 @@ static void process_config_file(struct sc_context *ctx, struct _sc_ctx_options * load_parameters(ctx, ctx->conf_blocks[i], opts); } -int sc_establish_context(struct sc_context **ctx_out, const char *app_name) +int sc_establish_context(sc_context_t **ctx_out, const char *app_name) { const char *default_app = "default"; - struct sc_context *ctx; + sc_context_t *ctx; struct _sc_ctx_options opts; assert(ctx_out != NULL); - ctx = (struct sc_context *) calloc(1, sizeof(struct sc_context)); + ctx = (sc_context_t *) calloc(1, sizeof(sc_context_t)); if (ctx == NULL) return SC_ERROR_OUT_OF_MEMORY; memset(&opts, 0, sizeof(opts)); @@ -675,14 +675,14 @@ int sc_establish_context(struct sc_context **ctx_out, const char *app_name) return SC_SUCCESS; } -int sc_release_context(struct sc_context *ctx) +int sc_release_context(sc_context_t *ctx) { int i; assert(ctx != NULL); SC_FUNC_CALLED(ctx, 1); for (i = 0; i < ctx->reader_count; i++) { - struct sc_reader *rdr = ctx->reader[i]; + sc_reader_t *rdr = ctx->reader[i]; if (rdr->ops->release != NULL) rdr->ops->release(rdr); @@ -719,7 +719,7 @@ int sc_release_context(struct sc_context *ctx) return SC_SUCCESS; } -int sc_set_card_driver(struct sc_context *ctx, const char *short_name) +int sc_set_card_driver(sc_context_t *ctx, const char *short_name) { int i = 0, match = 0; @@ -743,7 +743,7 @@ int sc_set_card_driver(struct sc_context *ctx, const char *short_name) return SC_SUCCESS; } -int sc_get_cache_dir(struct sc_context *ctx, char *buf, size_t bufsize) +int sc_get_cache_dir(sc_context_t *ctx, char *buf, size_t bufsize) { char *homedir; const char *cache_dir; @@ -771,7 +771,7 @@ int sc_get_cache_dir(struct sc_context *ctx, char *buf, size_t bufsize) return SC_SUCCESS; } -int sc_make_cache_dir(struct sc_context *ctx) +int sc_make_cache_dir(sc_context_t *ctx) { char dirname[PATH_MAX], *sp; int r; diff --git a/src/libopensc/dir.c b/src/libopensc/dir.c index 0939a6e1..8e0cbb96 100644 --- a/src/libopensc/dir.c +++ b/src/libopensc/dir.c @@ -47,9 +47,9 @@ static const struct app_entry * find_app_entry(const u8 * aid, size_t aid_len) return NULL; } -const struct sc_app_info * sc_find_pkcs15_app(struct sc_card *card) +const sc_app_info_t * sc_find_pkcs15_app(sc_card_t *card) { - const struct sc_app_info *app = NULL; + const sc_app_info_t *app = NULL; unsigned int i; i = sizeof(apps)/sizeof(apps[0]); @@ -72,11 +72,11 @@ static const struct sc_asn1_entry c_asn1_dir[] = { { NULL } }; -static int parse_dir_record(struct sc_card *card, u8 ** buf, size_t *buflen, +static int parse_dir_record(sc_card_t *card, u8 ** buf, size_t *buflen, int rec_nr) { struct sc_asn1_entry asn1_dirrecord[5], asn1_dir[2]; - struct sc_app_info *app = NULL; + sc_app_info_t *app = NULL; const struct app_entry *ae; int r; u8 aid[128], label[128], path[128]; @@ -104,7 +104,7 @@ static int parse_dir_record(struct sc_card *card, u8 ** buf, size_t *buflen, sc_error(card->ctx, "AID is too long.\n"); return SC_ERROR_INVALID_ASN1_OBJECT; } - app = (struct sc_app_info *) malloc(sizeof(struct sc_app_info)); + app = (sc_app_info_t *) malloc(sizeof(sc_app_info_t)); if (app == NULL) return SC_ERROR_OUT_OF_MEMORY; @@ -150,9 +150,9 @@ static int parse_dir_record(struct sc_card *card, u8 ** buf, size_t *buflen, return 0; } -int sc_enum_apps(struct sc_card *card) +int sc_enum_apps(sc_card_t *card) { - struct sc_path path; + sc_path_t path; int ef_structure; size_t file_size; int r; @@ -230,7 +230,7 @@ int sc_enum_apps(struct sc_card *card) return card->app_count; } -void sc_free_apps(struct sc_card *card) +void sc_free_apps(sc_card_t *card) { int i; @@ -244,7 +244,7 @@ void sc_free_apps(struct sc_card *card) card->app_count = -1; } -const struct sc_app_info * sc_find_app_by_aid(struct sc_card *card, +const sc_app_info_t * sc_find_app_by_aid(sc_card_t *card, const u8 *aid, size_t aid_len) { int i; @@ -258,11 +258,11 @@ const struct sc_app_info * sc_find_app_by_aid(struct sc_card *card, return NULL; } -static int encode_dir_record(struct sc_context *ctx, const struct sc_app_info *app, +static int encode_dir_record(sc_context_t *ctx, const sc_app_info_t *app, u8 **buf, size_t *buflen) { struct sc_asn1_entry asn1_dirrecord[5], asn1_dir[2]; - struct sc_app_info tapp = *app; + sc_app_info_t tapp = *app; int r; size_t label_len; @@ -289,7 +289,7 @@ static int encode_dir_record(struct sc_context *ctx, const struct sc_app_info *a return 0; } -static int update_transparent(struct sc_card *card, struct sc_file *file) +static int update_transparent(sc_card_t *card, sc_file_t *file) { u8 *rec, *buf = NULL, *tmp; size_t rec_size, buf_size = 0; @@ -334,8 +334,8 @@ static int update_transparent(struct sc_card *card, struct sc_file *file) return 0; } -static int update_single_record(struct sc_card *card, struct sc_file *file, - struct sc_app_info *app) +static int update_single_record(sc_card_t *card, sc_file_t *file, + sc_app_info_t *app) { u8 *rec; size_t rec_size; @@ -350,7 +350,7 @@ static int update_single_record(struct sc_card *card, struct sc_file *file, return 0; } -static int update_records(struct sc_card *card, struct sc_file *file) +static int update_records(sc_card_t *card, sc_file_t *file) { int i, r; @@ -362,10 +362,10 @@ static int update_records(struct sc_card *card, struct sc_file *file) return 0; } -int sc_update_dir(struct sc_card *card, struct sc_app_info *app) +int sc_update_dir(sc_card_t *card, sc_app_info_t *app) { - struct sc_path path; - struct sc_file *file; + sc_path_t path; + sc_file_t *file; int r; sc_format_path("3F002F00", &path); diff --git a/src/libopensc/iso7816.c b/src/libopensc/iso7816.c index ccd86317..53cf2e92 100644 --- a/src/libopensc/iso7816.c +++ b/src/libopensc/iso7816.c @@ -76,7 +76,7 @@ const static struct sc_card_error iso7816_errors[] = { { 0x6A8A, SC_ERROR_FILE_ALREADY_EXISTS, "Application exists"}, }; -static int iso7816_check_sw(struct sc_card *card, int sw1, int sw2) +static int iso7816_check_sw(sc_card_t *card, int sw1, int sw2) { const int err_count = sizeof(iso7816_errors)/sizeof(iso7816_errors[0]); int i; @@ -102,11 +102,11 @@ static int iso7816_check_sw(struct sc_card *card, int sw1, int sw2) return SC_ERROR_CARD_CMD_FAILED; } -static int iso7816_read_binary(struct sc_card *card, +static int iso7816_read_binary(sc_card_t *card, unsigned int idx, u8 *buf, size_t count, unsigned long flags) { - struct sc_apdu apdu; + sc_apdu_t apdu; u8 recvbuf[SC_MAX_APDU_BUFFER_SIZE]; int r; @@ -126,11 +126,11 @@ static int iso7816_read_binary(struct sc_card *card, SC_FUNC_RETURN(card->ctx, 3, apdu.resplen); } -static int iso7816_read_record(struct sc_card *card, +static int iso7816_read_record(sc_card_t *card, unsigned int rec_nr, u8 *buf, size_t count, unsigned long flags) { - struct sc_apdu apdu; + sc_apdu_t apdu; u8 recvbuf[SC_MAX_APDU_BUFFER_SIZE]; int r; @@ -152,11 +152,11 @@ static int iso7816_read_record(struct sc_card *card, SC_FUNC_RETURN(card->ctx, 3, apdu.resplen); } -static int iso7816_write_record(struct sc_card *card, unsigned int rec_nr, +static int iso7816_write_record(sc_card_t *card, unsigned int rec_nr, const u8 *buf, size_t count, unsigned long flags) { - struct sc_apdu apdu; + sc_apdu_t apdu; int r; if (count > 256) { @@ -179,11 +179,11 @@ static int iso7816_write_record(struct sc_card *card, unsigned int rec_nr, SC_FUNC_RETURN(card->ctx, 3, count); } -static int iso7816_append_record(struct sc_card *card, +static int iso7816_append_record(sc_card_t *card, const u8 *buf, size_t count, unsigned long flags) { - struct sc_apdu apdu; + sc_apdu_t apdu; int r; if (count > 256) { @@ -204,11 +204,11 @@ static int iso7816_append_record(struct sc_card *card, SC_FUNC_RETURN(card->ctx, 3, count); } -static int iso7816_update_record(struct sc_card *card, unsigned int rec_nr, +static int iso7816_update_record(sc_card_t *card, unsigned int rec_nr, const u8 *buf, size_t count, unsigned long flags) { - struct sc_apdu apdu; + sc_apdu_t apdu; int r; if (count > 256) { @@ -231,11 +231,11 @@ static int iso7816_update_record(struct sc_card *card, unsigned int rec_nr, SC_FUNC_RETURN(card->ctx, 3, count); } -static int iso7816_write_binary(struct sc_card *card, +static int iso7816_write_binary(sc_card_t *card, unsigned int idx, const u8 *buf, size_t count, unsigned long flags) { - struct sc_apdu apdu; + sc_apdu_t apdu; int r; assert(count <= card->max_send_size); @@ -252,11 +252,11 @@ static int iso7816_write_binary(struct sc_card *card, SC_FUNC_RETURN(card->ctx, 3, count); } -static int iso7816_update_binary(struct sc_card *card, +static int iso7816_update_binary(sc_card_t *card, unsigned int idx, const u8 *buf, size_t count, unsigned long flags) { - struct sc_apdu apdu; + sc_apdu_t apdu; int r; assert(count <= card->max_send_size); @@ -273,10 +273,10 @@ static int iso7816_update_binary(struct sc_card *card, SC_FUNC_RETURN(card->ctx, 3, count); } -static int iso7816_process_fci(struct sc_card *card, struct sc_file *file, +static int iso7816_process_fci(sc_card_t *card, sc_file_t *file, const u8 *buf, size_t buflen) { - struct sc_context *ctx = card->ctx; + sc_context_t *ctx = card->ctx; size_t taglen, len = buflen; const u8 *tag = NULL, *p = buf; @@ -377,16 +377,16 @@ static int iso7816_process_fci(struct sc_card *card, struct sc_file *file, return 0; } -static int iso7816_select_file(struct sc_card *card, - const struct sc_path *in_path, - struct sc_file **file_out) +static int iso7816_select_file(sc_card_t *card, + const sc_path_t *in_path, + sc_file_t **file_out) { - struct sc_context *ctx; - struct sc_apdu apdu; + sc_context_t *ctx; + sc_apdu_t apdu; u8 buf[SC_MAX_APDU_BUFFER_SIZE]; u8 pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf; int r, pathlen; - struct sc_file *file = NULL; + sc_file_t *file = NULL; assert(card != NULL && in_path != NULL); ctx = card->ctx; @@ -464,10 +464,10 @@ static int iso7816_select_file(struct sc_card *card, return 0; } -static int iso7816_get_challenge(struct sc_card *card, u8 *rnd, size_t len) +static int iso7816_get_challenge(sc_card_t *card, u8 *rnd, size_t len) { int r; - struct sc_apdu apdu; + sc_apdu_t apdu; u8 buf[10]; sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, @@ -490,7 +490,7 @@ static int iso7816_get_challenge(struct sc_card *card, u8 *rnd, size_t len) return 0; } -static int iso7816_construct_fci(struct sc_card *card, const struct sc_file *file, +static int iso7816_construct_fci(sc_card_t *card, const sc_file_t *file, u8 *out, size_t *outlen) { u8 *p = out; @@ -541,12 +541,12 @@ static int iso7816_construct_fci(struct sc_card *card, const struct sc_file *fil return 0; } -static int iso7816_create_file(struct sc_card *card, struct sc_file *file) +static int iso7816_create_file(sc_card_t *card, sc_file_t *file) { int r; size_t len; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; - struct sc_apdu apdu; + sc_apdu_t apdu; len = SC_MAX_APDU_BUFFER_SIZE; @@ -565,9 +565,9 @@ static int iso7816_create_file(struct sc_card *card, struct sc_file *file) return sc_check_sw(card, apdu.sw1, apdu.sw2); } -static int iso7816_get_response(struct sc_card *card, sc_apdu_t *orig_apdu, size_t count) +static int iso7816_get_response(sc_card_t *card, sc_apdu_t *orig_apdu, size_t count) { - struct sc_apdu apdu; + sc_apdu_t apdu; int r; sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xC0, 0x00, 0x00); @@ -591,11 +591,11 @@ static int iso7816_get_response(struct sc_card *card, sc_apdu_t *orig_apdu, size SC_FUNC_RETURN(card->ctx, 3, apdu.resplen); } -static int iso7816_delete_file(struct sc_card *card, const struct sc_path *path) +static int iso7816_delete_file(sc_card_t *card, const sc_path_t *path) { int r; u8 sbuf[2]; - struct sc_apdu apdu; + sc_apdu_t apdu; SC_FUNC_CALLED(card->ctx, 1); if (path->type != SC_PATH_TYPE_FILE_ID && path->len != 2) { @@ -614,11 +614,11 @@ static int iso7816_delete_file(struct sc_card *card, const struct sc_path *path) return sc_check_sw(card, apdu.sw1, apdu.sw2); } -static int iso7816_set_security_env(struct sc_card *card, - const struct sc_security_env *env, +static int iso7816_set_security_env(sc_card_t *card, + const sc_security_env_t *env, int se_num) { - struct sc_apdu apdu; + sc_apdu_t apdu; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 *p; int r, locked = 0; @@ -694,9 +694,9 @@ err: return r; } -static int iso7816_restore_security_env(struct sc_card *card, int se_num) +static int iso7816_restore_security_env(sc_card_t *card, int se_num) { - struct sc_apdu apdu; + sc_apdu_t apdu; int r; u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; @@ -710,12 +710,12 @@ static int iso7816_restore_security_env(struct sc_card *card, int se_num) return sc_check_sw(card, apdu.sw1, apdu.sw2); } -static int iso7816_compute_signature(struct sc_card *card, +static int iso7816_compute_signature(sc_card_t *card, const u8 * data, size_t datalen, u8 * out, size_t outlen) { int r; - struct sc_apdu apdu; + sc_apdu_t apdu; u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; @@ -748,12 +748,12 @@ static int iso7816_compute_signature(struct sc_card *card, SC_FUNC_RETURN(card->ctx, 4, sc_check_sw(card, apdu.sw1, apdu.sw2)); } -static int iso7816_decipher(struct sc_card *card, +static int iso7816_decipher(sc_card_t *card, const u8 * crgram, size_t crgram_len, u8 * out, size_t outlen) { int r; - struct sc_apdu apdu; + sc_apdu_t apdu; u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; @@ -787,8 +787,8 @@ static int iso7816_decipher(struct sc_card *card, SC_FUNC_RETURN(card->ctx, 2, sc_check_sw(card, apdu.sw1, apdu.sw2)); } -static int iso7816_build_pin_apdu(struct sc_card *card, - struct sc_apdu *apdu, +static int iso7816_build_pin_apdu(sc_card_t *card, + sc_apdu_t *apdu, struct sc_pin_cmd_data *data) { static u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; @@ -866,10 +866,10 @@ static int iso7816_build_pin_apdu(struct sc_card *card, return 0; } -static int iso7816_pin_cmd(struct sc_card *card, struct sc_pin_cmd_data *data, +static int iso7816_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *data, int *tries_left) { - struct sc_apdu local_apdu, *apdu; + sc_apdu_t local_apdu, *apdu; int r; if (tries_left) @@ -933,9 +933,9 @@ static int iso7816_pin_cmd(struct sc_card *card, struct sc_pin_cmd_data *data, /* * For some cards, selecting the MF clears all access rights gained */ -static int iso7816_logout(struct sc_card *card) +static int iso7816_logout(sc_card_t *card) { - struct sc_path in_path; + sc_path_t in_path; in_path.value[0] = 0x3F; in_path.value[1] = 0x00; in_path.len = 2; @@ -960,7 +960,7 @@ static struct sc_card_driver iso_driver = { &iso_ops }; -static int no_match(struct sc_card *card) +static int no_match(sc_card_t *card) { return 0; } diff --git a/src/libopensc/log.c b/src/libopensc/log.c index eda9e8e2..0e4b057b 100644 --- a/src/libopensc/log.c +++ b/src/libopensc/log.c @@ -36,7 +36,7 @@ #endif #ifndef __GNUC__ -void sc_error(struct sc_context *ctx, const char *format, ...) +void sc_error(sc_context_t *ctx, const char *format, ...) { va_list ap; @@ -45,7 +45,7 @@ void sc_error(struct sc_context *ctx, const char *format, ...) va_end(ap); } -void sc_debug(struct sc_context *ctx, const char *format, ...) +void sc_debug(sc_context_t *ctx, const char *format, ...) { va_list ap; @@ -56,7 +56,7 @@ void sc_debug(struct sc_context *ctx, const char *format, ...) #endif -void sc_do_log(struct sc_context *ctx, int type, const char *file, int line, const char *func, const char *format, ...) +void sc_do_log(sc_context_t *ctx, int type, const char *file, int line, const char *func, const char *format, ...) { va_list ap; @@ -65,7 +65,7 @@ void sc_do_log(struct sc_context *ctx, int type, const char *file, int line, con va_end(ap); } -void sc_do_log_va(struct sc_context *ctx, int type, const char *file, int line, const char *func, const char *format, va_list args) +void sc_do_log_va(sc_context_t *ctx, int type, const char *file, int line, const char *func, const char *format, va_list args) { int (*display_fn)(sc_context_t *, const char *); char buf[1536], *p; @@ -116,7 +116,7 @@ void sc_do_log_va(struct sc_context *ctx, int type, const char *file, int line, display_fn(ctx, buf); } -void sc_hex_dump(struct sc_context *ctx, const u8 * in, size_t count, char *buf, size_t len) +void sc_hex_dump(sc_context_t *ctx, const u8 * in, size_t count, char *buf, size_t len) { char *p = buf; int lines = 0; diff --git a/src/libopensc/opensc.h b/src/libopensc/opensc.h index 4fc987cd..eb782714 100644 --- a/src/libopensc/opensc.h +++ b/src/libopensc/opensc.h @@ -190,7 +190,7 @@ typedef unsigned __int64 sc_timestamp_t; #define SC_EVENT_CARD_INSERTED 0x0001 #define SC_EVENT_CARD_REMOVED 0x0002 -struct sc_security_env { +typedef struct sc_security_env { unsigned long flags; int operation; unsigned int algorithm, algorithm_flags; @@ -199,8 +199,7 @@ struct sc_security_env { struct sc_path file_ref; u8 key_ref[8]; size_t key_ref_len; -}; -typedef struct sc_security_env sc_security_env_t; +} sc_security_env_t; struct sc_algorithm_id { unsigned int algorithm; @@ -221,7 +220,7 @@ struct sc_pbes2_params { struct sc_algorithm_id key_encr_alg; }; -struct sc_algorithm_info { +typedef struct sc_algorithm_info { unsigned int algorithm; unsigned int key_length; unsigned int flags; @@ -231,10 +230,9 @@ struct sc_algorithm_info { unsigned long exponent; } _rsa; } u; -}; -typedef struct sc_algorithm_info sc_algorithm_info_t; +} sc_algorithm_info_t; -struct sc_app_info { +typedef struct sc_app_info { u8 aid[SC_MAX_AID_SIZE]; size_t aid_len; char *label; @@ -244,8 +242,7 @@ struct sc_app_info { const char *desc; /* App description, if known */ int rec_nr; /* -1, if EF(DIR) is transparent */ -}; -typedef struct sc_app_info sc_app_info_t; +} sc_app_info_t; struct sc_card_cache { struct sc_path current_path; @@ -277,7 +274,7 @@ struct sc_reader_driver { #define SC_SLOT_CAP_DISPLAY 0x00000001 #define SC_SLOT_CAP_PIN_PAD 0x00000002 -struct sc_slot_info { +typedef struct sc_slot_info { int id; unsigned long flags, capabilities; unsigned int supported_protocols, active_protocol; @@ -292,15 +289,14 @@ struct sc_slot_info { } atr_info; void *drv_data; -}; -typedef struct sc_slot_info sc_slot_info_t; +} sc_slot_info_t; struct sc_event_listener { unsigned int event_mask; void (*func)(void *, const struct sc_slot_info *, unsigned int event); }; -struct sc_reader { +typedef struct sc_reader { struct sc_context *ctx; const struct sc_reader_driver *driver; const struct sc_reader_operations *ops; @@ -309,8 +305,7 @@ struct sc_reader { struct sc_slot_info slot[SC_MAX_SLOTS]; int slot_count; -}; -typedef struct sc_reader sc_reader_t; +} sc_reader_t; /* This will be the new interface for handling PIN commands. * It is supposed to support pin pads (with or without display) @@ -459,7 +454,7 @@ void sc_mutex_free(struct sc_mutex *p); /* Card doesn't return any File Control Info. */ #define SC_CARD_CAP_NO_FCI 0x00000008 -struct sc_card { +typedef struct sc_card { struct sc_context *ctx; struct sc_reader *reader; struct sc_slot_info *slot; @@ -496,8 +491,7 @@ struct sc_card { sc_mutex_t *mutex; unsigned int magic; -}; -typedef struct sc_card sc_card_t; +} sc_card_t; struct sc_card_operations { /* Called in sc_connect_card(). Must return 1, if the current @@ -616,16 +610,16 @@ struct sc_card_operations { int (*delete_record)(sc_card_t *card, unsigned int rec_nr); }; -struct sc_card_driver { +typedef struct sc_card_driver { const char *name; const char *short_name; struct sc_card_operations *ops; struct sc_atr_table *atr_map; unsigned int natrs; void *dll; -}; +} sc_card_driver_t; -struct sc_context { +typedef struct sc_context { scconf_context *conf; scconf_block *conf_blocks[3]; char *app_name; @@ -647,8 +641,7 @@ struct sc_context { sc_mutex_t *mutex; unsigned int magic; -}; -typedef struct sc_context sc_context_t; +} sc_context_t; /* Base64 encoding/decoding functions */ int sc_base64_encode(const u8 *in, size_t inlen, u8 *out, size_t outlen, @@ -659,8 +652,8 @@ int sc_base64_decode(const char *in, u8 *out, size_t outlen); sc_timestamp_t sc_current_time(void); /* APDU handling functions */ -int sc_transmit_apdu(struct sc_card *card, struct sc_apdu *apdu); -void sc_format_apdu(struct sc_card *card, struct sc_apdu *apdu, int cse, int ins, +int sc_transmit_apdu(sc_card_t *card, sc_apdu_t *apdu); +void sc_format_apdu(sc_card_t *card, sc_apdu_t *apdu, int cse, int ins, int p1, int p2); /** @@ -669,40 +662,40 @@ void sc_format_apdu(struct sc_card *card, struct sc_apdu *apdu, int cse, int ins * @param app_name A string that identifies the application, used primarily * in finding application-specific configuration data. Can be NULL. */ -int sc_establish_context(struct sc_context **ctx, const char *app_name); +int sc_establish_context(sc_context_t **ctx, const char *app_name); /** * Releases an established OpenSC context * @param ctx A pointer to the context structure to be released */ -int sc_release_context(struct sc_context *ctx); +int sc_release_context(sc_context_t *ctx); /** * Forces the use of a specified card driver * @param ctx OpenSC context * @param short_name The short name of the driver to use (e.g. 'emv') */ -int sc_set_card_driver(struct sc_context *ctx, const char *short_name); +int sc_set_card_driver(sc_context_t *ctx, const char *short_name); /** * Connects to a card in a reader and auto-detects the card driver. * The ATR (Answer to Reset) string of the card is also retrieved. * @param reader Reader structure * @param slot_id Slot ID to connect to * @param card The allocated card object will go here */ -int sc_connect_card(struct sc_reader *reader, int slot_id, - struct sc_card **card); +int sc_connect_card(sc_reader_t *reader, int slot_id, + sc_card_t **card); /** * Disconnects from a card, and frees the card structure. Any locks * made by the application must be released before calling this function. * NOTE: The card is not reset nor powered down after the operation. * @param card The card to disconnect */ -int sc_disconnect_card(struct sc_card *card, int action); +int sc_disconnect_card(sc_card_t *card, int action); /** * Returns 1 if the magic value of the card object is correct. Mostly * used internally by the library. * @param card The card object to check */ -inline int sc_card_valid(const struct sc_card *card); +inline int sc_card_valid(const sc_card_t *card); /** * Checks if a card is present in a reader @@ -715,7 +708,7 @@ inline int sc_card_valid(const struct sc_card *card); * always set. In addition, if the card was exchanged, * the SC_SLOT_CARD_CHANGED flag is set. */ -int sc_detect_card_presence(struct sc_reader *reader, int slot_id); +int sc_detect_card_presence(sc_reader_t *reader, int slot_id); /** * Waits for an event on readers. Note: only the event is detected, @@ -735,7 +728,7 @@ int sc_detect_card_presence(struct sc_reader *reader, int slot_id); * @retval = 0 if a an event happened * @retval = 1 if the timeout occured */ -int sc_wait_for_event(struct sc_reader **readers, int *slots, size_t nslots, +int sc_wait_for_event(sc_reader_t **readers, int *slots, size_t nslots, unsigned int event_mask, int *reader, unsigned int *event, int timeout); @@ -746,7 +739,7 @@ int sc_wait_for_event(struct sc_reader **readers, int *slots, size_t nslots, * @param card The card to lock * @retval SC_SUCCESS on success */ -int sc_lock(struct sc_card *card); +int sc_lock(sc_card_t *card); /** * Unlocks a previously locked card. After the lock count drops to zero, * the card is again placed in shared mode, where other processes @@ -754,7 +747,7 @@ int sc_lock(struct sc_card *card); * @param card The card to unlock * @retval SC_SUCCESS on success */ -int sc_unlock(struct sc_card *card); +int sc_unlock(sc_card_t *card); /* ISO 7816-4 related functions */ @@ -765,17 +758,17 @@ int sc_unlock(struct sc_card *card); * @param file If not NULL, will receive a pointer to a new structure * @retval SC_SUCCESS on success */ -int sc_select_file(struct sc_card *card, const struct sc_path *path, - struct sc_file **file); +int sc_select_file(sc_card_t *card, const sc_path_t *path, + sc_file_t **file); -int sc_list_files(struct sc_card *card, u8 * buf, size_t buflen); +int sc_list_files(sc_card_t *card, u8 * buf, size_t buflen); /* TODO: finish writing API docs */ -int sc_read_binary(struct sc_card *card, unsigned int idx, u8 * buf, +int sc_read_binary(sc_card_t *card, unsigned int idx, u8 * buf, size_t count, unsigned long flags); -int sc_write_binary(struct sc_card *card, unsigned int idx, const u8 * buf, +int sc_write_binary(sc_card_t *card, unsigned int idx, const u8 * buf, size_t count, unsigned long flags); -int sc_update_binary(struct sc_card *card, unsigned int idx, const u8 * buf, +int sc_update_binary(sc_card_t *card, unsigned int idx, const u8 * buf, size_t count, unsigned long flags); /** * Reads a record from the current (i.e. selected) file. @@ -786,39 +779,39 @@ int sc_update_binary(struct sc_card *card, unsigned int idx, const u8 * buf, * @param flags Flags * @retval Number of bytes read or an error value */ -int sc_read_record(struct sc_card *card, unsigned int rec_nr, u8 * buf, +int sc_read_record(sc_card_t *card, unsigned int rec_nr, u8 * buf, size_t count, unsigned long flags); -int sc_write_record(struct sc_card *card, unsigned int rec_nr, const u8 * buf, +int sc_write_record(sc_card_t *card, unsigned int rec_nr, const u8 * buf, size_t count, unsigned long flags); -int sc_append_record(struct sc_card *card, const u8 * buf, size_t count, +int sc_append_record(sc_card_t *card, const u8 * buf, size_t count, unsigned long flags); -int sc_update_record(struct sc_card *card, unsigned int rec_nr, const u8 * buf, +int sc_update_record(sc_card_t *card, unsigned int rec_nr, const u8 * buf, size_t count, unsigned long flags); -int sc_delete_record(struct sc_card *card, unsigned int rec_nr); +int sc_delete_record(sc_card_t *card, unsigned int rec_nr); /* get/put data functions */ int sc_get_data(sc_card_t *, unsigned int, u8 *, size_t); int sc_put_data(sc_card_t *, unsigned int, const u8 *, size_t); -int sc_get_challenge(struct sc_card *card, u8 * rndout, size_t len); +int sc_get_challenge(sc_card_t *card, u8 * rndout, size_t len); /* ISO 7816-8 related functions */ -int sc_restore_security_env(struct sc_card *card, int se_num); -int sc_set_security_env(struct sc_card *card, +int sc_restore_security_env(sc_card_t *card, int se_num); +int sc_set_security_env(sc_card_t *card, const struct sc_security_env *env, int se_num); -int sc_decipher(struct sc_card *card, const u8 * crgram, size_t crgram_len, +int sc_decipher(sc_card_t *card, const u8 * crgram, size_t crgram_len, u8 * out, size_t outlen); -int sc_compute_signature(struct sc_card *card, const u8 * data, +int sc_compute_signature(sc_card_t *card, const u8 * data, size_t data_len, u8 * out, size_t outlen); -int sc_verify(struct sc_card *card, unsigned int type, int ref, const u8 *buf, +int sc_verify(sc_card_t *card, unsigned int type, int ref, const u8 *buf, size_t buflen, int *tries_left); -int sc_logout(struct sc_card *card); -int sc_pin_cmd(struct sc_card *card, struct sc_pin_cmd_data *, int *tries_left); -int sc_change_reference_data(struct sc_card *card, unsigned int type, +int sc_logout(sc_card_t *card); +int sc_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *, int *tries_left); +int sc_change_reference_data(sc_card_t *card, unsigned int type, int ref, const u8 *old, size_t oldlen, const u8 *newref, size_t newlen, int *tries_left); -int sc_reset_retry_counter(struct sc_card *card, unsigned int type, +int sc_reset_retry_counter(sc_card_t *card, unsigned int type, int ref, const u8 *puk, size_t puklen, const u8 *newref, size_t newlen); int sc_build_pin(u8 *buf, size_t buflen, struct sc_pin_cmd_pin *pin, int pad); @@ -833,52 +826,52 @@ int sc_pkcs1_add_digest_info_prefix(unsigned int algorithm, const u8 *in_dat, size_t in_len, u8 *out_dat, size_t *out_len); int sc_pkcs1_strip_digest_info_prefix(unsigned int *algorithm, const u8 *in_dat, size_t in_len, u8 *out_dat, size_t *out_len); -int sc_pkcs1_encode(struct sc_context *ctx, unsigned long flags, +int sc_pkcs1_encode(sc_context_t *ctx, unsigned long flags, const u8 *in, size_t in_len, u8 *out, size_t *out_len, size_t mod_len); int sc_strip_zero_padding(const u8 *in,size_t in_len, u8 *out, size_t *out_len); /* ISO 7816-9 */ -int sc_create_file(struct sc_card *card, struct sc_file *file); -int sc_delete_file(struct sc_card *card, const struct sc_path *path); +int sc_create_file(sc_card_t *card, sc_file_t *file); +int sc_delete_file(sc_card_t *card, const sc_path_t *path); /* Card controls */ -int sc_card_ctl(struct sc_card *card, unsigned long command, void *arg); +int sc_card_ctl(sc_card_t *card, unsigned long command, void *arg); -inline int sc_file_valid(const struct sc_file *file); -struct sc_file * sc_file_new(void); -void sc_file_free(struct sc_file *file); -void sc_file_dup(struct sc_file **dest, const struct sc_file *src); +inline int sc_file_valid(const sc_file_t *file); +sc_file_t * sc_file_new(void); +void sc_file_free(sc_file_t *file); +void sc_file_dup(sc_file_t **dest, const sc_file_t *src); -int sc_file_add_acl_entry(struct sc_file *file, unsigned int operation, +int sc_file_add_acl_entry(sc_file_t *file, unsigned int operation, unsigned int method, unsigned long key_ref); -const struct sc_acl_entry * sc_file_get_acl_entry(const struct sc_file *file, +const struct sc_acl_entry * sc_file_get_acl_entry(const sc_file_t *file, unsigned int operation); -void sc_file_clear_acl_entries(struct sc_file *file, unsigned int operation); +void sc_file_clear_acl_entries(sc_file_t *file, unsigned int operation); -int sc_file_set_sec_attr(struct sc_file *file, const u8 *sec_attr, +int sc_file_set_sec_attr(sc_file_t *file, const u8 *sec_attr, size_t sec_attr_len); -int sc_file_set_prop_attr(struct sc_file *file, const u8 *prop_attr, +int sc_file_set_prop_attr(sc_file_t *file, const u8 *prop_attr, size_t prop_attr_len); -int sc_file_set_type_attr(struct sc_file *file, const u8 *type_attr, +int sc_file_set_type_attr(sc_file_t *file, const u8 *type_attr, size_t type_attr_len); -void sc_format_path(const char *path_in, struct sc_path *path_out); +void sc_format_path(const char *path_in, sc_path_t *path_out); const char *sc_print_path(const sc_path_t *path_in); int sc_compare_path(const sc_path_t *, const sc_path_t *); -int sc_append_path(struct sc_path *dest, const struct sc_path *src); -int sc_append_path_id(struct sc_path *dest, const u8 *id, size_t idlen); -int sc_append_file_id(struct sc_path *dest, unsigned int fid); +int sc_append_path(sc_path_t *dest, const sc_path_t *src); +int sc_append_path_id(sc_path_t *dest, const u8 *id, size_t idlen); +int sc_append_file_id(sc_path_t *dest, unsigned int fid); int sc_hex_to_bin(const char *in, u8 *out, size_t *outlen); int sc_bin_to_hex(const u8 *, size_t, char *, size_t, char separator); -int sc_get_cache_dir(struct sc_context *ctx, char *buf, size_t bufsize); -int sc_make_cache_dir(struct sc_context *ctx); +int sc_get_cache_dir(sc_context_t *ctx, char *buf, size_t bufsize); +int sc_make_cache_dir(sc_context_t *ctx); -int sc_enum_apps(struct sc_card *card); -void sc_free_apps(struct sc_card *card); -const struct sc_app_info * sc_find_pkcs15_app(struct sc_card *card); -const struct sc_app_info * sc_find_app_by_aid(struct sc_card *card, - const u8 *aid, size_t aid_len); -int sc_update_dir(struct sc_card *card, struct sc_app_info *app); +int sc_enum_apps(sc_card_t *card); +void sc_free_apps(sc_card_t *card); +const sc_app_info_t * sc_find_pkcs15_app(sc_card_t *card); +const sc_app_info_t * sc_find_app_by_aid(sc_card_t *card, + const u8 *aid, size_t aid_len); +int sc_update_dir(sc_card_t *card, sc_app_info_t *app); struct sc_card_error { int SWs; @@ -899,22 +892,22 @@ extern struct sc_reader_driver *sc_get_pcsc_driver(void); extern struct sc_reader_driver *sc_get_ctapi_driver(void); extern struct sc_reader_driver *sc_get_openct_driver(void); -extern struct sc_card_driver *sc_get_default_driver(void); -extern struct sc_card_driver *sc_get_emv_driver(void); -extern struct sc_card_driver *sc_get_etoken_driver(void); -extern struct sc_card_driver *sc_get_cryptoflex_driver(void); -extern struct sc_card_driver *sc_get_cyberflex_driver(void); -extern struct sc_card_driver *sc_get_gpk_driver(void); -extern struct sc_card_driver *sc_get_iso7816_driver(void); -extern struct sc_card_driver *sc_get_miocos_driver(void); -extern struct sc_card_driver *sc_get_mcrd_driver(void); -extern struct sc_card_driver *sc_get_setcos_driver(void); -extern struct sc_card_driver *sc_get_starcos_driver(void); -extern struct sc_card_driver *sc_get_tcos_driver(void); -extern struct sc_card_driver *sc_get_openpgp_driver(void); -extern struct sc_card_driver *sc_get_jcop_driver(void); -extern struct sc_card_driver *sc_get_oberthur_driver(void); -extern struct sc_card_driver *sc_get_belpic_driver(void); +extern sc_card_driver_t *sc_get_default_driver(void); +extern sc_card_driver_t *sc_get_emv_driver(void); +extern sc_card_driver_t *sc_get_etoken_driver(void); +extern sc_card_driver_t *sc_get_cryptoflex_driver(void); +extern sc_card_driver_t *sc_get_cyberflex_driver(void); +extern sc_card_driver_t *sc_get_gpk_driver(void); +extern sc_card_driver_t *sc_get_iso7816_driver(void); +extern sc_card_driver_t *sc_get_miocos_driver(void); +extern sc_card_driver_t *sc_get_mcrd_driver(void); +extern sc_card_driver_t *sc_get_setcos_driver(void); +extern sc_card_driver_t *sc_get_starcos_driver(void); +extern sc_card_driver_t *sc_get_tcos_driver(void); +extern sc_card_driver_t *sc_get_openpgp_driver(void); +extern sc_card_driver_t *sc_get_jcop_driver(void); +extern sc_card_driver_t *sc_get_oberthur_driver(void); +extern sc_card_driver_t *sc_get_belpic_driver(void); #ifdef __cplusplus } diff --git a/src/libopensc/padding.c b/src/libopensc/padding.c index 798ae6ef..3913225b 100644 --- a/src/libopensc/padding.c +++ b/src/libopensc/padding.c @@ -199,7 +199,7 @@ int sc_pkcs1_strip_digest_info_prefix(unsigned int *algorithm, } /* general PKCS#1 encoding function */ -int sc_pkcs1_encode(struct sc_context *ctx, unsigned long flags, +int sc_pkcs1_encode(sc_context_t *ctx, unsigned long flags, const u8 *in, size_t in_len, u8 *out, size_t *out_len, size_t mod_len) { int i; diff --git a/src/libopensc/pinpad-ccid.c b/src/libopensc/pinpad-ccid.c index fa7d13bd..7e6fdc13 100644 --- a/src/libopensc/pinpad-ccid.c +++ b/src/libopensc/pinpad-ccid.c @@ -106,7 +106,7 @@ static int ccid_build_verify_pin_block(u8 * buf, size_t * size, struct sc_pin_cm /* Do the PIN command */ int -ccid_pin_cmd(struct sc_reader *reader, sc_slot_info_t * slot, +ccid_pin_cmd(sc_reader_t *reader, sc_slot_info_t * slot, struct sc_pin_cmd_data *data) { u8 rbuf[SC_MAX_APDU_BUFFER_SIZE], sbuf[SC_MAX_APDU_BUFFER_SIZE]; diff --git a/src/libopensc/pkcs15-algo.c b/src/libopensc/pkcs15-algo.c index 4c5268ce..5fffbb5d 100644 --- a/src/libopensc/pkcs15-algo.c +++ b/src/libopensc/pkcs15-algo.c @@ -35,7 +35,7 @@ static struct sc_asn1_entry c_asn1_des_iv[] = { }; static int -asn1_decode_des_params(struct sc_context *ctx, void **paramp, +asn1_decode_des_params(sc_context_t *ctx, void **paramp, const u8 *buf, size_t buflen, int depth) { struct sc_asn1_entry asn1_des_iv[2]; @@ -57,7 +57,7 @@ asn1_decode_des_params(struct sc_context *ctx, void **paramp, } static int -asn1_encode_des_params(struct sc_context *ctx, void *params, +asn1_encode_des_params(sc_context_t *ctx, void *params, u8 **buf, size_t *buflen, int depth) { struct sc_asn1_entry asn1_des_iv[2]; @@ -77,7 +77,7 @@ static const struct sc_asn1_entry c_asn1_pbkdf2_params[] = { }; static int -asn1_decode_pbkdf2_params(struct sc_context *ctx, void **paramp, +asn1_decode_pbkdf2_params(sc_context_t *ctx, void **paramp, const u8 *buf, size_t buflen, int depth) { struct sc_pbkdf2_params info; @@ -110,7 +110,7 @@ asn1_decode_pbkdf2_params(struct sc_context *ctx, void **paramp, } static int -asn1_encode_pbkdf2_params(struct sc_context *ctx, void *params, +asn1_encode_pbkdf2_params(sc_context_t *ctx, void *params, u8 **buf, size_t *buflen, int depth) { struct sc_pbkdf2_params *info; @@ -140,7 +140,7 @@ static const struct sc_asn1_entry c_asn1_pbes2_params[] = { }; static int -asn1_decode_pbes2_params(struct sc_context *ctx, void **paramp, +asn1_decode_pbes2_params(sc_context_t *ctx, void **paramp, const u8 *buf, size_t buflen, int depth) { struct sc_asn1_entry asn1_pbes2_params[3]; @@ -165,7 +165,7 @@ asn1_decode_pbes2_params(struct sc_context *ctx, void **paramp, } static int -asn1_encode_pbes2_params(struct sc_context *ctx, void *params, +asn1_encode_pbes2_params(sc_context_t *ctx, void *params, u8 **buf, size_t *buflen, int depth) { struct sc_asn1_entry asn1_pbes2_params[3]; @@ -289,7 +289,7 @@ static const struct sc_asn1_entry c_asn1_alg_id[6] = { }; int -sc_asn1_decode_algorithm_id(struct sc_context *ctx, const u8 *in, +sc_asn1_decode_algorithm_id(sc_context_t *ctx, const u8 *in, size_t len, struct sc_algorithm_id *id, int depth) { @@ -321,7 +321,7 @@ sc_asn1_decode_algorithm_id(struct sc_context *ctx, const u8 *in, } int -sc_asn1_encode_algorithm_id(struct sc_context *ctx, +sc_asn1_encode_algorithm_id(sc_context_t *ctx, u8 **buf, size_t *len, const struct sc_algorithm_id *id, int depth) diff --git a/src/libopensc/pkcs15-cache.c b/src/libopensc/pkcs15-cache.c index ce136e1c..cfb8c251 100644 --- a/src/libopensc/pkcs15-cache.c +++ b/src/libopensc/pkcs15-cache.c @@ -32,7 +32,7 @@ #include static int generate_cache_filename(struct sc_pkcs15_card *p15card, - const struct sc_path *path, + const sc_path_t *path, char *buf, size_t bufsize) { char dir[PATH_MAX]; @@ -64,7 +64,7 @@ static int generate_cache_filename(struct sc_pkcs15_card *p15card, } int sc_pkcs15_read_cached_file(struct sc_pkcs15_card *p15card, - const struct sc_path *path, + const sc_path_t *path, u8 **buf, size_t *bufsize) { char fname[PATH_MAX]; @@ -120,7 +120,7 @@ int sc_pkcs15_read_cached_file(struct sc_pkcs15_card *p15card, } int sc_pkcs15_cache_file(struct sc_pkcs15_card *p15card, - const struct sc_path *path, + const sc_path_t *path, const u8 *buf, size_t bufsize) { char fname[PATH_MAX]; diff --git a/src/libopensc/pkcs15-cert.c b/src/libopensc/pkcs15-cert.c index 44418956..20c19497 100644 --- a/src/libopensc/pkcs15-cert.c +++ b/src/libopensc/pkcs15-cert.c @@ -30,7 +30,7 @@ #endif #include -static int parse_x509_cert(struct sc_context *ctx, const u8 *buf, size_t buflen, struct sc_pkcs15_cert *cert) +static int parse_x509_cert(sc_context_t *ctx, const u8 *buf, size_t buflen, struct sc_pkcs15_cert *cert) { int r; struct sc_algorithm_id pk_alg, sig_alg; @@ -176,7 +176,7 @@ int sc_pkcs15_decode_cdf_entry(struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *obj, const u8 ** buf, size_t *buflen) { - struct sc_context *ctx = p15card->card->ctx; + sc_context_t *ctx = p15card->card->ctx; struct sc_pkcs15_cert_info info; struct sc_asn1_entry asn1_cred_ident[3], asn1_com_cert_attr[4], asn1_x509_cert_attr[2], asn1_type_cert_attr[2], @@ -227,7 +227,7 @@ int sc_pkcs15_decode_cdf_entry(struct sc_pkcs15_card *p15card, return 0; } -int sc_pkcs15_encode_cdf_entry(struct sc_context *ctx, +int sc_pkcs15_encode_cdf_entry(sc_context_t *ctx, const struct sc_pkcs15_object *obj, u8 **buf, size_t *bufsize) { diff --git a/src/libopensc/pkcs15-data.c b/src/libopensc/pkcs15-data.c index 03dec7a2..0cf79143 100644 --- a/src/libopensc/pkcs15-data.c +++ b/src/libopensc/pkcs15-data.c @@ -83,7 +83,7 @@ int sc_pkcs15_decode_dodf_entry(struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *obj, const u8 ** buf, size_t *buflen) { - struct sc_context *ctx = p15card->card->ctx; + sc_context_t *ctx = p15card->card->ctx; struct sc_pkcs15_data_info info; struct sc_asn1_entry asn1_com_data_attr[3], asn1_type_data_attr[2], @@ -120,7 +120,7 @@ int sc_pkcs15_decode_dodf_entry(struct sc_pkcs15_card *p15card, return 0; } -int sc_pkcs15_encode_dodf_entry(struct sc_context *ctx, +int sc_pkcs15_encode_dodf_entry(sc_context_t *ctx, const struct sc_pkcs15_object *obj, u8 **buf, size_t *bufsize) { diff --git a/src/libopensc/pkcs15-infocamere.c b/src/libopensc/pkcs15-infocamere.c index 1241ecc7..dde76f7a 100644 --- a/src/libopensc/pkcs15-infocamere.c +++ b/src/libopensc/pkcs15-infocamere.c @@ -28,11 +28,11 @@ int sc_pkcs15emu_infocamere_init_ex(sc_pkcs15_card_t *, sc_pkcs15emu_opt_t *); -static int (*set_security_env)(sc_card_t *, const struct sc_security_env *, int); +static int (*set_security_env)(sc_card_t *, const sc_security_env_t *, int); -static int set_sec_env(sc_card_t *card, const struct sc_security_env *env, int se_num) +static int set_sec_env(sc_card_t *card, const sc_security_env_t *env, int se_num) { - struct sc_security_env tenv = *env; + sc_security_env_t tenv = *env; if (tenv.operation == SC_SEC_OPERATION_SIGN) tenv.operation = SC_SEC_OPERATION_DECIPHER; return set_security_env(card, &tenv, se_num); @@ -62,7 +62,7 @@ sc_pkcs15emu_infocamere_init(sc_pkcs15_card_t *p15card) sc_card_t *card = p15card->card; sc_path_t path; - struct sc_file *file; + sc_file_t *file; sc_pkcs15_id_t id, auth_id; unsigned char buffer[256]; unsigned char ef_gdo[256]; diff --git a/src/libopensc/pkcs15-pin.c b/src/libopensc/pkcs15-pin.c index aa85d274..b8691c2e 100644 --- a/src/libopensc/pkcs15-pin.c +++ b/src/libopensc/pkcs15-pin.c @@ -55,7 +55,7 @@ int sc_pkcs15_decode_aodf_entry(struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *obj, const u8 ** buf, size_t *buflen) { - struct sc_context *ctx = p15card->card->ctx; + sc_context_t *ctx = p15card->card->ctx; struct sc_pkcs15_pin_info info; int r; size_t flags_len = sizeof(info.flags); @@ -112,7 +112,7 @@ int sc_pkcs15_decode_aodf_entry(struct sc_pkcs15_card *p15card, return 0; } -int sc_pkcs15_encode_aodf_entry(struct sc_context *ctx, +int sc_pkcs15_encode_aodf_entry(sc_context_t *ctx, const struct sc_pkcs15_object *obj, u8 **buf, size_t *buflen) { @@ -166,7 +166,7 @@ int sc_pkcs15_verify_pin(struct sc_pkcs15_card *p15card, const u8 *pincode, size_t pinlen) { int r; - struct sc_card *card; + sc_card_t *card; struct sc_pin_cmd_data args; assert(p15card != NULL); @@ -248,7 +248,7 @@ int sc_pkcs15_change_pin(struct sc_pkcs15_card *p15card, const u8 *newpin, size_t newpinlen) { int r; - struct sc_card *card; + sc_card_t *card; struct sc_pin_cmd_data data; size_t max_length; @@ -327,7 +327,7 @@ int sc_pkcs15_unblock_pin(struct sc_pkcs15_card *p15card, const u8 *newpin, size_t newpinlen) { int r; - struct sc_card *card; + sc_card_t *card; struct sc_pin_cmd_data data; struct sc_pkcs15_object *pin_obj, *puk_obj; struct sc_pkcs15_pin_info *puk_info = NULL; diff --git a/src/libopensc/pkcs15-postecert.c b/src/libopensc/pkcs15-postecert.c index e45440f6..8b41794a 100644 --- a/src/libopensc/pkcs15-postecert.c +++ b/src/libopensc/pkcs15-postecert.c @@ -28,12 +28,12 @@ int sc_pkcs15emu_postecert_init_ex(sc_pkcs15_card_t *, sc_pkcs15emu_opt_t *); -static int (*set_security_env) (sc_card_t *, const struct sc_security_env *, int); +static int (*set_security_env) (sc_card_t *, const sc_security_env_t *, int); -static int set_sec_env(sc_card_t * card, const struct sc_security_env *env, +static int set_sec_env(sc_card_t * card, const sc_security_env_t *env, int se_num) { - struct sc_security_env tenv = *env; + sc_security_env_t tenv = *env; if (tenv.operation == SC_SEC_OPERATION_SIGN) tenv.operation = SC_SEC_OPERATION_DECIPHER; return set_security_env(card, &tenv, se_num); diff --git a/src/libopensc/pkcs15-prkey.c b/src/libopensc/pkcs15-prkey.c index 2790def2..eff9d21a 100644 --- a/src/libopensc/pkcs15-prkey.c +++ b/src/libopensc/pkcs15-prkey.c @@ -83,7 +83,7 @@ int sc_pkcs15_decode_prkdf_entry(struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *obj, const u8 ** buf, size_t *buflen) { - struct sc_context *ctx = p15card->card->ctx; + sc_context_t *ctx = p15card->card->ctx; struct sc_pkcs15_prkey_info info; int r; size_t usage_len = sizeof(info.usage); @@ -161,7 +161,7 @@ int sc_pkcs15_decode_prkdf_entry(struct sc_pkcs15_card *p15card, return 0; } -int sc_pkcs15_encode_prkdf_entry(struct sc_context *ctx, +int sc_pkcs15_encode_prkdf_entry(sc_context_t *ctx, const struct sc_pkcs15_object *obj, u8 **buf, size_t *buflen) { @@ -244,7 +244,7 @@ static const struct sc_asn1_entry c_asn1_dsa_prkey_obj[] = { }; static int -sc_pkcs15_encode_prkey_dsa(struct sc_context *ctx, +sc_pkcs15_encode_prkey_dsa(sc_context_t *ctx, struct sc_pkcs15_prkey_dsa *key, u8 **buf, size_t *buflen) { @@ -258,7 +258,7 @@ sc_pkcs15_encode_prkey_dsa(struct sc_context *ctx, } static int -sc_pkcs15_decode_prkey_dsa(struct sc_context *ctx, +sc_pkcs15_decode_prkey_dsa(sc_context_t *ctx, struct sc_pkcs15_prkey_dsa *key, const u8 *buf, size_t buflen) { @@ -272,7 +272,7 @@ sc_pkcs15_decode_prkey_dsa(struct sc_context *ctx, } int -sc_pkcs15_encode_prkey(struct sc_context *ctx, +sc_pkcs15_encode_prkey(sc_context_t *ctx, struct sc_pkcs15_prkey *key, u8 **buf, size_t *len) { @@ -284,7 +284,7 @@ sc_pkcs15_encode_prkey(struct sc_context *ctx, } int -sc_pkcs15_decode_prkey(struct sc_context *ctx, +sc_pkcs15_decode_prkey(sc_context_t *ctx, struct sc_pkcs15_prkey *key, const u8 *buf, size_t len) { @@ -301,10 +301,10 @@ sc_pkcs15_read_prkey(struct sc_pkcs15_card *p15card, const char *passphrase, struct sc_pkcs15_prkey **out) { - struct sc_context *ctx = p15card->card->ctx; + sc_context_t *ctx = p15card->card->ctx; struct sc_pkcs15_prkey_info *info; struct sc_pkcs15_prkey key; - struct sc_path path; + sc_path_t path; u8 *data = NULL; size_t len; int r; diff --git a/src/libopensc/pkcs15-pubkey.c b/src/libopensc/pkcs15-pubkey.c index 54960b69..8fbd48b4 100644 --- a/src/libopensc/pkcs15-pubkey.c +++ b/src/libopensc/pkcs15-pubkey.c @@ -77,7 +77,7 @@ int sc_pkcs15_decode_pukdf_entry(struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *obj, const u8 ** buf, size_t *buflen) { - struct sc_context *ctx = p15card->card->ctx; + sc_context_t *ctx = p15card->card->ctx; struct sc_pkcs15_pubkey_info info; int r; size_t usage_len = sizeof(info.usage); @@ -142,7 +142,7 @@ int sc_pkcs15_decode_pukdf_entry(struct sc_pkcs15_card *p15card, return 0; } -int sc_pkcs15_encode_pukdf_entry(struct sc_context *ctx, +int sc_pkcs15_encode_pukdf_entry(sc_context_t *ctx, const struct sc_pkcs15_object *obj, u8 **buf, size_t *buflen) { @@ -232,7 +232,7 @@ static struct sc_asn1_entry c_asn1_dsa_pub_coefficients[5] = { }; int -sc_pkcs15_decode_pubkey_rsa(struct sc_context *ctx, +sc_pkcs15_decode_pubkey_rsa(sc_context_t *ctx, struct sc_pkcs15_pubkey_rsa *key, const u8 *buf, size_t buflen) { @@ -256,7 +256,7 @@ sc_pkcs15_decode_pubkey_rsa(struct sc_context *ctx, } int -sc_pkcs15_encode_pubkey_rsa(struct sc_context *ctx, +sc_pkcs15_encode_pubkey_rsa(sc_context_t *ctx, struct sc_pkcs15_pubkey_rsa *key, u8 **buf, size_t *buflen) { @@ -280,7 +280,7 @@ sc_pkcs15_encode_pubkey_rsa(struct sc_context *ctx, } int -sc_pkcs15_decode_pubkey_dsa(struct sc_context *ctx, +sc_pkcs15_decode_pubkey_dsa(sc_context_t *ctx, struct sc_pkcs15_pubkey_dsa *key, const u8 *buf, size_t buflen) { @@ -309,7 +309,7 @@ sc_pkcs15_decode_pubkey_dsa(struct sc_context *ctx, } int -sc_pkcs15_encode_pubkey_dsa(struct sc_context *ctx, +sc_pkcs15_encode_pubkey_dsa(sc_context_t *ctx, struct sc_pkcs15_pubkey_dsa *key, u8 **buf, size_t *buflen) { @@ -337,7 +337,7 @@ sc_pkcs15_encode_pubkey_dsa(struct sc_context *ctx, } int -sc_pkcs15_encode_pubkey(struct sc_context *ctx, +sc_pkcs15_encode_pubkey(sc_context_t *ctx, struct sc_pkcs15_pubkey *key, u8 **buf, size_t *len) { @@ -351,7 +351,7 @@ sc_pkcs15_encode_pubkey(struct sc_context *ctx, } int -sc_pkcs15_decode_pubkey(struct sc_context *ctx, +sc_pkcs15_decode_pubkey(sc_context_t *ctx, struct sc_pkcs15_pubkey *key, const u8 *buf, size_t len) { diff --git a/src/libopensc/pkcs15-sec.c b/src/libopensc/pkcs15-sec.c index da167789..6f3809db 100644 --- a/src/libopensc/pkcs15-sec.c +++ b/src/libopensc/pkcs15-sec.c @@ -30,9 +30,9 @@ static int select_key_file(struct sc_pkcs15_card *p15card, const struct sc_pkcs15_prkey_info *prkey, - struct sc_security_env *senv) + sc_security_env_t *senv) { - struct sc_path path, file_id; + sc_path_t path, file_id; int r; if (prkey->path.len < 2) @@ -63,9 +63,9 @@ int sc_pkcs15_decipher(struct sc_pkcs15_card *p15card, const u8 * in, size_t inlen, u8 *out, size_t outlen) { int r; - struct sc_algorithm_info *alg_info; - struct sc_security_env senv; - struct sc_context *ctx = p15card->card->ctx; + sc_algorithm_info_t *alg_info; + sc_security_env_t senv; + sc_context_t *ctx = p15card->card->ctx; const struct sc_pkcs15_prkey_info *prkey = (const struct sc_pkcs15_prkey_info *) obj->data; unsigned long pad_flags = 0; @@ -151,9 +151,9 @@ int sc_pkcs15_compute_signature(struct sc_pkcs15_card *p15card, u8 *out, size_t outlen) { int r; - struct sc_security_env senv; - struct sc_context *ctx = p15card->card->ctx; - struct sc_algorithm_info *alg_info; + sc_security_env_t senv; + sc_context_t *ctx = p15card->card->ctx; + sc_algorithm_info_t *alg_info; const struct sc_pkcs15_prkey_info *prkey = (const struct sc_pkcs15_prkey_info *) obj->data; u8 buf[512], *tmpin, *tmpout, *help; size_t tmpoutlen; diff --git a/src/libopensc/pkcs15-starcert.c b/src/libopensc/pkcs15-starcert.c index 70cc6cbf..a2893deb 100644 --- a/src/libopensc/pkcs15-starcert.c +++ b/src/libopensc/pkcs15-starcert.c @@ -153,10 +153,10 @@ static int sc_pkcs15emu_starcert_init(sc_pkcs15_card_t *p15card) int r, i; char buf[256]; - struct sc_path path; - struct sc_file *file = NULL; - struct sc_card *card = p15card->card; - struct sc_serial_number serial; + sc_path_t path; + sc_file_t *file = NULL; + sc_card_t *card = p15card->card; + sc_serial_number_t serial; /* get serial number */ r = sc_card_ctl(card, SC_CARDCTL_GET_SERIALNR, &serial); diff --git a/src/libopensc/pkcs15-wrap.c b/src/libopensc/pkcs15-wrap.c index 04c59e54..636577c5 100644 --- a/src/libopensc/pkcs15-wrap.c +++ b/src/libopensc/pkcs15-wrap.c @@ -42,7 +42,7 @@ #ifndef HAVE_OPENSSL int -sc_pkcs15_wrap_data(struct sc_context *ctx, +sc_pkcs15_wrap_data(sc_context_t *ctx, const char *passphrase, const u8 *in, size_t in_len, u8 **out, size_t *out_len) @@ -51,7 +51,7 @@ sc_pkcs15_wrap_data(struct sc_context *ctx, } int -sc_pkcs15_unwrap_data(struct sc_context *ctx, +sc_pkcs15_unwrap_data(sc_context_t *ctx, const char *passphrase, const u8 *in, size_t in_len, u8 **out, size_t *out_len) @@ -62,7 +62,7 @@ sc_pkcs15_unwrap_data(struct sc_context *ctx, #else /* HAVE_OPENSSL */ static int -sc_pkcs15_derive_key(struct sc_context *ctx, +sc_pkcs15_derive_key(sc_context_t *ctx, const struct sc_algorithm_id *der_alg, const struct sc_algorithm_id *enc_alg, const char *passphrase, @@ -120,7 +120,7 @@ sc_pkcs15_derive_key(struct sc_context *ctx, } static int -do_cipher(struct sc_context *ctx, EVP_CIPHER_CTX *cipher_ctx, +do_cipher(sc_context_t *ctx, EVP_CIPHER_CTX *cipher_ctx, const u8 *in, size_t in_len, u8 **out, size_t *out_len) { @@ -156,7 +156,7 @@ fail: free(p); } int -sc_pkcs15_wrap_data(struct sc_context *ctx, +sc_pkcs15_wrap_data(sc_context_t *ctx, const char *passphrase, const u8 *in, size_t in_len, u8 **out, size_t *out_len) @@ -201,7 +201,7 @@ sc_pkcs15_wrap_data(struct sc_context *ctx, int -sc_pkcs15_unwrap_data(struct sc_context *ctx, +sc_pkcs15_unwrap_data(sc_context_t *ctx, const char *passphrase, const u8 *in, size_t in_len, u8 **out, size_t *out_len) @@ -285,7 +285,7 @@ static const struct sc_asn1_entry c_asn1_kek_attr[] = { }; int -sc_pkcs15_decode_enveloped_data(struct sc_context *ctx, +sc_pkcs15_decode_enveloped_data(sc_context_t *ctx, struct sc_pkcs15_enveloped_data *result, const u8 *buf, size_t buflen) { @@ -338,7 +338,7 @@ sc_pkcs15_decode_enveloped_data(struct sc_context *ctx, } int -sc_pkcs15_encode_enveloped_data(struct sc_context *ctx, +sc_pkcs15_encode_enveloped_data(sc_context_t *ctx, struct sc_pkcs15_enveloped_data *data, u8 **buf, size_t *buflen) { diff --git a/src/libopensc/pkcs15.c b/src/libopensc/pkcs15.c index 7e976c31..4b326ae0 100644 --- a/src/libopensc/pkcs15.c +++ b/src/libopensc/pkcs15.c @@ -108,7 +108,7 @@ err: return; } -int sc_pkcs15_encode_tokeninfo(struct sc_context *ctx, +int sc_pkcs15_encode_tokeninfo(sc_context_t *ctx, struct sc_pkcs15_card *card, u8 **buf, size_t *buflen) { @@ -167,7 +167,7 @@ static const struct sc_asn1_entry c_asn1_ddo[] = { static int parse_ddo(struct sc_pkcs15_card *p15card, const u8 * buf, size_t buflen) { struct sc_asn1_entry asn1_ddo[5]; - struct sc_path odf_path, ti_path; + sc_path_t odf_path, ti_path; int r; sc_copy_asn1_entry(c_asn1_ddo, asn1_ddo); @@ -228,10 +228,10 @@ static int encode_ddo(struct sc_pkcs15_card *p15card, u8 **buf, size_t *buflen) #endif #if 0 -int sc_pkcs15_create_dir(struct sc_pkcs15_card *p15card, struct sc_card *card) +int sc_pkcs15_create_dir(struct sc_pkcs15_card *p15card, sc_card_t *card) { - struct sc_path path; - struct sc_file file; + sc_path_t path; + sc_file_t file; u8 *buf; size_t bufsize; int r, i; @@ -303,7 +303,7 @@ static int parse_odf(const u8 * buf, size_t buflen, struct sc_pkcs15_card *card) const u8 *p = buf; size_t left = buflen; int r, i; - struct sc_path path; + sc_path_t path; struct sc_asn1_entry asn1_obj_or_path[] = { { "path", SC_ASN1_PATH, SC_ASN1_CONS | SC_ASN1_SEQUENCE, 0, &path }, { NULL } @@ -326,11 +326,11 @@ static int parse_odf(const u8 * buf, size_t buflen, struct sc_pkcs15_card *card) return 0; } -int sc_pkcs15_encode_odf(struct sc_context *ctx, +int sc_pkcs15_encode_odf(sc_context_t *ctx, struct sc_pkcs15_card *p15card, u8 **buf, size_t *buflen) { - struct sc_path path; + sc_path_t path; struct sc_asn1_entry asn1_obj_or_path[] = { { "path", SC_ASN1_PATH, SC_ASN1_CONS | SC_ASN1_SEQUENCE, 0, &path }, { NULL } @@ -469,9 +469,9 @@ static int sc_pkcs15_bind_internal(sc_pkcs15_card_t *p15card) unsigned char buf[SC_MAX_APDU_BUFFER_SIZE]; int err, ok = 0; size_t len; - struct sc_path tmppath; - struct sc_card *card = p15card->card; - struct sc_context *ctx = card->ctx; + sc_path_t tmppath; + sc_card_t *card = p15card->card; + sc_context_t *ctx = card->ctx; if (ctx->debug > 4) sc_debug(ctx, "trying normal pkcs15 processing\n"); @@ -491,7 +491,7 @@ static int sc_pkcs15_bind_internal(sc_pkcs15_card_t *p15card) } sc_format_path("3F005015", &p15card->file_app->path); if (card->app_count > 0) { - const struct sc_app_info *info; + const sc_app_info_t *info; info = sc_find_pkcs15_app(card); if (info != NULL) { @@ -594,11 +594,11 @@ end: return SC_SUCCESS; } -int sc_pkcs15_bind(struct sc_card *card, +int sc_pkcs15_bind(sc_card_t *card, struct sc_pkcs15_card **p15card_out) { struct sc_pkcs15_card *p15card = NULL; - struct sc_context *ctx; + sc_context_t *ctx; scconf_block *conf_block = NULL, **blocks; int i, r, emu_first, enable_emu; @@ -661,10 +661,10 @@ error: } #if 0 -int sc_pkcs15_detect(struct sc_card *card) +int sc_pkcs15_detect(sc_card_t *card) { int r; - struct sc_path path; + sc_path_t path; sc_format_path("NA0000063504B43532D3135", &path); r = sc_select_file(card, &path, NULL); @@ -1119,7 +1119,7 @@ void sc_pkcs15_remove_df(struct sc_pkcs15_card *p15card, free(obj); } -int sc_pkcs15_encode_df(struct sc_context *ctx, +int sc_pkcs15_encode_df(sc_context_t *ctx, struct sc_pkcs15_card *p15card, struct sc_pkcs15_df *df, u8 **buf_out, size_t *bufsize_out) @@ -1127,7 +1127,7 @@ int sc_pkcs15_encode_df(struct sc_context *ctx, u8 *buf = NULL, *tmp = NULL; size_t bufsize = 0, tmpsize; const struct sc_pkcs15_object *obj; - int (* func)(struct sc_context *, const struct sc_pkcs15_object *nobj, + int (* func)(sc_context_t *, const struct sc_pkcs15_object *nobj, u8 **nbuf, size_t *nbufsize) = NULL; int r; @@ -1181,7 +1181,7 @@ int sc_pkcs15_encode_df(struct sc_context *ctx, int sc_pkcs15_parse_df(struct sc_pkcs15_card *p15card, struct sc_pkcs15_df *df) { - struct sc_context *ctx = p15card->card->ctx; + sc_context_t *ctx = p15card->card->ctx; u8 *buf; const u8 *p; size_t bufsize; @@ -1269,12 +1269,12 @@ ret: } int sc_pkcs15_read_file(struct sc_pkcs15_card *p15card, - const struct sc_path *in_path, + const sc_path_t *in_path, u8 **buf, size_t *buflen, - struct sc_file **file_out) + sc_file_t **file_out) { - struct sc_file *file = NULL; - struct sc_path tmp_path, *path = &tmp_path; + sc_file_t *file = NULL; + sc_path_t tmp_path, *path = &tmp_path; u8 *data = NULL; size_t len = 0, offset = 0; int r = -1; @@ -1285,12 +1285,12 @@ int sc_pkcs15_read_file(struct sc_pkcs15_card *p15card, if (in_path->type == SC_PATH_TYPE_FILE_ID) { /* in case of a FID prepend the application DF */ - memcpy(path, &p15card->file_app->path, sizeof(struct sc_path)); + memcpy(path, &p15card->file_app->path, sizeof(sc_path_t)); sc_append_path(path, in_path); path->index = in_path->index; path->count = in_path->count; } else { - memcpy(path, in_path, sizeof(struct sc_path)); + memcpy(path, in_path, sizeof(sc_path_t)); } if (p15card->opts.use_cache) { diff --git a/src/libopensc/reader-ctapi.c b/src/libopensc/reader-ctapi.c index e1773909..4d99a150 100644 --- a/src/libopensc/reader-ctapi.c +++ b/src/libopensc/reader-ctapi.c @@ -79,7 +79,7 @@ struct ctapi_slot_data { }; /* Reset slot or reader */ -static int ctapi_reset(struct sc_reader *reader, struct sc_slot_info *slot) +static int ctapi_reset(sc_reader_t *reader, sc_slot_info_t *slot) { struct ctapi_private_data *priv = GET_PRIV_DATA(reader); char rv; @@ -107,7 +107,7 @@ static int ctapi_reset(struct sc_reader *reader, struct sc_slot_info *slot) return 0; } -static void set_default_fu(struct sc_reader *reader) +static void set_default_fu(sc_reader_t *reader) { if (!reader) return; @@ -120,7 +120,7 @@ static void set_default_fu(struct sc_reader *reader) /* Detect functional units of the reader according to CT-BCS spec version 1.0 (14.04.2004, http://www.teletrust.de/down/mct1-0_t4.zip) */ -static void detect_functional_units(struct sc_reader *reader) +static void detect_functional_units(sc_reader_t *reader) { struct ctapi_private_data *priv = GET_PRIV_DATA(reader); char rv; @@ -237,8 +237,8 @@ static void detect_functional_units(struct sc_reader *reader) } } -static int refresh_slot_attributes(struct sc_reader *reader, - struct sc_slot_info *slot) +static int refresh_slot_attributes(sc_reader_t *reader, + sc_slot_info_t *slot) { struct ctapi_private_data *priv = GET_PRIV_DATA(reader); char rv; @@ -286,7 +286,7 @@ static int refresh_slot_attributes(struct sc_reader *reader, return 0; } -static int ctapi_transmit(struct sc_reader *reader, struct sc_slot_info *slot, +static int ctapi_transmit(sc_reader_t *reader, sc_slot_info_t *slot, const u8 *sendbuf, size_t sendsize, u8 *recvbuf, size_t *recvsize, unsigned long control) @@ -315,7 +315,7 @@ static int ctapi_transmit(struct sc_reader *reader, struct sc_slot_info *slot, return 0; } -static int ctapi_detect_card_presence(struct sc_reader *reader, struct sc_slot_info *slot) +static int ctapi_detect_card_presence(sc_reader_t *reader, sc_slot_info_t *slot) { int r; @@ -325,7 +325,7 @@ static int ctapi_detect_card_presence(struct sc_reader *reader, struct sc_slot_i return slot->flags; } -static int ctapi_connect(struct sc_reader *reader, struct sc_slot_info *slot) +static int ctapi_connect(sc_reader_t *reader, sc_slot_info_t *slot) { struct ctapi_private_data *priv = GET_PRIV_DATA(reader); char rv; @@ -379,23 +379,23 @@ static int ctapi_connect(struct sc_reader *reader, struct sc_slot_info *slot) return 0; } -static int ctapi_disconnect(struct sc_reader *reader, struct sc_slot_info *slot, +static int ctapi_disconnect(sc_reader_t *reader, sc_slot_info_t *slot, int action) { return 0; } -static int ctapi_lock(struct sc_reader *reader, struct sc_slot_info *slot) +static int ctapi_lock(sc_reader_t *reader, sc_slot_info_t *slot) { return 0; } -static int ctapi_unlock(struct sc_reader *reader, struct sc_slot_info *slot) +static int ctapi_unlock(sc_reader_t *reader, sc_slot_info_t *slot) { return 0; } -static int ctapi_release(struct sc_reader *reader) +static int ctapi_release(sc_reader_t *reader) { struct ctapi_private_data *priv = GET_PRIV_DATA(reader); @@ -428,7 +428,7 @@ static struct ctapi_module * add_module(struct ctapi_global_private_data *gpriv, return &gpriv->modules[i]; } -static int ctapi_load_module(struct sc_context *ctx, +static int ctapi_load_module(sc_context_t *ctx, struct ctapi_global_private_data *gpriv, scconf_block *conf) { @@ -467,7 +467,7 @@ static int ctapi_load_module(struct sc_context *ctx, int port; char namebuf[128]; char rv; - struct sc_reader *reader; + sc_reader_t *reader; struct ctapi_private_data *priv; if (sscanf(list->data, "%d", &port) != 1) { @@ -479,7 +479,7 @@ static int ctapi_load_module(struct sc_context *ctx, sc_error(ctx, "CT_init() failed with %d\n", rv); continue; } - reader = (struct sc_reader *) malloc(sizeof(struct sc_reader)); + reader = (sc_reader_t *) malloc(sizeof(sc_reader_t)); priv = (struct ctapi_private_data *) malloc(sizeof(struct ctapi_private_data)); memset(reader, 0, sizeof(*reader)); reader->drv_data = priv; @@ -514,7 +514,7 @@ symerr: return -1; } -static int ctapi_init(struct sc_context *ctx, void **reader_data) +static int ctapi_init(sc_context_t *ctx, void **reader_data) { int i; struct ctapi_global_private_data *gpriv; @@ -544,7 +544,7 @@ static int ctapi_init(struct sc_context *ctx, void **reader_data) return 0; } -static int ctapi_finish(struct sc_context *ctx, void *prv_data) +static int ctapi_finish(sc_context_t *ctx, void *prv_data) { struct ctapi_global_private_data *priv = (struct ctapi_global_private_data *) prv_data; diff --git a/src/libopensc/reader-openct.c b/src/libopensc/reader-openct.c index 36a19507..d6456f5b 100644 --- a/src/libopensc/reader-openct.c +++ b/src/libopensc/reader-openct.c @@ -32,28 +32,28 @@ #define PREALLOCATE 5 /* function declarations */ -static int openct_reader_init(struct sc_context *ctx, void **priv_data); -static int openct_add_reader(struct sc_context *ctx, unsigned int num, ct_info_t *info); -static int openct_reader_finish(struct sc_context *ctx, void *priv_data); -static int openct_reader_release(struct sc_reader *reader); -static int openct_reader_detect_card_presence(struct sc_reader *reader, - struct sc_slot_info *slot); -static int openct_reader_connect(struct sc_reader *reader, - struct sc_slot_info *slot); -static int openct_reader_disconnect(struct sc_reader *reader, - struct sc_slot_info *slot, int action); -static int openct_reader_transmit(struct sc_reader *reader, - struct sc_slot_info *slot, +static int openct_reader_init(sc_context_t *ctx, void **priv_data); +static int openct_add_reader(sc_context_t *ctx, unsigned int num, ct_info_t *info); +static int openct_reader_finish(sc_context_t *ctx, void *priv_data); +static int openct_reader_release(sc_reader_t *reader); +static int openct_reader_detect_card_presence(sc_reader_t *reader, + sc_slot_info_t *slot); +static int openct_reader_connect(sc_reader_t *reader, + sc_slot_info_t *slot); +static int openct_reader_disconnect(sc_reader_t *reader, + sc_slot_info_t *slot, int action); +static int openct_reader_transmit(sc_reader_t *reader, + sc_slot_info_t *slot, const u8 *sendbuf, size_t sendsize, u8 *recvbuf, size_t *recvsize, unsigned long control); -static int openct_reader_perform_verify(struct sc_reader *reader, - struct sc_slot_info *slot, +static int openct_reader_perform_verify(sc_reader_t *reader, + sc_slot_info_t *slot, struct sc_pin_cmd_data *info); -static int openct_reader_lock(struct sc_reader *reader, - struct sc_slot_info *slot); -static int openct_reader_unlock(struct sc_reader *reader, - struct sc_slot_info *slot); -static int openct_error(struct sc_reader *, int); +static int openct_reader_lock(sc_reader_t *reader, + sc_slot_info_t *slot); +static int openct_reader_unlock(sc_reader_t *reader, + sc_slot_info_t *slot); +static int openct_error(sc_reader_t *, int); static struct sc_reader_operations openct_ops; @@ -82,7 +82,7 @@ struct slot_data { * is loaded */ static int -openct_reader_init(struct sc_context *ctx, void **priv_data) +openct_reader_init(sc_context_t *ctx, void **priv_data) { unsigned int i; @@ -101,7 +101,7 @@ openct_reader_init(struct sc_context *ctx, void **priv_data) } static int -openct_add_reader(struct sc_context *ctx, unsigned int num, ct_info_t *info) +openct_add_reader(sc_context_t *ctx, unsigned int num, ct_info_t *info) { sc_reader_t *reader; struct driver_data *data; @@ -152,7 +152,7 @@ openct_add_reader(struct sc_context *ctx, unsigned int num, ct_info_t *info) * deallocate the private data and any resources. */ int -openct_reader_finish(struct sc_context *ctx, void *priv_data) +openct_reader_finish(sc_context_t *ctx, void *priv_data) { SC_FUNC_CALLED(ctx, 1); return SC_NO_ERROR; @@ -164,7 +164,7 @@ openct_reader_finish(struct sc_context *ctx, void *priv_data) * freed by OpenSC. */ int -openct_reader_release(struct sc_reader *reader) +openct_reader_release(sc_reader_t *reader) { struct driver_data *data = (struct driver_data *) reader->drv_data; @@ -184,8 +184,8 @@ openct_reader_release(struct sc_reader *reader) * Check whether a card was added/removed */ int -openct_reader_detect_card_presence(struct sc_reader *reader, - struct sc_slot_info *slot) +openct_reader_detect_card_presence(sc_reader_t *reader, + sc_slot_info_t *slot) { struct driver_data *data = (struct driver_data *) reader->drv_data; int rc, status; @@ -208,8 +208,8 @@ openct_reader_detect_card_presence(struct sc_reader *reader, } static int -openct_reader_connect(struct sc_reader *reader, - struct sc_slot_info *slot) +openct_reader_connect(sc_reader_t *reader, + sc_slot_info_t *slot) { struct driver_data *data = (struct driver_data *) reader->drv_data; int rc; @@ -243,8 +243,8 @@ openct_reader_connect(struct sc_reader *reader, } static int -openct_reader_reconnect(struct sc_reader *reader, - struct sc_slot_info *slot) +openct_reader_reconnect(sc_reader_t *reader, + sc_slot_info_t *slot) { struct driver_data *data = (struct driver_data *) reader->drv_data; int rc; @@ -258,8 +258,8 @@ openct_reader_reconnect(struct sc_reader *reader, } int -openct_reader_disconnect(struct sc_reader *reader, - struct sc_slot_info *slot, int action) +openct_reader_disconnect(sc_reader_t *reader, + sc_slot_info_t *slot, int action) { struct driver_data *data = (struct driver_data *) reader->drv_data; @@ -271,8 +271,8 @@ openct_reader_disconnect(struct sc_reader *reader, } int -openct_reader_transmit(struct sc_reader *reader, - struct sc_slot_info *slot, +openct_reader_transmit(sc_reader_t *reader, + sc_slot_info_t *slot, const u8 *sendbuf, size_t sendsize, u8 *recvbuf, size_t *recvsize, unsigned long control) { @@ -300,8 +300,8 @@ openct_reader_transmit(struct sc_reader *reader, } int -openct_reader_perform_verify(struct sc_reader *reader, - struct sc_slot_info *slot, +openct_reader_perform_verify(sc_reader_t *reader, + sc_slot_info_t *slot, struct sc_pin_cmd_data *info) { struct driver_data *data = (struct driver_data *) reader->drv_data; @@ -363,8 +363,8 @@ openct_reader_perform_verify(struct sc_reader *reader, int -openct_reader_lock(struct sc_reader *reader, - struct sc_slot_info *slot) +openct_reader_lock(sc_reader_t *reader, + sc_slot_info_t *slot) { struct driver_data *data = (struct driver_data *) reader->drv_data; struct slot_data *slot_data = (struct slot_data *) slot->drv_data; @@ -390,8 +390,8 @@ openct_reader_lock(struct sc_reader *reader, } int -openct_reader_unlock(struct sc_reader *reader, - struct sc_slot_info *slot) +openct_reader_unlock(sc_reader_t *reader, + sc_slot_info_t *slot) { struct driver_data *data = (struct driver_data *) reader->drv_data; struct slot_data *slot_data = (struct slot_data *) slot->drv_data; @@ -416,7 +416,7 @@ openct_reader_unlock(struct sc_reader *reader, * Handle an error code returned by OpenCT */ int -openct_error(struct sc_reader *reader, int code) +openct_error(sc_reader_t *reader, int code) { if (code >= 0) return code; diff --git a/src/libopensc/reader-pcsc.c b/src/libopensc/reader-pcsc.c index 9e859fee..d5286abb 100644 --- a/src/libopensc/reader-pcsc.c +++ b/src/libopensc/reader-pcsc.c @@ -77,7 +77,7 @@ struct pcsc_slot_data { SCARD_READERSTATE_A reader_state; }; -static int pcsc_detect_card_presence(struct sc_reader *reader, struct sc_slot_info *slot); +static int pcsc_detect_card_presence(sc_reader_t *reader, sc_slot_info_t *slot); static int pcsc_ret_to_error(long rv) { @@ -123,7 +123,7 @@ static DWORD opensc_proto_to_pcsc(unsigned int proto) } } -static int pcsc_transmit(struct sc_reader *reader, struct sc_slot_info *slot, +static int pcsc_transmit(sc_reader_t *reader, sc_slot_info_t *slot, const u8 *sendbuf, size_t sendsize, u8 *recvbuf, size_t *recvsize, unsigned long control) @@ -187,7 +187,7 @@ static int pcsc_transmit(struct sc_reader *reader, struct sc_slot_info *slot, return 0; } -static int refresh_slot_attributes(struct sc_reader *reader, struct sc_slot_info *slot) +static int refresh_slot_attributes(sc_reader_t *reader, sc_slot_info_t *slot) { struct pcsc_private_data *priv = GET_PRIV_DATA(reader); struct pcsc_slot_data *pslot = GET_SLOT_DATA(slot); @@ -254,7 +254,7 @@ static int refresh_slot_attributes(struct sc_reader *reader, struct sc_slot_info return 0; } -static int pcsc_detect_card_presence(struct sc_reader *reader, struct sc_slot_info *slot) +static int pcsc_detect_card_presence(sc_reader_t *reader, sc_slot_info_t *slot) { int rv; @@ -267,14 +267,14 @@ static int pcsc_detect_card_presence(struct sc_reader *reader, struct sc_slot_in * This function ignores the list of slots, because with * pcsc we have a 1:1 mapping of readers and slots anyway */ -static int pcsc_wait_for_event(struct sc_reader **readers, - struct sc_slot_info **slots, +static int pcsc_wait_for_event(sc_reader_t **readers, + sc_slot_info_t **slots, size_t nslots, unsigned int event_mask, int *reader, unsigned int *event, int timeout) { - struct sc_context *ctx; + sc_context_t *ctx; SCARDCONTEXT pcsc_ctx; LONG ret; SCARD_READERSTATE_A rgReaderStates[SC_MAX_READERS]; @@ -377,7 +377,7 @@ static int pcsc_wait_for_event(struct sc_reader **readers, } } -static int pcsc_connect(struct sc_reader *reader, struct sc_slot_info *slot) +static int pcsc_connect(sc_reader_t *reader, sc_slot_info_t *slot) { DWORD active_proto, protocol; SCARDHANDLE card_handle; @@ -444,7 +444,7 @@ static int pcsc_connect(struct sc_reader *reader, struct sc_slot_info *slot) return 0; } -static int pcsc_disconnect(struct sc_reader *reader, struct sc_slot_info *slot, +static int pcsc_disconnect(sc_reader_t *reader, sc_slot_info_t *slot, int action) { struct pcsc_slot_data *pslot = GET_SLOT_DATA(slot); @@ -456,7 +456,7 @@ static int pcsc_disconnect(struct sc_reader *reader, struct sc_slot_info *slot, return 0; } -static int pcsc_lock(struct sc_reader *reader, struct sc_slot_info *slot) +static int pcsc_lock(sc_reader_t *reader, sc_slot_info_t *slot) { long rv; struct pcsc_slot_data *pslot = GET_SLOT_DATA(slot); @@ -470,7 +470,7 @@ static int pcsc_lock(struct sc_reader *reader, struct sc_slot_info *slot) return 0; } -static int pcsc_unlock(struct sc_reader *reader, struct sc_slot_info *slot) +static int pcsc_unlock(sc_reader_t *reader, sc_slot_info_t *slot) { long rv; struct pcsc_slot_data *pslot = GET_SLOT_DATA(slot); @@ -484,7 +484,7 @@ static int pcsc_unlock(struct sc_reader *reader, struct sc_slot_info *slot) return 0; } -static int pcsc_release(struct sc_reader *reader) +static int pcsc_release(sc_reader_t *reader) { int i; struct pcsc_private_data *priv = GET_PRIV_DATA(reader); @@ -508,7 +508,7 @@ static struct sc_reader_driver pcsc_drv = { &pcsc_ops }; -static int pcsc_init(struct sc_context *ctx, void **reader_data) +static int pcsc_init(sc_context_t *ctx, void **reader_data) { LONG rv; DWORD reader_buf_size; @@ -554,10 +554,10 @@ static int pcsc_init(struct sc_context *ctx, void **reader_data) } p = reader_buf; do { - struct sc_reader *reader = (struct sc_reader *) malloc(sizeof(struct sc_reader)); + sc_reader_t *reader = (sc_reader_t *) malloc(sizeof(sc_reader_t)); struct pcsc_private_data *priv = (struct pcsc_private_data *) malloc(sizeof(struct pcsc_private_data)); struct pcsc_slot_data *pslot = (struct pcsc_slot_data *) malloc(sizeof(struct pcsc_slot_data)); - struct sc_slot_info *slot; + sc_slot_info_t *slot; if (reader == NULL || priv == NULL || pslot == NULL) { if (reader) @@ -600,7 +600,7 @@ static int pcsc_init(struct sc_context *ctx, void **reader_data) return 0; } -static int pcsc_finish(struct sc_context *ctx, void *prv_data) +static int pcsc_finish(sc_context_t *ctx, void *prv_data) { struct pcsc_global_private_data *priv = (struct pcsc_global_private_data *) prv_data; @@ -613,7 +613,7 @@ static int pcsc_finish(struct sc_context *ctx, void *prv_data) } static int -pcsc_pin_cmd(struct sc_reader *reader, sc_slot_info_t * slot, struct sc_pin_cmd_data *data) +pcsc_pin_cmd(sc_reader_t *reader, sc_slot_info_t * slot, struct sc_pin_cmd_data *data) { /* XXX: temporary */ if (slot->capabilities & SC_SLOT_CAP_PIN_PAD) { diff --git a/src/libopensc/sc.c b/src/libopensc/sc.c index 80ff24ab..2ae55ad7 100644 --- a/src/libopensc/sc.c +++ b/src/libopensc/sc.c @@ -102,7 +102,7 @@ int sc_bin_to_hex(const u8 *in, size_t in_len, char *out, size_t out_len, return 0; } -struct sc_slot_info * _sc_get_slot_info(struct sc_reader *reader, int slot_id) +sc_slot_info_t * _sc_get_slot_info(sc_reader_t *reader, int slot_id) { assert(reader != NULL); if (slot_id < 0 || slot_id > reader->slot_count) @@ -110,10 +110,10 @@ struct sc_slot_info * _sc_get_slot_info(struct sc_reader *reader, int slot_id) return &reader->slot[slot_id]; } -int sc_detect_card_presence(struct sc_reader *reader, int slot_id) +int sc_detect_card_presence(sc_reader_t *reader, int slot_id) { int r; - struct sc_slot_info *slot = _sc_get_slot_info(reader, slot_id); + sc_slot_info_t *slot = _sc_get_slot_info(reader, slot_id); if (slot == NULL) SC_FUNC_RETURN(reader->ctx, 0, SC_ERROR_SLOT_NOT_FOUND); @@ -125,12 +125,12 @@ int sc_detect_card_presence(struct sc_reader *reader, int slot_id) SC_FUNC_RETURN(reader->ctx, 1, r); } -int sc_wait_for_event(struct sc_reader *readers[], int slot_id[], size_t nslots, +int sc_wait_for_event(sc_reader_t *readers[], int slot_id[], size_t nslots, unsigned int event_mask, int *reader, unsigned int *event, int timeout) { - struct sc_slot_info *slotp[SC_MAX_SLOTS * SC_MAX_READERS]; - struct sc_context *ctx; + sc_slot_info_t *slotp[SC_MAX_SLOTS * SC_MAX_READERS]; + sc_context_t *ctx; unsigned int j; int r; @@ -156,7 +156,7 @@ int sc_wait_for_event(struct sc_reader *readers[], int slot_id[], size_t nslots, SC_FUNC_RETURN(ctx, 1, r); } -void sc_format_path(const char *str, struct sc_path *path) +void sc_format_path(const char *str, sc_path_t *path) { int type = SC_PATH_TYPE_PATH; @@ -173,7 +173,7 @@ void sc_format_path(const char *str, struct sc_path *path) return; } -int sc_append_path(struct sc_path *dest, const struct sc_path *src) +int sc_append_path(sc_path_t *dest, const sc_path_t *src) { assert(dest != NULL && src != NULL); if (dest->len + src->len > SC_MAX_PATH_SIZE) @@ -183,7 +183,7 @@ int sc_append_path(struct sc_path *dest, const struct sc_path *src) return 0; } -int sc_append_path_id(struct sc_path *dest, const u8 *id, size_t idlen) +int sc_append_path_id(sc_path_t *dest, const u8 *id, size_t idlen) { if (dest->len + idlen > SC_MAX_PATH_SIZE) return SC_ERROR_INVALID_ARGUMENTS; @@ -192,7 +192,7 @@ int sc_append_path_id(struct sc_path *dest, const u8 *id, size_t idlen) return 0; } -int sc_append_file_id(struct sc_path *dest, unsigned int fid) +int sc_append_file_id(sc_path_t *dest, unsigned int fid) { u8 id[2] = { fid >> 8, fid & 0xff }; @@ -219,10 +219,10 @@ int sc_compare_path(const sc_path_t *path1, const sc_path_t *path2) && !memcmp(path1->value, path2->value, path1->len); } -int sc_file_add_acl_entry(struct sc_file *file, unsigned int operation, +int sc_file_add_acl_entry(sc_file_t *file, unsigned int operation, unsigned int method, unsigned long key_ref) { - struct sc_acl_entry *p, *_new; + sc_acl_entry_t *p, *_new; assert(file != NULL); assert(operation < SC_MAX_AC_OPS); @@ -230,28 +230,28 @@ int sc_file_add_acl_entry(struct sc_file *file, unsigned int operation, switch (method) { case SC_AC_NEVER: sc_file_clear_acl_entries(file, operation); - file->acl[operation] = (struct sc_acl_entry *) 1; + file->acl[operation] = (sc_acl_entry_t *) 1; return 0; case SC_AC_NONE: sc_file_clear_acl_entries(file, operation); - file->acl[operation] = (struct sc_acl_entry *) 2; + file->acl[operation] = (sc_acl_entry_t *) 2; return 0; case SC_AC_UNKNOWN: sc_file_clear_acl_entries(file, operation); - file->acl[operation] = (struct sc_acl_entry *) 3; + file->acl[operation] = (sc_acl_entry_t *) 3; return 0; default: /* NONE and UNKNOWN get zapped when a new AC is added. * If the ACL is NEVER, additional entries will be * dropped silently. */ - if (file->acl[operation] == (struct sc_acl_entry *) 1) + if (file->acl[operation] == (sc_acl_entry_t *) 1) return 0; - if (file->acl[operation] == (struct sc_acl_entry *) 2 - || file->acl[operation] == (struct sc_acl_entry *) 3) + if (file->acl[operation] == (sc_acl_entry_t *) 2 + || file->acl[operation] == (sc_acl_entry_t *) 3) file->acl[operation] = NULL; } - _new = (struct sc_acl_entry *) malloc(sizeof(struct sc_acl_entry)); + _new = (sc_acl_entry_t *) malloc(sizeof(sc_acl_entry_t)); if (_new == NULL) return SC_ERROR_OUT_OF_MEMORY; _new->method = method; @@ -270,17 +270,17 @@ int sc_file_add_acl_entry(struct sc_file *file, unsigned int operation, return 0; } -const struct sc_acl_entry * sc_file_get_acl_entry(const struct sc_file *file, +const sc_acl_entry_t * sc_file_get_acl_entry(const sc_file_t *file, unsigned int operation) { - struct sc_acl_entry *p; - static const struct sc_acl_entry e_never = { + sc_acl_entry_t *p; + static const sc_acl_entry_t e_never = { SC_AC_NEVER, SC_AC_KEY_REF_NONE, NULL }; - static const struct sc_acl_entry e_none = { + static const sc_acl_entry_t e_none = { SC_AC_NONE, SC_AC_KEY_REF_NONE, NULL }; - static const struct sc_acl_entry e_unknown = { + static const sc_acl_entry_t e_unknown = { SC_AC_UNKNOWN, SC_AC_KEY_REF_NONE, NULL }; @@ -288,51 +288,51 @@ const struct sc_acl_entry * sc_file_get_acl_entry(const struct sc_file *file, assert(operation < SC_MAX_AC_OPS); p = file->acl[operation]; - if (p == (struct sc_acl_entry *) 1) + if (p == (sc_acl_entry_t *) 1) return &e_never; - if (p == (struct sc_acl_entry *) 2) + if (p == (sc_acl_entry_t *) 2) return &e_none; - if (p == (struct sc_acl_entry *) 3) + if (p == (sc_acl_entry_t *) 3) return &e_unknown; return file->acl[operation]; } -void sc_file_clear_acl_entries(struct sc_file *file, unsigned int operation) +void sc_file_clear_acl_entries(sc_file_t *file, unsigned int operation) { - struct sc_acl_entry *e; + sc_acl_entry_t *e; assert(file != NULL); assert(operation < SC_MAX_AC_OPS); e = file->acl[operation]; - if (e == (struct sc_acl_entry *) 1 || - e == (struct sc_acl_entry *) 2 || - e == (struct sc_acl_entry *) 3) { + if (e == (sc_acl_entry_t *) 1 || + e == (sc_acl_entry_t *) 2 || + e == (sc_acl_entry_t *) 3) { file->acl[operation] = NULL; return; } while (e != NULL) { - struct sc_acl_entry *tmp = e->next; + sc_acl_entry_t *tmp = e->next; free(e); e = tmp; } file->acl[operation] = NULL; } -struct sc_file * sc_file_new() +sc_file_t * sc_file_new() { - struct sc_file *file = (struct sc_file *) malloc(sizeof(struct sc_file)); + sc_file_t *file = (sc_file_t *) malloc(sizeof(sc_file_t)); if (file == NULL) return NULL; - memset(file, 0, sizeof(struct sc_file)); + memset(file, 0, sizeof(sc_file_t)); file->magic = SC_FILE_MAGIC; return file; } -void sc_file_free(struct sc_file *file) +void sc_file_free(sc_file_t *file) { unsigned int i; assert(sc_file_valid(file)); @@ -348,10 +348,10 @@ void sc_file_free(struct sc_file *file) free(file); } -void sc_file_dup(struct sc_file **dest, const struct sc_file *src) +void sc_file_dup(sc_file_t **dest, const sc_file_t *src) { - struct sc_file *newf; - const struct sc_acl_entry *e; + sc_file_t *newf; + const sc_acl_entry_t *e; unsigned int op; assert(sc_file_valid(src)); @@ -370,7 +370,7 @@ void sc_file_dup(struct sc_file **dest, const struct sc_file *src) } } -int sc_file_set_sec_attr(struct sc_file *file, const u8 *sec_attr, +int sc_file_set_sec_attr(sc_file_t *file, const u8 *sec_attr, size_t sec_attr_len) { u8 *tmp; @@ -398,7 +398,7 @@ int sc_file_set_sec_attr(struct sc_file *file, const u8 *sec_attr, return 0; } -int sc_file_set_prop_attr(struct sc_file *file, const u8 *prop_attr, +int sc_file_set_prop_attr(sc_file_t *file, const u8 *prop_attr, size_t prop_attr_len) { u8 *tmp; @@ -426,7 +426,7 @@ int sc_file_set_prop_attr(struct sc_file *file, const u8 *prop_attr, return 0; } -int sc_file_set_type_attr(struct sc_file *file, const u8 *type_attr, +int sc_file_set_type_attr(sc_file_t *file, const u8 *type_attr, size_t type_attr_len) { u8 *tmp; @@ -454,14 +454,14 @@ int sc_file_set_type_attr(struct sc_file *file, const u8 *type_attr, return 0; } -inline int sc_file_valid(const struct sc_file *file) { +inline int sc_file_valid(const sc_file_t *file) { #ifndef NDEBUG assert(file != NULL); #endif return file->magic == SC_FILE_MAGIC; } -int _sc_parse_atr(struct sc_context *ctx, struct sc_slot_info *slot) +int _sc_parse_atr(sc_context_t *ctx, sc_slot_info_t *slot) { u8 *p = slot->atr; int atr_len = (int) slot->atr_len; diff --git a/src/libopensc/sec.c b/src/libopensc/sec.c index 03571cdb..57e13037 100644 --- a/src/libopensc/sec.c +++ b/src/libopensc/sec.c @@ -26,7 +26,7 @@ #include #include -int sc_decipher(struct sc_card *card, +int sc_decipher(sc_card_t *card, const u8 * crgram, size_t crgram_len, u8 * out, size_t outlen) { int r; @@ -39,7 +39,7 @@ int sc_decipher(struct sc_card *card, SC_FUNC_RETURN(card->ctx, 2, r); } -int sc_compute_signature(struct sc_card *card, +int sc_compute_signature(sc_card_t *card, const u8 * data, size_t datalen, u8 * out, size_t outlen) { @@ -53,8 +53,8 @@ int sc_compute_signature(struct sc_card *card, SC_FUNC_RETURN(card->ctx, 2, r); } -int sc_set_security_env(struct sc_card *card, - const struct sc_security_env *env, +int sc_set_security_env(sc_card_t *card, + const sc_security_env_t *env, int se_num) { int r; @@ -67,7 +67,7 @@ int sc_set_security_env(struct sc_card *card, SC_FUNC_RETURN(card->ctx, 2, r); } -int sc_restore_security_env(struct sc_card *card, int se_num) +int sc_restore_security_env(sc_card_t *card, int se_num) { int r; @@ -79,7 +79,7 @@ int sc_restore_security_env(struct sc_card *card, int se_num) SC_FUNC_RETURN(card->ctx, 2, r); } -int sc_verify(struct sc_card *card, unsigned int type, int ref, +int sc_verify(sc_card_t *card, unsigned int type, int ref, const u8 *pin, size_t pinlen, int *tries_left) { struct sc_pin_cmd_data data; @@ -94,7 +94,7 @@ int sc_verify(struct sc_card *card, unsigned int type, int ref, return sc_pin_cmd(card, &data, tries_left); } -int sc_logout(struct sc_card *card) +int sc_logout(sc_card_t *card) { int r; if (card->ops->logout == NULL) @@ -104,7 +104,7 @@ int sc_logout(struct sc_card *card) SC_FUNC_RETURN(card->ctx, 2, r); } -int sc_change_reference_data(struct sc_card *card, unsigned int type, +int sc_change_reference_data(sc_card_t *card, unsigned int type, int ref, const u8 *old, size_t oldlen, const u8 *newref, size_t newlen, int *tries_left) @@ -123,7 +123,7 @@ int sc_change_reference_data(struct sc_card *card, unsigned int type, return sc_pin_cmd(card, &data, tries_left); } -int sc_reset_retry_counter(struct sc_card *card, unsigned int type, int ref, +int sc_reset_retry_counter(sc_card_t *card, unsigned int type, int ref, const u8 *puk, size_t puklen, const u8 *newref, size_t newlen) { @@ -148,7 +148,7 @@ int sc_reset_retry_counter(struct sc_card *card, unsigned int type, int ref, * send this PIN to the card. If no PIN was given, the driver should * ask the reader to obtain the pin(s) via the pin pad */ -int sc_pin_cmd(struct sc_card *card, struct sc_pin_cmd_data *data, +int sc_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *data, int *tries_left) { int r;