Merge pull request #337 from frankmorgner/7816

7816
This commit is contained in:
Frank Morgner 2014-12-19 11:37:48 +01:00
commit a7bf05ecc4
8 changed files with 116 additions and 59 deletions

View File

@ -2219,12 +2219,14 @@ iasecc_keyset_change(struct sc_card *card, struct sc_pin_cmd_data *data, int *tr
update.fields[0].parent_tag = IASECC_SDO_KEYSET_TAG; update.fields[0].parent_tag = IASECC_SDO_KEYSET_TAG;
update.fields[0].tag = IASECC_SDO_KEYSET_TAG_MAC; update.fields[0].tag = IASECC_SDO_KEYSET_TAG_MAC;
update.fields[0].value = data->pin2.data; /* FIXME is it safe to modify the const value here? */
update.fields[0].value = (unsigned char *) data->pin2.data;
update.fields[0].size = 16; update.fields[0].size = 16;
update.fields[1].parent_tag = IASECC_SDO_KEYSET_TAG; update.fields[1].parent_tag = IASECC_SDO_KEYSET_TAG;
update.fields[1].tag = IASECC_SDO_KEYSET_TAG_ENC; update.fields[1].tag = IASECC_SDO_KEYSET_TAG_ENC;
update.fields[1].value = data->pin2.data + 16; /* FIXME is it safe to modify the const value here? */
update.fields[1].value = (unsigned char *) data->pin2.data + 16;
update.fields[1].size = 16; update.fields[1].size = 16;
rv = iasecc_sm_sdo_update(card, (scb & IASECC_SCB_METHOD_MASK_REF), &update); rv = iasecc_sm_sdo_update(card, (scb & IASECC_SCB_METHOD_MASK_REF), &update);

View File

@ -91,7 +91,7 @@ parse_dir_record(sc_card_t *card, u8 ** buf, size_t *buflen, int rec_nr)
else else
app->label = NULL; app->label = NULL;
if (asn1_dirrecord[2].flags & SC_ASN1_PRESENT) { if (asn1_dirrecord[2].flags & SC_ASN1_PRESENT && path_len > 0) {
/* application path present: ignore AID */ /* application path present: ignore AID */
if (path_len > SC_MAX_PATH_SIZE) { if (path_len > SC_MAX_PATH_SIZE) {
free(app); free(app);

View File

@ -452,17 +452,42 @@ iso7816_select_file(struct sc_card *card, const struct sc_path *in_path, struct
struct sc_apdu apdu; struct sc_apdu apdu;
unsigned char buf[SC_MAX_APDU_BUFFER_SIZE]; unsigned char buf[SC_MAX_APDU_BUFFER_SIZE];
unsigned char pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf; unsigned char pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf;
int r, pathlen; int r, pathlen, pathtype;
struct sc_file *file = NULL; struct sc_file *file = NULL;
assert(card != NULL && in_path != NULL); assert(card != NULL && in_path != NULL);
ctx = card->ctx; ctx = card->ctx;
memcpy(path, in_path->value, in_path->len); memcpy(path, in_path->value, in_path->len);
pathlen = in_path->len; pathlen = in_path->len;
pathtype = in_path->type;
if (in_path->aid.len) {
if (!pathlen) {
memcpy(path, in_path->aid.value, in_path->aid.len);
pathlen = in_path->aid.len;
pathtype = SC_PATH_TYPE_DF_NAME;
} else {
/* First, select the application */
sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xA4, 4, 0);
apdu.data = in_path->aid.value;
apdu.datalen = in_path->aid.len;
apdu.lc = in_path->aid.len;
r = sc_transmit_apdu(card, &apdu);
LOG_TEST_RET(ctx, r, "APDU transmit failed");
r = sc_check_sw(card, apdu.sw1, apdu.sw2);
if (r)
LOG_FUNC_RETURN(ctx, r);
if (pathtype == SC_PATH_TYPE_PATH
|| pathtype == SC_PATH_TYPE_DF_NAME)
pathtype = SC_PATH_TYPE_FROM_CURRENT;
}
}
sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xA4, 0, 0); sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xA4, 0, 0);
switch (in_path->type) { switch (pathtype) {
case SC_PATH_TYPE_FILE_ID: case SC_PATH_TYPE_FILE_ID:
apdu.p1 = 0; apdu.p1 = 0;
if (pathlen != 2) if (pathlen != 2)

View File

@ -116,7 +116,7 @@ int sc_bin_to_hex(const u8 *in, size_t in_len, char *out, size_t out_len,
*/ */
size_t sc_right_trim(u8 *buf, size_t len) { size_t sc_right_trim(u8 *buf, size_t len) {
size_t i; long i;
for(i=len-1; i >=0; i--) { for(i=len-1; i >=0; i--) {
if(!isprint(buf[i])) { if(!isprint(buf[i])) {

View File

@ -348,8 +348,9 @@ static char * opt_puk_label = NULL;
static char * opt_pubkey_label = NULL; static char * opt_pubkey_label = NULL;
static char * opt_cert_label = NULL; static char * opt_cert_label = NULL;
static const char * opt_pins[4]; static const char * opt_pins[4];
static char * pins[4];
static char * opt_serial = NULL; static char * opt_serial = NULL;
static char * opt_passphrase = NULL; static const char * opt_passphrase = NULL;
static char * opt_newkey = NULL; static char * opt_newkey = NULL;
static char * opt_outkey = NULL; static char * opt_outkey = NULL;
static char * opt_application_id = NULL; static char * opt_application_id = NULL;
@ -458,6 +459,10 @@ main(int argc, char **argv)
return 1; return 1;
} }
for (n = 0; n < sizeof pins; n++) {
pins[n] = NULL;
}
for (n = 0; n < ACTION_MAX; n++) { for (n = 0; n < ACTION_MAX; n++) {
unsigned int action = n; unsigned int action = n;
@ -577,6 +582,10 @@ main(int argc, char **argv)
} }
} }
for (n = 0; n < sizeof pins; n++) {
free(pins[n]);
}
out: out:
if (profile) { if (profile) {
sc_pkcs15init_unbind(profile); sc_pkcs15init_unbind(profile);
@ -754,9 +763,10 @@ do_init_app(struct sc_profile *profile)
if (!opt_pins[2] && !opt_no_prompt && !opt_no_sopin) { if (!opt_pins[2] && !opt_no_prompt && !opt_no_sopin) {
r = get_new_pin(&hints, role, "pin", &opt_pins[2]); r = get_new_pin(&hints, role, "pin", &pins[2]);
if (r < 0) if (r < 0)
goto failed; goto failed;
opt_pins[2] = pins[2];
} }
if (!so_puk_disabled && opt_pins[2] && !opt_pins[3] && !opt_no_prompt) { if (!so_puk_disabled && opt_pins[2] && !opt_pins[3] && !opt_no_prompt) {
@ -766,9 +776,10 @@ do_init_app(struct sc_profile *profile)
role = "user"; role = "user";
hints.flags |= SC_UI_PIN_OPTIONAL; hints.flags |= SC_UI_PIN_OPTIONAL;
r = get_new_pin(&hints, role, "puk", &opt_pins[3]); r = get_new_pin(&hints, role, "puk", &pins[3]);
if (r < 0) if (r < 0)
goto failed; goto failed;
opt_pins[3] = pins[3];
} }
args.so_pin = (const u8 *) opt_pins[2]; args.so_pin = (const u8 *) opt_pins[2];
@ -819,9 +830,11 @@ do_store_pin(struct sc_profile *profile)
} }
sc_pkcs15init_get_pin_info(profile, SC_PKCS15INIT_USER_PIN, &info); sc_pkcs15init_get_pin_info(profile, SC_PKCS15INIT_USER_PIN, &info);
if (opt_pins[0] == NULL) if (opt_pins[0] == NULL) {
if ((r = get_new_pin(&hints, "user", "pin", &opt_pins[0])) < 0) if ((r = get_new_pin(&hints, "user", "pin", &pins[0])) < 0)
goto failed; goto failed;
opt_pins[0] = pins[0];
}
if (*opt_pins[0] == '\0') { if (*opt_pins[0] == '\0') {
util_error("You must specify a PIN\n"); util_error("You must specify a PIN\n");
@ -839,9 +852,9 @@ do_store_pin(struct sc_profile *profile)
sc_pkcs15init_get_pin_info(profile, SC_PKCS15INIT_USER_PUK, &info); sc_pkcs15init_get_pin_info(profile, SC_PKCS15INIT_USER_PUK, &info);
hints.flags |= SC_UI_PIN_OPTIONAL; hints.flags |= SC_UI_PIN_OPTIONAL;
if ((r = get_new_pin(&hints, "user", "puk", &opt_pins[1])) < 0) if ((r = get_new_pin(&hints, "user", "puk", &pins[1])) < 0)
goto failed; goto failed;
opt_pins[1] = pins[1];
} }
if (opt_puk_authid && opt_pins[1]) if (opt_puk_authid && opt_pins[1])
@ -1693,19 +1706,19 @@ get_pin_callback(struct sc_profile *profile,
switch (id) { switch (id) {
case SC_PKCS15INIT_USER_PIN: case SC_PKCS15INIT_USER_PIN:
name = "User PIN"; name = "User PIN";
secret = opt_pins[OPT_PIN1 & 3]; secret = (char *) opt_pins[OPT_PIN1 & 3];
break; break;
case SC_PKCS15INIT_USER_PUK: case SC_PKCS15INIT_USER_PUK:
name = "User PIN unlock key"; name = "User PIN unlock key";
secret = opt_pins[OPT_PUK1 & 3]; secret = (char *) opt_pins[OPT_PUK1 & 3];
break; break;
case SC_PKCS15INIT_SO_PIN: case SC_PKCS15INIT_SO_PIN:
name = "Security officer PIN"; name = "Security officer PIN";
secret = opt_pins[OPT_PIN2 & 3]; secret = (char *) opt_pins[OPT_PIN2 & 3];
break; break;
case SC_PKCS15INIT_SO_PUK: case SC_PKCS15INIT_SO_PUK:
name = "Security officer PIN unlock key"; name = "Security officer PIN unlock key";
secret = opt_pins[OPT_PUK2 & 3]; secret = (char *) opt_pins[OPT_PUK2 & 3];
break; break;
} }
} }
@ -1713,22 +1726,22 @@ get_pin_callback(struct sc_profile *profile,
if (!(info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_SO_PIN) if (!(info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_SO_PIN)
&& !(info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN)) { && !(info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN)) {
name = "User PIN"; name = "User PIN";
secret = opt_pins[OPT_PIN1 & 3]; secret = (char *) opt_pins[OPT_PIN1 & 3];
} }
else if (!(info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_SO_PIN) else if (!(info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_SO_PIN)
&& (info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN)) { && (info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN)) {
name = "User PUK"; name = "User PUK";
secret = opt_pins[OPT_PUK1 & 3]; secret = (char *) opt_pins[OPT_PUK1 & 3];
} }
else if ((info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_SO_PIN) else if ((info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_SO_PIN)
&& !(info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN)) { && !(info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN)) {
name = "Security officer PIN"; name = "Security officer PIN";
secret = opt_pins[OPT_PIN2 & 3]; secret = (char *) opt_pins[OPT_PIN2 & 3];
} }
else if ((info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_SO_PIN) else if ((info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_SO_PIN)
&& (info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN)) { && (info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN)) {
name = "Security officer PIN unlock key"; name = "Security officer PIN unlock key";
secret = opt_pins[OPT_PUK2 & 3]; secret = (char *) opt_pins[OPT_PUK2 & 3];
} }
} }
if (secret) if (secret)
@ -1997,7 +2010,7 @@ do_read_private_key(const char *filename, const char *format,
int r; int r;
if (opt_passphrase) if (opt_passphrase)
passphrase = opt_passphrase; passphrase = (char *) opt_passphrase;
if (!format || !strcasecmp(format, "pem")) { if (!format || !strcasecmp(format, "pem")) {
r = do_read_pem_private_key(filename, passphrase, pk); r = do_read_pem_private_key(filename, passphrase, pk);
@ -2026,8 +2039,12 @@ do_read_private_key(const char *filename, const char *format,
return SC_ERROR_NOT_SUPPORTED; return SC_ERROR_NOT_SUPPORTED;
} }
if (NULL == opt_passphrase)
free(passphrase);
if (r < 0) if (r < 0)
util_fatal("Unable to read private key from %s\n", filename); util_fatal("Unable to read private key from %s\n", filename);
return r; return r;
} }
@ -2157,7 +2174,7 @@ static size_t determine_filesize(const char *filename)
static int static int
do_read_data_object(const char *name, u8 **out, size_t *outlen) do_read_data_object(const char *name, u8 **out, size_t *outlen)
{ {
FILE *inf; FILE *inf;
size_t filesize = determine_filesize(name); size_t filesize = determine_filesize(name);
int c; int c;
@ -2452,8 +2469,6 @@ handle_option(const struct option *opt)
opt_serial = optarg; opt_serial = optarg;
break; break;
case OPT_PASSPHRASE: case OPT_PASSPHRASE:
free(opt_passphrase);
opt_passphrase = NULL;
util_get_pin(optarg, &opt_passphrase); util_get_pin(optarg, &opt_passphrase);
break; break;
case OPT_PUBKEY: case OPT_PUBKEY:
@ -2773,7 +2788,7 @@ static int verify_pin(struct sc_pkcs15_card *p15card, char *auth_id_str)
{ {
struct sc_pkcs15_object *pin_obj = NULL; struct sc_pkcs15_object *pin_obj = NULL;
char pin_label[64]; char pin_label[64];
char *pin; char *pin = NULL;
int r; int r;
if (!auth_id_str) { if (!auth_id_str) {
@ -2817,7 +2832,7 @@ static int verify_pin(struct sc_pkcs15_card *p15card, char *auth_id_str)
} }
if (opt_pins[0] != NULL) { if (opt_pins[0] != NULL) {
pin = opt_pins[0]; pin = (char *) opt_pins[0];
} }
else { else {
sc_ui_hints_t hints; sc_ui_hints_t hints;
@ -2844,5 +2859,8 @@ static int verify_pin(struct sc_pkcs15_card *p15card, char *auth_id_str)
if (r < 0) if (r < 0)
fprintf(stderr, "Operation failed: %s\n", sc_strerror(r)); fprintf(stderr, "Operation failed: %s\n", sc_strerror(r));
if (NULL == opt_pins[0])
free(pin);
return r; return r;
} }

View File

@ -52,9 +52,9 @@ static char * opt_data = NULL;
static char * opt_pubkey = NULL; static char * opt_pubkey = NULL;
static char * opt_outfile = NULL; static char * opt_outfile = NULL;
static char * opt_bind_to_aid = NULL; static char * opt_bind_to_aid = NULL;
static const u8 * opt_newpin = NULL; static const char * opt_newpin = NULL;
static const u8 * opt_pin = NULL; static const char * opt_pin = NULL;
static const u8 * opt_puk = NULL; static const char * opt_puk = NULL;
static int verbose = 0; static int verbose = 0;
static int opt_no_prompt = 0; static int opt_no_prompt = 0;
@ -1116,7 +1116,7 @@ static int verify_pin(void)
} }
if (opt_pin != NULL) if (opt_pin != NULL)
pin = opt_pin; pin = (unsigned char *) opt_pin;
else else
pin = get_pin("Please enter PIN", pin_obj); pin = get_pin("Please enter PIN", pin_obj);
@ -1127,13 +1127,16 @@ static int verify_pin(void)
return -1; return -1;
} }
if (opt_pin == NULL)
free(pin);
return 0; return 0;
} }
static int authenticate(sc_pkcs15_object_t *obj) static int authenticate(sc_pkcs15_object_t *obj)
{ {
sc_pkcs15_object_t *pin_obj; sc_pkcs15_object_t *pin_obj;
u8 *pin; u8 *pin = NULL;
int r; int r;
if (obj->auth_id.len == 0) if (obj->auth_id.len == 0)
@ -1143,11 +1146,16 @@ static int authenticate(sc_pkcs15_object_t *obj)
return r; return r;
if (opt_pin != NULL) if (opt_pin != NULL)
pin = opt_pin; pin = (u8 *) opt_pin;
else else
pin = get_pin("Please enter PIN", pin_obj); pin = get_pin("Please enter PIN", pin_obj);
return sc_pkcs15_verify_pin(p15card, pin_obj, pin, pin? strlen((char *) pin) : 0); r = sc_pkcs15_verify_pin(p15card, pin_obj, pin, pin? strlen((char *) pin) : 0);
if (opt_pin == NULL)
free(pin);
return r;
} }
static void print_pin_info(const struct sc_pkcs15_object *obj) static void print_pin_info(const struct sc_pkcs15_object *obj)
@ -1307,7 +1315,7 @@ static int unblock_pin(void)
if (pinfo->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN) if (pinfo->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
return 1; return 1;
puk = opt_puk; puk = (u8 *) opt_puk;
if (puk == NULL) { if (puk == NULL) {
sc_pkcs15_object_t *puk_obj = NULL; sc_pkcs15_object_t *puk_obj = NULL;
@ -1338,7 +1346,7 @@ static int unblock_pin(void)
printf("PUK value will be prompted with pinpad.\n"); printf("PUK value will be prompted with pinpad.\n");
/* FIXME should OPENSSL_cleanse on pin/puk data */ /* FIXME should OPENSSL_cleanse on pin/puk data */
pin = opt_pin ? opt_pin : opt_newpin; pin = opt_pin ? (u8 *) opt_pin : (u8 *) opt_newpin;
while (pin == NULL) { while (pin == NULL) {
u8 *pin2; u8 *pin2;
@ -1365,7 +1373,12 @@ static int unblock_pin(void)
r = sc_pkcs15_unblock_pin(p15card, pin_obj, r = sc_pkcs15_unblock_pin(p15card, pin_obj,
puk, puk ? strlen((char *) puk) : 0, puk, puk ? strlen((char *) puk) : 0,
pin, pin ? strlen((char *) pin) : 0); pin, pin ? strlen((char *) pin) : 0);
/* FIXME must free the puk somewhere */
if (NULL == opt_puk)
free(puk);
if (NULL == opt_pin && NULL == opt_newpin)
free(pin);
if (r == SC_ERROR_PIN_CODE_INCORRECT) { if (r == SC_ERROR_PIN_CODE_INCORRECT) {
fprintf(stderr, "PUK code incorrect; tries left: %d\n", pinfo->tries_left); fprintf(stderr, "PUK code incorrect; tries left: %d\n", pinfo->tries_left);
return 3; return 3;
@ -1405,7 +1418,7 @@ static int change_pin(void)
} }
} }
pincode = opt_pin; pincode = (u8 *) opt_pin;
if (pincode == NULL) { if (pincode == NULL) {
pincode = get_pin("Enter old PIN", pin_obj); pincode = get_pin("Enter old PIN", pin_obj);
if (!pinpad_present && pincode == NULL) if (!pinpad_present && pincode == NULL)
@ -1420,7 +1433,7 @@ static int change_pin(void)
if (pincode == NULL && verbose) if (pincode == NULL && verbose)
printf("Old PIN value will be prompted with pinpad.\n"); printf("Old PIN value will be prompted with pinpad.\n");
newpin = opt_newpin; newpin = (u8 *) opt_newpin;
while (newpin == NULL) { while (newpin == NULL) {
u8 *newpin2; u8 *newpin2;
@ -1459,7 +1472,12 @@ static int change_pin(void)
} }
if (verbose) if (verbose)
printf("PIN code changed successfully.\n"); printf("PIN code changed successfully.\n");
/* FIXME must free the pincode somewhere */
if (opt_pin == NULL)
free(pincode);
if (opt_newpin == NULL)
free(newpin);
return 0; return 0;
} }
@ -1890,13 +1908,13 @@ int main(int argc, char * const argv[])
opt_reader = optarg; opt_reader = optarg;
break; break;
case OPT_PIN: case OPT_PIN:
util_get_pin(optarg, (const u8 **) &opt_pin); util_get_pin(optarg, &opt_pin);
break; break;
case OPT_NEWPIN: case OPT_NEWPIN:
util_get_pin(optarg, (const u8 **) &opt_newpin); util_get_pin(optarg, &opt_newpin);
break; break;
case OPT_PUK: case OPT_PUK:
util_get_pin(optarg, (const u8 **) &opt_puk); util_get_pin(optarg, &opt_puk);
break; break;
case 'o': case 'o':
opt_outfile = optarg; opt_outfile = optarg;

View File

@ -664,7 +664,7 @@ static int recreate_password_from_shares(char **pwd, int *pwdlen, int num_of_pas
static int import_dkek_share(sc_card_t *card, const char *inf, int iter, char *password, int num_of_password_shares) static int import_dkek_share(sc_card_t *card, const char *inf, int iter, const char *password, int num_of_password_shares)
{ {
sc_cardctl_sc_hsm_dkek_t dkekinfo; sc_cardctl_sc_hsm_dkek_t dkekinfo;
EVP_CIPHER_CTX ctx; EVP_CIPHER_CTX ctx;
@ -712,7 +712,7 @@ static int import_dkek_share(sc_card_t *card, const char *inf, int iter, char *p
} }
} else { } else {
pwd = password; pwd = (char *) password;
pwdlen = strlen(password); pwdlen = strlen(password);
} }
@ -904,7 +904,7 @@ static int generate_pwd_shares(sc_card_t *card, char **pwd, int *pwdlen, int pas
static int create_dkek_share(sc_card_t *card, const char *outf, int iter, char *password, int password_shares_threshold, int password_shares_total) static int create_dkek_share(sc_card_t *card, const char *outf, int iter, const char *password, int password_shares_threshold, int password_shares_total)
{ {
EVP_CIPHER_CTX ctx; EVP_CIPHER_CTX ctx;
FILE *out = NULL; FILE *out = NULL;
@ -927,7 +927,7 @@ static int create_dkek_share(sc_card_t *card, const char *outf, int iter, char *
} }
} else { } else {
pwd = password; pwd = (char *) password;
pwdlen = strlen(password); pwdlen = strlen(password);
} }
@ -1439,7 +1439,7 @@ int main(int argc, char * const argv[])
const char *opt_so_pin = NULL; const char *opt_so_pin = NULL;
const char *opt_pin = NULL; const char *opt_pin = NULL;
const char *opt_filename = NULL; const char *opt_filename = NULL;
char *opt_password = NULL; const char *opt_password = NULL;
int opt_retry_counter = 3; int opt_retry_counter = 3;
int opt_dkek_shares = -1; int opt_dkek_shares = -1;
int opt_key_reference = -1; int opt_key_reference = -1;
@ -1484,18 +1484,12 @@ int main(int argc, char * const argv[])
action_count++; action_count++;
break; break;
case OPT_PASSWORD: case OPT_PASSWORD:
free(opt_password);
opt_password = NULL;
util_get_pin(optarg, &opt_password); util_get_pin(optarg, &opt_password);
break; break;
case OPT_SO_PIN: case OPT_SO_PIN:
free(opt_so_pin);
opt_so_pin = NULL;
util_get_pin(optarg, &opt_so_pin); util_get_pin(optarg, &opt_so_pin);
break; break;
case OPT_PIN: case OPT_PIN:
free(opt_pin);
opt_pin = NULL;
util_get_pin(optarg, &opt_pin); util_get_pin(optarg, &opt_pin);
break; break;
case OPT_RETRY: case OPT_RETRY:

View File

@ -126,7 +126,7 @@ static void print_openssl_error(void)
printf("%s\n", ERR_error_string(r, NULL)); printf("%s\n", ERR_error_string(r, NULL));
} }
static int verify_pin(sc_card_t *card, int pin_reference, char *pin_value) static int verify_pin(sc_card_t *card, int pin_reference, const char *pin_value)
{ {
int r, tries_left = -1; int r, tries_left = -1;
struct sc_pin_cmd_data data; struct sc_pin_cmd_data data;
@ -178,8 +178,8 @@ static int verify_pin(sc_card_t *card, int pin_reference, char *pin_value)
static int change_pin(sc_card_t *card, static int change_pin(sc_card_t *card,
int pin_reference, int pin_reference,
char *pin_value1, const char *pin_value1,
char *pin_value2) const char *pin_value2)
{ {
int r, tries_left = -1; int r, tries_left = -1;
struct sc_pin_cmd_data data; struct sc_pin_cmd_data data;
@ -236,8 +236,8 @@ static int change_pin(sc_card_t *card,
static int unlock_pin(sc_card_t *card, static int unlock_pin(sc_card_t *card,
int pin_reference, int pin_reference,
char *puk_value, const char *puk_value,
char *pin_value) const char *pin_value)
{ {
int r, tries_left = -1; int r, tries_left = -1;
struct sc_pin_cmd_data data; struct sc_pin_cmd_data data;