diff options
Diffstat (limited to 'scd/iso7816.c')
-rw-r--r-- | scd/iso7816.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/scd/iso7816.c b/scd/iso7816.c index 450590175..dcb2845c7 100644 --- a/scd/iso7816.c +++ b/scd/iso7816.c @@ -193,18 +193,26 @@ iso7816_select_file (int slot, int tag, int is_dir) } -/* Do a select file command with a direct path. */ +/* Do a select file command with a direct path. If TOPDF is set, the + * actual used path is 3f00/<topdf>/<path>. */ 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 short topdf) { int sw, p0, p1; unsigned char buffer[100]; - int buflen; + int buflen = 0; - if (pathlen/2 >= sizeof buffer) + if (pathlen*2 + 2 >= sizeof buffer) return gpg_error (GPG_ERR_TOO_LARGE); - for (buflen = 0; pathlen; pathlen--, path++) + if (topdf) + { + buffer[buflen++] = topdf >> 8; + buffer[buflen++] = topdf; + } + + for (; pathlen; pathlen--, path++) { buffer[buflen++] = (*path >> 8); buffer[buflen++] = *path; |