aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2020-03-31 09:53:36 +0000
committerWerner Koch <[email protected]>2020-04-01 12:55:30 +0000
commit64142caafe5c89ad4db36b47c2dc917a9ac66a8e (patch)
tree5ed614b7e28ca33c7471c9f9980169f966b689c1
parentscd:p15: Improve diagnostics (diff)
downloadgnupg-64142caafe5c89ad4db36b47c2dc917a9ac66a8e.tar.gz
gnupg-64142caafe5c89ad4db36b47c2dc917a9ac66a8e.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 <[email protected]>
-rw-r--r--scd/iso7816.c18
-rw-r--r--scd/iso7816.h3
2 files changed, 17 insertions, 4 deletions
diff --git a/scd/iso7816.c b/scd/iso7816.c
index 627481fd4..6920a683e 100644
--- a/scd/iso7816.c
+++ b/scd/iso7816.c
@@ -722,8 +722,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;
@@ -746,13 +747,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);
}
@@ -811,6 +812,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 8da5a943a..b46c7601b 100644
--- a/scd/iso7816.h
+++ b/scd/iso7816.h
@@ -117,6 +117,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,