API fixup: use defined type instead of struct for exposed structs

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2232 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
bert 2005-03-08 20:59:35 +00:00
parent 8c9895c896
commit 2d97002824
41 changed files with 927 additions and 934 deletions

View File

@ -26,10 +26,10 @@
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
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, const u8 *in, size_t len, const u8 **newp, size_t *len_left,
int choice, int depth); 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); u8 **ptr, size_t *size, int depth);
static const char *tag2str(unsigned int tag) 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); 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 buflen, unsigned int tag_in, size_t *taglen_in)
{ {
size_t left = buflen, taglen; size_t left = buflen, taglen;
@ -330,7 +330,7 @@ const u8 *sc_asn1_find_tag(struct sc_context *ctx, const u8 * buf,
return NULL; 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) unsigned int tag_in, size_t *taglen_out)
{ {
const u8 *p = *buf; 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; 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) unsigned int tag_in, size_t *taglen_out)
{ {
return sc_asn1_skip_tag(ctx, &buf, &buflen, tag_in, 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; 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) const u8 * data, size_t datalen, u8 ** out, size_t * outlen)
{ {
u8 t; u8 t;
@ -726,8 +726,8 @@ static const struct sc_asn1_entry c_asn1_path[4] = {
{ NULL } { NULL }
}; };
static int asn1_decode_path(struct sc_context *ctx, const u8 *in, size_t len, static int asn1_decode_path(sc_context_t *ctx, const u8 *in, size_t len,
struct sc_path *path, int depth) sc_path_t *path, int depth)
{ {
int idx, count, r; int idx, count, r;
struct sc_asn1_entry asn1_path[4]; 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; 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) u8 **buf, size_t *bufsize, int depth)
{ {
int r; int r;
struct sc_asn1_entry asn1_path[4]; 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_copy_asn1_entry(c_asn1_path, asn1_path);
sc_format_asn1_entry(asn1_path + 0, (void *) &tpath.value, (void *) &tpath.len, 1); 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 } { 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, size_t len, struct sc_asn1_pkcs15_object *obj,
int depth) int depth)
{ {
@ -816,7 +816,7 @@ static int asn1_decode_p15_object(struct sc_context *ctx, const u8 *in,
return r; 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) u8 **buf, size_t *bufsize, int depth)
{ {
int r; int r;
@ -848,13 +848,13 @@ static int asn1_encode_p15_object(struct sc_context *ctx, const struct sc_asn1_p
return r; 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) const u8 *obj, size_t objlen, int depth)
{ {
void *parm = entry->parm; 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) = 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; size_t *len = (size_t *) entry->arg;
int r = 0; int r = 0;
@ -986,7 +986,7 @@ static int asn1_decode_entry(struct sc_context *ctx,struct sc_asn1_entry *entry,
break; break;
case SC_ASN1_PATH: case SC_ASN1_PATH:
if (entry->parm != NULL) 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; break;
case SC_ASN1_PKCS15_ID: case SC_ASN1_PKCS15_ID:
if (entry->parm != NULL) { if (entry->parm != NULL) {
@ -1022,7 +1022,7 @@ static int asn1_decode_entry(struct sc_context *ctx,struct sc_asn1_entry *entry,
return 0; 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, const u8 *in, size_t len, const u8 **newp, size_t *len_left,
int choice, int depth) int choice, int depth)
{ {
@ -1114,25 +1114,25 @@ decode_ok:
SC_FUNC_RETURN(ctx, 3, 0); 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) 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); 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) 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); 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) u8 **obj, size_t *objlen, int depth)
{ {
void *parm = entry->parm; 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) = 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; const size_t *len = (const size_t *) entry->arg;
int r = 0; int r = 0;
u8 * buf = NULL; 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); r = sc_asn1_encode_object_id(&buf, &buflen, (struct sc_object_id *) parm);
break; break;
case SC_ASN1_PATH: 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; break;
case SC_ASN1_PKCS15_ID: case SC_ASN1_PKCS15_ID:
if (entry->parm != NULL) { if (entry->parm != NULL) {
@ -1308,7 +1308,7 @@ no_object:
return r; 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) u8 **ptr, size_t *size, int depth)
{ {
int r, idx = 0; int r, idx = 0;
@ -1346,20 +1346,20 @@ static int asn1_encode(struct sc_context *ctx, const struct sc_asn1_entry *asn1,
return 0; 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) u8 **ptr, size_t *size)
{ {
return asn1_encode(ctx, asn1, ptr, size, 0); 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) u8 **ptr, size_t *size, int depth)
{ {
return asn1_encode(ctx, asn1, ptr, size, depth); return asn1_encode(ctx, asn1, ptr, size, depth);
} }
int 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, const u8 *in, size_t len, const u8 **newp, size_t *left,
int choice, int depth) int choice, int depth)
{ {

View File

@ -591,7 +591,7 @@ static LONG SCR_SCardChangePIN(LPCTSTR szPinPadDll, const SCR_Card * pCard, BYTE
#if defined(HAVE_GUI) ||defined(BELPIC_PIN_PAD) #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); struct belpic_priv_data *priv = DRVDATA(card);
int lang = priv->lang; int lang = priv->lang;
@ -662,7 +662,7 @@ int belpic_set_language(const char *reader, int lang)
#endif /* BELPIC_SET_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) if (memcmp(lang, "en", 2) == 0)
return LNG_ENG; return LNG_ENG;
@ -737,9 +737,9 @@ static int get_pref(const char *prefs, int prefs_len, const char *title, const c
return -1; 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 prefs[240], *lg_value;
u8 path[] = { 0x3F, 0x00, 0xDF, 0x01, 0x40, 0x39 }; u8 path[] = { 0x3F, 0x00, 0xDF, 0x01, 0x40, 0x39 };
int r, i, len; int r, i, len;
@ -817,7 +817,7 @@ static int get_language(struct sc_card *card)
#endif /* GET_LANG_FROM_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; scconf_block *conf_block = NULL, **blocks;
int i; int i;
@ -849,7 +849,7 @@ static void load_pin_pad_err(const char *reader_name, const char *pp_reader_lib,
reader_name); 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) const char *reader_name, const char *pp_reader_lib)
{ {
LONG r; LONG r;
@ -920,7 +920,7 @@ static int belpic_load_pin_pad_lib(struct sc_card *card, struct belpic_priv_data
return 1; 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; int i = 0;
char *reader_name = card->reader->name, *conf_reader, *conf_lib; 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 */ #endif /* BELPIC_PIN_PAD */
static int belpic_finish(struct sc_card *card) static int belpic_finish(sc_card_t *card)
{ {
free(DRVDATA(card)); free(DRVDATA(card));
return 0; return 0;
} }
static int belpic_match_card(struct sc_card *card) static int belpic_match_card(sc_card_t *card)
{ {
int i; int i;
@ -974,7 +974,7 @@ static int belpic_match_card(struct sc_card *card)
return 1; return 1;
} }
static int belpic_init(struct sc_card *card) static int belpic_init(sc_card_t *card)
{ {
struct belpic_priv_data *priv = NULL; struct belpic_priv_data *priv = NULL;
scconf_block *conf_block; scconf_block *conf_block;
@ -1058,14 +1058,14 @@ static int belpic_init(struct sc_card *card)
return 0; return 0;
} }
static int belpic_select_file(struct sc_card *card, static int belpic_select_file(sc_card_t *card,
const struct sc_path *in_path, struct sc_file **file_out) const sc_path_t *in_path, sc_file_t **file_out)
{ {
struct sc_context *ctx; sc_context_t *ctx;
struct sc_apdu apdu; sc_apdu_t apdu;
u8 pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf; u8 pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf;
int r, pathlen; int r, pathlen;
struct sc_file *file = NULL; sc_file_t *file = NULL;
assert(card != NULL && in_path != NULL); assert(card != NULL && in_path != NULL);
ctx = card->ctx; ctx = card->ctx;
@ -1109,7 +1109,7 @@ static int belpic_select_file(struct sc_card *card,
return 0; 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) unsigned int idx, u8 * buf, size_t count, unsigned long flags)
{ {
int r; int r;
@ -1142,7 +1142,7 @@ static int belpic_read_binary(struct sc_card *card,
#ifdef BELPIC_PIN_PAD #ifdef BELPIC_PIN_PAD
/* Test the result code of the pin pad reader + the card's status bytes */ /* 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 #if 0
printf("PP res: 0x%0x (%d), SW1-SW2 = %02x %02x\n", r, r, card_status[0], card_status[1]); 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 */ /* 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, struct belpic_priv_data *priv, int pin_ref,
int pin_usage, int *tries_left) 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 */ /* 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) struct belpic_priv_data *priv, int pin_ref, int *tries_left)
{ {
BYTE card_status[2]; 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 */ #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) int *tries_left, int pin_usage)
{ {
#ifdef BELPIC_PIN_PAD #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); 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) if (SSO_OK(card->ctx) && data->cmd == SC_PIN_CMD_VERIFY)
return 0; /* Don't log in right now, just say it's OK */ 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 * or by belpic-compute_signature the first fime an auth signature is done
* and the allow_sso is true * 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_pin_cmd_data data;
struct sc_apdu apdu; sc_apdu_t apdu;
u8 pin_data[BELPIC_MAX_USER_PIN_LEN + 1]; u8 pin_data[BELPIC_MAX_USER_PIN_LEN + 1];
int pin_len; int pin_len;
int tries_left; int tries_left;
@ -1442,10 +1442,10 @@ static int belpic_askpin_verify(struct sc_card *card, int pin_usage)
} }
#endif /* HAVE_GUI */ #endif /* HAVE_GUI */
static int belpic_set_security_env(struct sc_card *card, static int belpic_set_security_env(sc_card_t *card,
const struct sc_security_env *env, int se_num) 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 sbuf[SC_MAX_APDU_BUFFER_SIZE];
int r; int r;
@ -1515,7 +1515,7 @@ static int belpic_set_security_env(struct sc_card *card,
return r; 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) size_t data_len, u8 * out, size_t outlen)
{ {
int r; int r;
@ -1533,10 +1533,10 @@ static int belpic_compute_signature(struct sc_card *card, const u8 * data,
return r; return r;
} }
static int belpic_logout(struct sc_card *card) static int belpic_logout(sc_card_t *card)
{ {
#if 0 #if 0
struct sc_apdu apdu; sc_apdu_t apdu;
int r; int r;
sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0xE6, 0x00, 0x00); sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0xE6, 0x00, 0x00);

View File

@ -28,22 +28,22 @@ static struct sc_card_driver default_drv = {
&default_ops &default_ops
}; };
static int default_finish(struct sc_card *card) static int default_finish(sc_card_t *card)
{ {
return 0; return 0;
} }
static int default_match_card(struct sc_card *card) static int default_match_card(sc_card_t *card)
{ {
return 1; /* always match */ 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 classes[] = { 0x00, 0xC0, 0xB0, 0xA0 };
int class_count = sizeof(classes)/sizeof(int); int class_count = sizeof(classes)/sizeof(int);
u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
struct sc_apdu apdu; sc_apdu_t apdu;
int i, r; int i, r;
if (card->ctx->debug >= 2) if (card->ctx->debug >= 2)
@ -101,7 +101,7 @@ static int autodetect_class(struct sc_card *card)
return 0; return 0;
} }
static int default_init(struct sc_card *card) static int default_init(sc_card_t *card)
{ {
int r; int r;

View File

@ -28,7 +28,7 @@ static struct sc_card_driver emv_drv = {
&emv_ops &emv_ops
}; };
static int emv_finish(struct sc_card *card) static int emv_finish(sc_card_t *card)
{ {
return 0; 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; 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 i, r, hbcount = 0, match = 1;
int tx1[4], tx2[4], t0; int tx1[4], tx2[4], t0;
@ -114,7 +114,7 @@ static int emv_match_card(struct sc_card *card)
return match; return match;
} }
static int emv_init(struct sc_card *card) static int emv_init(sc_card_t *card)
{ {
card->drv_data = NULL; card->drv_data = NULL;
card->cla = 0x00; card->cla = 0x00;
@ -122,8 +122,8 @@ static int emv_init(struct sc_card *card)
return 0; return 0;
} }
static int emv_select_file(struct sc_card *card, const struct sc_path *path, static int emv_select_file(sc_card_t *card, const sc_path_t *path,
struct sc_file **file) sc_file_t **file)
{ {
int r; int r;
struct sc_card_driver *iso_drv = sc_get_iso7816_driver(); struct sc_card_driver *iso_drv = sc_get_iso7816_driver();

View File

@ -54,12 +54,12 @@ static struct sc_atr_table etoken_atrs[] = {
{ NULL } { NULL }
}; };
static int etoken_finish(struct sc_card *card) static int etoken_finish(sc_card_t *card)
{ {
return 0; return 0;
} }
static int etoken_match_card(struct sc_card *card) static int etoken_match_card(sc_card_t *card)
{ {
int i; int i;
@ -69,7 +69,7 @@ static int etoken_match_card(struct sc_card *card)
return 1; return 1;
} }
static int etoken_init(struct sc_card *card) static int etoken_init(sc_card_t *card)
{ {
unsigned long flags; unsigned long flags;
@ -150,7 +150,7 @@ const static struct sc_card_error etoken_errors[] = {
{ 0x9850, SC_NO_ERROR, "over/underflow useing in/decrease"} { 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]); const int err_count = sizeof(etoken_errors)/sizeof(etoken_errors[0]);
int i; int i;
@ -238,9 +238,9 @@ static u8* etoken_extract_fid(u8 *buf, int buflen) {
return NULL; 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]; u8 rbuf[256];
int r; int r;
int len; int len;
@ -307,7 +307,7 @@ get_next_part:
SC_FUNC_RETURN(card->ctx, 1, r); 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; 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); 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) { if (e != NULL) {
switch (e->method) { switch (e->method) {
@ -380,7 +380,7 @@ static const int ef_acl[9] = {
-1 /* DEC */ -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; size_t i;
const int *idx; 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)); add_acl_entry(file, idx[i], (u8)((i < len) ? buf[i] : 0xFF));
} }
static int etoken_select_file(struct sc_card *card, static int etoken_select_file(sc_card_t *card,
const struct sc_path *in_path, const sc_path_t *in_path,
struct sc_file **file) sc_file_t **file)
{ {
int r; int r;
@ -406,7 +406,7 @@ static int etoken_select_file(struct sc_card *card,
SC_FUNC_RETURN(card->ctx, 1, r); 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; int r, i, byte;
const int *idx; const int *idx;
@ -504,9 +504,9 @@ out: SC_FUNC_RETURN(card->ctx, 1, r);
* Restore the indicated SE * Restore the indicated SE
*/ */
static int 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; int r;
SC_FUNC_CALLED(card->ctx, 1); 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. * XXX Need to find out how the Aladdin drivers do it.
*/ */
static int static int
etoken_set_security_env(struct sc_card *card, etoken_set_security_env(sc_card_t *card,
const struct sc_security_env *env, const sc_security_env_t *env,
int se_num) int se_num)
{ {
struct sc_apdu apdu; sc_apdu_t apdu;
u8 data[3]; u8 data[3];
int key_id, r; int key_id, r;
@ -583,11 +583,11 @@ etoken_set_security_env(struct sc_card *card,
/* internal function to do the actual signature computation */ /* internal function to do the actual signature computation */
static int 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) u8 *out, size_t outlen)
{ {
int r; int r;
struct sc_apdu apdu; sc_apdu_t apdu;
u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
u8 sbuf[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 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) u8 *out, size_t outlen)
{ {
int r; int r;
u8 buf[SC_MAX_APDU_BUFFER_SIZE]; u8 buf[SC_MAX_APDU_BUFFER_SIZE];
size_t buf_len = sizeof(buf), tmp_len = buf_len; 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); assert(card != NULL && data != NULL && out != NULL);
ctx = card->ctx; ctx = card->ctx;
@ -674,9 +674,9 @@ etoken_compute_signature(struct sc_card *card, const u8 *data, size_t datalen,
} }
static int 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]; u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
int r; int r;
@ -718,9 +718,9 @@ etoken_lifecycle_get(struct sc_card *card, int *mode)
} }
static int 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 r;
int current; int current;
@ -754,10 +754,10 @@ etoken_lifecycle_set(struct sc_card *card, int *mode)
} }
static int 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_cardctl_etoken_obj_info *args)
{ {
struct sc_apdu apdu; sc_apdu_t apdu;
int r; int r;
SC_FUNC_CALLED(card->ctx, 1); SC_FUNC_CALLED(card->ctx, 1);
@ -782,10 +782,10 @@ etoken_put_data_oci(struct sc_card *card,
} }
static int 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_cardctl_etoken_obj_info *args)
{ {
struct sc_apdu apdu; sc_apdu_t apdu;
int r; int r;
memset(&apdu, 0, sizeof(apdu)); memset(&apdu, 0, sizeof(apdu));
@ -808,10 +808,10 @@ etoken_put_data_seci(struct sc_card *card,
} }
static int 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_cardctl_etoken_genkey_info *args)
{ {
struct sc_apdu apdu; sc_apdu_t apdu;
u8 data[8]; u8 data[8];
int r; 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) static int etoken_get_serialnr(sc_card_t *card, sc_serial_number_t *serial)
{ {
int r; int r;
struct sc_apdu apdu; sc_apdu_t apdu;
u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xca, 0x01, 0x81); 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 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) { switch (cmd) {
case SC_CARDCTL_ETOKEN_PUT_DATA_FCI: 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 :-/ * Unfortunately, it doesn't seem to work without this flag :-/
*/ */
static int 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) int *tries_left)
{ {
data->flags |= SC_PIN_CMD_NEED_PADDING; data->flags |= SC_PIN_CMD_NEED_PADDING;

View File

@ -97,13 +97,13 @@ static struct sc_card_driver cyberflex_drv = {
&cyberflex_ops &cyberflex_ops
}; };
static int flex_finish(struct sc_card *card) static int flex_finish(sc_card_t *card)
{ {
free(card->drv_data); free(card->drv_data);
return 0; return 0;
} }
static int cryptoflex_match_card(struct sc_card *card) static int cryptoflex_match_card(sc_card_t *card)
{ {
int i; int i;
@ -121,7 +121,7 @@ static int cryptoflex_match_card(struct sc_card *card)
return 0; return 0;
} }
static int cyberflex_match_card(struct sc_card *card) static int cyberflex_match_card(sc_card_t *card)
{ {
int i; int i;
@ -138,7 +138,7 @@ static int cyberflex_match_card(struct sc_card *card)
return 0; return 0;
} }
static int flex_init(struct sc_card *card) static int flex_init(sc_card_t *card)
{ {
struct flex_private_data *data; 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 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 #if 0
struct sc_apdu apdu; sc_apdu_t apdu;
u8 rbuf[3]; u8 rbuf[3];
int r; int r;
@ -430,7 +430,7 @@ cyberflex_process_file_attrs(sc_card_t *card, sc_file_t *file,
return 0; 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) int need_info)
{ {
const u8 *curptr = card->cache.current_path.value; 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; 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) int result)
{ {
struct sc_path *curpath = &card->cache.current_path; sc_path_t *curpath = &card->cache.current_path;
if (result < 0) { if (result < 0) {
curpath->len = 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, static int select_file_id(sc_card_t *card, const u8 *buf, size_t buflen,
u8 p1, struct sc_file **file_out) u8 p1, sc_file_t **file_out)
{ {
int r; int r;
struct sc_apdu apdu; sc_apdu_t apdu;
u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
struct sc_file *file; sc_file_t *file;
if (card->ctx->debug >= 4) { if (card->ctx->debug >= 4) {
char string[32]; char string[32];
@ -561,8 +561,8 @@ static int select_file_id(struct sc_card *card, const u8 *buf, size_t buflen,
return 0; return 0;
} }
static int flex_select_file(struct sc_card *card, const struct sc_path *path, static int flex_select_file(sc_card_t *card, const sc_path_t *path,
struct sc_file **file_out) sc_file_t **file_out)
{ {
int r; int r;
const u8 *pathptr = path->value; 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); 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]; u8 rbuf[4];
int r; int r;
size_t count = 0; 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... * 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]; u8 rbuf[6];
int r; int r;
size_t count = 0, p2 = 0; 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; 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; int r;
SC_FUNC_CALLED(card->ctx, 1); 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); 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) if (e == NULL)
return -1; return -1;
@ -734,7 +734,7 @@ static int acl_to_ac_nibble(const struct sc_acl_entry *e)
return -1; 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) while (e != NULL && e->method != SC_AC_AUT)
e = e->next; 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[8] = p[9] = p[10] = 0;
p[13] = p[14] = p[15] = 0; /* Key numbers */ p[13] = p[14] = p[15] = 0; /* Key numbers */
for (i = 0; i < 6; i++) { for (i = 0; i < 6; i++) {
const struct sc_acl_entry *entry; const sc_acl_entry_t *entry;
if (ops[i] == -1) if (ops[i] == -1)
continue; continue;
entry = sc_file_get_acl_entry(file, ops[i]); 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; 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]; u8 sbuf[18];
size_t sendlen; size_t sendlen;
int r, rec_nr; int r, rec_nr;
struct sc_apdu apdu; sc_apdu_t apdu;
/* Build the file attrs. These are not the real FCI bytes /* Build the file attrs. These are not the real FCI bytes
* in the standard sense, but its a convenient way of * 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; return 0;
} }
static int flex_set_security_env(struct sc_card *card, static int flex_set_security_env(sc_card_t *card,
const struct sc_security_env *env, const sc_security_env_t *env,
int se_num) int se_num)
{ {
struct flex_private_data *prv = (struct flex_private_data *) card->drv_data; 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; 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; 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) size_t data_len, u8 * out, size_t outlen)
{ {
struct flex_private_data *prv = (struct flex_private_data *) card->drv_data; 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]; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
int r; int r;
size_t i; 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) size_t data_len, u8 * out, size_t outlen)
{ {
struct flex_private_data *prv = DRV_DATA(card); struct flex_private_data *prv = DRV_DATA(card);
struct sc_apdu apdu; sc_apdu_t apdu;
u8 alg_id, key_id; u8 alg_id, key_id;
int r; int r;
@ -1076,7 +1076,7 @@ cyberflex_compute_signature(sc_card_t *card, const u8 *data,
return apdu.resplen; 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, const u8 * crgram, size_t crgram_len,
u8 * out, size_t outlen) 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 */ /* 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 sc_cardctl_default_key *data)
{ {
struct flex_private_data *prv = DRV_DATA(card); 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 */ /* Generate key on-card */
static int flex_generate_key(sc_card_t *card, struct sc_cardctl_cryptoflex_genkey_info *data) 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]; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
int r, p1, p2; 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; 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) { switch (cmd) {
case SC_CARDCTL_GET_DEFAULT_KEY: 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; 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) struct sc_pin_cmd_data *data)
{ {
static u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; 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; 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) int *tries_left)
{ {
sc_apdu_t apdu; 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; 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; int r;
sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0x22, 0x07, 0x00); sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0x22, 0x07, 0x00);

View File

@ -84,7 +84,7 @@ struct gpk_private_data {
}; };
#define DRVDATA(card) ((struct gpk_private_data *) ((card)->drv_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 * 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 * return 1 if this driver can handle the card
*/ */
static int static int
gpk_match_card(struct sc_card *card) gpk_match_card(sc_card_t *card)
{ {
int i; int i;
@ -151,7 +151,7 @@ gpk_match_card(struct sc_card *card)
* Initialize the card struct * Initialize the card struct
*/ */
static int static int
gpk_init(struct sc_card *card) gpk_init(sc_card_t *card)
{ {
struct gpk_private_data *priv; struct gpk_private_data *priv;
unsigned long exponent, flags, kg; unsigned long exponent, flags, kg;
@ -216,7 +216,7 @@ gpk_init(struct sc_card *card)
* Card is being closed; discard any private data etc * Card is being closed; discard any private data etc
*/ */
static int static int
gpk_finish(struct sc_card *card) gpk_finish(sc_card_t *card)
{ {
if (card->drv_data) if (card->drv_data)
free(card->drv_data); free(card->drv_data);
@ -231,7 +231,7 @@ gpk_finish(struct sc_card *card)
*/ */
#if 0 #if 0
static int 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; 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 * Select a DF/EF
*/ */
static int 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) int need_info)
{ {
unsigned short int *curptr, *ptr; unsigned short int *curptr, *ptr;
@ -326,7 +326,7 @@ okay:
} }
static void 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; 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. * some fuzz involved.
*/ */
static void 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; unsigned int npins = 0;
ac[0] = ac[1] = 0; ac[0] = ac[1] = 0;
@ -391,9 +391,9 @@ acl_to_ac(struct sc_file *file, unsigned int op, u8 *ac)
} }
static int static int
gpk_parse_fci(struct sc_card *card, gpk_parse_fci(sc_card_t *card,
const u8 *buf, size_t buflen, const u8 *buf, size_t buflen,
struct sc_file *file) sc_file_t *file)
{ {
const u8 *end, *next; const u8 *end, *next;
unsigned int tag, len; unsigned int tag, len;
@ -427,9 +427,9 @@ gpk_parse_fci(struct sc_card *card,
} }
static int static int
gpk_parse_fileinfo(struct sc_card *card, gpk_parse_fileinfo(sc_card_t *card,
const u8 *buf, size_t buflen, const u8 *buf, size_t buflen,
struct sc_file *file) sc_file_t *file)
{ {
const u8 *sp, *end, *next; const u8 *sp, *end, *next;
int i, rc; int i, rc;
@ -511,12 +511,12 @@ gpk_parse_fileinfo(struct sc_card *card,
} }
static int static int
gpk_select(struct sc_card *card, u8 kind, gpk_select(sc_card_t *card, u8 kind,
const u8 *buf, size_t buflen, const u8 *buf, size_t buflen,
struct sc_file **file) sc_file_t **file)
{ {
struct gpk_private_data *priv = DRVDATA(card); struct gpk_private_data *priv = DRVDATA(card);
struct sc_apdu apdu; sc_apdu_t apdu;
u8 resbuf[256]; u8 resbuf[256];
int r; int r;
@ -568,10 +568,10 @@ gpk_select(struct sc_card *card, u8 kind,
} }
static int static int
gpk_select_id(struct sc_card *card, u8 kind, unsigned short int fid, gpk_select_id(sc_card_t *card, u8 kind, unsigned short int fid,
struct sc_file **file) sc_file_t **file)
{ {
struct sc_path *cp = &card->cache.current_path; sc_path_t *cp = &card->cache.current_path;
u8 fbuf[2]; u8 fbuf[2];
int r; int r;
@ -606,8 +606,8 @@ gpk_select_id(struct sc_card *card, u8 kind, unsigned short int fid,
} }
static int static int
gpk_select_file(struct sc_card *card, const struct sc_path *path, gpk_select_file(sc_card_t *card, const sc_path_t *path,
struct sc_file **file) sc_file_t **file)
{ {
unsigned short int pathtmp[SC_MAX_PATH_SIZE/2]; unsigned short int pathtmp[SC_MAX_PATH_SIZE/2];
unsigned short int *pathptr; unsigned short int *pathptr;
@ -722,7 +722,7 @@ done:
* Required because by default the GPKs do word offsets * Required because by default the GPKs do word offsets
*/ */
static int 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) u8 *buf, size_t count, unsigned long flags)
{ {
struct gpk_private_data *priv = DRVDATA(card); struct gpk_private_data *priv = DRVDATA(card);
@ -737,7 +737,7 @@ gpk_read_binary(struct sc_card *card, unsigned int offset,
} }
static int 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) const u8 *buf, size_t count, unsigned long flags)
{ {
struct gpk_private_data *priv = DRVDATA(card); struct gpk_private_data *priv = DRVDATA(card);
@ -752,7 +752,7 @@ gpk_write_binary(struct sc_card *card, unsigned int offset,
} }
static int 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) const u8 *buf, size_t count, unsigned long flags)
{ {
struct gpk_private_data *priv = DRVDATA(card); struct gpk_private_data *priv = DRVDATA(card);
@ -770,7 +770,7 @@ gpk_update_binary(struct sc_card *card, unsigned int offset,
* Secure messaging * Secure messaging
*/ */
static int 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) u8 *crycks1)
{ {
struct gpk_private_data *priv = DRVDATA(card); 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 * Verify secure messaging response
*/ */
static int 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 if (apdu->resplen < 3
|| memcmp(apdu->resp + apdu->resplen - 3, crycks, 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). * (the GPK4000 has lots of bizarre file types).
*/ */
static int 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 gpk_private_data *priv = DRVDATA(card);
struct sc_apdu apdu; sc_apdu_t apdu;
u8 data[28+3], crycks[3], resp[3]; u8 data[28+3], crycks[3], resp[3];
size_t datalen, namelen; size_t datalen, namelen;
int r; 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 * Verify a key presented by the user for secure messaging
*/ */
static int 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 gpk_private_data *priv = DRVDATA(card);
struct sc_apdu apdu; sc_apdu_t apdu;
u8 rnd[8], resp[258]; u8 rnd[8], resp[258];
int r; 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? * and other flags?
*/ */
static int static int
gpk_set_security_env(struct sc_card *card, gpk_set_security_env(sc_card_t *card,
const struct sc_security_env *env, const sc_security_env_t *env,
int se_num) int se_num)
{ {
struct gpk_private_data *priv = DRVDATA(card); struct gpk_private_data *priv = DRVDATA(card);
struct sc_apdu apdu; sc_apdu_t apdu;
unsigned int context, algorithm; unsigned int context, algorithm;
unsigned int file_id; unsigned int file_id;
u8 sysrec[7]; u8 sysrec[7];
@ -1157,7 +1157,7 @@ gpk_set_security_env(struct sc_card *card,
* Not sure what this is supposed to do. * Not sure what this is supposed to do.
*/ */
static int 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; return 0;
} }
@ -1182,9 +1182,9 @@ reverse(u8 *out, size_t outlen, const u8 *in, size_t inlen)
*/ */
#ifdef dontuse #ifdef dontuse
static int 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; unsigned int count, chain, len;
int r; 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. * Send the hashed data to the card.
*/ */
static int 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]; u8 tsegid[64];
int r; 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. * Note we hash everything manually and send it to the card.
*/ */
static int 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) size_t data_len, u8 * out, size_t outlen)
{ {
struct gpk_private_data *priv = DRVDATA(card); struct gpk_private_data *priv = DRVDATA(card);
struct sc_apdu apdu; sc_apdu_t apdu;
u8 cardsig[1024/8]; u8 cardsig[1024/8];
int r; 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. * SSL session key you will be able to decrypt using this card.
*/ */
static int 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) u8 *out, size_t outlen)
{ {
struct gpk_private_data *priv = DRVDATA(card); struct gpk_private_data *priv = DRVDATA(card);
struct sc_apdu apdu; sc_apdu_t apdu;
u8 buffer[256]; u8 buffer[256];
int r; int r;
@ -1364,10 +1364,10 @@ gpk_decipher(struct sc_card *card, const u8 *in, size_t inlen,
* Erase card * Erase card
*/ */
static int static int
gpk_erase_card(struct sc_card *card) gpk_erase_card(sc_card_t *card)
{ {
struct gpk_private_data *priv = DRVDATA(card); struct gpk_private_data *priv = DRVDATA(card);
struct sc_apdu apdu; sc_apdu_t apdu;
u8 offset; u8 offset;
int r; int r;
@ -1417,11 +1417,11 @@ gpk_erase_card(struct sc_card *card)
* AC2 for normal files). * AC2 for normal files).
*/ */
static int 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 gpk_private_data *priv = DRVDATA(card);
struct sc_file *file = args->file; sc_file_t *file = args->file;
struct sc_apdu apdu; sc_apdu_t apdu;
u8 data[8], crycks[3], resp[3]; u8 data[8], crycks[3], resp[3];
int r; 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 * Initialize the private portion of a public key file
*/ */
static int 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; int r;
if (card->ctx->debug) 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 * Initialize the private portion of a public key file
*/ */
static int 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; int r;
u8 buffer[256]; 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 * Store a privat key component
*/ */
static int 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); struct gpk_private_data *priv = DRVDATA(card);
des_key_schedule k1, k2; des_key_schedule k1, k2;
struct sc_apdu apdu; sc_apdu_t apdu;
unsigned int n; unsigned int n;
u8 temp[256]; u8 temp[256];
int r; 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 * This function lets pkcs15init query for the transport key
*/ */
static int 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->method == SC_AC_PRO && data->key_ref == 1) {
if (data->len < 16) if (data->len < 16)
@ -1632,10 +1632,10 @@ gpk_get_default_key(struct sc_card *card, struct sc_cardctl_default_key *data)
*/ */
#if 0 #if 0
static int 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 gpk_private_data *priv = DRVDATA(card);
struct sc_path path; sc_path_t path;
u8 value; u8 value;
int r; int r;
@ -1657,9 +1657,9 @@ gpk_max_session_key(struct sc_card *card)
* GetInfo call * GetInfo call
*/ */
int 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; int r, retry = 0;
/* We may have to retry the get info command. It /* 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; int r;
u8 rbuf[10]; u8 rbuf[10];
struct sc_apdu apdu; sc_apdu_t apdu;
if (card->type != SC_CARD_TYPE_GPK_GPK16000) if (card->type != SC_CARD_TYPE_GPK_GPK16000)
return SC_ERROR_NOT_SUPPORTED; 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 * Dispatch card_ctl calls
*/ */
static int 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) { switch (cmd) {
case SC_CARDCTL_ERASE_CARD: 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 static int
gpk_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *data, int *tries_left) 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; int r;
/* Special case - External Authenticate */ /* Special case - External Authenticate */

View File

@ -50,9 +50,9 @@ static struct sc_card_driver jcop_drv = {
struct jcop_private_data struct jcop_private_data
{ {
struct sc_file *virtmf; sc_file_t *virtmf;
struct sc_file *virtdir; sc_file_t *virtdir;
struct sc_path aid; sc_path_t aid;
int selected; int selected;
int invalid_senv; int invalid_senv;
int nfiles; int nfiles;
@ -60,7 +60,7 @@ struct jcop_private_data
}; };
#define DRVDATA(card) ((struct jcop_private_data *) ((card)->drv_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); struct jcop_private_data *drvdata=DRVDATA(card);
if (drvdata) { if (drvdata) {
@ -73,7 +73,7 @@ static int jcop_finish(struct sc_card *card)
return 0; return 0;
} }
static int jcop_match_card(struct sc_card *card) static int jcop_match_card(sc_card_t *card)
{ {
int i; 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 jcop_private_data *drvdata;
struct sc_file *f; sc_file_t *f;
int flags; int flags;
drvdata=(struct jcop_private_data *) malloc(sizeof(struct jcop_private_data)); 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; 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) struct sc_cardctl_default_key *data)
{ {
const char *key; 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 that, I fake an MF containing the AppDF and a fixed DIR pointing at
the fake AppDF. This has the added advantage of allowing the fake AppDF. This has the added advantage of allowing
opensc-explorer to be used with this driver */ opensc-explorer to be used with this driver */
static int jcop_select_file(struct sc_card *card, const struct sc_path *path, static int jcop_select_file(sc_card_t *card, const sc_path_t *path,
struct sc_file **file) sc_file_t **file)
{ {
struct jcop_private_data *drvdata=DRVDATA(card); struct jcop_private_data *drvdata=DRVDATA(card);
int r,selecting; int r,selecting;
struct sc_card_driver *iso_drv = sc_get_iso7816_driver(); struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
const struct sc_card_operations *iso_ops = iso_drv->ops; const struct sc_card_operations *iso_ops = iso_drv->ops;
sc_path_t shortpath; sc_path_t shortpath;
struct sc_file *tfile, **fileptr; sc_file_t *tfile, **fileptr;
if (!drvdata) if (!drvdata)
return SC_ERROR_FILE_NOT_FOUND; 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; 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) { u8 * buf, size_t count, unsigned long flags) {
struct jcop_private_data *drvdata=DRVDATA(card); struct jcop_private_data *drvdata=DRVDATA(card);
struct sc_card_driver *iso_drv = sc_get_iso7816_driver(); struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
const struct sc_card_operations *iso_ops = iso_drv->ops; const struct sc_card_operations *iso_ops = iso_drv->ops;
struct sc_file *tfile; sc_file_t *tfile;
int r; int r;
if (drvdata->selected == SELECT_MF) { 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); 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 jcop_private_data *drvdata=DRVDATA(card);
struct sc_card_driver *iso_drv = sc_get_iso7816_driver(); struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
const struct sc_card_operations *iso_ops = iso_drv->ops; const struct sc_card_operations *iso_ops = iso_drv->ops;
struct sc_file *tfile; sc_file_t *tfile;
int r; int r;
if (drvdata->selected == SELECT_MF) { 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; 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) { int nibble) {
switch (nibble & 0x7) { switch (nibble & 0x7) {
case 0: 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) { const u8 *buf, size_t buflen) {
struct jcop_private_data *drvdata=DRVDATA(card); struct jcop_private_data *drvdata=DRVDATA(card);
struct sc_card_driver *iso_drv = sc_get_iso7816_driver(); 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; 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) if (e == NULL)
return -1; 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); struct jcop_private_data *drvdata=DRVDATA(card);
unsigned char sec_attr_data[3]; unsigned char sec_attr_data[3];
int ops[6]; 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 */ ops[5] = SC_AC_OP_ERASE; /* delete */
memset(sec_attr_data, 0, 3); memset(sec_attr_data, 0, 3);
for (i = 0; i < 6; i++) { for (i = 0; i < 6; i++) {
const struct sc_acl_entry *entry; const sc_acl_entry_t *entry;
if (ops[i] == -1) { if (ops[i] == -1) {
sec_attr_data[i/2] |= 1 << ((i % 2) ? 0 : 4); sec_attr_data[i/2] |= 1 << ((i % 2) ? 0 : 4);
continue; continue;
@ -553,19 +553,19 @@ static int jcop_create_file(struct sc_card *card, struct sc_file *file) {
} }
/* no record oriented file services */ /* 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, unsigned int rec_nr, u8 *buf,
size_t count, unsigned long flags) { size_t count, unsigned long flags) {
return SC_ERROR_NOT_SUPPORTED; 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, unsigned int rec_nr, const u8 *buf,
size_t count, unsigned long flags) { size_t count, unsigned long flags) {
return SC_ERROR_NOT_SUPPORTED; 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, const u8 *buf, size_t count,
unsigned long flags) { unsigned long flags) {
return SC_ERROR_NOT_SUPPORTED; 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 /* We need to trap these functions so that proper errors can be returned
when one of the virtual files is selected */ 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, unsigned int idx, const u8 *buf,
size_t count, unsigned long flags) { size_t count, unsigned long flags) {
struct jcop_private_data *drvdata=DRVDATA(card); 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, unsigned int idx, const u8 *buf,
size_t count, unsigned long flags) { 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); 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 jcop_private_data *drvdata=DRVDATA(card);
struct sc_card_driver *iso_drv = sc_get_iso7816_driver(); struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
const struct sc_card_operations *iso_ops = iso_drv->ops; 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 /* BlueZ doesn't support stored security environments. you have
to construct one with SET every time */ to construct one with SET every time */
static int jcop_set_security_env(struct sc_card *card, static int jcop_set_security_env(sc_card_t *card,
const struct sc_security_env *env, const sc_security_env_t *env,
int se_num) int se_num)
{ {
struct sc_apdu apdu; sc_apdu_t apdu;
u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
u8 *p; u8 *p;
int r; int r;
@ -639,7 +639,7 @@ static int jcop_set_security_env(struct sc_card *card,
} }
if (env->flags & SC_SEC_ENV_ALG_PRESENT) { if (env->flags & SC_SEC_ENV_ALG_PRESENT) {
struct sc_security_env tmp; sc_security_env_t tmp;
tmp = *env; tmp = *env;
tmp.flags &= ~SC_SEC_ENV_ALG_PRESENT; 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; drvdata->invalid_senv=0;
return 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, const u8 * data, size_t datalen,
u8 * out, size_t outlen) { u8 * out, size_t outlen) {
int r; int r;
struct sc_apdu apdu; sc_apdu_t apdu;
u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
struct jcop_private_data *drvdata=DRVDATA(card); 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, const u8 * crgram, size_t crgram_len,
u8 * out, size_t outlen) { u8 * out, size_t outlen) {
int r; int r;
struct sc_apdu apdu; sc_apdu_t apdu;
u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
struct jcop_private_data *drvdata=DRVDATA(card); 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)); 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 modlen;
int r; int r;
struct sc_apdu apdu; sc_apdu_t apdu;
u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
u8 *p; u8 *p;
@ -899,7 +899,7 @@ static int jcop_generate_key(struct sc_card *card, struct sc_cardctl_jcop_genkey
return 0; 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) { switch (cmd) {
case SC_CARDCTL_GET_DEFAULT_KEY: 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 * you need to reset the card." - javacard@zurich.ibm.com, when asked about
* how to invalidate logged in pins. * 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 */ return 0; /* Can't */
} }

View File

@ -91,15 +91,15 @@ struct mcrd_priv_data {
#define DRVDATA(card) ((struct mcrd_priv_data *) ((card)->drv_data)) #define DRVDATA(card) ((struct mcrd_priv_data *) ((card)->drv_data))
static int load_special_files(struct sc_card *card); static int load_special_files(sc_card_t *card);
static int select_part (struct sc_card *card, u8 kind, unsigned short int fid, static int select_part (sc_card_t *card, u8 kind, unsigned short int fid,
struct sc_file **file); sc_file_t **file);
/* Return the DF_info for the current path. If does not yet exist, /* Return the DF_info for the current path. If does not yet exist,
create it. Returns NULL on error. */ 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 mcrd_priv_data *priv = DRVDATA (card);
struct df_info_s *dfi; struct df_info_s *dfi;
@ -151,9 +151,9 @@ static void clear_special_files (struct df_info_s *dfi)
*/ */
static int 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; int r;
u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
@ -171,9 +171,9 @@ mcrd_delete_ref_to_authkey (struct sc_card *card)
} }
static int 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; int r;
u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
assert (card != NULL); assert (card != NULL);
@ -192,10 +192,10 @@ mcrd_delete_ref_to_signkey (struct sc_card *card)
} }
static int 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; sc_apdu_t apdu;
struct sc_path path; sc_path_t path;
int r; int r;
u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
u8 keyref_data[SC_ESTEID_KEYREF_FILE_RECLEN]; 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)); 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; int i;
@ -253,7 +253,7 @@ static int mcrd_match_card(struct sc_card *card)
return 1; return 1;
} }
static int mcrd_init(struct sc_card *card) static int mcrd_init(sc_card_t *card)
{ {
unsigned long flags; unsigned long flags;
struct mcrd_priv_data *priv; struct mcrd_priv_data *priv;
@ -280,7 +280,7 @@ static int mcrd_init(struct sc_card *card)
return 0; return 0;
} }
static int mcrd_finish(struct sc_card *card) static int mcrd_finish(sc_card_t *card)
{ {
struct mcrd_priv_data *priv; 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. /* Load the rule and keyd file into our private data.
Return 0 on success */ 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); struct mcrd_priv_data *priv = DRVDATA (card);
int r, recno; int r, recno;
struct df_info_s *dfi; 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"); SC_TEST_RET(ctx, r, "selecting EF_Rule failed");
for (recno=1;; recno++) { for (recno=1;; recno++) {
struct sc_apdu apdu; sc_apdu_t apdu;
u8 recvbuf[200]; u8 recvbuf[200];
sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 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"); SC_TEST_RET(ctx, r, "selecting EF_KeyD failed");
for (recno=1;; recno++) { for (recno=1;; recno++) {
struct sc_apdu apdu; sc_apdu_t apdu;
u8 recvbuf[200]; u8 recvbuf[200];
sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 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 /* 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 NULL the reference data is returned; this shoudl be an array of at
least 2 bytes. Returns -1 on error. */ 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) u8 *ref_data)
{ {
struct sc_context *ctx = card->ctx; sc_context_t *ctx = card->ctx;
struct df_info_s *dfi; struct df_info_s *dfi;
struct keyd_record_s *keyd; struct keyd_record_s *keyd;
size_t len, taglen; 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. */ /* 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) const u8 *buf, size_t buflen)
{ {
struct sc_context *ctx = card->ctx; sc_context_t *ctx = card->ctx;
struct df_info_s *dfi; struct df_info_s *dfi;
struct rule_record_s *rule; struct rule_record_s *rule;
size_t left, taglen; 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) const u8 *buf, size_t buflen)
{ {
struct sc_context *ctx = card->ctx; sc_context_t *ctx = card->ctx;
size_t taglen, len = buflen; size_t taglen, len = buflen;
const u8 *tag = NULL, *p = buf; const u8 *tag = NULL, *p = buf;
int bad_fde = 0; 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. */ /* Send a select command and parse the response. */
static int static int
do_select(struct sc_card *card, u8 kind, do_select(sc_card_t *card, u8 kind,
const u8 *buf, size_t buflen, 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]; u8 resbuf[SC_MAX_APDU_BUFFER_SIZE];
int r; 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 /* Wrapper around do_select to be used when multiple selects are
required. */ required. */
static int static int
select_part (struct sc_card *card, u8 kind, unsigned short int fid, select_part (sc_card_t *card, u8 kind, unsigned short int fid,
struct sc_file **file) sc_file_t **file)
{ {
u8 fbuf[2]; u8 fbuf[2];
int r; 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 passed as true only DF are selected, otherwise the function tries
to figure out whether the last path item is a DF or EF. */ to figure out whether the last path item is a DF or EF. */
static int static int
select_down (struct sc_card *card, select_down (sc_card_t *card,
unsigned short *pathptr, size_t pathlen, unsigned short *pathptr, size_t pathlen,
int df_only, int df_only,
struct sc_file **file) sc_file_t **file)
{ {
struct mcrd_priv_data *priv = DRVDATA (card); struct mcrd_priv_data *priv = DRVDATA (card);
int r; int r;
@ -817,9 +817,9 @@ select_down (struct sc_card *card,
usual sc_path structure. */ usual sc_path structure. */
static int 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, size_t pathlen,
struct sc_file **file) sc_file_t **file)
{ {
struct mcrd_priv_data *priv = DRVDATA (card); struct mcrd_priv_data *priv = DRVDATA (card);
int r; int r;
@ -902,8 +902,8 @@ select_file_by_path (struct sc_card *card, unsigned short *pathptr,
} }
static int static int
select_file_by_fid (struct sc_card *card, unsigned short *pathptr, select_file_by_fid (sc_card_t *card, unsigned short *pathptr,
size_t pathlen, struct sc_file **file) size_t pathlen, sc_file_t **file)
{ {
struct mcrd_priv_data *priv = DRVDATA (card); struct mcrd_priv_data *priv = DRVDATA (card);
int r; int r;
@ -966,8 +966,8 @@ select_file_by_fid (struct sc_card *card, unsigned short *pathptr,
/* This drivers select command handler. */ /* This drivers select command handler. */
static int static int
mcrd_select_file(struct sc_card *card, const struct sc_path *path, mcrd_select_file(sc_card_t *card, const sc_path_t *path,
struct sc_file **file) sc_file_t **file)
{ {
struct mcrd_priv_data *priv = DRVDATA (card); struct mcrd_priv_data *priv = DRVDATA (card);
int r = 0; int r = 0;
@ -1038,9 +1038,9 @@ mcrd_select_file(struct sc_card *card, const struct sc_path *path,
/* Crypto operations */ /* 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; int r;
sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0x22, 0xF3, se_num); 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 It has been generalized [?] and modified by information coming from
openpgp card implementation, EstEID 'manual' and some other sources. -mp openpgp card implementation, EstEID 'manual' and some other sources. -mp
*/ */
static int mcrd_set_security_env(struct sc_card *card, static int mcrd_set_security_env(sc_card_t *card,
const struct sc_security_env *env, const sc_security_env_t *env,
int se_num) int se_num)
{ {
struct mcrd_priv_data *priv = DRVDATA(card); struct mcrd_priv_data *priv = DRVDATA(card);
struct sc_apdu apdu; sc_apdu_t apdu;
u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
u8 *p; u8 *p;
int r, locked = 0; int r, locked = 0;
@ -1177,14 +1177,14 @@ err:
} }
/* heavily modified by -mp */ /* 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, const u8 * data, size_t datalen,
u8 * out, size_t outlen) u8 * out, size_t outlen)
{ {
struct mcrd_priv_data *priv = DRVDATA(card); struct mcrd_priv_data *priv = DRVDATA(card);
sc_security_env_t *env = &priv->sec_env; sc_security_env_t *env = &priv->sec_env;
int r; int r;
struct sc_apdu apdu; sc_apdu_t apdu;
assert(card != NULL && data != NULL && out != NULL); assert(card != NULL && data != NULL && out != NULL);
SC_FUNC_CALLED(card->ctx, 2); SC_FUNC_CALLED(card->ctx, 2);
@ -1223,13 +1223,13 @@ static int mcrd_compute_signature(struct sc_card *card,
} }
/* added by -mp */ /* 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, const u8 * crgram, size_t crgram_len, u8 * out,
size_t out_len) size_t out_len)
{ {
int r; int r;
struct sc_apdu apdu; sc_apdu_t apdu;
struct mcrd_priv_data *priv = DRVDATA(card); struct mcrd_priv_data *priv = DRVDATA(card);
sc_security_env_t *env = &priv->sec_env; sc_security_env_t *env = &priv->sec_env;
u8 *temp; 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) */ /* 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) int *tries_left)
{ {
SC_FUNC_CALLED(card->ctx, 3); SC_FUNC_CALLED(card->ctx, 3);

View File

@ -39,12 +39,12 @@ static struct sc_card_driver miocos_drv = {
&miocos_ops &miocos_ops
}; };
static int miocos_finish(struct sc_card *card) static int miocos_finish(sc_card_t *card)
{ {
return 0; return 0;
} }
static int miocos_match_card(struct sc_card *card) static int miocos_match_card(sc_card_t *card)
{ {
int i; int i;
@ -54,7 +54,7 @@ static int miocos_match_card(struct sc_card *card)
return 1; return 1;
} }
static int miocos_init(struct sc_card *card) static int miocos_init(sc_card_t *card)
{ {
card->name = "MioCOS"; card->name = "MioCOS";
card->cla = 0x00; 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 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) { switch (e->method) {
case SC_AC_NONE: case SC_AC_NONE:
@ -99,7 +99,7 @@ static int acl_to_byte(const struct sc_acl_entry *e)
return 0x00; 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 *buf, size_t *buflen)
{ {
u8 *p = buf; u8 *p = buf;
@ -202,9 +202,9 @@ static int encode_file_structure(struct sc_card *card, const struct sc_file *fil
return 0; 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]; u8 sbuf[32];
size_t buflen; size_t buflen;
int r; int r;
@ -227,12 +227,12 @@ static int miocos_create_file(struct sc_card *card, struct sc_file *file)
return 0; return 0;
} }
static int miocos_set_security_env(struct sc_card *card, static int miocos_set_security_env(sc_card_t *card,
const struct sc_security_env *env, const sc_security_env_t *env,
int se_num) int se_num)
{ {
if (env->flags & SC_SEC_ENV_ALG_PRESENT) { if (env->flags & SC_SEC_ENV_ALG_PRESENT) {
struct sc_security_env tmp; sc_security_env_t tmp;
tmp = *env; tmp = *env;
tmp.flags &= ~SC_SEC_ENV_ALG_PRESENT; 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); 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; 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); 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 i;
const int df_ops[8] = { 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]; u8 rbuf[256];
const u8 *seq = rbuf; const u8 *seq = rbuf;
size_t left; 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) if (tag == NULL || taglen == 0)
continue; continue;
for (j = 0; j < SC_MAX_AC_OPS; j++) { 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) if (e == NULL)
continue; continue;
if (e->method != SC_AC_CHV) 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; return 0;
} }
static int miocos_select_file(struct sc_card *card, static int miocos_select_file(sc_card_t *card,
const struct sc_path *in_path, const sc_path_t *in_path,
struct sc_file **file) sc_file_t **file)
{ {
int r; int r;
@ -394,9 +394,9 @@ static int miocos_select_file(struct sc_card *card,
return 0; 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; int r;
sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xCA, 0x01, 0); 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; 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; int r;
struct sc_apdu apdu; sc_apdu_t apdu;
SC_FUNC_CALLED(card->ctx, 1); SC_FUNC_CALLED(card->ctx, 1);
if (path->type != SC_PATH_TYPE_FILE_ID && path->len != 2) { 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, static int miocos_create_ac(sc_card_t *card,
struct sc_cardctl_miocos_ac_info *ac) struct sc_cardctl_miocos_ac_info *ac)
{ {
struct sc_apdu apdu; sc_apdu_t apdu;
u8 sbuf[20]; u8 sbuf[20];
int miocos_type, r; int miocos_type, r;
size_t sendsize; 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); 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) void *arg)
{ {
switch (cmd) { switch (cmd) {

View File

@ -113,7 +113,7 @@ static NTLV_t oberthur_aids[] = {
static unsigned char rsa_der[PUBKEY_2048_ASN1_SIZE]; static unsigned char rsa_der[PUBKEY_2048_ASN1_SIZE];
static int rsa_der_len = 0; 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 auth_ops;
static struct sc_card_operations *iso_ops; static struct sc_card_operations *iso_ops;
static struct sc_card_driver auth_drv = { static struct sc_card_driver auth_drv = {
@ -122,19 +122,19 @@ static struct sc_card_driver auth_drv = {
&auth_ops &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); int type, int reference, int cmd, int *out_ref);
static int auth_read_component(sc_card_t *card, static int auth_read_component(sc_card_t *card,
enum SC_CARDCTL_OBERTHUR_KEY_TYPE type, int num, enum SC_CARDCTL_OBERTHUR_KEY_TYPE type, int num,
unsigned char *out, size_t outlen); 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); 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); struct sc_cardctl_oberthur_createpin_info *args);
static int static int
auth_finish(struct sc_card *card) auth_finish(sc_card_t *card)
{ {
free(card->drv_data); free(card->drv_data);
return 0; return 0;
@ -142,9 +142,9 @@ auth_finish(struct sc_card *card)
static int 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]; unsigned char apdu_resp[SC_MAX_APDU_BUFFER_SIZE];
struct auth_private_data *data = (struct auth_private_data *) card->drv_data; struct auth_private_data *data = (struct auth_private_data *) card->drv_data;
int rv, ii; int rv, ii;
@ -206,7 +206,7 @@ auth_select_aid(struct sc_card *card)
} }
static int static int
auth_match_card(struct sc_card *card) auth_match_card(sc_card_t *card)
{ {
int i; int i;
@ -217,7 +217,7 @@ auth_match_card(struct sc_card *card)
} }
static int static int
auth_init(struct sc_card *card) auth_init(sc_card_t *card)
{ {
unsigned long flags; unsigned long flags;
struct auth_private_data *data; struct auth_private_data *data;
@ -265,7 +265,7 @@ auth_init(struct sc_card *card)
static void 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) u8 acl_byte)
{ {
struct auth_private_data *data = (struct auth_private_data *) card->drv_data; 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 static int
decode_file_structure_V5 (struct sc_card *card, unsigned char *buf, int buflen, decode_file_structure_V5 (sc_card_t *card, unsigned char *buf, int buflen,
struct sc_file *file) sc_file_t *file)
{ {
u8 type, attr[SC_OBERTHUR_MAX_ATTR_SIZE]; u8 type, attr[SC_OBERTHUR_MAX_ATTR_SIZE];
int attr_len = sizeof(attr); int attr_len = sizeof(attr);
@ -483,7 +483,7 @@ decode_file_structure_V5 (struct sc_card *card, unsigned char *buf, int buflen,
static int 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) int need_info)
{ {
const u8 *curptr = card->cache.current_path.value; 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 #if 0
static void 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) { switch (path->type) {
case SC_PATH_TYPE_FILE_ID: case SC_PATH_TYPE_FILE_ID:
@ -553,13 +553,13 @@ auth_cache_path(struct sc_card *card, const struct sc_path *path)
#endif #endif
static int 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; int rv;
struct sc_apdu apdu; sc_apdu_t apdu;
u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
struct sc_file *file; sc_file_t *file;
struct sc_path *cache_path = &card->cache.current_path; sc_path_t *cache_path = &card->cache.current_path;
struct auth_private_data *prv = (struct auth_private_data *) card->drv_data; struct auth_private_data *prv = (struct auth_private_data *) card->drv_data;
last_selected_file.magic = 0; last_selected_file.magic = 0;
@ -598,7 +598,7 @@ select_parent(struct sc_card *card, struct sc_file **file_out)
return rv; return rv;
} }
memcpy(&last_selected_file, file, sizeof(struct sc_file)); memcpy(&last_selected_file, file, sizeof(sc_file_t));
if (file_out) if (file_out)
*file_out = file; *file_out = file;
@ -610,11 +610,11 @@ select_parent(struct sc_card *card, struct sc_file **file_out)
static int 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; int ii,rv;
struct sc_file *file = NULL; sc_file_t *file = NULL;
struct sc_path *cache_path = &card->cache.current_path; sc_path_t *cache_path = &card->cache.current_path;
last_selected_file.magic = 0; last_selected_file.magic = 0;
for(ii=0;;ii++) { 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); memcpy(cache_path->value, "\x3F\x00", 2);
cache_path->len = 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) if (file && file_out)
*file_out = file; *file_out = file;
else if (file) else if (file)
@ -644,13 +644,13 @@ select_mf(struct sc_card *card, struct sc_file **file_out)
static int static int
select_file_id(struct sc_card *card, const u8 *buf, size_t buflen, select_file_id(sc_card_t *card, const u8 *buf, size_t buflen,
u8 p1, struct sc_file **file_out) u8 p1, sc_file_t **file_out)
{ {
int rv; int rv;
struct sc_apdu apdu; sc_apdu_t apdu;
u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; 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; struct auth_private_data *prv = (struct auth_private_data *) card->drv_data;
last_selected_file.magic = 0; last_selected_file.magic = 0;
@ -697,10 +697,10 @@ select_file_id(struct sc_card *card, const u8 *buf, size_t buflen,
return rv; 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) { 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; size_t len = cache_path->len;
if (len < sizeof(cache_path->value)) { 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 static int
auth_select_file(struct sc_card *card, const struct sc_path *path, auth_select_file(sc_card_t *card, const sc_path_t *path,
struct sc_file **file_out) sc_file_t **file_out)
{ {
int rv; int rv;
const u8 *pathptr = path->value; const u8 *pathptr = path->value;
@ -789,9 +789,9 @@ auth_select_file(struct sc_card *card, const struct sc_path *path,
static int 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]; u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
int rv; int rv;
@ -815,11 +815,11 @@ auth_list_files(struct sc_card *card, u8 *buf, size_t buflen)
static int 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; int rv;
u8 sbuf[2]; 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_debug(card->ctx, "path; type=%d, path=%s\n", path->type, sc_print_path(path));
SC_FUNC_CALLED(card->ctx, 1); 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) { if (path->len > 2) {
struct sc_path parent = *path; sc_path_t parent = *path;
parent.len -= 2; parent.len -= 2;
parent.type = SC_PATH_TYPE_PATH; 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]; u8 lbuf[SC_MAX_APDU_BUFFER_SIZE];
int ii, len; int ii, len;
#if 0 #if 0
struct sc_file *file; sc_file_t *file;
if (!(file = sc_file_new())) if (!(file = sc_file_new()))
SC_FUNC_RETURN(card->ctx, 0, SC_ERROR_OUT_OF_MEMORY); 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 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; 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 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 *buf, size_t *buflen)
{ {
u8 *p = buf; 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++) { for (ii = 0; ii < sizeof(ops); ii++) {
const struct sc_acl_entry *entry; const sc_acl_entry_t *entry;
p[16+ii] = 0xFF; p[16+ii] = 0xFF;
if (ops[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 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]; u8 sbuf[0x18];
size_t sendlen = sizeof(sbuf); size_t sendlen = sizeof(sbuf);
int rv, rec_nr; int rv, rec_nr;
struct sc_apdu apdu; sc_apdu_t apdu;
struct sc_path path; sc_path_t path;
struct auth_private_data *prv = (struct auth_private_data *) card->drv_data; 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)); 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 static int
auth_set_security_env(struct sc_card *card, auth_set_security_env(sc_card_t *card,
const struct sc_security_env *env, int se_num) const sc_security_env_t *env, int se_num)
{ {
auth_senv_t *senv = &((struct auth_private_data *) card->drv_data)->senv; auth_senv_t *senv = &((struct auth_private_data *) card->drv_data)->senv;
long unsigned pads = env->algorithm_flags & SC_ALGORITHM_RSA_PADS; long unsigned pads = env->algorithm_flags & SC_ALGORITHM_RSA_PADS;
long unsigned supported_pads = long unsigned supported_pads =
SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_PAD_ISO9796; SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_PAD_ISO9796;
struct sc_file *key_file = NULL; sc_file_t *key_file = NULL;
struct sc_apdu apdu; sc_apdu_t apdu;
u8 rsa_sbuf[7] = {0x80, 0x01, 0xFF, 0x81, 0x02, 0xFF, 0xFF}; u8 rsa_sbuf[7] = {0x80, 0x01, 0xFF, 0x81, 0x02, 0xFF, 0xFF};
int des_buf_len; int des_buf_len;
u8 des_sbuf[17] = {0x80, 0x01, 0x01, 0x81, 0x02, 0xFF, 0xFF, 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 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; return 0;
} }
static int 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) const u8 *in, size_t ilen, u8 * out, size_t olen)
{ {
auth_senv_t *senv = &((struct auth_private_data *) card->drv_data)->senv; 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]; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
int rv; int rv;
@ -1390,12 +1390,12 @@ auth_compute_signature(struct sc_card *card,
} }
static int 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) u8 * out, size_t outlen)
{ {
auth_senv_t *senv = &((struct auth_private_data *) card->drv_data)->senv; 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 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]; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
int rv; int rv;
@ -1498,7 +1498,7 @@ done:
/* Return the default AAK for this type of card */ /* Return the default AAK for this type of card */
static int 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; return SC_ERROR_NO_DEFAULT_KEY;
} }
@ -1527,7 +1527,7 @@ auth_encode_exponent(unsigned long exponent, u8 *buff, size_t buff_len)
static int static int
auth_generate_key(sc_card_t *card, struct sc_cardctl_oberthur_genkey_info *data) 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]; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
int rv = 0; int rv = 0;
@ -1596,7 +1596,7 @@ auth_generate_key(sc_card_t *card, struct sc_cardctl_oberthur_genkey_info *data)
static int static int
auth_update_component(sc_card_t *card, struct sc_cardctl_oberthur_updatekey_info *args) 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 sbuf[SC_MAX_APDU_BUFFER_SIZE + 0x10];
u8 ins, p1, p2; u8 ins, p1, p2;
int rv, len; int rv, len;
@ -1715,7 +1715,7 @@ auth_update_component(sc_card_t *card, struct sc_cardctl_oberthur_updatekey_info
static int 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) { switch (cmd) {
case SC_CARDCTL_GET_DEFAULT_KEY: 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 num, unsigned char *out, size_t outlen)
{ {
int rv; int rv;
struct sc_apdu apdu; sc_apdu_t apdu;
struct auth_private_data *prv = (struct auth_private_data *) card->drv_data; struct auth_private_data *prv = (struct auth_private_data *) card->drv_data;
unsigned char resp[SC_MAX_APDU_BUFFER_SIZE]; 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) int type, int reference, int cmd, int *out_ref)
{ {
struct auth_private_data *prv = (struct auth_private_data *) card->drv_data; 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 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) unsigned int type)
{ {
struct auth_private_data *data = (struct auth_private_data *) card->drv_data; 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 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) int ref, const u8 *data, size_t data_len, int *tries_left)
{ {
sc_apdu_t apdu; sc_apdu_t apdu;
@ -1925,7 +1925,7 @@ auth_verify(struct sc_card *card, unsigned int type,
static int 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, int ref, const u8 *old, size_t oldlen,
const u8 *_new, size_t newlen, int *tries_left) 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 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, int ref, const u8 *puk, size_t puklen,
const u8 *pin, size_t pinlen) const u8 *pin, size_t pinlen)
{ {
@ -2016,7 +2016,7 @@ auth_reset_retry_counter(struct sc_card *card, unsigned int type,
static int 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) struct sc_cardctl_oberthur_createpin_info *args)
{ {
sc_apdu_t apdu; sc_apdu_t apdu;
@ -2079,7 +2079,7 @@ auth_create_reference_data (struct sc_card *card,
static int static int
auth_logout(struct sc_card *card) auth_logout(sc_card_t *card)
{ {
sc_apdu_t apdu; sc_apdu_t apdu;
int rv, pin_ref; int rv, pin_ref;
@ -2110,7 +2110,7 @@ auth_logout(struct sc_card *card)
} }
static int 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) const u8 *buf, size_t count)
{ {
int ii, rv; int ii, rv;
@ -2179,7 +2179,7 @@ end:
static int 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) const u8 *buf, size_t count, unsigned long flags)
{ {
int rv = 0; int rv = 0;
@ -2217,7 +2217,7 @@ auth_update_binary(struct sc_card *card, unsigned int offset,
static int 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) u8 *buf, size_t count, unsigned long flags)
{ {
int rv; int rv;
@ -2296,10 +2296,10 @@ auth_read_binary(struct sc_card *card, unsigned int offset,
static int 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; 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_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); sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0x32, nr_rec, 0x04);

View File

@ -51,12 +51,12 @@ static struct sc_card_driver setcos_drv = {
&setcos_ops &setcos_ops
}; };
static int setcos_finish(struct sc_card *card) static int setcos_finish(sc_card_t *card)
{ {
return 0; 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; const char *src = (const char *) card->slot->atr_info.hist_bytes;
size_t srclen = card->slot->atr_info.hist_bytes_len; 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; return 0;
} }
static int setcos_match_card(struct sc_card *card) static int setcos_match_card(sc_card_t *card)
{ {
int i; int i;
@ -110,7 +110,7 @@ static int select_fineid_app(sc_card_t * card)
return r; return r;
} }
static int setcos_init(struct sc_card *card) static int setcos_init(sc_card_t *card)
{ {
card->name = "SetCOS"; 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 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) { switch (e->method) {
case SC_AC_NONE: case SC_AC_NONE:
@ -184,7 +184,7 @@ static u8 acl_to_byte(const struct sc_acl_entry *e)
return 0x00; 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) if (file->prop_attr_len == 0)
sc_file_set_prop_attr(file, (const u8 *) "\x03\x00\x00", 3); 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); return iso_ops->create_file(card, file);
} }
static int setcos_set_security_env2(struct sc_card *card, static int setcos_set_security_env2(sc_card_t *card,
const struct sc_security_env *env, int se_num) 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 sbuf[SC_MAX_APDU_BUFFER_SIZE];
u8 *p; u8 *p;
int r, locked = 0; int r, locked = 0;
@ -299,11 +299,11 @@ err:
return r; return r;
} }
static int setcos_set_security_env(struct sc_card *card, static int setcos_set_security_env(sc_card_t *card,
const struct sc_security_env *env, int se_num) const sc_security_env_t *env, int se_num)
{ {
if (env->flags & SC_SEC_ENV_ALG_PRESENT) { if (env->flags & SC_SEC_ENV_ALG_PRESENT) {
struct sc_security_env tmp; sc_security_env_t tmp;
tmp = *env; tmp = *env;
tmp.flags &= ~SC_SEC_ENV_ALG_PRESENT; 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); 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; 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); 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 i;
int idx[6]; 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]); add_acl_entry(file, idx[i], buf[i]);
} }
static int setcos_select_file(struct sc_card *card, static int setcos_select_file(sc_card_t *card,
const struct sc_path *in_path, struct sc_file **file) const sc_path_t *in_path, sc_file_t **file)
{ {
int r; int r;
@ -405,9 +405,9 @@ static int setcos_select_file(struct sc_card *card,
return 0; 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; int r;
sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xAA, 0, 0); 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 #if 0
static int setcos_logout(struct sc_card *card) static int setcos_logout(sc_card_t *card)
{ {
return 0; return 0;
} }

View File

@ -66,7 +66,7 @@ typedef struct starcos_ex_data_st {
} starcos_ex_data; } starcos_ex_data;
/* the starcos part */ /* the starcos part */
static int starcos_match_card(struct sc_card *card) static int starcos_match_card(sc_card_t *card)
{ {
int i; int i;
@ -76,7 +76,7 @@ static int starcos_match_card(struct sc_card *card)
return 1; return 1;
} }
static int starcos_init(struct sc_card *card) static int starcos_init(sc_card_t *card)
{ {
int flags; int flags;
starcos_ex_data *ex_data; starcos_ex_data *ex_data;
@ -112,14 +112,14 @@ static int starcos_init(struct sc_card *card)
return 0; return 0;
} }
static int starcos_finish(struct sc_card *card) static int starcos_finish(sc_card_t *card)
{ {
if (card->drv_data) if (card->drv_data)
free((starcos_ex_data *)card->drv_data); free((starcos_ex_data *)card->drv_data);
return 0; 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) const u8 *buf, size_t buflen)
{ {
/* NOTE: According to the Starcos S 2.1 manual it's possible /* 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; 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, u8 aid[16], size_t len,
struct sc_file **file_out) sc_file_t **file_out)
{ {
sc_apdu_t apdu; sc_apdu_t apdu;
int r; int r;
@ -260,9 +260,9 @@ static int starcos_select_aid(struct sc_card *card,
SC_FUNC_RETURN(card->ctx, 2, SC_SUCCESS); 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, u8 id_hi, u8 id_lo,
struct sc_file **file_out) sc_file_t **file_out)
{ {
sc_apdu_t apdu; sc_apdu_t apdu;
u8 data[] = {id_hi, id_lo}; 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); SC_FUNC_RETURN(card->ctx, 2, SC_SUCCESS);
} }
static int starcos_select_file(struct sc_card *card, static int starcos_select_file(sc_card_t *card,
const struct sc_path *in_path, const sc_path_t *in_path,
struct sc_file **file_out) sc_file_t **file_out)
{ {
u8 pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf; u8 pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf;
int r; int r;
@ -526,9 +526,9 @@ static int starcos_select_file(struct sc_card *card,
#define STARCOS_AC_NEVER 0x5f #define STARCOS_AC_NEVER 0x5f
#define STARCOS_PINID2STATE(a) ((((a) & 0x0f) == 0x01) ? ((a) & 0x0f) : (0x0f - ((0x0f & (a)) >> 1))) #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) if (!entry)
return def; return def;
else if (entry->method & SC_AC_CHV) { 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 * from the OpenSC internal acl (storing the result in the supplied
* sc_starcos_create_data structure). * 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) sc_starcos_create_data *data)
{ {
int r; 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 * in the sc_starcos_create_data.mf structure. Note: CREATE END must be
* called separately to activate the ACs. * 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; int r;
struct sc_apdu apdu; sc_apdu_t apdu;
struct sc_context *ctx = card->ctx; sc_context_t *ctx = card->ctx;
if (ctx->debug >= 3) if (ctx->debug >= 3)
sc_debug(ctx, "creating MF \n"); 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 * stored in a sc_starcos_create_data.df data structure. Note: CREATE END must
* be called separately to activate the ACs. * 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; int r;
size_t len; size_t len;
struct sc_apdu apdu; sc_apdu_t apdu;
struct sc_context *ctx = card->ctx; sc_context_t *ctx = card->ctx;
if (ctx->debug >= 3) if (ctx->debug >= 3)
sc_debug(ctx, "creating DF\n"); 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 * This function creates a EF based on the information stored in
* the sc_starcos_create_data.ef data structure. * 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; int r;
struct sc_apdu apdu; sc_apdu_t apdu;
struct sc_context *ctx = card->ctx; sc_context_t *ctx = card->ctx;
if (ctx->debug >= 3) if (ctx->debug >= 3)
sc_debug(ctx, "creating EF\n"); 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 * This function finishs the creation of a DF (or MF) and activates
* the ACs. * 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; int r;
u8 fid[2]; u8 fid[2];
struct sc_apdu apdu; sc_apdu_t apdu;
if (file->type != SC_FILE_TYPE_DF) if (file->type != SC_FILE_TYPE_DF)
return SC_ERROR_INVALID_ARGUMENTS; 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 * This function creates MF, DF or EF based on the supplied
* information in the sc_file structure (using starcos_process_acl). * 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; int r;
sc_starcos_create_data data; 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). * 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 */ { /* restore the delivery state */
int r; int r;
u8 sbuf[2]; u8 sbuf[2];
struct sc_apdu apdu; sc_apdu_t apdu;
sbuf[0] = 0x3f; sbuf[0] = 0x3f;
sbuf[1] = 0x00; 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) * information supplied in the sc_starcos_wkey_data structure)
* and set a supplied key (depending on the mode). * 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; int r;
u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
const u8 *p; const u8 *p;
size_t len = sizeof(sbuf), tlen, offset = 0; size_t len = sizeof(sbuf), tlen, offset = 0;
struct sc_apdu apdu; sc_apdu_t apdu;
if (!data->mode) /* mode == 0 => install */ if (!data->mode) /* mode == 0 => install */
{ /* install key header */ { /* 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 * This function generates a public key pair and stores the created
* private key in the ISF (specified by the KID). * 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; int r;
size_t i, len = data->key_length >> 3; size_t i, len = data->key_length >> 3;
struct sc_apdu apdu; sc_apdu_t apdu;
u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
u8 sbuf[2], *p, *q; u8 sbuf[2], *p, *q;
/* generate key */ /* 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 * COMPUTE SIGNATURE or INTERNAL AUTHENTICATE must be used for signature
* calculation. * calculation.
*/ */
static int starcos_set_security_env(struct sc_card *card, static int starcos_set_security_env(sc_card_t *card,
const struct sc_security_env *env, const sc_security_env_t *env,
int se_num) int se_num)
{ {
u8 *p, *pp, keyID; u8 *p, *pp, keyID;
int r, operation = env->operation; int r, operation = env->operation;
struct sc_apdu apdu; sc_apdu_t apdu;
u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
starcos_ex_data *ex_data = (starcos_ex_data *)card->drv_data; starcos_ex_data *ex_data = (starcos_ex_data *)card->drv_data;
@ -1154,12 +1154,12 @@ try_authenticate:
return SC_ERROR_INVALID_ARGUMENTS; 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, const u8 * data, size_t datalen,
u8 * out, size_t outlen) u8 * out, size_t outlen)
{ {
int r; int r;
struct sc_apdu apdu; sc_apdu_t apdu;
u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
starcos_ex_data *ex_data = (starcos_ex_data *)card->drv_data; 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)); 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]); const int err_count = sizeof(starcos_errors)/sizeof(starcos_errors[0]);
int i; int i;
@ -1279,7 +1279,7 @@ static int starcos_get_serialnr(sc_card_t *card, sc_serial_number_t *serial)
{ {
int r; int r;
u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
struct sc_apdu apdu; sc_apdu_t apdu;
if (!serial) if (!serial)
return SC_ERROR_INVALID_ARGUMENTS; 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; 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; 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; int r;
struct sc_apdu apdu; sc_apdu_t apdu;
const u8 mf_buf[2] = {0x3f, 0x00}; const u8 mf_buf[2] = {0x3f, 0x00};
sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xA4, 0x00, 0x0C); sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xA4, 0x00, 0x0C);

View File

@ -50,13 +50,13 @@ typedef struct tcos_data_st {
unsigned int pad_flags; unsigned int pad_flags;
} tcos_data; } tcos_data;
static int tcos_finish(struct sc_card *card) static int tcos_finish(sc_card_t *card)
{ {
free(card->drv_data); free(card->drv_data);
return 0; return 0;
} }
static int tcos_match_card(struct sc_card *card) static int tcos_match_card(sc_card_t *card)
{ {
int i; int i;
@ -66,7 +66,7 @@ static int tcos_match_card(struct sc_card *card)
return 1; return 1;
} }
static int tcos_init(struct sc_card *card) static int tcos_init(sc_card_t *card)
{ {
unsigned long flags; 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 OpenSC should be enhanced to allow for the command based security
attributes of TCOS. FIXME: This just allows to create a very basic attributes of TCOS. FIXME: This just allows to create a very basic
file. */ 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 *out, size_t *outlen)
{ {
u8 *p = out; 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; int r;
size_t len; size_t len;
u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
struct sc_apdu apdu; sc_apdu_t apdu;
len = SC_MAX_APDU_BUFFER_SIZE; len = SC_MAX_APDU_BUFFER_SIZE;
r = tcos_construct_fci(file, sbuf, &len); 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 OpenSC should be enhanced to allow for the command based security
attributes of TCOS. FIXME: This just allows to create a very basic attributes of TCOS. FIXME: This just allows to create a very basic
file. */ file. */
static void parse_sec_attr(struct sc_card *card, static void parse_sec_attr(sc_card_t *card,
struct sc_file *file, const u8 *buf, size_t len) sc_file_t *file, const u8 *buf, size_t len)
{ {
int op; int op;
@ -316,7 +316,7 @@ static void parse_sec_attr(struct sc_card *card,
} }
/* Arghh. duplicated from iso7816.c */ /* 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) const u8 *buf, size_t buflen)
{ {
size_t taglen, len = 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 needed to cope with some starngeness in APDU construction. It is
probably better to have this specfic for TCOS, so that support for probably better to have this specfic for TCOS, so that support for
other cards does not break. */ other cards does not break. */
static int hacked_iso7816_select_file(struct sc_card *card, static int hacked_iso7816_select_file(sc_card_t *card,
const struct sc_path *in_path, const sc_path_t *in_path,
struct sc_file **file_out) sc_file_t **file_out)
{ {
struct sc_context *ctx; sc_context_t *ctx;
struct sc_apdu apdu; sc_apdu_t apdu;
u8 buf[SC_MAX_APDU_BUFFER_SIZE]; u8 buf[SC_MAX_APDU_BUFFER_SIZE];
u8 pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf; u8 pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf;
int r, pathlen; int r, pathlen;
struct sc_file *file = NULL; sc_file_t *file = NULL;
assert(card != NULL && in_path != NULL); assert(card != NULL && in_path != NULL);
ctx = card->ctx; 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, static int tcos_select_file(sc_card_t *card,
const struct sc_path *in_path, const sc_path_t *in_path,
struct sc_file **file) sc_file_t **file)
{ {
int r; int r;
@ -534,9 +534,9 @@ static int tcos_select_file(struct sc_card *card,
return 0; 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 rbuf[SC_MAX_APDU_BUFFER_SIZE];
u8 p1s[2] = { 0x01, 0x02 }; u8 p1s[2] = { 0x01, 0x02 };
int r, i, count = 0; 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; int r;
u8 sbuf[2]; u8 sbuf[2];
struct sc_apdu apdu; sc_apdu_t apdu;
SC_FUNC_CALLED(card->ctx, 1); SC_FUNC_CALLED(card->ctx, 1);
if (path->type != SC_PATH_TYPE_FILE_ID && path->len != 2) { 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 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] uses parameters which are not described in the TCOS specs. [wk]
*/ */
static int tcos_set_security_env(struct sc_card *card, static int tcos_set_security_env(sc_card_t *card,
const struct sc_security_env *env, const sc_security_env_t *env,
int se_num) int se_num)
{ {
struct sc_apdu apdu; sc_apdu_t apdu;
u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
u8 *p; u8 *p;
int r, locked = 0; int r, locked = 0;
@ -678,7 +678,7 @@ err:
/* See tcos_set_security_env() for comments. So we always return /* See tcos_set_security_env() for comments. So we always return
success */ 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; 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 * TCOS decipher command (same as iso7816_decipher besides setting
* the padding byte). * 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, const u8 * crgram, size_t crgram_len,
u8 * out, size_t outlen) u8 * out, size_t outlen)
{ {
int r; int r;
struct sc_apdu apdu; sc_apdu_t apdu;
tcos_data *xdata; tcos_data *xdata;
u8 pad_byte; u8 pad_byte;
u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; 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 /* Issue the SET PERMANENT command. With ENABLE_NULLPIN set the
NullPIN method will be activated, otherwise the permanent operation NullPIN method will be activated, otherwise the permanent operation
will be done on the active file. */ 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; int r;
struct sc_apdu apdu; sc_apdu_t apdu;
SC_FUNC_CALLED(card->ctx, 1); SC_FUNC_CALLED(card->ctx, 1);
sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0xEE, 0x00, 0x00); 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; 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) { switch (cmd) {
case SC_CARDCTL_TCOS_SETPERM: case SC_CARDCTL_TCOS_SETPERM:

View File

@ -27,13 +27,13 @@
#endif #endif
#include <string.h> #include <string.h>
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); assert(card->ops->check_sw != NULL);
return card->ops->check_sw(card, sw1, sw2); 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) { if (apdu->le > 256) {
sc_error(ctx, "Value of Le too big (maximum 256 bytes)\n"); 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; 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 sbuf[SC_MAX_APDU_BUFFER_SIZE];
u8 rbuf[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; 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; int r;
size_t orig_resplen; size_t orig_resplen;
@ -304,7 +304,7 @@ int sc_transmit_apdu(struct sc_card *card, struct sc_apdu *apdu)
return 0; 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) int cse, int ins, int p1, int p2)
{ {
assert(card != NULL && apdu != NULL); assert(card != NULL && apdu != NULL);
@ -318,11 +318,11 @@ void sc_format_apdu(struct sc_card *card, struct sc_apdu *apdu,
return; 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) if (card == NULL)
return NULL; return NULL;
card->ops = (struct sc_card_operations *) malloc(sizeof(struct sc_card_operations)); 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; 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)); assert(sc_card_valid(card));
sc_free_apps(card); sc_free_apps(card);
@ -352,12 +352,12 @@ static void sc_card_free(struct sc_card *card)
free(card); free(card);
} }
int sc_connect_card(struct sc_reader *reader, int slot_id, int sc_connect_card(sc_reader_t *reader, int slot_id,
struct sc_card **card_out) sc_card_t **card_out)
{ {
struct sc_card *card; sc_card_t *card;
struct sc_context *ctx = reader->ctx; sc_context_t *ctx = reader->ctx;
struct sc_slot_info *slot = _sc_get_slot_info(reader, slot_id); sc_slot_info_t *slot = _sc_get_slot_info(reader, slot_id);
struct sc_card_driver *driver; struct sc_card_driver *driver;
int i, r = 0, idx; int i, r = 0, idx;
@ -478,9 +478,9 @@ err:
SC_FUNC_RETURN(ctx, 1, r); 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)); assert(sc_card_valid(card));
ctx = card->ctx; ctx = card->ctx;
SC_FUNC_CALLED(ctx, 1); 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); SC_FUNC_RETURN(ctx, 1, 0);
} }
int sc_lock(struct sc_card *card) int sc_lock(sc_card_t *card)
{ {
int r = 0; int r = 0;
@ -520,7 +520,7 @@ int sc_lock(struct sc_card *card)
return r; return r;
} }
int sc_unlock(struct sc_card *card) int sc_unlock(sc_card_t *card)
{ {
int r = 0; int r = 0;
@ -549,7 +549,7 @@ int sc_unlock(struct sc_card *card)
return r; 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; 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); 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; 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); 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; 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); 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) unsigned char *buf, size_t count, unsigned long flags)
{ {
size_t max_le = card->max_recv_size; 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); 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) const u8 *buf, size_t count, unsigned long flags)
{ {
size_t max_lc = card->max_send_size; 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); 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) const u8 *buf, size_t count, unsigned long flags)
{ {
size_t max_lc = card->max_send_size; 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); SC_FUNC_RETURN(card->ctx, 2, r);
} }
int sc_select_file(struct sc_card *card, int sc_select_file(sc_card_t *card,
const struct sc_path *in_path, const sc_path_t *in_path,
struct sc_file **file) sc_file_t **file)
{ {
int r; 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); 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; 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); 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) size_t count, unsigned long flags)
{ {
int r; 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); 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) size_t count, unsigned long flags)
{ {
int r; 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); 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) unsigned long flags)
{ {
int r; 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); 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) size_t count, unsigned long flags)
{ {
int r; 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); 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; 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); 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 #ifndef NDEBUG
assert(card != NULL); assert(card != NULL);
#endif #endif
@ -862,7 +862,7 @@ inline int sc_card_valid(const struct sc_card *card) {
} }
int 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; 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); 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); 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 (!p) {
if (card->algorithms) if (card->algorithms)
free(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; 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) unsigned long flags, unsigned long exponent)
{ {
struct sc_algorithm_info info; sc_algorithm_info_t info;
memset(&info, 0, sizeof(info)); memset(&info, 0, sizeof(info));
info.algorithm = SC_ALGORITHM_RSA; 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); 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) unsigned int key_length)
{ {
int i; int i;
for (i = 0; i < card->algorithm_count; 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) if (info->algorithm != SC_ALGORITHM_RSA)
continue; continue;
@ -930,7 +930,7 @@ struct sc_algorithm_info * _sc_card_find_rsa_alg(struct sc_card *card,
return NULL; 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; u8 *card_atr_bin = atr;
size_t card_atr_bin_len = atr_len; 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; 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; int res;
@ -1029,7 +1029,7 @@ scconf_block *_sc_match_atr_block(sc_context_t *ctx, struct sc_card_driver *driv
return NULL; 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; 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; 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; unsigned int i;
@ -1087,7 +1087,7 @@ int _sc_free_atr(struct sc_context *ctx, struct sc_card_driver *driver)
return SC_SUCCESS; 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; scconf_block *atrblock = NULL;
int ok = 0; int ok = 0;

View File

@ -152,11 +152,11 @@ ctbcs_build_modify_verification_apdu(sc_apdu_t *apdu, struct sc_pin_cmd_data *da
} }
int 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_pin_cmd_data *data)
{ {
struct sc_card dummy_card, *card; sc_card_t dummy_card, *card;
struct sc_apdu apdu; sc_apdu_t apdu;
struct sc_card_operations ops; struct sc_card_operations ops;
int r; int r;

View File

@ -35,7 +35,7 @@
# define DEF_APDU_MASQ SC_APDU_MASQUERADE_4AS3 # define DEF_APDU_MASQ SC_APDU_MASQUERADE_4AS3
#endif #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); assert(reader != NULL);
reader->ctx = ctx; 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; ctx->debug = 0;
if (ctx->debug_file && ctx->debug_file != stdout) 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); 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) struct _sc_ctx_options *opts)
{ {
int err = 0; 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 * find library module for provided driver in configuration file
* if not found assume library name equals to module name * 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; int i;
const char *libname = NULL; 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 == 0 -> reader driver
* type == 1 -> card 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 *name, int type)
{ {
const char *version, *libname; const char *version, *libname;
@ -370,7 +370,7 @@ static void *load_dynamic_driver(struct sc_context *ctx, void **dll,
return modinit(name); 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) struct _sc_ctx_options *opts)
{ {
const struct _sc_driver_entry *ent; const struct _sc_driver_entry *ent;
@ -410,7 +410,7 @@ static int load_reader_drivers(struct sc_context *ctx,
return SC_SUCCESS; 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) struct sc_card_driver *driver)
{ {
scconf_block **blocks, *blk; scconf_block **blocks, *blk;
@ -431,7 +431,7 @@ static int load_card_driver_options(struct sc_context *ctx,
return SC_SUCCESS; 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) struct _sc_ctx_options *opts)
{ {
const struct _sc_driver_entry *ent; const struct _sc_driver_entry *ent;
@ -472,7 +472,7 @@ static int load_card_drivers(struct sc_context *ctx,
return SC_SUCCESS; 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_ctx_options *opts)
{ {
struct sc_card_driver *driver; struct sc_card_driver *driver;
@ -550,7 +550,7 @@ static int load_card_atrs(struct sc_context *ctx,
return SC_SUCCESS; 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; int i, r, count = 0;
scconf_block **blocks; 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); 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"; const char *default_app = "default";
struct sc_context *ctx; sc_context_t *ctx;
struct _sc_ctx_options opts; struct _sc_ctx_options opts;
assert(ctx_out != NULL); 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) if (ctx == NULL)
return SC_ERROR_OUT_OF_MEMORY; return SC_ERROR_OUT_OF_MEMORY;
memset(&opts, 0, sizeof(opts)); 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; return SC_SUCCESS;
} }
int sc_release_context(struct sc_context *ctx) int sc_release_context(sc_context_t *ctx)
{ {
int i; int i;
assert(ctx != NULL); assert(ctx != NULL);
SC_FUNC_CALLED(ctx, 1); SC_FUNC_CALLED(ctx, 1);
for (i = 0; i < ctx->reader_count; i++) { 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) if (rdr->ops->release != NULL)
rdr->ops->release(rdr); rdr->ops->release(rdr);
@ -719,7 +719,7 @@ int sc_release_context(struct sc_context *ctx)
return SC_SUCCESS; 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; 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; 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; char *homedir;
const char *cache_dir; 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; 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; char dirname[PATH_MAX], *sp;
int r; int r;

View File

@ -47,9 +47,9 @@ static const struct app_entry * find_app_entry(const u8 * aid, size_t aid_len)
return NULL; 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; unsigned int i;
i = sizeof(apps)/sizeof(apps[0]); i = sizeof(apps)/sizeof(apps[0]);
@ -72,11 +72,11 @@ static const struct sc_asn1_entry c_asn1_dir[] = {
{ NULL } { 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) int rec_nr)
{ {
struct sc_asn1_entry asn1_dirrecord[5], asn1_dir[2]; 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; const struct app_entry *ae;
int r; int r;
u8 aid[128], label[128], path[128]; 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"); sc_error(card->ctx, "AID is too long.\n");
return SC_ERROR_INVALID_ASN1_OBJECT; 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) if (app == NULL)
return SC_ERROR_OUT_OF_MEMORY; 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; 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; int ef_structure;
size_t file_size; size_t file_size;
int r; int r;
@ -230,7 +230,7 @@ int sc_enum_apps(struct sc_card *card)
return card->app_count; return card->app_count;
} }
void sc_free_apps(struct sc_card *card) void sc_free_apps(sc_card_t *card)
{ {
int i; int i;
@ -244,7 +244,7 @@ void sc_free_apps(struct sc_card *card)
card->app_count = -1; 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) const u8 *aid, size_t aid_len)
{ {
int i; int i;
@ -258,11 +258,11 @@ const struct sc_app_info * sc_find_app_by_aid(struct sc_card *card,
return NULL; 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) u8 **buf, size_t *buflen)
{ {
struct sc_asn1_entry asn1_dirrecord[5], asn1_dir[2]; struct sc_asn1_entry asn1_dirrecord[5], asn1_dir[2];
struct sc_app_info tapp = *app; sc_app_info_t tapp = *app;
int r; int r;
size_t label_len; 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; 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; u8 *rec, *buf = NULL, *tmp;
size_t rec_size, buf_size = 0; 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; return 0;
} }
static int update_single_record(struct sc_card *card, struct sc_file *file, static int update_single_record(sc_card_t *card, sc_file_t *file,
struct sc_app_info *app) sc_app_info_t *app)
{ {
u8 *rec; u8 *rec;
size_t rec_size; size_t rec_size;
@ -350,7 +350,7 @@ static int update_single_record(struct sc_card *card, struct sc_file *file,
return 0; 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; int i, r;
@ -362,10 +362,10 @@ static int update_records(struct sc_card *card, struct sc_file *file)
return 0; 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; sc_path_t path;
struct sc_file *file; sc_file_t *file;
int r; int r;
sc_format_path("3F002F00", &path); sc_format_path("3F002F00", &path);

View File

@ -76,7 +76,7 @@ const static struct sc_card_error iso7816_errors[] = {
{ 0x6A8A, SC_ERROR_FILE_ALREADY_EXISTS, "Application exists"}, { 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]); const int err_count = sizeof(iso7816_errors)/sizeof(iso7816_errors[0]);
int i; 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; 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 int idx, u8 *buf, size_t count,
unsigned long flags) unsigned long flags)
{ {
struct sc_apdu apdu; sc_apdu_t apdu;
u8 recvbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 recvbuf[SC_MAX_APDU_BUFFER_SIZE];
int r; int r;
@ -126,11 +126,11 @@ static int iso7816_read_binary(struct sc_card *card,
SC_FUNC_RETURN(card->ctx, 3, apdu.resplen); 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 int rec_nr, u8 *buf, size_t count,
unsigned long flags) unsigned long flags)
{ {
struct sc_apdu apdu; sc_apdu_t apdu;
u8 recvbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 recvbuf[SC_MAX_APDU_BUFFER_SIZE];
int r; int r;
@ -152,11 +152,11 @@ static int iso7816_read_record(struct sc_card *card,
SC_FUNC_RETURN(card->ctx, 3, apdu.resplen); 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, const u8 *buf, size_t count,
unsigned long flags) unsigned long flags)
{ {
struct sc_apdu apdu; sc_apdu_t apdu;
int r; int r;
if (count > 256) { 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); 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, const u8 *buf, size_t count,
unsigned long flags) unsigned long flags)
{ {
struct sc_apdu apdu; sc_apdu_t apdu;
int r; int r;
if (count > 256) { if (count > 256) {
@ -204,11 +204,11 @@ static int iso7816_append_record(struct sc_card *card,
SC_FUNC_RETURN(card->ctx, 3, count); 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, const u8 *buf, size_t count,
unsigned long flags) unsigned long flags)
{ {
struct sc_apdu apdu; sc_apdu_t apdu;
int r; int r;
if (count > 256) { 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); 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, unsigned int idx, const u8 *buf,
size_t count, unsigned long flags) size_t count, unsigned long flags)
{ {
struct sc_apdu apdu; sc_apdu_t apdu;
int r; int r;
assert(count <= card->max_send_size); 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); 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, unsigned int idx, const u8 *buf,
size_t count, unsigned long flags) size_t count, unsigned long flags)
{ {
struct sc_apdu apdu; sc_apdu_t apdu;
int r; int r;
assert(count <= card->max_send_size); 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); 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) const u8 *buf, size_t buflen)
{ {
struct sc_context *ctx = card->ctx; sc_context_t *ctx = card->ctx;
size_t taglen, len = buflen; size_t taglen, len = buflen;
const u8 *tag = NULL, *p = buf; 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; return 0;
} }
static int iso7816_select_file(struct sc_card *card, static int iso7816_select_file(sc_card_t *card,
const struct sc_path *in_path, const sc_path_t *in_path,
struct sc_file **file_out) sc_file_t **file_out)
{ {
struct sc_context *ctx; sc_context_t *ctx;
struct sc_apdu apdu; sc_apdu_t apdu;
u8 buf[SC_MAX_APDU_BUFFER_SIZE]; u8 buf[SC_MAX_APDU_BUFFER_SIZE];
u8 pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf; u8 pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf;
int r, pathlen; int r, pathlen;
struct sc_file *file = NULL; sc_file_t *file = NULL;
assert(card != NULL && in_path != NULL); assert(card != NULL && in_path != NULL);
ctx = card->ctx; ctx = card->ctx;
@ -464,10 +464,10 @@ static int iso7816_select_file(struct sc_card *card,
return 0; 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; int r;
struct sc_apdu apdu; sc_apdu_t apdu;
u8 buf[10]; u8 buf[10];
sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 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; 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 *out, size_t *outlen)
{ {
u8 *p = out; u8 *p = out;
@ -541,12 +541,12 @@ static int iso7816_construct_fci(struct sc_card *card, const struct sc_file *fil
return 0; 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; int r;
size_t len; size_t len;
u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
struct sc_apdu apdu; sc_apdu_t apdu;
len = SC_MAX_APDU_BUFFER_SIZE; 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); 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; int r;
sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xC0, 0x00, 0x00); 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); 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; int r;
u8 sbuf[2]; u8 sbuf[2];
struct sc_apdu apdu; sc_apdu_t apdu;
SC_FUNC_CALLED(card->ctx, 1); SC_FUNC_CALLED(card->ctx, 1);
if (path->type != SC_PATH_TYPE_FILE_ID && path->len != 2) { 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); return sc_check_sw(card, apdu.sw1, apdu.sw2);
} }
static int iso7816_set_security_env(struct sc_card *card, static int iso7816_set_security_env(sc_card_t *card,
const struct sc_security_env *env, const sc_security_env_t *env,
int se_num) int se_num)
{ {
struct sc_apdu apdu; sc_apdu_t apdu;
u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
u8 *p; u8 *p;
int r, locked = 0; int r, locked = 0;
@ -694,9 +694,9 @@ err:
return r; 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; int r;
u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; 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); 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, const u8 * data, size_t datalen,
u8 * out, size_t outlen) u8 * out, size_t outlen)
{ {
int r; int r;
struct sc_apdu apdu; sc_apdu_t apdu;
u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
u8 sbuf[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)); 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, const u8 * crgram, size_t crgram_len,
u8 * out, size_t outlen) u8 * out, size_t outlen)
{ {
int r; int r;
struct sc_apdu apdu; sc_apdu_t apdu;
u8 rbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
u8 sbuf[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)); SC_FUNC_RETURN(card->ctx, 2, sc_check_sw(card, apdu.sw1, apdu.sw2));
} }
static int iso7816_build_pin_apdu(struct sc_card *card, static int iso7816_build_pin_apdu(sc_card_t *card,
struct sc_apdu *apdu, sc_apdu_t *apdu,
struct sc_pin_cmd_data *data) struct sc_pin_cmd_data *data)
{ {
static u8 sbuf[SC_MAX_APDU_BUFFER_SIZE]; static u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
@ -866,10 +866,10 @@ static int iso7816_build_pin_apdu(struct sc_card *card,
return 0; 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) int *tries_left)
{ {
struct sc_apdu local_apdu, *apdu; sc_apdu_t local_apdu, *apdu;
int r; int r;
if (tries_left) 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 * 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[0] = 0x3F;
in_path.value[1] = 0x00; in_path.value[1] = 0x00;
in_path.len = 2; in_path.len = 2;
@ -960,7 +960,7 @@ static struct sc_card_driver iso_driver = {
&iso_ops &iso_ops
}; };
static int no_match(struct sc_card *card) static int no_match(sc_card_t *card)
{ {
return 0; return 0;
} }

View File

@ -36,7 +36,7 @@
#endif #endif
#ifndef __GNUC__ #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; va_list ap;
@ -45,7 +45,7 @@ void sc_error(struct sc_context *ctx, const char *format, ...)
va_end(ap); 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; va_list ap;
@ -56,7 +56,7 @@ void sc_debug(struct sc_context *ctx, const char *format, ...)
#endif #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; 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); 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 *); int (*display_fn)(sc_context_t *, const char *);
char buf[1536], *p; 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); 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; char *p = buf;
int lines = 0; int lines = 0;

View File

@ -190,7 +190,7 @@ typedef unsigned __int64 sc_timestamp_t;
#define SC_EVENT_CARD_INSERTED 0x0001 #define SC_EVENT_CARD_INSERTED 0x0001
#define SC_EVENT_CARD_REMOVED 0x0002 #define SC_EVENT_CARD_REMOVED 0x0002
struct sc_security_env { typedef struct sc_security_env {
unsigned long flags; unsigned long flags;
int operation; int operation;
unsigned int algorithm, algorithm_flags; unsigned int algorithm, algorithm_flags;
@ -199,8 +199,7 @@ struct sc_security_env {
struct sc_path file_ref; struct sc_path file_ref;
u8 key_ref[8]; u8 key_ref[8];
size_t key_ref_len; size_t key_ref_len;
}; } sc_security_env_t;
typedef struct sc_security_env sc_security_env_t;
struct sc_algorithm_id { struct sc_algorithm_id {
unsigned int algorithm; unsigned int algorithm;
@ -221,7 +220,7 @@ struct sc_pbes2_params {
struct sc_algorithm_id key_encr_alg; struct sc_algorithm_id key_encr_alg;
}; };
struct sc_algorithm_info { typedef struct sc_algorithm_info {
unsigned int algorithm; unsigned int algorithm;
unsigned int key_length; unsigned int key_length;
unsigned int flags; unsigned int flags;
@ -231,10 +230,9 @@ struct sc_algorithm_info {
unsigned long exponent; unsigned long exponent;
} _rsa; } _rsa;
} u; } u;
}; } sc_algorithm_info_t;
typedef struct sc_algorithm_info sc_algorithm_info_t;
struct sc_app_info { typedef struct sc_app_info {
u8 aid[SC_MAX_AID_SIZE]; u8 aid[SC_MAX_AID_SIZE];
size_t aid_len; size_t aid_len;
char *label; char *label;
@ -244,8 +242,7 @@ struct sc_app_info {
const char *desc; /* App description, if known */ const char *desc; /* App description, if known */
int rec_nr; /* -1, if EF(DIR) is transparent */ int rec_nr; /* -1, if EF(DIR) is transparent */
}; } sc_app_info_t;
typedef struct sc_app_info sc_app_info_t;
struct sc_card_cache { struct sc_card_cache {
struct sc_path current_path; struct sc_path current_path;
@ -277,7 +274,7 @@ struct sc_reader_driver {
#define SC_SLOT_CAP_DISPLAY 0x00000001 #define SC_SLOT_CAP_DISPLAY 0x00000001
#define SC_SLOT_CAP_PIN_PAD 0x00000002 #define SC_SLOT_CAP_PIN_PAD 0x00000002
struct sc_slot_info { typedef struct sc_slot_info {
int id; int id;
unsigned long flags, capabilities; unsigned long flags, capabilities;
unsigned int supported_protocols, active_protocol; unsigned int supported_protocols, active_protocol;
@ -292,15 +289,14 @@ struct sc_slot_info {
} atr_info; } atr_info;
void *drv_data; void *drv_data;
}; } sc_slot_info_t;
typedef struct sc_slot_info sc_slot_info_t;
struct sc_event_listener { struct sc_event_listener {
unsigned int event_mask; unsigned int event_mask;
void (*func)(void *, const struct sc_slot_info *, unsigned int event); void (*func)(void *, const struct sc_slot_info *, unsigned int event);
}; };
struct sc_reader { typedef struct sc_reader {
struct sc_context *ctx; struct sc_context *ctx;
const struct sc_reader_driver *driver; const struct sc_reader_driver *driver;
const struct sc_reader_operations *ops; const struct sc_reader_operations *ops;
@ -309,8 +305,7 @@ struct sc_reader {
struct sc_slot_info slot[SC_MAX_SLOTS]; struct sc_slot_info slot[SC_MAX_SLOTS];
int slot_count; int slot_count;
}; } sc_reader_t;
typedef struct sc_reader sc_reader_t;
/* This will be the new interface for handling PIN commands. /* This will be the new interface for handling PIN commands.
* It is supposed to support pin pads (with or without display) * 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. */ /* Card doesn't return any File Control Info. */
#define SC_CARD_CAP_NO_FCI 0x00000008 #define SC_CARD_CAP_NO_FCI 0x00000008
struct sc_card { typedef struct sc_card {
struct sc_context *ctx; struct sc_context *ctx;
struct sc_reader *reader; struct sc_reader *reader;
struct sc_slot_info *slot; struct sc_slot_info *slot;
@ -496,8 +491,7 @@ struct sc_card {
sc_mutex_t *mutex; sc_mutex_t *mutex;
unsigned int magic; unsigned int magic;
}; } sc_card_t;
typedef struct sc_card sc_card_t;
struct sc_card_operations { struct sc_card_operations {
/* Called in sc_connect_card(). Must return 1, if the current /* 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); 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 *name;
const char *short_name; const char *short_name;
struct sc_card_operations *ops; struct sc_card_operations *ops;
struct sc_atr_table *atr_map; struct sc_atr_table *atr_map;
unsigned int natrs; unsigned int natrs;
void *dll; void *dll;
}; } sc_card_driver_t;
struct sc_context { typedef struct sc_context {
scconf_context *conf; scconf_context *conf;
scconf_block *conf_blocks[3]; scconf_block *conf_blocks[3];
char *app_name; char *app_name;
@ -647,8 +641,7 @@ struct sc_context {
sc_mutex_t *mutex; sc_mutex_t *mutex;
unsigned int magic; unsigned int magic;
}; } sc_context_t;
typedef struct sc_context sc_context_t;
/* Base64 encoding/decoding functions */ /* Base64 encoding/decoding functions */
int sc_base64_encode(const u8 *in, size_t inlen, u8 *out, size_t outlen, 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); sc_timestamp_t sc_current_time(void);
/* APDU handling functions */ /* APDU handling functions */
int sc_transmit_apdu(struct sc_card *card, struct sc_apdu *apdu); int sc_transmit_apdu(sc_card_t *card, sc_apdu_t *apdu);
void sc_format_apdu(struct sc_card *card, struct sc_apdu *apdu, int cse, int ins, void sc_format_apdu(sc_card_t *card, sc_apdu_t *apdu, int cse, int ins,
int p1, int p2); 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 * @param app_name A string that identifies the application, used primarily
* in finding application-specific configuration data. Can be NULL. * 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 * Releases an established OpenSC context
* @param ctx A pointer to the context structure to be released * @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 * Forces the use of a specified card driver
* @param ctx OpenSC context * @param ctx OpenSC context
* @param short_name The short name of the driver to use (e.g. 'emv') * @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. * 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. * The ATR (Answer to Reset) string of the card is also retrieved.
* @param reader Reader structure * @param reader Reader structure
* @param slot_id Slot ID to connect to * @param slot_id Slot ID to connect to
* @param card The allocated card object will go here */ * @param card The allocated card object will go here */
int sc_connect_card(struct sc_reader *reader, int slot_id, int sc_connect_card(sc_reader_t *reader, int slot_id,
struct sc_card **card); sc_card_t **card);
/** /**
* Disconnects from a card, and frees the card structure. Any locks * Disconnects from a card, and frees the card structure. Any locks
* made by the application must be released before calling this function. * made by the application must be released before calling this function.
* NOTE: The card is not reset nor powered down after the operation. * NOTE: The card is not reset nor powered down after the operation.
* @param card The card to disconnect * @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 * Returns 1 if the magic value of the card object is correct. Mostly
* used internally by the library. * used internally by the library.
* @param card The card object to check * @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 * 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, * always set. In addition, if the card was exchanged,
* the SC_SLOT_CARD_CHANGED flag is set. * 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, * 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 = 0 if a an event happened
* @retval = 1 if the timeout occured * @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, unsigned int event_mask,
int *reader, unsigned int *event, int timeout); 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 * @param card The card to lock
* @retval SC_SUCCESS on success * @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, * Unlocks a previously locked card. After the lock count drops to zero,
* the card is again placed in shared mode, where other processes * 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 * @param card The card to unlock
* @retval SC_SUCCESS on success * @retval SC_SUCCESS on success
*/ */
int sc_unlock(struct sc_card *card); int sc_unlock(sc_card_t *card);
/* ISO 7816-4 related functions */ /* 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 * @param file If not NULL, will receive a pointer to a new structure
* @retval SC_SUCCESS on success * @retval SC_SUCCESS on success
*/ */
int sc_select_file(struct sc_card *card, const struct sc_path *path, int sc_select_file(sc_card_t *card, const sc_path_t *path,
struct sc_file **file); 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 */ /* 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); 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); 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); size_t count, unsigned long flags);
/** /**
* Reads a record from the current (i.e. selected) file. * 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 * @param flags Flags
* @retval Number of bytes read or an error value * @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); 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); 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); 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); 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 */ /* get/put data functions */
int sc_get_data(sc_card_t *, unsigned int, u8 *, size_t); 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_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 */ /* ISO 7816-8 related functions */
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 sc_set_security_env(struct sc_card *card, int sc_set_security_env(sc_card_t *card,
const struct sc_security_env *env, int se_num); 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); 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); 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); size_t buflen, int *tries_left);
int sc_logout(struct sc_card *card); int sc_logout(sc_card_t *card);
int sc_pin_cmd(struct sc_card *card, struct sc_pin_cmd_data *, int *tries_left); int sc_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *, int *tries_left);
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, int ref, const u8 *old, size_t oldlen,
const u8 *newref, size_t newlen, const u8 *newref, size_t newlen,
int *tries_left); 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, int ref, const u8 *puk, size_t puklen,
const u8 *newref, size_t newlen); const u8 *newref, size_t newlen);
int sc_build_pin(u8 *buf, size_t buflen, struct sc_pin_cmd_pin *pin, int pad); 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); size_t in_len, u8 *out_dat, size_t *out_len);
int sc_pkcs1_strip_digest_info_prefix(unsigned int *algorithm, 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); 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); 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); int sc_strip_zero_padding(const u8 *in,size_t in_len, u8 *out, size_t *out_len);
/* ISO 7816-9 */ /* ISO 7816-9 */
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 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);
/* Card controls */ /* 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); inline int sc_file_valid(const sc_file_t *file);
struct sc_file * sc_file_new(void); sc_file_t * sc_file_new(void);
void sc_file_free(struct sc_file *file); void sc_file_free(sc_file_t *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);
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); 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); 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); 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); 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); 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); 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_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(sc_path_t *dest, const sc_path_t *src);
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);
int sc_append_file_id(struct sc_path *dest, unsigned int fid); 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_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_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_get_cache_dir(sc_context_t *ctx, char *buf, size_t bufsize);
int sc_make_cache_dir(struct sc_context *ctx); int sc_make_cache_dir(sc_context_t *ctx);
int sc_enum_apps(struct sc_card *card); int sc_enum_apps(sc_card_t *card);
void sc_free_apps(struct sc_card *card); void sc_free_apps(sc_card_t *card);
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 * 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); const u8 *aid, size_t aid_len);
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_card_error { struct sc_card_error {
int SWs; 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_ctapi_driver(void);
extern struct sc_reader_driver *sc_get_openct_driver(void); extern struct sc_reader_driver *sc_get_openct_driver(void);
extern struct sc_card_driver *sc_get_default_driver(void); extern sc_card_driver_t *sc_get_default_driver(void);
extern struct sc_card_driver *sc_get_emv_driver(void); extern sc_card_driver_t *sc_get_emv_driver(void);
extern struct sc_card_driver *sc_get_etoken_driver(void); extern sc_card_driver_t *sc_get_etoken_driver(void);
extern struct sc_card_driver *sc_get_cryptoflex_driver(void); extern sc_card_driver_t *sc_get_cryptoflex_driver(void);
extern struct sc_card_driver *sc_get_cyberflex_driver(void); extern sc_card_driver_t *sc_get_cyberflex_driver(void);
extern struct sc_card_driver *sc_get_gpk_driver(void); extern sc_card_driver_t *sc_get_gpk_driver(void);
extern struct sc_card_driver *sc_get_iso7816_driver(void); extern sc_card_driver_t *sc_get_iso7816_driver(void);
extern struct sc_card_driver *sc_get_miocos_driver(void); extern sc_card_driver_t *sc_get_miocos_driver(void);
extern struct sc_card_driver *sc_get_mcrd_driver(void); extern sc_card_driver_t *sc_get_mcrd_driver(void);
extern struct sc_card_driver *sc_get_setcos_driver(void); extern sc_card_driver_t *sc_get_setcos_driver(void);
extern struct sc_card_driver *sc_get_starcos_driver(void); extern sc_card_driver_t *sc_get_starcos_driver(void);
extern struct sc_card_driver *sc_get_tcos_driver(void); extern sc_card_driver_t *sc_get_tcos_driver(void);
extern struct sc_card_driver *sc_get_openpgp_driver(void); extern sc_card_driver_t *sc_get_openpgp_driver(void);
extern struct sc_card_driver *sc_get_jcop_driver(void); extern sc_card_driver_t *sc_get_jcop_driver(void);
extern struct sc_card_driver *sc_get_oberthur_driver(void); extern sc_card_driver_t *sc_get_oberthur_driver(void);
extern struct sc_card_driver *sc_get_belpic_driver(void); extern sc_card_driver_t *sc_get_belpic_driver(void);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -199,7 +199,7 @@ int sc_pkcs1_strip_digest_info_prefix(unsigned int *algorithm,
} }
/* general PKCS#1 encoding function */ /* 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) const u8 *in, size_t in_len, u8 *out, size_t *out_len, size_t mod_len)
{ {
int i; int i;

View File

@ -106,7 +106,7 @@ static int ccid_build_verify_pin_block(u8 * buf, size_t * size, struct sc_pin_cm
/* Do the PIN command */ /* Do the PIN command */
int 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) struct sc_pin_cmd_data *data)
{ {
u8 rbuf[SC_MAX_APDU_BUFFER_SIZE], sbuf[SC_MAX_APDU_BUFFER_SIZE]; u8 rbuf[SC_MAX_APDU_BUFFER_SIZE], sbuf[SC_MAX_APDU_BUFFER_SIZE];

View File

@ -35,7 +35,7 @@ static struct sc_asn1_entry c_asn1_des_iv[] = {
}; };
static int 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) const u8 *buf, size_t buflen, int depth)
{ {
struct sc_asn1_entry asn1_des_iv[2]; struct sc_asn1_entry asn1_des_iv[2];
@ -57,7 +57,7 @@ asn1_decode_des_params(struct sc_context *ctx, void **paramp,
} }
static int 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) u8 **buf, size_t *buflen, int depth)
{ {
struct sc_asn1_entry asn1_des_iv[2]; struct sc_asn1_entry asn1_des_iv[2];
@ -77,7 +77,7 @@ static const struct sc_asn1_entry c_asn1_pbkdf2_params[] = {
}; };
static int 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) const u8 *buf, size_t buflen, int depth)
{ {
struct sc_pbkdf2_params info; struct sc_pbkdf2_params info;
@ -110,7 +110,7 @@ asn1_decode_pbkdf2_params(struct sc_context *ctx, void **paramp,
} }
static int 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) u8 **buf, size_t *buflen, int depth)
{ {
struct sc_pbkdf2_params *info; struct sc_pbkdf2_params *info;
@ -140,7 +140,7 @@ static const struct sc_asn1_entry c_asn1_pbes2_params[] = {
}; };
static int 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) const u8 *buf, size_t buflen, int depth)
{ {
struct sc_asn1_entry asn1_pbes2_params[3]; struct sc_asn1_entry asn1_pbes2_params[3];
@ -165,7 +165,7 @@ asn1_decode_pbes2_params(struct sc_context *ctx, void **paramp,
} }
static int 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) u8 **buf, size_t *buflen, int depth)
{ {
struct sc_asn1_entry asn1_pbes2_params[3]; struct sc_asn1_entry asn1_pbes2_params[3];
@ -289,7 +289,7 @@ static const struct sc_asn1_entry c_asn1_alg_id[6] = {
}; };
int 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, size_t len, struct sc_algorithm_id *id,
int depth) int depth)
{ {
@ -321,7 +321,7 @@ sc_asn1_decode_algorithm_id(struct sc_context *ctx, const u8 *in,
} }
int int
sc_asn1_encode_algorithm_id(struct sc_context *ctx, sc_asn1_encode_algorithm_id(sc_context_t *ctx,
u8 **buf, size_t *len, u8 **buf, size_t *len,
const struct sc_algorithm_id *id, const struct sc_algorithm_id *id,
int depth) int depth)

View File

@ -32,7 +32,7 @@
#include <assert.h> #include <assert.h>
static int generate_cache_filename(struct sc_pkcs15_card *p15card, 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 *buf, size_t bufsize)
{ {
char dir[PATH_MAX]; 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, 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) u8 **buf, size_t *bufsize)
{ {
char fname[PATH_MAX]; 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, 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) const u8 *buf, size_t bufsize)
{ {
char fname[PATH_MAX]; char fname[PATH_MAX];

View File

@ -30,7 +30,7 @@
#endif #endif
#include <assert.h> #include <assert.h>
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; int r;
struct sc_algorithm_id pk_alg, sig_alg; 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, struct sc_pkcs15_object *obj,
const u8 ** buf, size_t *buflen) 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_pkcs15_cert_info info;
struct sc_asn1_entry asn1_cred_ident[3], asn1_com_cert_attr[4], struct sc_asn1_entry asn1_cred_ident[3], asn1_com_cert_attr[4],
asn1_x509_cert_attr[2], asn1_type_cert_attr[2], 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; 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, const struct sc_pkcs15_object *obj,
u8 **buf, size_t *bufsize) u8 **buf, size_t *bufsize)
{ {

View File

@ -83,7 +83,7 @@ int sc_pkcs15_decode_dodf_entry(struct sc_pkcs15_card *p15card,
struct sc_pkcs15_object *obj, struct sc_pkcs15_object *obj,
const u8 ** buf, size_t *buflen) 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_pkcs15_data_info info;
struct sc_asn1_entry asn1_com_data_attr[3], struct sc_asn1_entry asn1_com_data_attr[3],
asn1_type_data_attr[2], asn1_type_data_attr[2],
@ -120,7 +120,7 @@ int sc_pkcs15_decode_dodf_entry(struct sc_pkcs15_card *p15card,
return 0; 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, const struct sc_pkcs15_object *obj,
u8 **buf, size_t *bufsize) u8 **buf, size_t *bufsize)
{ {

View File

@ -28,11 +28,11 @@
int sc_pkcs15emu_infocamere_init_ex(sc_pkcs15_card_t *, sc_pkcs15emu_opt_t *); 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) if (tenv.operation == SC_SEC_OPERATION_SIGN)
tenv.operation = SC_SEC_OPERATION_DECIPHER; tenv.operation = SC_SEC_OPERATION_DECIPHER;
return set_security_env(card, &tenv, se_num); 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_card_t *card = p15card->card;
sc_path_t path; sc_path_t path;
struct sc_file *file; sc_file_t *file;
sc_pkcs15_id_t id, auth_id; sc_pkcs15_id_t id, auth_id;
unsigned char buffer[256]; unsigned char buffer[256];
unsigned char ef_gdo[256]; unsigned char ef_gdo[256];

View File

@ -55,7 +55,7 @@ int sc_pkcs15_decode_aodf_entry(struct sc_pkcs15_card *p15card,
struct sc_pkcs15_object *obj, struct sc_pkcs15_object *obj,
const u8 ** buf, size_t *buflen) 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; struct sc_pkcs15_pin_info info;
int r; int r;
size_t flags_len = sizeof(info.flags); size_t flags_len = sizeof(info.flags);
@ -112,7 +112,7 @@ int sc_pkcs15_decode_aodf_entry(struct sc_pkcs15_card *p15card,
return 0; 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, const struct sc_pkcs15_object *obj,
u8 **buf, size_t *buflen) 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) const u8 *pincode, size_t pinlen)
{ {
int r; int r;
struct sc_card *card; sc_card_t *card;
struct sc_pin_cmd_data args; struct sc_pin_cmd_data args;
assert(p15card != NULL); assert(p15card != NULL);
@ -248,7 +248,7 @@ int sc_pkcs15_change_pin(struct sc_pkcs15_card *p15card,
const u8 *newpin, size_t newpinlen) const u8 *newpin, size_t newpinlen)
{ {
int r; int r;
struct sc_card *card; sc_card_t *card;
struct sc_pin_cmd_data data; struct sc_pin_cmd_data data;
size_t max_length; size_t max_length;
@ -327,7 +327,7 @@ int sc_pkcs15_unblock_pin(struct sc_pkcs15_card *p15card,
const u8 *newpin, size_t newpinlen) const u8 *newpin, size_t newpinlen)
{ {
int r; int r;
struct sc_card *card; sc_card_t *card;
struct sc_pin_cmd_data data; struct sc_pin_cmd_data data;
struct sc_pkcs15_object *pin_obj, *puk_obj; struct sc_pkcs15_object *pin_obj, *puk_obj;
struct sc_pkcs15_pin_info *puk_info = NULL; struct sc_pkcs15_pin_info *puk_info = NULL;

View File

@ -28,12 +28,12 @@
int sc_pkcs15emu_postecert_init_ex(sc_pkcs15_card_t *, sc_pkcs15emu_opt_t *); 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) int se_num)
{ {
struct sc_security_env tenv = *env; sc_security_env_t tenv = *env;
if (tenv.operation == SC_SEC_OPERATION_SIGN) if (tenv.operation == SC_SEC_OPERATION_SIGN)
tenv.operation = SC_SEC_OPERATION_DECIPHER; tenv.operation = SC_SEC_OPERATION_DECIPHER;
return set_security_env(card, &tenv, se_num); return set_security_env(card, &tenv, se_num);

View File

@ -83,7 +83,7 @@ int sc_pkcs15_decode_prkdf_entry(struct sc_pkcs15_card *p15card,
struct sc_pkcs15_object *obj, struct sc_pkcs15_object *obj,
const u8 ** buf, size_t *buflen) 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; struct sc_pkcs15_prkey_info info;
int r; int r;
size_t usage_len = sizeof(info.usage); size_t usage_len = sizeof(info.usage);
@ -161,7 +161,7 @@ int sc_pkcs15_decode_prkdf_entry(struct sc_pkcs15_card *p15card,
return 0; 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, const struct sc_pkcs15_object *obj,
u8 **buf, size_t *buflen) u8 **buf, size_t *buflen)
{ {
@ -244,7 +244,7 @@ static const struct sc_asn1_entry c_asn1_dsa_prkey_obj[] = {
}; };
static int 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, struct sc_pkcs15_prkey_dsa *key,
u8 **buf, size_t *buflen) u8 **buf, size_t *buflen)
{ {
@ -258,7 +258,7 @@ sc_pkcs15_encode_prkey_dsa(struct sc_context *ctx,
} }
static int 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, struct sc_pkcs15_prkey_dsa *key,
const u8 *buf, size_t buflen) const u8 *buf, size_t buflen)
{ {
@ -272,7 +272,7 @@ sc_pkcs15_decode_prkey_dsa(struct sc_context *ctx,
} }
int int
sc_pkcs15_encode_prkey(struct sc_context *ctx, sc_pkcs15_encode_prkey(sc_context_t *ctx,
struct sc_pkcs15_prkey *key, struct sc_pkcs15_prkey *key,
u8 **buf, size_t *len) u8 **buf, size_t *len)
{ {
@ -284,7 +284,7 @@ sc_pkcs15_encode_prkey(struct sc_context *ctx,
} }
int int
sc_pkcs15_decode_prkey(struct sc_context *ctx, sc_pkcs15_decode_prkey(sc_context_t *ctx,
struct sc_pkcs15_prkey *key, struct sc_pkcs15_prkey *key,
const u8 *buf, size_t len) const u8 *buf, size_t len)
{ {
@ -301,10 +301,10 @@ sc_pkcs15_read_prkey(struct sc_pkcs15_card *p15card,
const char *passphrase, const char *passphrase,
struct sc_pkcs15_prkey **out) 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_info *info;
struct sc_pkcs15_prkey key; struct sc_pkcs15_prkey key;
struct sc_path path; sc_path_t path;
u8 *data = NULL; u8 *data = NULL;
size_t len; size_t len;
int r; int r;

View File

@ -77,7 +77,7 @@ int sc_pkcs15_decode_pukdf_entry(struct sc_pkcs15_card *p15card,
struct sc_pkcs15_object *obj, struct sc_pkcs15_object *obj,
const u8 ** buf, size_t *buflen) 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; struct sc_pkcs15_pubkey_info info;
int r; int r;
size_t usage_len = sizeof(info.usage); size_t usage_len = sizeof(info.usage);
@ -142,7 +142,7 @@ int sc_pkcs15_decode_pukdf_entry(struct sc_pkcs15_card *p15card,
return 0; 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, const struct sc_pkcs15_object *obj,
u8 **buf, size_t *buflen) u8 **buf, size_t *buflen)
{ {
@ -232,7 +232,7 @@ static struct sc_asn1_entry c_asn1_dsa_pub_coefficients[5] = {
}; };
int 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, struct sc_pkcs15_pubkey_rsa *key,
const u8 *buf, size_t buflen) const u8 *buf, size_t buflen)
{ {
@ -256,7 +256,7 @@ sc_pkcs15_decode_pubkey_rsa(struct sc_context *ctx,
} }
int 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, struct sc_pkcs15_pubkey_rsa *key,
u8 **buf, size_t *buflen) u8 **buf, size_t *buflen)
{ {
@ -280,7 +280,7 @@ sc_pkcs15_encode_pubkey_rsa(struct sc_context *ctx,
} }
int 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, struct sc_pkcs15_pubkey_dsa *key,
const u8 *buf, size_t buflen) const u8 *buf, size_t buflen)
{ {
@ -309,7 +309,7 @@ sc_pkcs15_decode_pubkey_dsa(struct sc_context *ctx,
} }
int 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, struct sc_pkcs15_pubkey_dsa *key,
u8 **buf, size_t *buflen) u8 **buf, size_t *buflen)
{ {
@ -337,7 +337,7 @@ sc_pkcs15_encode_pubkey_dsa(struct sc_context *ctx,
} }
int int
sc_pkcs15_encode_pubkey(struct sc_context *ctx, sc_pkcs15_encode_pubkey(sc_context_t *ctx,
struct sc_pkcs15_pubkey *key, struct sc_pkcs15_pubkey *key,
u8 **buf, size_t *len) u8 **buf, size_t *len)
{ {
@ -351,7 +351,7 @@ sc_pkcs15_encode_pubkey(struct sc_context *ctx,
} }
int int
sc_pkcs15_decode_pubkey(struct sc_context *ctx, sc_pkcs15_decode_pubkey(sc_context_t *ctx,
struct sc_pkcs15_pubkey *key, struct sc_pkcs15_pubkey *key,
const u8 *buf, size_t len) const u8 *buf, size_t len)
{ {

View File

@ -30,9 +30,9 @@
static int select_key_file(struct sc_pkcs15_card *p15card, static int select_key_file(struct sc_pkcs15_card *p15card,
const struct sc_pkcs15_prkey_info *prkey, 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; int r;
if (prkey->path.len < 2) 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) const u8 * in, size_t inlen, u8 *out, size_t outlen)
{ {
int r; int r;
struct sc_algorithm_info *alg_info; sc_algorithm_info_t *alg_info;
struct sc_security_env senv; sc_security_env_t senv;
struct sc_context *ctx = p15card->card->ctx; sc_context_t *ctx = p15card->card->ctx;
const struct sc_pkcs15_prkey_info *prkey = (const struct sc_pkcs15_prkey_info *) obj->data; const struct sc_pkcs15_prkey_info *prkey = (const struct sc_pkcs15_prkey_info *) obj->data;
unsigned long pad_flags = 0; unsigned long pad_flags = 0;
@ -151,9 +151,9 @@ int sc_pkcs15_compute_signature(struct sc_pkcs15_card *p15card,
u8 *out, size_t outlen) u8 *out, size_t outlen)
{ {
int r; int r;
struct sc_security_env senv; sc_security_env_t senv;
struct sc_context *ctx = p15card->card->ctx; sc_context_t *ctx = p15card->card->ctx;
struct sc_algorithm_info *alg_info; sc_algorithm_info_t *alg_info;
const struct sc_pkcs15_prkey_info *prkey = (const struct sc_pkcs15_prkey_info *) obj->data; const struct sc_pkcs15_prkey_info *prkey = (const struct sc_pkcs15_prkey_info *) obj->data;
u8 buf[512], *tmpin, *tmpout, *help; u8 buf[512], *tmpin, *tmpout, *help;
size_t tmpoutlen; size_t tmpoutlen;

View File

@ -153,10 +153,10 @@ static int sc_pkcs15emu_starcert_init(sc_pkcs15_card_t *p15card)
int r, i; int r, i;
char buf[256]; char buf[256];
struct sc_path path; sc_path_t path;
struct sc_file *file = NULL; sc_file_t *file = NULL;
struct sc_card *card = p15card->card; sc_card_t *card = p15card->card;
struct sc_serial_number serial; sc_serial_number_t serial;
/* get serial number */ /* get serial number */
r = sc_card_ctl(card, SC_CARDCTL_GET_SERIALNR, &serial); r = sc_card_ctl(card, SC_CARDCTL_GET_SERIALNR, &serial);

View File

@ -42,7 +42,7 @@
#ifndef HAVE_OPENSSL #ifndef HAVE_OPENSSL
int int
sc_pkcs15_wrap_data(struct sc_context *ctx, sc_pkcs15_wrap_data(sc_context_t *ctx,
const char *passphrase, const char *passphrase,
const u8 *in, size_t in_len, const u8 *in, size_t in_len,
u8 **out, size_t *out_len) u8 **out, size_t *out_len)
@ -51,7 +51,7 @@ sc_pkcs15_wrap_data(struct sc_context *ctx,
} }
int int
sc_pkcs15_unwrap_data(struct sc_context *ctx, sc_pkcs15_unwrap_data(sc_context_t *ctx,
const char *passphrase, const char *passphrase,
const u8 *in, size_t in_len, const u8 *in, size_t in_len,
u8 **out, size_t *out_len) u8 **out, size_t *out_len)
@ -62,7 +62,7 @@ sc_pkcs15_unwrap_data(struct sc_context *ctx,
#else /* HAVE_OPENSSL */ #else /* HAVE_OPENSSL */
static int 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 *der_alg,
const struct sc_algorithm_id *enc_alg, const struct sc_algorithm_id *enc_alg,
const char *passphrase, const char *passphrase,
@ -120,7 +120,7 @@ sc_pkcs15_derive_key(struct sc_context *ctx,
} }
static int 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, const u8 *in, size_t in_len,
u8 **out, size_t *out_len) u8 **out, size_t *out_len)
{ {
@ -156,7 +156,7 @@ fail: free(p);
} }
int int
sc_pkcs15_wrap_data(struct sc_context *ctx, sc_pkcs15_wrap_data(sc_context_t *ctx,
const char *passphrase, const char *passphrase,
const u8 *in, size_t in_len, const u8 *in, size_t in_len,
u8 **out, size_t *out_len) u8 **out, size_t *out_len)
@ -201,7 +201,7 @@ sc_pkcs15_wrap_data(struct sc_context *ctx,
int int
sc_pkcs15_unwrap_data(struct sc_context *ctx, sc_pkcs15_unwrap_data(sc_context_t *ctx,
const char *passphrase, const char *passphrase,
const u8 *in, size_t in_len, const u8 *in, size_t in_len,
u8 **out, size_t *out_len) u8 **out, size_t *out_len)
@ -285,7 +285,7 @@ static const struct sc_asn1_entry c_asn1_kek_attr[] = {
}; };
int 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, struct sc_pkcs15_enveloped_data *result,
const u8 *buf, size_t buflen) const u8 *buf, size_t buflen)
{ {
@ -338,7 +338,7 @@ sc_pkcs15_decode_enveloped_data(struct sc_context *ctx,
} }
int 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, struct sc_pkcs15_enveloped_data *data,
u8 **buf, size_t *buflen) u8 **buf, size_t *buflen)
{ {

View File

@ -108,7 +108,7 @@ err:
return; return;
} }
int sc_pkcs15_encode_tokeninfo(struct sc_context *ctx, int sc_pkcs15_encode_tokeninfo(sc_context_t *ctx,
struct sc_pkcs15_card *card, struct sc_pkcs15_card *card,
u8 **buf, size_t *buflen) 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) static int parse_ddo(struct sc_pkcs15_card *p15card, const u8 * buf, size_t buflen)
{ {
struct sc_asn1_entry asn1_ddo[5]; struct sc_asn1_entry asn1_ddo[5];
struct sc_path odf_path, ti_path; sc_path_t odf_path, ti_path;
int r; int r;
sc_copy_asn1_entry(c_asn1_ddo, asn1_ddo); 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 #endif
#if 0 #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; sc_path_t path;
struct sc_file file; sc_file_t file;
u8 *buf; u8 *buf;
size_t bufsize; size_t bufsize;
int r, i; 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; const u8 *p = buf;
size_t left = buflen; size_t left = buflen;
int r, i; int r, i;
struct sc_path path; sc_path_t path;
struct sc_asn1_entry asn1_obj_or_path[] = { struct sc_asn1_entry asn1_obj_or_path[] = {
{ "path", SC_ASN1_PATH, SC_ASN1_CONS | SC_ASN1_SEQUENCE, 0, &path }, { "path", SC_ASN1_PATH, SC_ASN1_CONS | SC_ASN1_SEQUENCE, 0, &path },
{ NULL } { NULL }
@ -326,11 +326,11 @@ static int parse_odf(const u8 * buf, size_t buflen, struct sc_pkcs15_card *card)
return 0; 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, struct sc_pkcs15_card *p15card,
u8 **buf, size_t *buflen) u8 **buf, size_t *buflen)
{ {
struct sc_path path; sc_path_t path;
struct sc_asn1_entry asn1_obj_or_path[] = { struct sc_asn1_entry asn1_obj_or_path[] = {
{ "path", SC_ASN1_PATH, SC_ASN1_CONS | SC_ASN1_SEQUENCE, 0, &path }, { "path", SC_ASN1_PATH, SC_ASN1_CONS | SC_ASN1_SEQUENCE, 0, &path },
{ NULL } { NULL }
@ -469,9 +469,9 @@ static int sc_pkcs15_bind_internal(sc_pkcs15_card_t *p15card)
unsigned char buf[SC_MAX_APDU_BUFFER_SIZE]; unsigned char buf[SC_MAX_APDU_BUFFER_SIZE];
int err, ok = 0; int err, ok = 0;
size_t len; size_t len;
struct sc_path tmppath; sc_path_t tmppath;
struct sc_card *card = p15card->card; sc_card_t *card = p15card->card;
struct sc_context *ctx = card->ctx; sc_context_t *ctx = card->ctx;
if (ctx->debug > 4) if (ctx->debug > 4)
sc_debug(ctx, "trying normal pkcs15 processing\n"); 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); sc_format_path("3F005015", &p15card->file_app->path);
if (card->app_count > 0) { if (card->app_count > 0) {
const struct sc_app_info *info; const sc_app_info_t *info;
info = sc_find_pkcs15_app(card); info = sc_find_pkcs15_app(card);
if (info != NULL) { if (info != NULL) {
@ -594,11 +594,11 @@ end:
return SC_SUCCESS; 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_out)
{ {
struct sc_pkcs15_card *p15card = NULL; struct sc_pkcs15_card *p15card = NULL;
struct sc_context *ctx; sc_context_t *ctx;
scconf_block *conf_block = NULL, **blocks; scconf_block *conf_block = NULL, **blocks;
int i, r, emu_first, enable_emu; int i, r, emu_first, enable_emu;
@ -661,10 +661,10 @@ error:
} }
#if 0 #if 0
int sc_pkcs15_detect(struct sc_card *card) int sc_pkcs15_detect(sc_card_t *card)
{ {
int r; int r;
struct sc_path path; sc_path_t path;
sc_format_path("NA0000063504B43532D3135", &path); sc_format_path("NA0000063504B43532D3135", &path);
r = sc_select_file(card, &path, NULL); r = sc_select_file(card, &path, NULL);
@ -1119,7 +1119,7 @@ void sc_pkcs15_remove_df(struct sc_pkcs15_card *p15card,
free(obj); 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_card *p15card,
struct sc_pkcs15_df *df, struct sc_pkcs15_df *df,
u8 **buf_out, size_t *bufsize_out) 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; u8 *buf = NULL, *tmp = NULL;
size_t bufsize = 0, tmpsize; size_t bufsize = 0, tmpsize;
const struct sc_pkcs15_object *obj; 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; u8 **nbuf, size_t *nbufsize) = NULL;
int r; 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, int sc_pkcs15_parse_df(struct sc_pkcs15_card *p15card,
struct sc_pkcs15_df *df) struct sc_pkcs15_df *df)
{ {
struct sc_context *ctx = p15card->card->ctx; sc_context_t *ctx = p15card->card->ctx;
u8 *buf; u8 *buf;
const u8 *p; const u8 *p;
size_t bufsize; size_t bufsize;
@ -1269,12 +1269,12 @@ ret:
} }
int sc_pkcs15_read_file(struct sc_pkcs15_card *p15card, 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, u8 **buf, size_t *buflen,
struct sc_file **file_out) sc_file_t **file_out)
{ {
struct sc_file *file = NULL; sc_file_t *file = NULL;
struct sc_path tmp_path, *path = &tmp_path; sc_path_t tmp_path, *path = &tmp_path;
u8 *data = NULL; u8 *data = NULL;
size_t len = 0, offset = 0; size_t len = 0, offset = 0;
int r = -1; 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) { if (in_path->type == SC_PATH_TYPE_FILE_ID) {
/* in case of a FID prepend the application DF */ /* 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); sc_append_path(path, in_path);
path->index = in_path->index; path->index = in_path->index;
path->count = in_path->count; path->count = in_path->count;
} else { } else {
memcpy(path, in_path, sizeof(struct sc_path)); memcpy(path, in_path, sizeof(sc_path_t));
} }
if (p15card->opts.use_cache) { if (p15card->opts.use_cache) {

View File

@ -79,7 +79,7 @@ struct ctapi_slot_data {
}; };
/* Reset slot or reader */ /* 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); struct ctapi_private_data *priv = GET_PRIV_DATA(reader);
char rv; char rv;
@ -107,7 +107,7 @@ static int ctapi_reset(struct sc_reader *reader, struct sc_slot_info *slot)
return 0; return 0;
} }
static void set_default_fu(struct sc_reader *reader) static void set_default_fu(sc_reader_t *reader)
{ {
if (!reader) return; 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 /* 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) */ (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); struct ctapi_private_data *priv = GET_PRIV_DATA(reader);
char rv; char rv;
@ -237,8 +237,8 @@ static void detect_functional_units(struct sc_reader *reader)
} }
} }
static int refresh_slot_attributes(struct sc_reader *reader, static int refresh_slot_attributes(sc_reader_t *reader,
struct sc_slot_info *slot) sc_slot_info_t *slot)
{ {
struct ctapi_private_data *priv = GET_PRIV_DATA(reader); struct ctapi_private_data *priv = GET_PRIV_DATA(reader);
char rv; char rv;
@ -286,7 +286,7 @@ static int refresh_slot_attributes(struct sc_reader *reader,
return 0; 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, const u8 *sendbuf, size_t sendsize,
u8 *recvbuf, size_t *recvsize, u8 *recvbuf, size_t *recvsize,
unsigned long control) unsigned long control)
@ -315,7 +315,7 @@ static int ctapi_transmit(struct sc_reader *reader, struct sc_slot_info *slot,
return 0; 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; int r;
@ -325,7 +325,7 @@ static int ctapi_detect_card_presence(struct sc_reader *reader, struct sc_slot_i
return slot->flags; 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); struct ctapi_private_data *priv = GET_PRIV_DATA(reader);
char rv; char rv;
@ -379,23 +379,23 @@ static int ctapi_connect(struct sc_reader *reader, struct sc_slot_info *slot)
return 0; 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) int action)
{ {
return 0; 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; 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; 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); 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]; 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, struct ctapi_global_private_data *gpriv,
scconf_block *conf) scconf_block *conf)
{ {
@ -467,7 +467,7 @@ static int ctapi_load_module(struct sc_context *ctx,
int port; int port;
char namebuf[128]; char namebuf[128];
char rv; char rv;
struct sc_reader *reader; sc_reader_t *reader;
struct ctapi_private_data *priv; struct ctapi_private_data *priv;
if (sscanf(list->data, "%d", &port) != 1) { 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); sc_error(ctx, "CT_init() failed with %d\n", rv);
continue; 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)); priv = (struct ctapi_private_data *) malloc(sizeof(struct ctapi_private_data));
memset(reader, 0, sizeof(*reader)); memset(reader, 0, sizeof(*reader));
reader->drv_data = priv; reader->drv_data = priv;
@ -514,7 +514,7 @@ symerr:
return -1; 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; int i;
struct ctapi_global_private_data *gpriv; struct ctapi_global_private_data *gpriv;
@ -544,7 +544,7 @@ static int ctapi_init(struct sc_context *ctx, void **reader_data)
return 0; 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; struct ctapi_global_private_data *priv = (struct ctapi_global_private_data *) prv_data;

View File

@ -32,28 +32,28 @@
#define PREALLOCATE 5 #define PREALLOCATE 5
/* function declarations */ /* function declarations */
static int openct_reader_init(struct sc_context *ctx, void **priv_data); static int openct_reader_init(sc_context_t *ctx, void **priv_data);
static int openct_add_reader(struct sc_context *ctx, unsigned int num, ct_info_t *info); static int openct_add_reader(sc_context_t *ctx, unsigned int num, ct_info_t *info);
static int openct_reader_finish(struct sc_context *ctx, void *priv_data); static int openct_reader_finish(sc_context_t *ctx, void *priv_data);
static int openct_reader_release(struct sc_reader *reader); static int openct_reader_release(sc_reader_t *reader);
static int openct_reader_detect_card_presence(struct sc_reader *reader, static int openct_reader_detect_card_presence(sc_reader_t *reader,
struct sc_slot_info *slot); sc_slot_info_t *slot);
static int openct_reader_connect(struct sc_reader *reader, static int openct_reader_connect(sc_reader_t *reader,
struct sc_slot_info *slot); sc_slot_info_t *slot);
static int openct_reader_disconnect(struct sc_reader *reader, static int openct_reader_disconnect(sc_reader_t *reader,
struct sc_slot_info *slot, int action); sc_slot_info_t *slot, int action);
static int openct_reader_transmit(struct sc_reader *reader, static int openct_reader_transmit(sc_reader_t *reader,
struct sc_slot_info *slot, sc_slot_info_t *slot,
const u8 *sendbuf, size_t sendsize, const u8 *sendbuf, size_t sendsize,
u8 *recvbuf, size_t *recvsize, unsigned long control); u8 *recvbuf, size_t *recvsize, unsigned long control);
static int openct_reader_perform_verify(struct sc_reader *reader, static int openct_reader_perform_verify(sc_reader_t *reader,
struct sc_slot_info *slot, sc_slot_info_t *slot,
struct sc_pin_cmd_data *info); struct sc_pin_cmd_data *info);
static int openct_reader_lock(struct sc_reader *reader, static int openct_reader_lock(sc_reader_t *reader,
struct sc_slot_info *slot); sc_slot_info_t *slot);
static int openct_reader_unlock(struct sc_reader *reader, static int openct_reader_unlock(sc_reader_t *reader,
struct sc_slot_info *slot); sc_slot_info_t *slot);
static int openct_error(struct sc_reader *, int); static int openct_error(sc_reader_t *, int);
static struct sc_reader_operations openct_ops; static struct sc_reader_operations openct_ops;
@ -82,7 +82,7 @@ struct slot_data {
* is loaded * is loaded
*/ */
static int 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; unsigned int i;
@ -101,7 +101,7 @@ openct_reader_init(struct sc_context *ctx, void **priv_data)
} }
static int 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; sc_reader_t *reader;
struct driver_data *data; 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. * deallocate the private data and any resources.
*/ */
int 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); SC_FUNC_CALLED(ctx, 1);
return SC_NO_ERROR; return SC_NO_ERROR;
@ -164,7 +164,7 @@ openct_reader_finish(struct sc_context *ctx, void *priv_data)
* freed by OpenSC. * freed by OpenSC.
*/ */
int 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; 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 * Check whether a card was added/removed
*/ */
int int
openct_reader_detect_card_presence(struct sc_reader *reader, openct_reader_detect_card_presence(sc_reader_t *reader,
struct sc_slot_info *slot) sc_slot_info_t *slot)
{ {
struct driver_data *data = (struct driver_data *) reader->drv_data; struct driver_data *data = (struct driver_data *) reader->drv_data;
int rc, status; int rc, status;
@ -208,8 +208,8 @@ openct_reader_detect_card_presence(struct sc_reader *reader,
} }
static int static int
openct_reader_connect(struct sc_reader *reader, openct_reader_connect(sc_reader_t *reader,
struct sc_slot_info *slot) sc_slot_info_t *slot)
{ {
struct driver_data *data = (struct driver_data *) reader->drv_data; struct driver_data *data = (struct driver_data *) reader->drv_data;
int rc; int rc;
@ -243,8 +243,8 @@ openct_reader_connect(struct sc_reader *reader,
} }
static int static int
openct_reader_reconnect(struct sc_reader *reader, openct_reader_reconnect(sc_reader_t *reader,
struct sc_slot_info *slot) sc_slot_info_t *slot)
{ {
struct driver_data *data = (struct driver_data *) reader->drv_data; struct driver_data *data = (struct driver_data *) reader->drv_data;
int rc; int rc;
@ -258,8 +258,8 @@ openct_reader_reconnect(struct sc_reader *reader,
} }
int int
openct_reader_disconnect(struct sc_reader *reader, openct_reader_disconnect(sc_reader_t *reader,
struct sc_slot_info *slot, int action) sc_slot_info_t *slot, int action)
{ {
struct driver_data *data = (struct driver_data *) reader->drv_data; struct driver_data *data = (struct driver_data *) reader->drv_data;
@ -271,8 +271,8 @@ openct_reader_disconnect(struct sc_reader *reader,
} }
int int
openct_reader_transmit(struct sc_reader *reader, openct_reader_transmit(sc_reader_t *reader,
struct sc_slot_info *slot, sc_slot_info_t *slot,
const u8 *sendbuf, size_t sendsize, const u8 *sendbuf, size_t sendsize,
u8 *recvbuf, size_t *recvsize, unsigned long control) u8 *recvbuf, size_t *recvsize, unsigned long control)
{ {
@ -300,8 +300,8 @@ openct_reader_transmit(struct sc_reader *reader,
} }
int int
openct_reader_perform_verify(struct sc_reader *reader, openct_reader_perform_verify(sc_reader_t *reader,
struct sc_slot_info *slot, sc_slot_info_t *slot,
struct sc_pin_cmd_data *info) struct sc_pin_cmd_data *info)
{ {
struct driver_data *data = (struct driver_data *) reader->drv_data; struct driver_data *data = (struct driver_data *) reader->drv_data;
@ -363,8 +363,8 @@ openct_reader_perform_verify(struct sc_reader *reader,
int int
openct_reader_lock(struct sc_reader *reader, openct_reader_lock(sc_reader_t *reader,
struct sc_slot_info *slot) sc_slot_info_t *slot)
{ {
struct driver_data *data = (struct driver_data *) reader->drv_data; struct driver_data *data = (struct driver_data *) reader->drv_data;
struct slot_data *slot_data = (struct slot_data *) slot->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 int
openct_reader_unlock(struct sc_reader *reader, openct_reader_unlock(sc_reader_t *reader,
struct sc_slot_info *slot) sc_slot_info_t *slot)
{ {
struct driver_data *data = (struct driver_data *) reader->drv_data; struct driver_data *data = (struct driver_data *) reader->drv_data;
struct slot_data *slot_data = (struct slot_data *) slot->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 * Handle an error code returned by OpenCT
*/ */
int int
openct_error(struct sc_reader *reader, int code) openct_error(sc_reader_t *reader, int code)
{ {
if (code >= 0) if (code >= 0)
return code; return code;

View File

@ -77,7 +77,7 @@ struct pcsc_slot_data {
SCARD_READERSTATE_A reader_state; 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) 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, const u8 *sendbuf, size_t sendsize,
u8 *recvbuf, size_t *recvsize, u8 *recvbuf, size_t *recvsize,
unsigned long control) unsigned long control)
@ -187,7 +187,7 @@ static int pcsc_transmit(struct sc_reader *reader, struct sc_slot_info *slot,
return 0; 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_private_data *priv = GET_PRIV_DATA(reader);
struct pcsc_slot_data *pslot = GET_SLOT_DATA(slot); 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; 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; 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 * This function ignores the list of slots, because with
* pcsc we have a 1:1 mapping of readers and slots anyway * pcsc we have a 1:1 mapping of readers and slots anyway
*/ */
static int pcsc_wait_for_event(struct sc_reader **readers, static int pcsc_wait_for_event(sc_reader_t **readers,
struct sc_slot_info **slots, sc_slot_info_t **slots,
size_t nslots, size_t nslots,
unsigned int event_mask, unsigned int event_mask,
int *reader, int *reader,
unsigned int *event, int timeout) unsigned int *event, int timeout)
{ {
struct sc_context *ctx; sc_context_t *ctx;
SCARDCONTEXT pcsc_ctx; SCARDCONTEXT pcsc_ctx;
LONG ret; LONG ret;
SCARD_READERSTATE_A rgReaderStates[SC_MAX_READERS]; 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; DWORD active_proto, protocol;
SCARDHANDLE card_handle; SCARDHANDLE card_handle;
@ -444,7 +444,7 @@ static int pcsc_connect(struct sc_reader *reader, struct sc_slot_info *slot)
return 0; 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) int action)
{ {
struct pcsc_slot_data *pslot = GET_SLOT_DATA(slot); 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; 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; long rv;
struct pcsc_slot_data *pslot = GET_SLOT_DATA(slot); 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; 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; long rv;
struct pcsc_slot_data *pslot = GET_SLOT_DATA(slot); 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; return 0;
} }
static int pcsc_release(struct sc_reader *reader) static int pcsc_release(sc_reader_t *reader)
{ {
int i; int i;
struct pcsc_private_data *priv = GET_PRIV_DATA(reader); struct pcsc_private_data *priv = GET_PRIV_DATA(reader);
@ -508,7 +508,7 @@ static struct sc_reader_driver pcsc_drv = {
&pcsc_ops &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; LONG rv;
DWORD reader_buf_size; DWORD reader_buf_size;
@ -554,10 +554,10 @@ static int pcsc_init(struct sc_context *ctx, void **reader_data)
} }
p = reader_buf; p = reader_buf;
do { 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_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 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 == NULL || priv == NULL || pslot == NULL) {
if (reader) if (reader)
@ -600,7 +600,7 @@ static int pcsc_init(struct sc_context *ctx, void **reader_data)
return 0; 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; 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 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 */ /* XXX: temporary */
if (slot->capabilities & SC_SLOT_CAP_PIN_PAD) { if (slot->capabilities & SC_SLOT_CAP_PIN_PAD) {

View File

@ -102,7 +102,7 @@ int sc_bin_to_hex(const u8 *in, size_t in_len, char *out, size_t out_len,
return 0; 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); assert(reader != NULL);
if (slot_id < 0 || slot_id > reader->slot_count) 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]; 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; 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) if (slot == NULL)
SC_FUNC_RETURN(reader->ctx, 0, SC_ERROR_SLOT_NOT_FOUND); 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); 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, unsigned int event_mask,
int *reader, unsigned int *event, int timeout) int *reader, unsigned int *event, int timeout)
{ {
struct sc_slot_info *slotp[SC_MAX_SLOTS * SC_MAX_READERS]; sc_slot_info_t *slotp[SC_MAX_SLOTS * SC_MAX_READERS];
struct sc_context *ctx; sc_context_t *ctx;
unsigned int j; unsigned int j;
int r; 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); 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; int type = SC_PATH_TYPE_PATH;
@ -173,7 +173,7 @@ void sc_format_path(const char *str, struct sc_path *path)
return; 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); assert(dest != NULL && src != NULL);
if (dest->len + src->len > SC_MAX_PATH_SIZE) 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; 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) if (dest->len + idlen > SC_MAX_PATH_SIZE)
return SC_ERROR_INVALID_ARGUMENTS; 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; 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 }; 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); && !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) unsigned int method, unsigned long key_ref)
{ {
struct sc_acl_entry *p, *_new; sc_acl_entry_t *p, *_new;
assert(file != NULL); assert(file != NULL);
assert(operation < SC_MAX_AC_OPS); 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) { switch (method) {
case SC_AC_NEVER: case SC_AC_NEVER:
sc_file_clear_acl_entries(file, operation); 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; return 0;
case SC_AC_NONE: case SC_AC_NONE:
sc_file_clear_acl_entries(file, operation); 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; return 0;
case SC_AC_UNKNOWN: case SC_AC_UNKNOWN:
sc_file_clear_acl_entries(file, operation); 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; return 0;
default: default:
/* NONE and UNKNOWN get zapped when a new AC is added. /* NONE and UNKNOWN get zapped when a new AC is added.
* If the ACL is NEVER, additional entries will be * If the ACL is NEVER, additional entries will be
* dropped silently. */ * dropped silently. */
if (file->acl[operation] == (struct sc_acl_entry *) 1) if (file->acl[operation] == (sc_acl_entry_t *) 1)
return 0; return 0;
if (file->acl[operation] == (struct sc_acl_entry *) 2 if (file->acl[operation] == (sc_acl_entry_t *) 2
|| file->acl[operation] == (struct sc_acl_entry *) 3) || file->acl[operation] == (sc_acl_entry_t *) 3)
file->acl[operation] = NULL; 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) if (_new == NULL)
return SC_ERROR_OUT_OF_MEMORY; return SC_ERROR_OUT_OF_MEMORY;
_new->method = method; _new->method = method;
@ -270,17 +270,17 @@ int sc_file_add_acl_entry(struct sc_file *file, unsigned int operation,
return 0; 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) unsigned int operation)
{ {
struct sc_acl_entry *p; sc_acl_entry_t *p;
static const struct sc_acl_entry e_never = { static const sc_acl_entry_t e_never = {
SC_AC_NEVER, SC_AC_KEY_REF_NONE, NULL 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 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 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); assert(operation < SC_MAX_AC_OPS);
p = file->acl[operation]; p = file->acl[operation];
if (p == (struct sc_acl_entry *) 1) if (p == (sc_acl_entry_t *) 1)
return &e_never; return &e_never;
if (p == (struct sc_acl_entry *) 2) if (p == (sc_acl_entry_t *) 2)
return &e_none; return &e_none;
if (p == (struct sc_acl_entry *) 3) if (p == (sc_acl_entry_t *) 3)
return &e_unknown; return &e_unknown;
return file->acl[operation]; 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(file != NULL);
assert(operation < SC_MAX_AC_OPS); assert(operation < SC_MAX_AC_OPS);
e = file->acl[operation]; e = file->acl[operation];
if (e == (struct sc_acl_entry *) 1 || if (e == (sc_acl_entry_t *) 1 ||
e == (struct sc_acl_entry *) 2 || e == (sc_acl_entry_t *) 2 ||
e == (struct sc_acl_entry *) 3) { e == (sc_acl_entry_t *) 3) {
file->acl[operation] = NULL; file->acl[operation] = NULL;
return; return;
} }
while (e != NULL) { while (e != NULL) {
struct sc_acl_entry *tmp = e->next; sc_acl_entry_t *tmp = e->next;
free(e); free(e);
e = tmp; e = tmp;
} }
file->acl[operation] = NULL; 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) if (file == NULL)
return NULL; return NULL;
memset(file, 0, sizeof(struct sc_file)); memset(file, 0, sizeof(sc_file_t));
file->magic = SC_FILE_MAGIC; file->magic = SC_FILE_MAGIC;
return file; return file;
} }
void sc_file_free(struct sc_file *file) void sc_file_free(sc_file_t *file)
{ {
unsigned int i; unsigned int i;
assert(sc_file_valid(file)); assert(sc_file_valid(file));
@ -348,10 +348,10 @@ void sc_file_free(struct sc_file *file)
free(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; sc_file_t *newf;
const struct sc_acl_entry *e; const sc_acl_entry_t *e;
unsigned int op; unsigned int op;
assert(sc_file_valid(src)); 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) size_t sec_attr_len)
{ {
u8 *tmp; u8 *tmp;
@ -398,7 +398,7 @@ int sc_file_set_sec_attr(struct sc_file *file, const u8 *sec_attr,
return 0; 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) size_t prop_attr_len)
{ {
u8 *tmp; u8 *tmp;
@ -426,7 +426,7 @@ int sc_file_set_prop_attr(struct sc_file *file, const u8 *prop_attr,
return 0; 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) size_t type_attr_len)
{ {
u8 *tmp; u8 *tmp;
@ -454,14 +454,14 @@ int sc_file_set_type_attr(struct sc_file *file, const u8 *type_attr,
return 0; return 0;
} }
inline int sc_file_valid(const struct sc_file *file) { inline int sc_file_valid(const sc_file_t *file) {
#ifndef NDEBUG #ifndef NDEBUG
assert(file != NULL); assert(file != NULL);
#endif #endif
return file->magic == SC_FILE_MAGIC; 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; u8 *p = slot->atr;
int atr_len = (int) slot->atr_len; int atr_len = (int) slot->atr_len;

View File

@ -26,7 +26,7 @@
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
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) const u8 * crgram, size_t crgram_len, u8 * out, size_t outlen)
{ {
int r; int r;
@ -39,7 +39,7 @@ int sc_decipher(struct sc_card *card,
SC_FUNC_RETURN(card->ctx, 2, r); 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, const u8 * data, size_t datalen,
u8 * out, size_t outlen) u8 * out, size_t outlen)
{ {
@ -53,8 +53,8 @@ int sc_compute_signature(struct sc_card *card,
SC_FUNC_RETURN(card->ctx, 2, r); SC_FUNC_RETURN(card->ctx, 2, r);
} }
int sc_set_security_env(struct sc_card *card, int sc_set_security_env(sc_card_t *card,
const struct sc_security_env *env, const sc_security_env_t *env,
int se_num) int se_num)
{ {
int r; int r;
@ -67,7 +67,7 @@ int sc_set_security_env(struct sc_card *card,
SC_FUNC_RETURN(card->ctx, 2, r); 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; 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); 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) const u8 *pin, size_t pinlen, int *tries_left)
{ {
struct sc_pin_cmd_data data; 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); return sc_pin_cmd(card, &data, tries_left);
} }
int sc_logout(struct sc_card *card) int sc_logout(sc_card_t *card)
{ {
int r; int r;
if (card->ops->logout == NULL) if (card->ops->logout == NULL)
@ -104,7 +104,7 @@ int sc_logout(struct sc_card *card)
SC_FUNC_RETURN(card->ctx, 2, r); 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, int ref, const u8 *old, size_t oldlen,
const u8 *newref, size_t newlen, const u8 *newref, size_t newlen,
int *tries_left) 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); 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, const u8 *puk, size_t puklen, const u8 *newref,
size_t newlen) 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 * 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 * 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 *tries_left)
{ {
int r; int r;