diff options
author | Werner Koch <wk@gnupg.org> | 2020-03-31 11:53:36 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2020-03-31 11:53:36 +0200 |
commit | c9ad81070a2bb1116d3f096a440c43e57e6f933a (patch) | |
tree | 57c6fdaf5ccbcaa420e3bff34bb1acede3d9ccbf /scd | |
parent | scd:p15: Improve diagnostics (diff) | |
download | gnupg2-c9ad81070a2bb1116d3f096a440c43e57e6f933a.tar.xz gnupg2-c9ad81070a2bb1116d3f096a440c43e57e6f933a.zip |
scd: Add function for binary read in extended mode.
* scd/iso7816.c (iso7816_read_binary): Factor code out to ...
(iso7816_read_binary_ext): new function. Add arg extended_mode.
Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'scd')
-rw-r--r-- | scd/iso7816.c | 18 | ||||
-rw-r--r-- | scd/iso7816.h | 3 |
2 files changed, 17 insertions, 4 deletions
diff --git a/scd/iso7816.c b/scd/iso7816.c index d44046e67..9d9ee2d66 100644 --- a/scd/iso7816.c +++ b/scd/iso7816.c @@ -825,8 +825,9 @@ iso7816_get_challenge (int slot, int length, unsigned char *buffer) stored in a newly allocated buffer at the address passed by RESULT. Returns the length of this data at the address of RESULTLEN. */ gpg_error_t -iso7816_read_binary (int slot, size_t offset, size_t nmax, - unsigned char **result, size_t *resultlen) +iso7816_read_binary_ext (int slot, int extended_mode, + size_t offset, size_t nmax, + unsigned char **result, size_t *resultlen) { int sw; unsigned char *buffer; @@ -849,13 +850,13 @@ iso7816_read_binary (int slot, size_t offset, size_t nmax, buffer = NULL; bufferlen = 0; n = read_all? 0 : nmax; - sw = apdu_send_le (slot, 0, 0x00, CMD_READ_BINARY, + sw = apdu_send_le (slot, extended_mode, 0x00, CMD_READ_BINARY, ((offset>>8) & 0xff), (offset & 0xff) , -1, NULL, n, &buffer, &bufferlen); if ( SW_EXACT_LENGTH_P(sw) ) { n = (sw & 0x00ff); - sw = apdu_send_le (slot, 0, 0x00, CMD_READ_BINARY, + sw = apdu_send_le (slot, extended_mode, 0x00, CMD_READ_BINARY, ((offset>>8) & 0xff), (offset & 0xff) , -1, NULL, n, &buffer, &bufferlen); } @@ -914,6 +915,15 @@ iso7816_read_binary (int slot, size_t offset, size_t nmax, return 0; } + +gpg_error_t +iso7816_read_binary (int slot, size_t offset, size_t nmax, + unsigned char **result, size_t *resultlen) +{ + return iso7816_read_binary_ext (slot, 0, offset, nmax, result, resultlen); +} + + /* Perform a READ RECORD command. RECNO gives the record number to read with 0 indicating the current record. RECCOUNT must be 1 (not all cards support reading of more than one record). SHORT_EF diff --git a/scd/iso7816.h b/scd/iso7816.h index c1940ad8d..1a9fed726 100644 --- a/scd/iso7816.h +++ b/scd/iso7816.h @@ -129,6 +129,9 @@ gpg_error_t iso7816_read_public_key (int slot, int extended_mode, gpg_error_t iso7816_get_challenge (int slot, int length, unsigned char *buffer); +gpg_error_t iso7816_read_binary_ext (int slot, int extended_mode, + size_t offset, size_t nmax, + unsigned char **result, size_t *resultlen); gpg_error_t iso7816_read_binary (int slot, size_t offset, size_t nmax, unsigned char **result, size_t *resultlen); gpg_error_t iso7816_read_record (int slot, int recno, int reccount, |