Ticket #20 (closed defect: fixed)
NB! Read about ReportingBugs before filing a ticket!
few fixes to pkcs15-init
| Reported by: | richard.musil@… | Owned by: | devel |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | pkcs15init | Version: | devel |
| Severity: | normal | Keywords: | |
| Cc: | Blocked By: | ||
| Blocking: |
Description
I am playing with pkcs15-init right now (trying to teach it new card) and during this found several quirks. I am submitting patch here with comments inside. Also I wonder, whether there is some standard procedure to submit patches, or if I should use Tickets?
Index: src/pkcs15init/profile.c
[default values for EF structure should not be intialized for DF type]
===================================================================
--- src/pkcs15init/profile.c (revision 2359)
+++ src/pkcs15init/profile.c (working copy)
@@ -236,7 +236,8 @@
}
file->type = type;
file->status = SC_FILE_STATUS_ACTIVATED;
- file->ef_structure = SC_FILE_EF_TRANSPARENT;
+ if (file->type != SC_FILE_TYPE_DF)
+ file->ef_structure = SC_FILE_EF_TRANSPARENT;
return file;
}
Index: src/libopensc/card.c
[when cards support only T=0, the TPDU cannot contain last Le byte]
[I have changed the logic for logging only because I was not able to figure out
the purpose of the original implementation, so feel free to ignore this change :)]
===================================================================
--- src/libopensc/card.c (revision 2359)
+++ src/libopensc/card.c (working copy)
@@ -180,10 +180,12 @@
return SC_ERROR_INVALID_ARGUMENTS;
memcpy(data, apdu->data, data_bytes);
data += data_bytes;
- if (apdu->le == 256)
- *data++ = 0x00;
- else
- *data++ = (u8) apdu->le;
+ /* omit Le in APDU for T=0 TPDU if necessary */
+ if (card->slot->active_protocol == SC_PROTO_T1)
+ if (apdu->le == 256)
+ *data++ = 0x00;
+ else
+ *data++ = (u8) apdu->le;
break;
}
sendsize = data - sbuf;
@@ -198,18 +200,18 @@
char buf[2048];
#ifndef OPENSC_DONT_LOG_SENSITIVE
- if (!apdu->sensitive || card->ctx->debug >= 6)
+ if (1)
#else
- if (!apdu->sensitive)
+ if (!apdu->sensitive)
#endif
- sc_hex_dump(card->ctx, sbuf, sendsize, buf, sizeof(buf));
- else
- /* sensitive information: just print the command
- * header and no data */
- snprintf(buf, sizeof(buf), "%02x %02x %02x %02x [sensitive data]",
- apdu->cla, apdu->ins, apdu->p1, apdu->p2);
+ sc_hex_dump(card->ctx, sbuf, sendsize, buf, sizeof(buf));
+ else
+ /* sensitive information: just print the command
+ * header and no data */
+ snprintf(buf, sizeof(buf), "%02x %02x %02x %02x [sensitive data]",
+ apdu->cla, apdu->ins, apdu->p1, apdu->p2);
- sc_debug(card->ctx, "Sending %d bytes (resp. %d bytes%s):\n%s",
+ sc_debug(card->ctx, "Sending %d bytes (expecting %d bytes%s):\n%s",
sendsize, recvsize,
apdu->sensitive ? ", sensitive" : "", buf);
}
Index: src/libopensc/iso7816.c
[when constructing FCI for file, EF structure type should be included
only for EF type - this is related to fix in profile.c]
===================================================================
--- src/libopensc/iso7816.c (revision 2359)
+++ src/libopensc/iso7816.c (working copy)
@@ -509,10 +509,10 @@
} else {
buf[0] = file->shareable ? 0x40 : 0;
switch (file->type) {
- case SC_FILE_TYPE_WORKING_EF:
- break;
case SC_FILE_TYPE_INTERNAL_EF:
buf[0] |= 0x08;
+ case SC_FILE_TYPE_WORKING_EF:
+ buf[0] |= file->ef_structure & 7;
break;
case SC_FILE_TYPE_DF:
buf[0] |= 0x38;
@@ -520,7 +520,6 @@
default:
return SC_ERROR_NOT_SUPPORTED;
}
- buf[0] |= file->ef_structure & 7;
sc_asn1_put_tag(0x82, buf, 1, p, 16, &p);
}
buf[0] = (file->id >> 8) & 0xFF;
Change History
Note: See
TracTickets for help on using
tickets.

You can submit a patch as an attachment here to a ticket describing the bug or send it to opensc-devel list.