libopensc: Removes useless attribute 'file' in 'struct sc_pkcs15_df'
There is no need to carry around that attribute, because it's easy to look up the 'file' as needed. This is done by issuing a single sc_select_file command in sc_pkcs15init_update_any_df (pkcs15-lib.c). The parameter 'file' of sc_pkcs15_add_df (pkcs15.c) became useless too and was removed in turn. git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5316 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
86af8eed3d
commit
3169f14b32
|
@ -372,7 +372,7 @@ sc_pkcs15emu_get_df(sc_pkcs15_card_t *p15card, unsigned int type)
|
||||||
if (!file)
|
if (!file)
|
||||||
return NULL;
|
return NULL;
|
||||||
sc_format_path("11001101", &file->path);
|
sc_format_path("11001101", &file->path);
|
||||||
sc_pkcs15_add_df(p15card, type, &file->path, file);
|
sc_pkcs15_add_df(p15card, type, &file->path);
|
||||||
sc_file_free(file);
|
sc_file_free(file);
|
||||||
created++;
|
created++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -502,7 +502,7 @@ sc_oberthur_parse_privateinfo (struct sc_pkcs15_card *p15card,
|
||||||
|
|
||||||
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "postpone adding of the private keys");
|
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "postpone adding of the private keys");
|
||||||
sc_format_path("5011A5A5", &path);
|
sc_format_path("5011A5A5", &path);
|
||||||
rv = sc_pkcs15_add_df(p15card, SC_PKCS15_PRKDF, &path, NULL);
|
rv = sc_pkcs15_add_df(p15card, SC_PKCS15_PRKDF, &path);
|
||||||
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "Add PrkDF error");
|
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "Add PrkDF error");
|
||||||
no_more_private_keys = 1;
|
no_more_private_keys = 1;
|
||||||
}
|
}
|
||||||
|
@ -521,7 +521,7 @@ sc_oberthur_parse_privateinfo (struct sc_pkcs15_card *p15card,
|
||||||
|
|
||||||
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "postpone adding of the private data");
|
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "postpone adding of the private data");
|
||||||
sc_format_path("5011A6A6", &path);
|
sc_format_path("5011A6A6", &path);
|
||||||
rv = sc_pkcs15_add_df(p15card, SC_PKCS15_DODF, &path, NULL);
|
rv = sc_pkcs15_add_df(p15card, SC_PKCS15_DODF, &path);
|
||||||
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "Add DODF error");
|
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "Add DODF error");
|
||||||
no_more_private_data = 1;
|
no_more_private_data = 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -317,7 +317,7 @@ static sc_pkcs15_df_t * sc_pkcs15emu_get_df(sc_pkcs15_card_t *p15card,
|
||||||
if (!file)
|
if (!file)
|
||||||
return NULL;
|
return NULL;
|
||||||
sc_format_path("11001101", &file->path);
|
sc_format_path("11001101", &file->path);
|
||||||
sc_pkcs15_add_df(p15card, type, &file->path, file);
|
sc_pkcs15_add_df(p15card, type, &file->path);
|
||||||
sc_file_free(file);
|
sc_file_free(file);
|
||||||
created++;
|
created++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -457,7 +457,7 @@ static int parse_odf(const u8 * buf, size_t buflen, struct sc_pkcs15_card *p15ca
|
||||||
r = sc_pkcs15_make_absolute_path(&p15card->file_app->path, &path);
|
r = sc_pkcs15_make_absolute_path(&p15card->file_app->path, &path);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
r = sc_pkcs15_add_df(p15card, odf_indexes[type], &path, NULL);
|
r = sc_pkcs15_add_df(p15card, odf_indexes[type], &path);
|
||||||
if (r)
|
if (r)
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -1482,9 +1482,7 @@ void sc_pkcs15_free_object(struct sc_pkcs15_object *obj)
|
||||||
free(obj);
|
free(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
int sc_pkcs15_add_df(struct sc_pkcs15_card *p15card,
|
int sc_pkcs15_add_df(struct sc_pkcs15_card *p15card, unsigned int type, const sc_path_t *path)
|
||||||
unsigned int type, const sc_path_t *path,
|
|
||||||
const sc_file_t *file)
|
|
||||||
{
|
{
|
||||||
struct sc_pkcs15_df *p, *newdf;
|
struct sc_pkcs15_df *p, *newdf;
|
||||||
|
|
||||||
|
@ -1493,14 +1491,6 @@ int sc_pkcs15_add_df(struct sc_pkcs15_card *p15card,
|
||||||
return SC_ERROR_OUT_OF_MEMORY;
|
return SC_ERROR_OUT_OF_MEMORY;
|
||||||
newdf->path = *path;
|
newdf->path = *path;
|
||||||
newdf->type = type;
|
newdf->type = type;
|
||||||
if (file != NULL) {
|
|
||||||
sc_file_dup(&newdf->file, file);
|
|
||||||
if (newdf->file == NULL) {
|
|
||||||
free(newdf);
|
|
||||||
return SC_ERROR_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p15card->df_list == NULL) {
|
if (p15card->df_list == NULL) {
|
||||||
p15card->df_list = newdf;
|
p15card->df_list = newdf;
|
||||||
|
@ -1525,8 +1515,6 @@ void sc_pkcs15_remove_df(struct sc_pkcs15_card *p15card,
|
||||||
obj->prev->next = obj->next;
|
obj->prev->next = obj->next;
|
||||||
if (obj->next != NULL)
|
if (obj->next != NULL)
|
||||||
obj->next->prev = obj->prev;
|
obj->next->prev = obj->prev;
|
||||||
if (obj->file)
|
|
||||||
sc_file_free(obj->file);
|
|
||||||
free(obj);
|
free(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1635,10 +1623,7 @@ int sc_pkcs15_parse_df(struct sc_pkcs15_card *p15card,
|
||||||
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "unknown DF type: %d", df->type);
|
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "unknown DF type: %d", df->type);
|
||||||
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS);
|
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS);
|
||||||
}
|
}
|
||||||
if (df->file != NULL)
|
r = sc_pkcs15_read_file(p15card, &df->path, &buf, &bufsize, NULL);
|
||||||
r = sc_pkcs15_read_file(p15card, &df->path, &buf, &bufsize, NULL);
|
|
||||||
else
|
|
||||||
r = sc_pkcs15_read_file(p15card, &df->path, &buf, &bufsize, &df->file);
|
|
||||||
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, r, "pkcs15 read file failed");
|
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, r, "pkcs15 read file failed");
|
||||||
|
|
||||||
p = buf;
|
p = buf;
|
||||||
|
|
|
@ -418,8 +418,6 @@ typedef struct sc_pkcs15_object sc_pkcs15_object_t;
|
||||||
struct sc_pkcs15_card;
|
struct sc_pkcs15_card;
|
||||||
|
|
||||||
struct sc_pkcs15_df {
|
struct sc_pkcs15_df {
|
||||||
struct sc_file *file;
|
|
||||||
|
|
||||||
struct sc_path path;
|
struct sc_path path;
|
||||||
int record_length;
|
int record_length;
|
||||||
unsigned int type;
|
unsigned int type;
|
||||||
|
@ -724,8 +722,7 @@ int sc_pkcs15_add_object(struct sc_pkcs15_card *p15card,
|
||||||
struct sc_pkcs15_object *obj);
|
struct sc_pkcs15_object *obj);
|
||||||
void sc_pkcs15_remove_object(struct sc_pkcs15_card *p15card,
|
void sc_pkcs15_remove_object(struct sc_pkcs15_card *p15card,
|
||||||
struct sc_pkcs15_object *obj);
|
struct sc_pkcs15_object *obj);
|
||||||
int sc_pkcs15_add_df(struct sc_pkcs15_card *, unsigned int,
|
int sc_pkcs15_add_df(struct sc_pkcs15_card *, unsigned int, const sc_path_t *);
|
||||||
const sc_path_t *, const struct sc_file *);
|
|
||||||
void sc_pkcs15_remove_df(struct sc_pkcs15_card *p15card,
|
void sc_pkcs15_remove_df(struct sc_pkcs15_card *p15card,
|
||||||
struct sc_pkcs15_df *df);
|
struct sc_pkcs15_df *df);
|
||||||
|
|
||||||
|
|
|
@ -2494,14 +2494,15 @@ sc_pkcs15init_update_any_df(struct sc_pkcs15_card *p15card,
|
||||||
{
|
{
|
||||||
struct sc_context *ctx = p15card->card->ctx;
|
struct sc_context *ctx = p15card->card->ctx;
|
||||||
struct sc_card *card = p15card->card;
|
struct sc_card *card = p15card->card;
|
||||||
struct sc_file *file = df->file, *pfile = NULL;
|
struct sc_file *file = NULL;
|
||||||
unsigned char *buf = NULL;
|
unsigned char *buf = NULL;
|
||||||
size_t bufsize;
|
size_t bufsize;
|
||||||
int update_odf = is_new, r = 0;
|
int update_odf = is_new, r = 0;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
LOG_FUNC_CALLED(ctx);
|
||||||
if (!sc_profile_get_file_by_path(profile, &df->path, &pfile))
|
sc_profile_get_file_by_path(profile, &df->path, &file);
|
||||||
file = pfile;
|
if (file == NULL)
|
||||||
|
sc_select_file(card, &df->path, &file);
|
||||||
|
|
||||||
r = sc_pkcs15_encode_df(card->ctx, p15card, df, &buf, &bufsize);
|
r = sc_pkcs15_encode_df(card->ctx, p15card, df, &buf, &bufsize);
|
||||||
if (r >= 0) {
|
if (r >= 0) {
|
||||||
|
@ -2523,8 +2524,8 @@ sc_pkcs15init_update_any_df(struct sc_pkcs15_card *p15card,
|
||||||
}
|
}
|
||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
if (pfile)
|
if (file)
|
||||||
sc_file_free(pfile);
|
sc_file_free(file);
|
||||||
|
|
||||||
LOG_TEST_RET(ctx, r, "Failed to encode or update xDF");
|
LOG_TEST_RET(ctx, r, "Failed to encode or update xDF");
|
||||||
|
|
||||||
|
@ -2560,7 +2561,7 @@ sc_pkcs15init_add_object(struct sc_pkcs15_card *p15card,
|
||||||
sc_log(ctx, "Profile doesn't define a DF file %u", df_type);
|
sc_log(ctx, "Profile doesn't define a DF file %u", df_type);
|
||||||
LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "DF not found in profile");
|
LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "DF not found in profile");
|
||||||
}
|
}
|
||||||
sc_pkcs15_add_df(p15card, df_type, &file->path, file);
|
sc_pkcs15_add_df(p15card, df_type, &file->path);
|
||||||
df = find_df_by_type(p15card, df_type);
|
df = find_df_by_type(p15card, df_type);
|
||||||
assert(df != NULL);
|
assert(df != NULL);
|
||||||
is_new = 1;
|
is_new = 1;
|
||||||
|
|
Loading…
Reference in New Issue