[Pkg-gnupg-commit] [gnupg2] 17/124: scd: Fix API of select_file/_path.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Wed Apr 5 15:55:28 UTC 2017


This is an automated email from the git hooks/post-receive script.

dkg pushed a commit to branch experimental
in repository gnupg2.

commit 0703de01c8fbc417a99ecf8e950fc306b8c8ac9c
Author: NIIBE Yutaka <gniibe at fsij.org>
Date:   Mon Mar 6 13:39:46 2017 +0900

    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 at fsij.org>
---
 scd/app-dinsig.c |  2 +-
 scd/app-help.c   |  2 +-
 scd/app-nks.c    |  8 ++++----
 scd/app-p15.c    | 15 +++++++--------
 scd/app.c        |  4 ++--
 scd/iso7816.c    | 34 +++++++---------------------------
 scd/iso7816.h    |  8 +++-----
 7 files changed, 25 insertions(+), 48 deletions(-)

diff --git a/scd/app-dinsig.c b/scd/app-dinsig.c
index 99e4f00..5d65845 100644
--- a/scd/app-dinsig.c
+++ b/scd/app-dinsig.c
@@ -193,7 +193,7 @@ do_readcert (app_t app, const char *certid,
   /* Read the entire file.  fixme: This could be optimized by first
      reading the header to figure out how long the certificate
      actually is. */
-  err = iso7816_select_file (app->slot, fid, 0, NULL, NULL);
+  err = iso7816_select_file (app->slot, fid, 0);
   if (err)
     {
       log_error ("error selecting FID 0x%04X: %s\n", fid, gpg_strerror (err));
diff --git a/scd/app-help.c b/scd/app-help.c
index 1cc86b1..85bcc66 100644
--- a/scd/app-help.c
+++ b/scd/app-help.c
@@ -106,7 +106,7 @@ app_help_read_length_of_cert (int slot, int fid, size_t *r_certoff)
   int class, tag, constructed, ndef;
   size_t resultlen, objlen, hdrlen;
 
-  err = iso7816_select_file (slot, fid, 0, NULL, NULL);
+  err = iso7816_select_file (slot, fid, 0);
   if (err)
     {
       log_info ("error selecting FID 0x%04X: %s\n", fid, gpg_strerror (err));
diff --git a/scd/app-nks.c b/scd/app-nks.c
index 4442a10..98dd588 100644
--- a/scd/app-nks.c
+++ b/scd/app-nks.c
@@ -151,7 +151,7 @@ keygripstr_from_pk_file (app_t app, int fid, char *r_gripstr)
   int i;
   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)
     return err;
   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
      reading the header to figure out how long the certificate
      actually is. */
-  err = iso7816_select_file (app->slot, fid, 0, NULL, NULL);
+  err = iso7816_select_file (app->slot, fid, 0);
   if (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);
 
   /* 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)
     return err;
   /* 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_is_msig = 1;
-      err = iso7816_select_file (app->slot, 0x5349, 0, NULL, NULL);
+      err = iso7816_select_file (app->slot, 0x5349, 0);
       if (!err)
         err = iso7816_read_record (app->slot, 1, 1, 0, &buffer, &buflen);
       if (!err)
diff --git a/scd/app-p15.c b/scd/app-p15.c
index 3def55b..db8c38e 100644
--- a/scd/app-p15.c
+++ b/scd/app-p15.c
@@ -409,7 +409,7 @@ select_and_read_binary (int slot, unsigned short efid, const char *efid_desc,
 {
   gpg_error_t err;
 
-  err = iso7816_select_file (slot, efid, 0, NULL, NULL);
+  err = iso7816_select_file (slot, efid, 0);
   if (err)
     {
       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)
     {
-      err = iso7816_select_path (app->slot, path+1, pathlen-1, NULL, NULL);
+      err = iso7816_select_path (app->slot, path+1, pathlen-1);
       if (err)
         {
           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. */
       for (i=0; i < pathlen; i++)
         {
-          err = iso7816_select_file (app->slot, path[i],
-                                     !(i+1 == pathlen), NULL, NULL);
+          err = iso7816_select_file (app->slot, path[i], !(i+1 == pathlen));
           if (err)
             {
               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];
 
   /* 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)
     {
       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. */
       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)
         {
           direct = 1;
@@ -3309,14 +3308,14 @@ app_select_p15 (app_t app)
           if (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)
     { /* Still not found:  Try the default DF. */
       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)
     {
diff --git a/scd/app.c b/scd/app.c
index 1d81631..e1c4e10 100644
--- a/scd/app.c
+++ b/scd/app.c
@@ -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. */
   if (!want_undefined)
     {
-      err = iso7816_select_file (slot, 0x3F00, 1, NULL, NULL);
+      err = iso7816_select_file (slot, 0x3F00, 1);
       if (!err)
-        err = iso7816_select_file (slot, 0x2F02, 0, NULL, NULL);
+        err = iso7816_select_file (slot, 0x2F02, 0);
       if (!err)
         err = iso7816_read_binary (slot, 0, 0, &result, &resultlen);
       if (!err)
diff --git a/scd/iso7816.c b/scd/iso7816.c
index 6cfa6b6..8f79698 100644
--- a/scd/iso7816.c
+++ b/scd/iso7816.c
@@ -138,8 +138,7 @@ iso7816_select_application (int slot, const char *aid, size_t aidlen,
 
 
 gpg_error_t
-iso7816_select_file (int slot, int tag, int is_dir,
-                     unsigned char **result, size_t *resultlen)
+iso7816_select_file (int slot, int tag, int is_dir)
 {
   int sw, p0, p1;
   unsigned char tagbuf[2];
@@ -147,41 +146,22 @@ iso7816_select_file (int slot, int tag, int is_dir,
   tagbuf[0] = (tag >> 8) & 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;
-      p1 = 0x0c; /* No FC return. */
-      sw = apdu_send_simple (slot, 0, 0x00, CMD_SELECT_FILE,
-                             p0, p1, 2, (char*)tagbuf );
-      return map_sw (sw);
-    }
-
-  return 0;
+  p0 = (tag == 0x3F00)? 0: is_dir? 1:2;
+  p1 = 0x0c; /* No FC return. */
+  sw = apdu_send_simple (slot, 0, 0x00, CMD_SELECT_FILE,
+                         p0, p1, 2, (char*)tagbuf );
+  return map_sw (sw);
 }
 
 
 /* Do a select file command with a direct path. */
 gpg_error_t
-iso7816_select_path (int slot, const unsigned short *path, size_t pathlen,
-                     unsigned char **result, size_t *resultlen)
+iso7816_select_path (int slot, const unsigned short *path, size_t pathlen)
 {
   int sw, p0, p1;
   unsigned char buffer[100];
   int buflen;
 
-  if (result || resultlen)
-    {
-      *result = NULL;
-      *resultlen = 0;
-      return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
-    }
-
   if (pathlen/2 >= sizeof buffer)
     return gpg_error (GPG_ERR_TOO_LARGE);
 
diff --git a/scd/iso7816.h b/scd/iso7816.h
index bcef473..4c71bbd 100644
--- a/scd/iso7816.h
+++ b/scd/iso7816.h
@@ -51,11 +51,9 @@ gpg_error_t iso7816_map_sw (int sw);
 gpg_error_t iso7816_select_application (int slot,
                                         const char *aid, size_t aidlen,
                                         unsigned int flags);
-gpg_error_t iso7816_select_file (int slot, int tag, int is_dir,
-                                 unsigned char **result, size_t *resultlen);
+gpg_error_t iso7816_select_file (int slot, int tag, int is_dir);
 gpg_error_t iso7816_select_path (int slot,
-                                 const unsigned short *path, size_t pathlen,
-                                 unsigned char **result, size_t *resultlen);
+                                 const unsigned short *path, size_t pathlen);
 gpg_error_t iso7816_list_directory (int slot, int list_dirs,
                                     unsigned char **result, size_t *resultlen);
 gpg_error_t iso7816_apdu_direct (int slot,
@@ -71,7 +69,7 @@ gpg_error_t iso7816_change_reference_data (int slot, int chvno,
                                const char *oldchv, size_t oldchvlen,
                                const char *newchv, size_t newchvlen);
 gpg_error_t iso7816_change_reference_data_kp (int slot, int chvno,
-					      int is_exchange,
+                                              int is_exchange,
                                               pininfo_t *pininfo);
 gpg_error_t iso7816_reset_retry_counter (int slot, int chvno,
                                          const char *newchv, size_t newchvlen);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git



More information about the Pkg-gnupg-commit mailing list