aboutsummaryrefslogtreecommitdiffstats
path: root/scd/iso7816.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2004-03-16 18:59:21 +0000
committerWerner Koch <[email protected]>2004-03-16 18:59:21 +0000
commite209ea3c39e7110d94e4420513f397d8656a75b7 (patch)
tree6ce23948ac5b3c3c1c0bb0205fc953fe7a24f13e /scd/iso7816.c
parent(main): Implemented --gpgconf-list. (diff)
downloadgnupg-e209ea3c39e7110d94e4420513f397d8656a75b7.tar.gz
gnupg-e209ea3c39e7110d94e4420513f397d8656a75b7.zip
* app-dinsig.c: Implemented. Based on app-nks.c and card-dinsig.c
* app-nks.c (get_length_of_cert): Removed. * app-help.c: New. (app_help_read_length_of_cert): New. Code taken from above. New optional arg R_CERTOFF. * card-dinsig.c: Removed. * card.c (card_get_serial_and_stamp): Do not bind to the old and never finsiged card-dinsig.c. * iso7816.c (iso7816_read_binary): Allow for an NMAX > 254.
Diffstat (limited to 'scd/iso7816.c')
-rw-r--r--scd/iso7816.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/scd/iso7816.c b/scd/iso7816.c
index d7d3c126b..24361d148 100644
--- a/scd/iso7816.c
+++ b/scd/iso7816.c
@@ -488,6 +488,8 @@ iso7816_read_binary (int slot, size_t offset, size_t nmax,
int sw;
unsigned char *buffer;
size_t bufferlen;
+ int read_all = !nmax;
+ size_t n;
if (!result || !resultlen)
return gpg_error (GPG_ERR_INV_VALUE);
@@ -496,18 +498,22 @@ iso7816_read_binary (int slot, size_t offset, size_t nmax,
/* We can only encode 15 bits in p0,p1 to indicate an offset. Thus
we check for this limit. */
- if (offset > 32767 || nmax > 254)
+ if (offset > 32767)
return gpg_error (GPG_ERR_INV_VALUE);
do
{
buffer = NULL;
bufferlen = 0;
- /* Fixme: Either the ccid driver of the TCOS cards have problems
+ /* Fixme: Either the ccid driver or the TCOS cards have problems
with an Le of 0. */
+ if (read_all || nmax > 254)
+ n = 254;
+ else
+ n = nmax;
sw = apdu_send_le (slot, 0x00, CMD_READ_BINARY,
- ((offset>>8) & 0xff), (offset & 0xff) , -1, NULL,
- nmax? nmax : 254, &buffer, &bufferlen);
+ ((offset>>8) & 0xff), (offset & 0xff) , -1, NULL,
+ n, &buffer, &bufferlen);
if (sw != SW_SUCCESS && sw != SW_EOF_REACHED)
{
@@ -545,8 +551,12 @@ iso7816_read_binary (int slot, size_t offset, size_t nmax,
if (offset > 32767)
break; /* We simply truncate the result for too large
files. */
+ if (nmax > bufferlen)
+ nmax -= bufferlen;
+ else
+ nmax = 0;
}
- while (!nmax && sw != SW_EOF_REACHED);
+ while ((read_all && sw != SW_EOF_REACHED) || (!read_all && nmax));
return 0;
}