libopensc: use 'struct sc_aid' instead of 'u8 *aid, size_t aid_len'
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5048 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
0611b6260f
commit
0761a61a65
|
@ -855,11 +855,11 @@ static int asn1_decode_se_info(sc_context_t *ctx, const u8 *obj, size_t objlen,
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
si->aid_len = sizeof(si->aid);
|
si->aid.len = sizeof(si->aid.value);
|
||||||
sc_copy_asn1_entry(c_asn1_se_info, asn1_se_info);
|
sc_copy_asn1_entry(c_asn1_se_info, asn1_se_info);
|
||||||
sc_format_asn1_entry(asn1_se_info + 0, &si->se, NULL, 0);
|
sc_format_asn1_entry(asn1_se_info + 0, &si->se, NULL, 0);
|
||||||
sc_format_asn1_entry(asn1_se_info + 1, &si->owner, NULL, 0);
|
sc_format_asn1_entry(asn1_se_info + 1, &si->owner, NULL, 0);
|
||||||
sc_format_asn1_entry(asn1_se_info + 2, &si->aid, &si->aid_len, 0);
|
sc_format_asn1_entry(asn1_se_info + 2, &si->aid.value, &si->aid.len, 0);
|
||||||
ret = asn1_decode(ctx, asn1_se_info, p, plen, &p, &plen, 0, depth+1);
|
ret = asn1_decode(ctx, asn1_se_info, p, plen, &p, &plen, 0, depth+1);
|
||||||
if (ret != SC_SUCCESS) {
|
if (ret != SC_SUCCESS) {
|
||||||
free(si);
|
free(si);
|
||||||
|
|
|
@ -59,7 +59,7 @@ static int parse_dir_record(sc_card_t *card, u8 ** buf, size_t *buflen,
|
||||||
sc_app_info_t *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[SC_MAX_AID_SIZE], label[128], path[128];
|
||||||
u8 ddo[128];
|
u8 ddo[128];
|
||||||
size_t aid_len = sizeof(aid), label_len = sizeof(label),
|
size_t aid_len = sizeof(aid), label_len = sizeof(label),
|
||||||
path_len = sizeof(path), ddo_len = sizeof(ddo);
|
path_len = sizeof(path), ddo_len = sizeof(ddo);
|
||||||
|
@ -88,8 +88,8 @@ static int parse_dir_record(sc_card_t *card, u8 ** buf, size_t *buflen,
|
||||||
if (app == NULL)
|
if (app == NULL)
|
||||||
return SC_ERROR_OUT_OF_MEMORY;
|
return SC_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
memcpy(app->aid, aid, aid_len);
|
memcpy(app->aid.value, aid, aid_len);
|
||||||
app->aid_len = aid_len;
|
app->aid.len = aid_len;
|
||||||
if (asn1_dirrecord[1].flags & SC_ASN1_PRESENT)
|
if (asn1_dirrecord[1].flags & SC_ASN1_PRESENT)
|
||||||
app->label = strdup((char *) label);
|
app->label = strdup((char *) label);
|
||||||
else
|
else
|
||||||
|
@ -209,9 +209,9 @@ int sc_enum_apps(sc_card_t *card)
|
||||||
/* Move known PKCS#15 applications to the head of the list */
|
/* Move known PKCS#15 applications to the head of the list */
|
||||||
for (ii=0, idx=0; ii<card->app_count; ii++) {
|
for (ii=0, idx=0; ii<card->app_count; ii++) {
|
||||||
for (jj=0; jj < sizeof(apps)/sizeof(apps[0]); jj++) {
|
for (jj=0; jj < sizeof(apps)/sizeof(apps[0]); jj++) {
|
||||||
if (apps[jj].aid_len != card->app[ii]->aid_len)
|
if (apps[jj].aid_len != card->app[ii]->aid.len)
|
||||||
continue;
|
continue;
|
||||||
if (memcmp(apps[jj].aid, card->app[ii]->aid, apps[jj].aid_len))
|
if (memcmp(apps[jj].aid, card->app[ii]->aid.value, apps[jj].aid_len))
|
||||||
continue;
|
continue;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -253,7 +253,7 @@ static int encode_dir_record(sc_context_t *ctx, const sc_app_info_t *app,
|
||||||
sc_copy_asn1_entry(c_asn1_dirrecord, asn1_dirrecord);
|
sc_copy_asn1_entry(c_asn1_dirrecord, asn1_dirrecord);
|
||||||
sc_copy_asn1_entry(c_asn1_dir, asn1_dir);
|
sc_copy_asn1_entry(c_asn1_dir, asn1_dir);
|
||||||
sc_format_asn1_entry(asn1_dir + 0, asn1_dirrecord, NULL, 1);
|
sc_format_asn1_entry(asn1_dir + 0, asn1_dirrecord, NULL, 1);
|
||||||
sc_format_asn1_entry(asn1_dirrecord + 0, (void *) tapp.aid, (void *) &tapp.aid_len, 1);
|
sc_format_asn1_entry(asn1_dirrecord + 0, (void *) tapp.aid.value, (void *) &tapp.aid.len, 1);
|
||||||
if (tapp.label != NULL) {
|
if (tapp.label != NULL) {
|
||||||
label_len = strlen(tapp.label);
|
label_len = strlen(tapp.label);
|
||||||
sc_format_asn1_entry(asn1_dirrecord + 1, tapp.label, &label_len, 1);
|
sc_format_asn1_entry(asn1_dirrecord + 1, tapp.label, &label_len, 1);
|
||||||
|
|
|
@ -207,8 +207,7 @@ typedef struct sc_algorithm_info {
|
||||||
} sc_algorithm_info_t;
|
} sc_algorithm_info_t;
|
||||||
|
|
||||||
typedef struct sc_app_info {
|
typedef struct sc_app_info {
|
||||||
u8 aid[SC_MAX_AID_SIZE];
|
struct sc_aid aid;
|
||||||
size_t aid_len;
|
|
||||||
char *label;
|
char *label;
|
||||||
struct sc_path path;
|
struct sc_path path;
|
||||||
u8 *ddo;
|
u8 *ddo;
|
||||||
|
@ -1120,9 +1119,6 @@ int sc_make_cache_dir(sc_context_t *ctx);
|
||||||
|
|
||||||
int sc_enum_apps(sc_card_t *card);
|
int sc_enum_apps(sc_card_t *card);
|
||||||
void sc_free_apps(sc_card_t *card);
|
void sc_free_apps(sc_card_t *card);
|
||||||
const sc_app_info_t * sc_find_pkcs15_app(sc_card_t *card);
|
|
||||||
const sc_app_info_t * sc_find_app_by_aid(sc_card_t *card,
|
|
||||||
const u8 *aid, size_t aid_len);
|
|
||||||
int sc_update_dir(sc_card_t *card, sc_app_info_t *app);
|
int sc_update_dir(sc_card_t *card, sc_app_info_t *app);
|
||||||
|
|
||||||
struct sc_algorithm_info * sc_card_find_rsa_alg(sc_card_t *card,
|
struct sc_algorithm_info * sc_card_find_rsa_alg(sc_card_t *card,
|
||||||
|
|
|
@ -659,9 +659,9 @@ const sc_app_info_t * sc_find_app(sc_card_t *card, struct sc_aid *aid)
|
||||||
return card->app[0];
|
return card->app[0];
|
||||||
|
|
||||||
for (ii=0; ii < card->app_count; ii++) {
|
for (ii=0; ii < card->app_count; ii++) {
|
||||||
if (card->app[ii]->aid_len != aid->len)
|
if (card->app[ii]->aid.len != aid->len)
|
||||||
continue;
|
continue;
|
||||||
if (memcmp(card->app[ii]->aid, aid->value, aid->len))
|
if (memcmp(card->app[ii]->aid.value, aid->value, aid->len))
|
||||||
continue;
|
continue;
|
||||||
return card->app[ii];
|
return card->app[ii];
|
||||||
}
|
}
|
||||||
|
@ -699,7 +699,7 @@ static int sc_pkcs15_bind_internal(sc_pkcs15_card_t *p15card, struct sc_aid *aid
|
||||||
info = sc_find_app(card, aid);
|
info = sc_find_app(card, aid);
|
||||||
if (info) {
|
if (info) {
|
||||||
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "bind to application('%s',aid:'%s')",
|
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "bind to application('%s',aid:'%s')",
|
||||||
info->label, sc_dump_hex(info->aid, info->aid_len));
|
info->label, sc_dump_hex(info->aid.value, info->aid.len));
|
||||||
if (info->path.len)
|
if (info->path.len)
|
||||||
p15card->file_app->path = info->path;
|
p15card->file_app->path = info->path;
|
||||||
|
|
||||||
|
|
|
@ -438,8 +438,7 @@ typedef struct sc_pkcs15_unusedspace sc_pkcs15_unusedspace_t;
|
||||||
typedef struct sc_pkcs15_sec_env_info {
|
typedef struct sc_pkcs15_sec_env_info {
|
||||||
int se;
|
int se;
|
||||||
struct sc_object_id owner;
|
struct sc_object_id owner;
|
||||||
u8 aid[SC_MAX_AID_SIZE];
|
struct sc_aid aid;
|
||||||
size_t aid_len;
|
|
||||||
} sc_pkcs15_sec_env_info_t;
|
} sc_pkcs15_sec_env_info_t;
|
||||||
|
|
||||||
typedef struct sc_pkcs15_tokeninfo {
|
typedef struct sc_pkcs15_tokeninfo {
|
||||||
|
|
|
@ -771,8 +771,8 @@ sc_pkcs15init_add_app(struct sc_card *card, struct sc_profile *profile,
|
||||||
|
|
||||||
app->path = p15card->file_app->path;
|
app->path = p15card->file_app->path;
|
||||||
if (p15card->file_app->namelen <= SC_MAX_AID_SIZE) {
|
if (p15card->file_app->namelen <= SC_MAX_AID_SIZE) {
|
||||||
app->aid_len = p15card->file_app->namelen;
|
app->aid.len = p15card->file_app->namelen;
|
||||||
memcpy(app->aid, p15card->file_app->name, app->aid_len);
|
memcpy(app->aid.value, p15card->file_app->name, app->aid.len);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set serial number if explicitly specified */
|
/* set serial number if explicitly specified */
|
||||||
|
|
Loading…
Reference in New Issue