diff --git a/src/libopensc/authentic.h b/src/libopensc/authentic.h index 3cbf2518..83250c49 100644 --- a/src/libopensc/authentic.h +++ b/src/libopensc/authentic.h @@ -123,12 +123,6 @@ #define AUTHENTIC_GP_SM_LEVEL_MAC 0x4000 #define AUTHENTIC_GP_SM_LEVEL_ENC_MAC 0x6000 -struct sc_authentic_tlv { - unsigned tag; - size_t size; - unsigned char *value; -}; - /* * DOCP (Data Object Control Parameters) * Common holder for the all DOCP types. diff --git a/src/libopensc/dir.c b/src/libopensc/dir.c index 2c71fc1c..4c270d93 100644 --- a/src/libopensc/dir.c +++ b/src/libopensc/dir.c @@ -110,16 +110,16 @@ static int parse_dir_record(sc_card_t *card, u8 ** buf, size_t *buflen, } else app->path.len = 0; if (asn1_dirrecord[3].flags & SC_ASN1_PRESENT) { - app->ddo = malloc(ddo_len); - if (app->ddo == NULL) { + app->ddo.value = malloc(ddo_len); + if (app->ddo.value == NULL) { free(app); return SC_ERROR_OUT_OF_MEMORY; } - memcpy(app->ddo, ddo, ddo_len); - app->ddo_len = ddo_len; + memcpy(app->ddo.value, ddo, ddo_len); + app->ddo.len = ddo_len; } else { - app->ddo = NULL; - app->ddo_len = 0; + app->ddo.value = NULL; + app->ddo.len = 0; } app->rec_nr = rec_nr; @@ -235,8 +235,8 @@ void sc_free_apps(sc_card_t *card) for (i = 0; i < card->app_count; i++) { if (card->app[i]->label) free(card->app[i]->label); - if (card->app[i]->ddo) - free(card->app[i]->ddo); + if (card->app[i]->ddo.value) + free(card->app[i]->ddo.value); free(card->app[i]); } card->app_count = -1; @@ -261,9 +261,9 @@ static int encode_dir_record(sc_context_t *ctx, const sc_app_info_t *app, if (tapp.path.len) sc_format_asn1_entry(asn1_dirrecord + 2, (void *) tapp.path.value, (void *) &tapp.path.len, 1); - if (tapp.ddo != NULL) - sc_format_asn1_entry(asn1_dirrecord + 3, (void *) tapp.ddo, - (void *) &tapp.ddo_len, 1); + if (tapp.ddo.value != NULL && tapp.ddo.len) + sc_format_asn1_entry(asn1_dirrecord + 3, (void *) tapp.ddo.value, + (void *) &tapp.ddo.len, 1); r = sc_asn1_encode(ctx, asn1_dir, buf, buflen); SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, r, "Encode DIR record error"); diff --git a/src/libopensc/opensc.h b/src/libopensc/opensc.h index d4ff85b7..954cf555 100644 --- a/src/libopensc/opensc.h +++ b/src/libopensc/opensc.h @@ -207,11 +207,12 @@ typedef struct sc_algorithm_info { } sc_algorithm_info_t; typedef struct sc_app_info { - struct sc_aid aid; char *label; + + struct sc_aid aid; + struct sc_lv_data ddo; + struct sc_path path; - u8 *ddo; - size_t ddo_len; int rec_nr; /* -1, if EF(DIR) is transparent */ } sc_app_info_t; diff --git a/src/libopensc/pkcs15.c b/src/libopensc/pkcs15.c index 7b6bd221..ac8e67d1 100644 --- a/src/libopensc/pkcs15.c +++ b/src/libopensc/pkcs15.c @@ -703,8 +703,8 @@ static int sc_pkcs15_bind_internal(sc_pkcs15_card_t *p15card, struct sc_aid *aid if (info->path.len) p15card->file_app->path = info->path; - if (info->ddo) - parse_ddo(p15card, info->ddo, info->ddo_len); + if (info->ddo.value && info->ddo.len) + parse_ddo(p15card, info->ddo.value, info->ddo.len); } else if (aid) { sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Application(aid:'%s') not found", sc_dump_hex(aid->value, aid->len)); diff --git a/src/libopensc/types.h b/src/libopensc/types.h index 6c359d24..84beab58 100644 --- a/src/libopensc/types.h +++ b/src/libopensc/types.h @@ -54,8 +54,19 @@ struct sc_object_id { }; struct sc_aid { - unsigned char value[SC_MAX_AID_SIZE]; size_t len; + unsigned char value[SC_MAX_AID_SIZE]; +}; + +struct sc_lv_data { + size_t len; + unsigned char *value; +}; + +struct sc_tlv_data { + unsigned tag; + size_t len; + unsigned char *value; }; #define SC_PATH_TYPE_FILE_ID 0