pkcs15init: profile: handles for 'profile-extention' and 'exclusive-aid' ...

'profile-extention' profile parameter used to load from the separate file 
the AID dependent profile part.

'exclusive-aid' profile parameter used to introduce the AID for the DF
that do not have file-id and that can be selected only by 'DF-NAME' selection.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5097 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
vtarasov 2011-01-17 15:18:11 +00:00
parent 35a54b511c
commit 1519cb38a1
1 changed files with 53 additions and 0 deletions

View File

@ -1353,6 +1353,55 @@ do_aid(struct state *cur, int argc, char **argv)
return res;
}
static int
do_exclusive_aid(struct state *cur, int argc, char **argv)
{
struct sc_file *file = cur->file->file;
const char *name = argv[0];
unsigned int len;
int res = 0;
#ifdef DEBUG_PROFILE
printf("do_exclusive_aid(): exclusive-aid '%s'\n", name);
printf("do_exclusive_aid(): current file '%s' (path:%s)\n", cur->file->ident, sc_print_path(&file->path));
#endif
sc_format_path(name, &file->path);
if (file->path.len > SC_MAX_AID_SIZE) {
parse_error(cur, "Path length is too big\n");
return 1;
}
memcpy(file->path.aid.value, file->path.value, file->path.len);
file->path.aid.len = file->path.len;
file->path.len = 0;
file->path.type = SC_PATH_TYPE_DF_NAME;
#ifdef DEBUG_PROFILE
printf("do_exclusive_aid(): '%s' exclusive-aid path %s\n", cur->file->ident, sc_print_path(&file->path));
#endif
if (*name == '=') {
len = strlen(++name);
if (len > sizeof(file->name)) {
parse_error(cur, "AID \"%s\" too long\n", name);
return 1;
}
memcpy(file->name, name, len);
file->namelen = len;
}
else {
file->namelen = sizeof(file->name);
res = sc_hex_to_bin(name, file->name, &file->namelen);
}
return res;
}
static int
do_profile_extention(struct state *cur, int argc, char **argv)
{
return setstr(&cur->file->profile_extention, argv[0]);
}
/*
* Parse ACL list.
* The way we do this is we first split things like CHV1
@ -1675,6 +1724,10 @@ static struct command fs_commands[] = {
{ "record-length", 1, 1, do_reclength },
{ "AID", 1, 1, do_aid },
{ "ACL", 1, -1, do_acl },
/* AID dependent sub-profile */
{ "profile-extention", 1, 1, do_profile_extention },
/* AID of the DFs without file-id */
{ "exclusive-aid", 1, 1, do_exclusive_aid },
{ NULL, 0, 0, NULL }
};