- Added support for user-defined serial numbers in

pkcs15-init and PIN flags in profiles


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@485 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
jey 2002-04-07 13:15:31 +00:00
parent 2936e46e12
commit 60fc3811eb
5 changed files with 36 additions and 2 deletions

View File

@ -9,7 +9,7 @@ cardinfo {
# This is the secure messaging key required for
# creating files in the MF
key AUT1 {
value = "=Muscle00";
value = "=12345678";
}
}

View File

@ -82,6 +82,7 @@ struct sc_pkcs15init_initargs {
const u8 * so_puk;
size_t so_puk_len;
const char * label;
const char * serial;
};
struct sc_pkcs15init_pinargs {
@ -159,6 +160,7 @@ extern int sc_pkcs15init_get_pin_info(struct sc_profile *, unsigned int,
extern int sc_pkcs15init_get_manufacturer(struct sc_profile *,
const char **);
extern int sc_pkcs15init_get_serial(struct sc_profile *, const char **);
extern int sc_pkcs15init_set_serial(struct sc_profile *, const char *);
extern int sc_pkcs15init_get_label(struct sc_profile *, const char **);
#endif /* PKCS15_INIT_H */

View File

@ -191,6 +191,8 @@ sc_pkcs15init_add_app(struct sc_card *card, struct sc_profile *profile,
app->aid_len = p15card->file_app->namelen;
memcpy(app->aid, p15card->file_app->name, app->aid_len);
}
if (args->serial)
sc_pkcs15init_set_serial(profile, args->serial);
if (args->label)
app->label = strdup(args->label);
else if (p15card->label)
@ -1152,6 +1154,16 @@ sc_pkcs15init_get_serial(struct sc_profile *profile, const char **res)
return 0;
}
int
sc_pkcs15init_set_serial(struct sc_profile *profile, const char *serial)
{
if (profile->p15_card->serial_number)
free(profile->p15_card->serial_number);
profile->p15_card->serial_number = strdup(serial);
return 0;
}
int
sc_pkcs15init_get_label(struct sc_profile *profile, const char **res)
{

View File

@ -908,6 +908,17 @@ do_pin_maxlength(struct state *cur, int argc, char **argv)
return 0;
}
static int
do_pin_flags(struct state *cur, int argc, char **argv)
{
unsigned int flags;
if (get_uint(cur, argv[0], &flags))
return 1;
cur->pin->pin.flags = flags;
return 0;
}
/*
* Key section
@ -973,7 +984,7 @@ static struct command pi_commands[] = {
{ "auth-id", 1, 1, do_pin_authid },
{ "max-length", 1, 1, do_pin_maxlength},
{ "min-length", 1, 1, do_pin_minlength},
{ "flags", 1, 1, do_pin_flags },
{ NULL, 0, 0, NULL }
};

View File

@ -87,6 +87,7 @@ enum {
OPT_PUK1 = 0x10001,
OPT_PIN2 = 0x10002,
OPT_PUK2 = 0x10003,
OPT_SERIAL=0x10004,
};
const struct option options[] = {
@ -97,6 +98,7 @@ const struct option options[] = {
{ "puk", required_argument, 0, OPT_PUK1 },
{ "so-pin", required_argument, 0, OPT_PIN2 },
{ "so-puk", required_argument, 0, OPT_PUK2 },
{ "serial", required_argument, 0, OPT_SERIAL },
{ "auth-id", required_argument, 0, 'a' },
{ "id", required_argument, 0, 'i' },
{ "label", required_argument, 0, 'l' },
@ -121,6 +123,7 @@ const char * option_help[] = {
"Specify unblock PIN",
"Specify security officer (SO) PIN",
"Specify unblock PIN for SO PIN",
"Specify the serial number of the card",
"Specify ID of PIN to use/create",
"Specify ID of key/certificate",
"Specify label of PIN/key",
@ -171,6 +174,7 @@ static char * opt_authid = 0;
static char * opt_objectid = 0;
static char * opt_objectlabel = 0;
static char * opt_pins[4];
static char * opt_serial = 0;
static char * opt_passphrase = 0;
static char * opt_newkey = 0;
static char * opt_outkey = 0;
@ -337,6 +341,8 @@ do_init_app(struct sc_profile *profile)
args.so_puk = (const u8 *) opt_pins[OPT_PUK2 & 3];
if (args.so_puk)
args.so_puk_len = strlen((char *) args.so_puk);
args.serial = (const char *) opt_serial;
return sc_pkcs15init_add_app(card, profile, &args);
}
@ -898,6 +904,9 @@ handle_option(int c)
case OPT_PIN2: case OPT_PUK2:
opt_pins[c & 3] = optarg;
break;
case OPT_SERIAL:
opt_serial = optarg;
break;
case OPT_PASSPHRASE:
opt_passphrase = optarg;
break;