1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

scd: Fix API of select_file/_path.

* scd/iso7816.c (iso7816_select_file, iso7816_select_path): Remove
unused arguments.
* scd/app-dinsig.c (do_readcert): Follow the change.
* scd/app-help.c (app_help_read_length_of_cert): Likewise.
* scd/app-nks.c (keygripstr_from_pk_file, do_readcert, do_readkey)
(switch_application): Likewise.
* scd/app-p15.c (select_and_read_binary, select_ef_by_path)
(micardo_mse, app_select_p15): Likewise.
* scd/app.c (app_new_register): Likewise.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2017-03-06 13:39:46 +09:00
parent 6d1e16d968
commit 0703de01c8
7 changed files with 25 additions and 48 deletions

View File

@ -193,7 +193,7 @@ do_readcert (app_t app, const char *certid,
/* Read the entire file. fixme: This could be optimized by first /* Read the entire file. fixme: This could be optimized by first
reading the header to figure out how long the certificate reading the header to figure out how long the certificate
actually is. */ actually is. */
err = iso7816_select_file (app->slot, fid, 0, NULL, NULL); err = iso7816_select_file (app->slot, fid, 0);
if (err) if (err)
{ {
log_error ("error selecting FID 0x%04X: %s\n", fid, gpg_strerror (err)); log_error ("error selecting FID 0x%04X: %s\n", fid, gpg_strerror (err));

View File

@ -106,7 +106,7 @@ app_help_read_length_of_cert (int slot, int fid, size_t *r_certoff)
int class, tag, constructed, ndef; int class, tag, constructed, ndef;
size_t resultlen, objlen, hdrlen; size_t resultlen, objlen, hdrlen;
err = iso7816_select_file (slot, fid, 0, NULL, NULL); err = iso7816_select_file (slot, fid, 0);
if (err) if (err)
{ {
log_info ("error selecting FID 0x%04X: %s\n", fid, gpg_strerror (err)); log_info ("error selecting FID 0x%04X: %s\n", fid, gpg_strerror (err));

View File

@ -151,7 +151,7 @@ keygripstr_from_pk_file (app_t app, int fid, char *r_gripstr)
int i; int i;
int offset[2] = { 0, 0 }; int offset[2] = { 0, 0 };
err = iso7816_select_file (app->slot, fid, 0, NULL, NULL); err = iso7816_select_file (app->slot, fid, 0);
if (err) if (err)
return err; return err;
err = iso7816_read_record (app->slot, 1, 1, 0, &buffer[0], &buflen[0]); err = iso7816_read_record (app->slot, 1, 1, 0, &buffer[0], &buflen[0]);
@ -528,7 +528,7 @@ do_readcert (app_t app, const char *certid,
/* Read the entire file. fixme: This could be optimized by first /* Read the entire file. fixme: This could be optimized by first
reading the header to figure out how long the certificate reading the header to figure out how long the certificate
actually is. */ actually is. */
err = iso7816_select_file (app->slot, fid, 0, NULL, NULL); err = iso7816_select_file (app->slot, fid, 0);
if (err) if (err)
{ {
log_error ("error selecting FID 0x%04X: %s\n", fid, gpg_strerror (err)); log_error ("error selecting FID 0x%04X: %s\n", fid, gpg_strerror (err));
@ -636,7 +636,7 @@ do_readkey (app_t app, int advanced, const char *keyid,
return gpg_error (GPG_ERR_UNSUPPORTED_OPERATION); return gpg_error (GPG_ERR_UNSUPPORTED_OPERATION);
/* Access the KEYD file which is always in the master directory. */ /* Access the KEYD file which is always in the master directory. */
err = iso7816_select_path (app->slot, path, DIM (path), NULL, NULL); err = iso7816_select_path (app->slot, path, DIM (path));
if (err) if (err)
return err; return err;
/* Due to the above select we need to re-select our application. */ /* Due to the above select we need to re-select our application. */
@ -1354,7 +1354,7 @@ switch_application (app_t app, int enable_sigg)
app->app_local->sigg_msig_checked = 1; app->app_local->sigg_msig_checked = 1;
app->app_local->sigg_is_msig = 1; app->app_local->sigg_is_msig = 1;
err = iso7816_select_file (app->slot, 0x5349, 0, NULL, NULL); err = iso7816_select_file (app->slot, 0x5349, 0);
if (!err) if (!err)
err = iso7816_read_record (app->slot, 1, 1, 0, &buffer, &buflen); err = iso7816_read_record (app->slot, 1, 1, 0, &buffer, &buflen);
if (!err) if (!err)

View File

@ -409,7 +409,7 @@ select_and_read_binary (int slot, unsigned short efid, const char *efid_desc,
{ {
gpg_error_t err; gpg_error_t err;
err = iso7816_select_file (slot, efid, 0, NULL, NULL); err = iso7816_select_file (slot, efid, 0);
if (err) if (err)
{ {
log_error ("error selecting %s (0x%04X): %s\n", log_error ("error selecting %s (0x%04X): %s\n",
@ -443,7 +443,7 @@ select_ef_by_path (app_t app, const unsigned short *path, size_t pathlen)
if (app->app_local->direct_path_selection) if (app->app_local->direct_path_selection)
{ {
err = iso7816_select_path (app->slot, path+1, pathlen-1, NULL, NULL); err = iso7816_select_path (app->slot, path+1, pathlen-1);
if (err) if (err)
{ {
log_error ("error selecting path "); log_error ("error selecting path ");
@ -461,8 +461,7 @@ select_ef_by_path (app_t app, const unsigned short *path, size_t pathlen)
supported by the card. */ supported by the card. */
for (i=0; i < pathlen; i++) for (i=0; i < pathlen; i++)
{ {
err = iso7816_select_file (app->slot, path[i], err = iso7816_select_file (app->slot, path[i], !(i+1 == pathlen));
!(i+1 == pathlen), NULL, NULL);
if (err) if (err)
{ {
log_error ("error selecting part %d from path ", i); log_error ("error selecting part %d from path ", i);
@ -2761,7 +2760,7 @@ micardo_mse (app_t app, unsigned short fid)
unsigned char msebuf[10]; unsigned char msebuf[10];
/* Read the KeyD file containing extra information on keys. */ /* Read the KeyD file containing extra information on keys. */
err = iso7816_select_file (app->slot, 0x0013, 0, NULL, NULL); err = iso7816_select_file (app->slot, 0x0013, 0);
if (err) if (err)
{ {
log_error ("error reading EF_keyD: %s\n", gpg_strerror (err)); log_error ("error reading EF_keyD: %s\n", gpg_strerror (err));
@ -3301,7 +3300,7 @@ app_select_p15 (app_t app)
Using the 2f02 just works. */ Using the 2f02 just works. */
unsigned short path[1] = { 0x2f00 }; unsigned short path[1] = { 0x2f00 };
rc = iso7816_select_path (app->slot, path, 1, NULL, NULL); rc = iso7816_select_path (app->slot, path, 1);
if (!rc) if (!rc)
{ {
direct = 1; direct = 1;
@ -3309,14 +3308,14 @@ app_select_p15 (app_t app)
if (def_home_df) if (def_home_df)
{ {
path[0] = def_home_df; path[0] = def_home_df;
rc = iso7816_select_path (app->slot, path, 1, NULL, NULL); rc = iso7816_select_path (app->slot, path, 1);
} }
} }
} }
if (rc) if (rc)
{ /* Still not found: Try the default DF. */ { /* Still not found: Try the default DF. */
def_home_df = 0x5015; def_home_df = 0x5015;
rc = iso7816_select_file (slot, def_home_df, 1, NULL, NULL); rc = iso7816_select_file (slot, def_home_df, 1);
} }
if (!rc) if (!rc)
{ {

View File

@ -208,9 +208,9 @@ app_new_register (int slot, ctrl_t ctrl, const char *name,
We skip this if the undefined application has been requested. */ We skip this if the undefined application has been requested. */
if (!want_undefined) if (!want_undefined)
{ {
err = iso7816_select_file (slot, 0x3F00, 1, NULL, NULL); err = iso7816_select_file (slot, 0x3F00, 1);
if (!err) if (!err)
err = iso7816_select_file (slot, 0x2F02, 0, NULL, NULL); err = iso7816_select_file (slot, 0x2F02, 0);
if (!err) if (!err)
err = iso7816_read_binary (slot, 0, 0, &result, &resultlen); err = iso7816_read_binary (slot, 0, 0, &result, &resultlen);
if (!err) if (!err)

View File

@ -138,8 +138,7 @@ iso7816_select_application (int slot, const char *aid, size_t aidlen,
gpg_error_t gpg_error_t
iso7816_select_file (int slot, int tag, int is_dir, iso7816_select_file (int slot, int tag, int is_dir)
unsigned char **result, size_t *resultlen)
{ {
int sw, p0, p1; int sw, p0, p1;
unsigned char tagbuf[2]; unsigned char tagbuf[2];
@ -147,14 +146,6 @@ iso7816_select_file (int slot, int tag, int is_dir,
tagbuf[0] = (tag >> 8) & 0xff; tagbuf[0] = (tag >> 8) & 0xff;
tagbuf[1] = tag & 0xff; tagbuf[1] = tag & 0xff;
if (result || resultlen)
{
*result = NULL;
*resultlen = 0;
return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
}
else
{
p0 = (tag == 0x3F00)? 0: is_dir? 1:2; p0 = (tag == 0x3F00)? 0: is_dir? 1:2;
p1 = 0x0c; /* No FC return. */ p1 = 0x0c; /* No FC return. */
sw = apdu_send_simple (slot, 0, 0x00, CMD_SELECT_FILE, sw = apdu_send_simple (slot, 0, 0x00, CMD_SELECT_FILE,
@ -162,26 +153,15 @@ iso7816_select_file (int slot, int tag, int is_dir,
return map_sw (sw); return map_sw (sw);
} }
return 0;
}
/* Do a select file command with a direct path. */ /* Do a select file command with a direct path. */
gpg_error_t gpg_error_t
iso7816_select_path (int slot, const unsigned short *path, size_t pathlen, iso7816_select_path (int slot, const unsigned short *path, size_t pathlen)
unsigned char **result, size_t *resultlen)
{ {
int sw, p0, p1; int sw, p0, p1;
unsigned char buffer[100]; unsigned char buffer[100];
int buflen; int buflen;
if (result || resultlen)
{
*result = NULL;
*resultlen = 0;
return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
}
if (pathlen/2 >= sizeof buffer) if (pathlen/2 >= sizeof buffer)
return gpg_error (GPG_ERR_TOO_LARGE); return gpg_error (GPG_ERR_TOO_LARGE);

View File

@ -51,11 +51,9 @@ gpg_error_t iso7816_map_sw (int sw);
gpg_error_t iso7816_select_application (int slot, gpg_error_t iso7816_select_application (int slot,
const char *aid, size_t aidlen, const char *aid, size_t aidlen,
unsigned int flags); unsigned int flags);
gpg_error_t iso7816_select_file (int slot, int tag, int is_dir, gpg_error_t iso7816_select_file (int slot, int tag, int is_dir);
unsigned char **result, size_t *resultlen);
gpg_error_t iso7816_select_path (int slot, gpg_error_t iso7816_select_path (int slot,
const unsigned short *path, size_t pathlen, const unsigned short *path, size_t pathlen);
unsigned char **result, size_t *resultlen);
gpg_error_t iso7816_list_directory (int slot, int list_dirs, gpg_error_t iso7816_list_directory (int slot, int list_dirs,
unsigned char **result, size_t *resultlen); unsigned char **result, size_t *resultlen);
gpg_error_t iso7816_apdu_direct (int slot, gpg_error_t iso7816_apdu_direct (int slot,