* [Qemu-devel] [PATCH v2 00/10] ccid and libcacard fixes for windows/mingw
@ 2013-03-27 20:36 Alon Levy
2013-03-27 20:36 ` [Qemu-devel] [PATCH v2 01/10] libcacard: change default ATR Alon Levy
` (10 more replies)
0 siblings, 11 replies; 13+ messages in thread
From: Alon Levy @ 2013-03-27 20:36 UTC (permalink / raw)
To: qemu-devel; +Cc: mlureau
This series:
1. fixes windows guests to show the ccid device
2. changes libcacard to use glib
3. makes libcacard build under mingw
4. does some cleanups
It contains a few patches already posted to the list (the two Jim Meyering patches) which were already acked.
I'll make a pull request once this had some time to be reviewed.
Tested with a fedora and windows 7 guest.
The main non cleanup patches are:
hw/usb/dev-smartcard-reader: support windows guest
libcacard: correct T0 historical bytes size
v2:
only resent patches that were not acked before.
did all the changes per Marc Andre's comments. Please look at the g_debug one, I'm not sure
about the ifdeffery there (not if it works, but if it looks ok).
Alon Levy (10):
libcacard: change default ATR
ccid-card-passthru: add atr check
ccid-card-passthru, dev-smartcard-reader: add debug environment
variables
dev-smartcard-reader: define structs for CCID_Parameter internals
dev-smartcard-reader: change default protocol to T=0
dev-smartcard-reader: copy atr protocol to ccid parameters
libcacard/vreader: add debugging messages for apdu
libcacard: move atr setting from macro to function
dev-smartcard-reader: empty implementation for Mechanical (fail
correctly)
libcacard/cac: change big switch functions to single return point
Makefile.objs | 1 +
hw/ccid-card-passthru.c | 61 ++++++++++++++++++++
hw/usb/dev-smartcard-reader.c | 130 ++++++++++++++++++++++++++++++++----------
include/qemu-common.h | 5 ++
libcacard/cac.c | 80 +++++++++++++++++---------
libcacard/cac.h | 8 +++
libcacard/vcard_emul_nss.c | 14 ++++-
libcacard/vcardt.c | 40 +++++++++++++
libcacard/vcardt.h | 5 --
libcacard/vcardt_internal.h | 6 ++
libcacard/vreader.c | 77 +++++++++++++++++++++++++
util/cutils.c | 23 ++++++++
12 files changed, 384 insertions(+), 66 deletions(-)
create mode 100644 libcacard/vcardt.c
create mode 100644 libcacard/vcardt_internal.h
--
1.8.1.4
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH v2 01/10] libcacard: change default ATR
2013-03-27 20:36 [Qemu-devel] [PATCH v2 00/10] ccid and libcacard fixes for windows/mingw Alon Levy
@ 2013-03-27 20:36 ` Alon Levy
2013-03-27 20:36 ` [Qemu-devel] [PATCH v2 02/10] ccid-card-passthru: add atr check Alon Levy
` (9 subsequent siblings)
10 siblings, 0 replies; 13+ messages in thread
From: Alon Levy @ 2013-03-27 20:36 UTC (permalink / raw)
To: qemu-devel; +Cc: mlureau
Signed-off-by: Alon Levy <alevy@redhat.com>
---
libcacard/vcardt.h | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/libcacard/vcardt.h b/libcacard/vcardt.h
index 538bdde..3b9a619 100644
--- a/libcacard/vcardt.h
+++ b/libcacard/vcardt.h
@@ -26,9 +26,17 @@ typedef struct VCardEmulStruct VCardEmul;
#define MAX_CHANNEL 4
/* create an ATR with appropriate historical bytes */
-#define VCARD_ATR_PREFIX(size) 0x3b, 0x66+(size), 0x00, 0xff, \
- 'V', 'C', 'A', 'R', 'D', '_'
+#define TS_DIRECT_CONVENTION 0x3b
+#define TA_PRESENT 0x10
+#define TB_PRESENT 0x20
+#define TC_PRESENT 0x40
+#define TD_PRESENT 0x80
+#define VCARD_ATR_PREFIX(size) \
+ TS_DIRECT_CONVENTION, \
+ TD_PRESENT + (6 + size), \
+ 0x00, \
+ 'V', 'C', 'A', 'R', 'D', '_'
typedef enum {
VCARD_DONE,
--
1.8.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH v2 02/10] ccid-card-passthru: add atr check
2013-03-27 20:36 [Qemu-devel] [PATCH v2 00/10] ccid and libcacard fixes for windows/mingw Alon Levy
2013-03-27 20:36 ` [Qemu-devel] [PATCH v2 01/10] libcacard: change default ATR Alon Levy
@ 2013-03-27 20:36 ` Alon Levy
2013-03-27 20:36 ` [Qemu-devel] [PATCH v2 03/10] ccid-card-passthru, dev-smartcard-reader: add debug environment variables Alon Levy
` (8 subsequent siblings)
10 siblings, 0 replies; 13+ messages in thread
From: Alon Levy @ 2013-03-27 20:36 UTC (permalink / raw)
To: qemu-devel; +Cc: mlureau
Signed-off-by: Alon Levy <alevy@redhat.com>
---
hw/ccid-card-passthru.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+)
diff --git a/hw/ccid-card-passthru.c b/hw/ccid-card-passthru.c
index 3566e55..111894f 100644
--- a/hw/ccid-card-passthru.c
+++ b/hw/ccid-card-passthru.c
@@ -138,6 +138,59 @@ static void ccid_card_vscard_handle_init(
ccid_card_vscard_send_init(card);
}
+static int check_atr(PassthruState *card, uint8_t *data, int len)
+{
+ int historical_length, opt_bytes;
+ int td_count = 0;
+ int td;
+
+ if (len < 2) {
+ return 0;
+ }
+ historical_length = data[1] & 0xf;
+ opt_bytes = 0;
+ if (data[0] != 0x3b && data[0] != 0x3f) {
+ DPRINTF(card, D_WARN, "atr's T0 is 0x%X, not in {0x3b, 0x3f}\n",
+ data[0]);
+ return 0;
+ }
+ td_count = 0;
+ td = data[1] >> 4;
+ while (td && td_count < 2 && opt_bytes + historical_length + 2 < len) {
+ td_count++;
+ if (td & 0x1) {
+ opt_bytes++;
+ }
+ if (td & 0x2) {
+ opt_bytes++;
+ }
+ if (td & 0x4) {
+ opt_bytes++;
+ }
+ if (td & 0x8) {
+ opt_bytes++;
+ td = data[opt_bytes + 2] >> 4;
+ }
+ }
+ if (len < 2 + historical_length + opt_bytes) {
+ DPRINTF(card, D_WARN,
+ "atr too short: len %d, but historical_len %d, T1 0x%X\n",
+ len, historical_length, data[1]);
+ return 0;
+ }
+ if (len > 2 + historical_length + opt_bytes) {
+ DPRINTF(card, D_WARN,
+ "atr too long: len %d, but hist/opt %d/%d, T1 0x%X\n",
+ len, historical_length, opt_bytes, data[1]);
+ /* let it through */
+ }
+ DPRINTF(card, D_VERBOSE,
+ "atr passes check: %d total length, %d historical, %d optional\n",
+ len, historical_length, opt_bytes);
+
+ return 1;
+}
+
static void ccid_card_vscard_handle_message(PassthruState *card,
VSCMsgHeader *scr_msg_header)
{
@@ -152,6 +205,12 @@ static void ccid_card_vscard_handle_message(PassthruState *card,
VSC_GENERAL_ERROR);
break;
}
+ if (!check_atr(card, data, scr_msg_header->length)) {
+ error_report("ATR is inconsistent, ignoring");
+ ccid_card_vscard_send_error(card, scr_msg_header->reader_id,
+ VSC_GENERAL_ERROR);
+ break;
+ }
memcpy(card->atr, data, scr_msg_header->length);
card->atr_length = scr_msg_header->length;
ccid_card_card_inserted(&card->base);
--
1.8.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH v2 03/10] ccid-card-passthru, dev-smartcard-reader: add debug environment variables
2013-03-27 20:36 [Qemu-devel] [PATCH v2 00/10] ccid and libcacard fixes for windows/mingw Alon Levy
2013-03-27 20:36 ` [Qemu-devel] [PATCH v2 01/10] libcacard: change default ATR Alon Levy
2013-03-27 20:36 ` [Qemu-devel] [PATCH v2 02/10] ccid-card-passthru: add atr check Alon Levy
@ 2013-03-27 20:36 ` Alon Levy
2013-03-27 20:36 ` [Qemu-devel] [PATCH v2 04/10] dev-smartcard-reader: define structs for CCID_Parameter internals Alon Levy
` (7 subsequent siblings)
10 siblings, 0 replies; 13+ messages in thread
From: Alon Levy @ 2013-03-27 20:36 UTC (permalink / raw)
To: qemu-devel; +Cc: mlureau
Introduces a new utility function: parse_debug_env to avoid code
duplication.
This overrides whatever debug value is set on the corresponding devices
from the command line, and is meant to ease the usage with any
management stack. For libvirt you can set environment variables by
extending the dom namespace, i.e:
<domain type='kvm' id='3' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
<qemu:commandline>
<qemu:env name='QEMU_CCID_PASSTHRU_DEBUG' value='4'/>
<qemu:env name='QEMU_CCID_DEBUG' value='4'/>
</qemu:commandline>
</domain>
Signed-off-by: Alon Levy <alevy@redhat.com>
---
hw/ccid-card-passthru.c | 2 ++
hw/usb/dev-smartcard-reader.c | 1 +
include/qemu-common.h | 5 +++++
util/cutils.c | 23 +++++++++++++++++++++++
4 files changed, 31 insertions(+)
diff --git a/hw/ccid-card-passthru.c b/hw/ccid-card-passthru.c
index 111894f..a5d4551 100644
--- a/hw/ccid-card-passthru.c
+++ b/hw/ccid-card-passthru.c
@@ -350,6 +350,8 @@ static int passthru_initfn(CCIDCardState *base)
error_report("missing chardev");
return -1;
}
+ card->debug = parse_debug_env("QEMU_CCID_PASSTHRU_DEBUG", D_VERBOSE,
+ card->debug);
assert(sizeof(DEFAULT_ATR) <= MAX_ATR_SIZE);
memcpy(card->atr, DEFAULT_ATR, sizeof(DEFAULT_ATR));
card->atr_length = sizeof(DEFAULT_ATR);
diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c
index 9145346..751bd04 100644
--- a/hw/usb/dev-smartcard-reader.c
+++ b/hw/usb/dev-smartcard-reader.c
@@ -1260,6 +1260,7 @@ static int ccid_initfn(USBDevice *dev)
s->bulk_out_pos = 0;
ccid_reset_parameters(s);
ccid_reset(s);
+ s->debug = parse_debug_env("QEMU_CCID_DEBUG", D_VERBOSE, s->debug);
return 0;
}
diff --git a/include/qemu-common.h b/include/qemu-common.h
index 31fff22..dee6015 100644
--- a/include/qemu-common.h
+++ b/include/qemu-common.h
@@ -479,4 +479,9 @@ can_use_buffer_find_nonzero_offset(const void *buf, size_t len)
}
size_t buffer_find_nonzero_offset(const void *buf, size_t len);
+/*
+ * helper to parse debug environment variables
+ */
+int parse_debug_env(const char *name, int max, int initial);
+
#endif
diff --git a/util/cutils.c b/util/cutils.c
index 5024253..a165819 100644
--- a/util/cutils.c
+++ b/util/cutils.c
@@ -482,3 +482,26 @@ int uleb128_decode_small(const uint8_t *in, uint32_t *n)
return 2;
}
}
+
+/*
+ * helper to parse debug environment variables
+ */
+int parse_debug_env(const char *name, int max, int initial)
+{
+ char *debug_env = getenv(name);
+ char *inv = NULL;
+ int debug;
+
+ if (!debug_env) {
+ return initial;
+ }
+ debug = strtol(debug_env, &inv, 10);
+ if (inv == debug_env) {
+ return initial;
+ }
+ if (debug < 0 || debug > max) {
+ fprintf(stderr, "warning: %s not in [0, %d]", name, max);
+ return initial;
+ }
+ return debug;
+}
--
1.8.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH v2 04/10] dev-smartcard-reader: define structs for CCID_Parameter internals
2013-03-27 20:36 [Qemu-devel] [PATCH v2 00/10] ccid and libcacard fixes for windows/mingw Alon Levy
` (2 preceding siblings ...)
2013-03-27 20:36 ` [Qemu-devel] [PATCH v2 03/10] ccid-card-passthru, dev-smartcard-reader: add debug environment variables Alon Levy
@ 2013-03-27 20:36 ` Alon Levy
2013-03-27 20:36 ` [Qemu-devel] [PATCH v2 05/10] dev-smartcard-reader: change default protocol to T=0 Alon Levy
` (6 subsequent siblings)
10 siblings, 0 replies; 13+ messages in thread
From: Alon Levy @ 2013-03-27 20:36 UTC (permalink / raw)
To: qemu-devel; +Cc: mlureau
Signed-off-by: Alon Levy <alevy@redhat.com>
---
hw/usb/dev-smartcard-reader.c | 74 +++++++++++++++++++++++++++----------------
1 file changed, 47 insertions(+), 27 deletions(-)
diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c
index 751bd04..014c0b1 100644
--- a/hw/usb/dev-smartcard-reader.c
+++ b/hw/usb/dev-smartcard-reader.c
@@ -189,10 +189,34 @@ typedef struct QEMU_PACKED CCID_SlotStatus {
uint8_t bClockStatus;
} CCID_SlotStatus;
+typedef struct QEMU_PACKED CCID_T0ProtocolDataStructure {
+ uint8_t bmFindexDindex;
+ uint8_t bmTCCKST0;
+ uint8_t bGuardTimeT0;
+ uint8_t bWaitingIntegerT0;
+ uint8_t bClockStop;
+} CCID_T0ProtocolDataStructure;
+
+typedef struct QEMU_PACKED CCID_T1ProtocolDataStructure {
+ uint8_t bmFindexDindex;
+ uint8_t bmTCCKST1;
+ uint8_t bGuardTimeT1;
+ uint8_t bWaitingIntegerT1;
+ uint8_t bClockStop;
+ uint8_t bIFSC;
+ uint8_t bNadValue;
+} CCID_T1ProtocolDataStructure;
+
+typedef union CCID_ProtocolDataStructure {
+ CCID_T0ProtocolDataStructure t0;
+ CCID_T1ProtocolDataStructure t1;
+ uint8_t data[7]; /* must be = max(sizeof(t0), sizeof(t1)) */
+} CCID_ProtocolDataStructure;
+
typedef struct QEMU_PACKED CCID_Parameter {
CCID_BULK_IN b;
uint8_t bProtocolNum;
- uint8_t abProtocolDataStructure[0];
+ CCID_ProtocolDataStructure abProtocolDataStructure;
} CCID_Parameter;
typedef struct QEMU_PACKED CCID_DataBlock {
@@ -224,7 +248,7 @@ typedef struct QEMU_PACKED CCID_SetParameters {
CCID_Header hdr;
uint8_t bProtocolNum;
uint16_t abRFU;
- uint8_t abProtocolDataStructure[0];
+ CCID_ProtocolDataStructure abProtocolDataStructure;
} CCID_SetParameters;
typedef struct CCID_Notify_Slot_Change {
@@ -254,8 +278,6 @@ typedef struct CCIDBus {
BusState qbus;
} CCIDBus;
-#define MAX_PROTOCOL_SIZE 7
-
/*
* powered - defaults to true, changed by PowerOn/PowerOff messages
*/
@@ -279,7 +301,7 @@ typedef struct USBCCIDState {
uint8_t bError;
uint8_t bmCommandStatus;
uint8_t bProtocolNum;
- uint8_t abProtocolDataStructure[MAX_PROTOCOL_SIZE];
+ CCID_ProtocolDataStructure abProtocolDataStructure;
uint32_t ulProtocolDataStructureSize;
uint32_t state_vmstate;
uint32_t migration_target_ip;
@@ -765,7 +787,7 @@ static void ccid_write_parameters(USBCCIDState *s, CCID_Header *recv)
h->b.bStatus = ccid_calc_status(s);
h->b.bError = s->bError;
h->bProtocolNum = s->bProtocolNum;
- memcpy(h->abProtocolDataStructure, s->abProtocolDataStructure, len);
+ h->abProtocolDataStructure = s->abProtocolDataStructure;
ccid_reset_error_status(s);
}
@@ -825,38 +847,36 @@ static void ccid_write_data_block_atr(USBCCIDState *s, CCID_Header *recv)
static void ccid_set_parameters(USBCCIDState *s, CCID_Header *recv)
{
CCID_SetParameters *ph = (CCID_SetParameters *) recv;
- uint32_t len = 0;
- if ((ph->bProtocolNum & 3) == 0) {
- len = 5;
- }
- if ((ph->bProtocolNum & 3) == 1) {
- len = 7;
- }
- if (len == 0) {
- s->bmCommandStatus = COMMAND_STATUS_FAILED;
- s->bError = 7; /* Protocol invalid or not supported */
+ uint32_t protocol_num = ph->bProtocolNum & 3;
+
+ if (protocol_num != 0 && protocol_num != 1) {
+ ccid_report_error_failed(s, ERROR_CMD_NOT_SUPPORTED);
return;
}
- s->bProtocolNum = ph->bProtocolNum;
- memcpy(s->abProtocolDataStructure, ph->abProtocolDataStructure, len);
- s->ulProtocolDataStructureSize = len;
- DPRINTF(s, 1, "%s: using len %d\n", __func__, len);
+ s->bProtocolNum = protocol_num;
+ s->abProtocolDataStructure = ph->abProtocolDataStructure;
}
/*
* must be 5 bytes for T=0, 7 bytes for T=1
* See page 52
*/
-static const uint8_t abDefaultProtocolDataStructure[7] = {
- 0x77, 0x00, 0x00, 0x00, 0x00, 0xfe /*IFSC*/, 0x00 /*NAD*/ };
+static const CCID_ProtocolDataStructure defaultProtocolDataStructure = {
+ .t1 = {
+ .bmFindexDindex = 0x77,
+ .bmTCCKST1 = 0x00,
+ .bGuardTimeT1 = 0x00,
+ .bWaitingIntegerT1 = 0x00,
+ .bClockStop = 0x00,
+ .bIFSC = 0xfe,
+ .bNadValue = 0x00,
+ }
+};
static void ccid_reset_parameters(USBCCIDState *s)
{
- uint32_t len = sizeof(abDefaultProtocolDataStructure);
-
s->bProtocolNum = 1; /* T=1 */
- s->ulProtocolDataStructureSize = len;
- memcpy(s->abProtocolDataStructure, abDefaultProtocolDataStructure, len);
+ s->abProtocolDataStructure = defaultProtocolDataStructure;
}
/* NOTE: only a single slot is supported (SLOT_0) */
@@ -1345,7 +1365,7 @@ static VMStateDescription ccid_vmstate = {
VMSTATE_UINT8(bError, USBCCIDState),
VMSTATE_UINT8(bmCommandStatus, USBCCIDState),
VMSTATE_UINT8(bProtocolNum, USBCCIDState),
- VMSTATE_BUFFER(abProtocolDataStructure, USBCCIDState),
+ VMSTATE_BUFFER(abProtocolDataStructure.data, USBCCIDState),
VMSTATE_UINT32(ulProtocolDataStructureSize, USBCCIDState),
VMSTATE_STRUCT_ARRAY(bulk_in_pending, USBCCIDState,
BULK_IN_PENDING_NUM, 1, bulk_in_vmstate, BulkIn),
--
1.8.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH v2 05/10] dev-smartcard-reader: change default protocol to T=0
2013-03-27 20:36 [Qemu-devel] [PATCH v2 00/10] ccid and libcacard fixes for windows/mingw Alon Levy
` (3 preceding siblings ...)
2013-03-27 20:36 ` [Qemu-devel] [PATCH v2 04/10] dev-smartcard-reader: define structs for CCID_Parameter internals Alon Levy
@ 2013-03-27 20:36 ` Alon Levy
2013-03-27 20:36 ` [Qemu-devel] [PATCH v2 06/10] dev-smartcard-reader: copy atr protocol to ccid parameters Alon Levy
` (5 subsequent siblings)
10 siblings, 0 replies; 13+ messages in thread
From: Alon Levy @ 2013-03-27 20:36 UTC (permalink / raw)
To: qemu-devel; +Cc: mlureau
We don't support T=1 so we shouldn't advertise it by default.
Two independent changes:
* Default ATR
sets T=0. This gets overwritten by the client provided ATR later.
* Class descriptor
changes dwAdvertise dwProtocols.PPPP to 0x1 and dwProtocols.RRRR=0 per spec.
Signed-off-by: Alon Levy <alevy@redhat.com>
---
hw/usb/dev-smartcard-reader.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c
index 014c0b1..bb96f02 100644
--- a/hw/usb/dev-smartcard-reader.c
+++ b/hw/usb/dev-smartcard-reader.c
@@ -335,8 +335,8 @@ static const uint8_t qemu_ccid_descriptor[] = {
*/
0x07, /* u8 bVoltageSupport; 01h - 5.0v, 02h - 3.0, 03 - 1.8 */
- 0x03, 0x00, /* u32 dwProtocols; RRRR PPPP. RRRR = 0000h.*/
- 0x00, 0x00, /* PPPP: 0001h = Protocol T=0, 0002h = Protocol T=1 */
+ 0x00, 0x00, /* u32 dwProtocols; RRRR PPPP. RRRR = 0000h.*/
+ 0x01, 0x00, /* PPPP: 0001h = Protocol T=0, 0002h = Protocol T=1 */
/* u32 dwDefaultClock; in kHZ (0x0fa0 is 4 MHz) */
0xa0, 0x0f, 0x00, 0x00,
/* u32 dwMaximumClock; */
@@ -875,7 +875,7 @@ static const CCID_ProtocolDataStructure defaultProtocolDataStructure = {
static void ccid_reset_parameters(USBCCIDState *s)
{
- s->bProtocolNum = 1; /* T=1 */
+ s->bProtocolNum = 0; /* T=0 */
s->abProtocolDataStructure = defaultProtocolDataStructure;
}
--
1.8.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH v2 06/10] dev-smartcard-reader: copy atr protocol to ccid parameters
2013-03-27 20:36 [Qemu-devel] [PATCH v2 00/10] ccid and libcacard fixes for windows/mingw Alon Levy
` (4 preceding siblings ...)
2013-03-27 20:36 ` [Qemu-devel] [PATCH v2 05/10] dev-smartcard-reader: change default protocol to T=0 Alon Levy
@ 2013-03-27 20:36 ` Alon Levy
2013-03-27 20:36 ` [Qemu-devel] [PATCH v2 07/10] libcacard/vreader: add debugging messages for apdu Alon Levy
` (4 subsequent siblings)
10 siblings, 0 replies; 13+ messages in thread
From: Alon Levy @ 2013-03-27 20:36 UTC (permalink / raw)
To: qemu-devel; +Cc: mlureau
Adds todos.
Signed-off-by: Alon Levy <alevy@redhat.com>
---
hw/usb/dev-smartcard-reader.c | 45 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c
index bb96f02..7040e8d 100644
--- a/hw/usb/dev-smartcard-reader.c
+++ b/hw/usb/dev-smartcard-reader.c
@@ -833,14 +833,59 @@ static void ccid_write_data_block_answer(USBCCIDState *s,
ccid_write_data_block(s, slot, seq, data, len);
}
+static uint8_t atr_get_protocol_num(const uint8_t *atr, uint32_t len)
+{
+ int i;
+
+ if (len < 2 || !(atr[1] & 0x80)) {
+ /* too short or TD1 not included */
+ return 0; /* T=0, default */
+ }
+ i = 1 + !!(atr[1] & 0x10) + !!(atr[1] & 0x20) + !!(atr[1] & 0x40);
+ i += !!(atr[1] & 0x80);
+ return atr[i] & 0x0f;
+}
+
static void ccid_write_data_block_atr(USBCCIDState *s, CCID_Header *recv)
{
const uint8_t *atr = NULL;
uint32_t len = 0;
+ uint8_t atr_protocol_num;
+ CCID_T0ProtocolDataStructure *t0 = &s->abProtocolDataStructure.t0;
+ CCID_T1ProtocolDataStructure *t1 = &s->abProtocolDataStructure.t1;
if (s->card) {
atr = ccid_card_get_atr(s->card, &len);
}
+ atr_protocol_num = atr_get_protocol_num(atr, len);
+ DPRINTF(s, D_VERBOSE, "%s: atr contains protocol=%d\n", __func__,
+ atr_protocol_num);
+ /* set parameters from ATR - see spec page 109 */
+ s->bProtocolNum = (atr_protocol_num <= 1 ? atr_protocol_num
+ : s->bProtocolNum);
+ switch (atr_protocol_num) {
+ case 0:
+ /* TODO: unimplemented ATR T0 parameters */
+ t0->bmFindexDindex = 0;
+ t0->bmTCCKST0 = 0;
+ t0->bGuardTimeT0 = 0;
+ t0->bWaitingIntegerT0 = 0;
+ t0->bClockStop = 0;
+ break;
+ case 1:
+ /* TODO: unimplemented ATR T1 parameters */
+ t1->bmFindexDindex = 0;
+ t1->bmTCCKST1 = 0;
+ t1->bGuardTimeT1 = 0;
+ t1->bWaitingIntegerT1 = 0;
+ t1->bClockStop = 0;
+ t1->bIFSC = 0;
+ t1->bNadValue = 0;
+ break;
+ default:
+ DPRINTF(s, D_WARN, "%s: error: unsupported ATR protocol %d\n",
+ __func__, atr_protocol_num);
+ }
ccid_write_data_block(s, recv->bSlot, recv->bSeq, atr, len);
}
--
1.8.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH v2 07/10] libcacard/vreader: add debugging messages for apdu
2013-03-27 20:36 [Qemu-devel] [PATCH v2 00/10] ccid and libcacard fixes for windows/mingw Alon Levy
` (5 preceding siblings ...)
2013-03-27 20:36 ` [Qemu-devel] [PATCH v2 06/10] dev-smartcard-reader: copy atr protocol to ccid parameters Alon Levy
@ 2013-03-27 20:36 ` Alon Levy
2013-03-27 20:36 ` [Qemu-devel] [PATCH v2 08/10] libcacard: move atr setting from macro to function Alon Levy
` (3 subsequent siblings)
10 siblings, 0 replies; 13+ messages in thread
From: Alon Levy @ 2013-03-27 20:36 UTC (permalink / raw)
To: qemu-devel; +Cc: mlureau
Using g_debug with log domain libcacard
Signed-off-by: Alon Levy <alevy@redhat.com>
---
libcacard/cac.c | 7 -----
libcacard/cac.h | 8 ++++++
libcacard/vreader.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 85 insertions(+), 7 deletions(-)
diff --git a/libcacard/cac.c b/libcacard/cac.c
index 927a4ca..5864539 100644
--- a/libcacard/cac.c
+++ b/libcacard/cac.c
@@ -12,13 +12,6 @@
#include "vcard_emul.h"
#include "card_7816.h"
-#define CAC_GET_PROPERTIES 0x56
-#define CAC_GET_ACR 0x4c
-#define CAC_READ_BUFFER 0x52
-#define CAC_UPDATE_BUFFER 0x58
-#define CAC_SIGN_DECRYPT 0x42
-#define CAC_GET_CERTIFICATE 0x36
-
/* private data for PKI applets */
typedef struct CACPKIAppletDataStruct {
unsigned char *cert;
diff --git a/libcacard/cac.h b/libcacard/cac.h
index 15a61be..d24a2a8 100644
--- a/libcacard/cac.h
+++ b/libcacard/cac.h
@@ -9,6 +9,14 @@
#define CAC_H 1
#include "vcard.h"
#include "vreader.h"
+
+#define CAC_GET_PROPERTIES 0x56
+#define CAC_GET_ACR 0x4c
+#define CAC_READ_BUFFER 0x52
+#define CAC_UPDATE_BUFFER 0x58
+#define CAC_SIGN_DECRYPT 0x42
+#define CAC_GET_CERTIFICATE 0x36
+
/*
* Initialize the cac card. This is the only public function in this file. All
* the rest are connected through function pointers.
diff --git a/libcacard/vreader.c b/libcacard/vreader.c
index f3efc27..5793d73 100644
--- a/libcacard/vreader.c
+++ b/libcacard/vreader.c
@@ -5,6 +5,12 @@
* See the COPYING.LIB file in the top-level directory.
*/
+#ifdef G_LOG_DOMAIN
+#undef G_LOG_DOMAIN
+#endif
+#define G_LOG_DOMAIN "libcacard"
+#include <glib.h>
+
#include "qemu-common.h"
#include "qemu/thread.h"
@@ -13,6 +19,9 @@
#include "card_7816.h"
#include "vreader.h"
#include "vevent.h"
+#include "cac.h" /* just for debugging defines */
+
+#define LIBCACARD_LOG_DOMAIN "libcacard"
struct VReaderStruct {
int reference_count;
@@ -24,6 +33,66 @@ struct VReaderStruct {
VReaderEmulFree reader_private_free;
};
+/*
+ * Debug helpers
+ */
+
+static const char *
+apdu_ins_to_string(int ins)
+{
+ switch (ins) {
+ case VCARD7816_INS_MANAGE_CHANNEL:
+ return "manage channel";
+ case VCARD7816_INS_EXTERNAL_AUTHENTICATE:
+ return "external authenticate";
+ case VCARD7816_INS_GET_CHALLENGE:
+ return "get challenge";
+ case VCARD7816_INS_INTERNAL_AUTHENTICATE:
+ return "internal authenticate";
+ case VCARD7816_INS_ERASE_BINARY:
+ return "erase binary";
+ case VCARD7816_INS_READ_BINARY:
+ return "read binary";
+ case VCARD7816_INS_WRITE_BINARY:
+ return "write binary";
+ case VCARD7816_INS_UPDATE_BINARY:
+ return "update binary";
+ case VCARD7816_INS_READ_RECORD:
+ return "read record";
+ case VCARD7816_INS_WRITE_RECORD:
+ return "write record";
+ case VCARD7816_INS_UPDATE_RECORD:
+ return "update record";
+ case VCARD7816_INS_APPEND_RECORD:
+ return "append record";
+ case VCARD7816_INS_ENVELOPE:
+ return "envelope";
+ case VCARD7816_INS_PUT_DATA:
+ return "put data";
+ case VCARD7816_INS_GET_DATA:
+ return "get data";
+ case VCARD7816_INS_SELECT_FILE:
+ return "select file";
+ case VCARD7816_INS_VERIFY:
+ return "verify";
+ case VCARD7816_INS_GET_RESPONSE:
+ return "get response";
+ case CAC_GET_PROPERTIES:
+ return "get properties";
+ case CAC_GET_ACR:
+ return "get acr";
+ case CAC_READ_BUFFER:
+ return "read buffer";
+ case CAC_UPDATE_BUFFER:
+ return "update buffer";
+ case CAC_SIGN_DECRYPT:
+ return "sign decrypt";
+ case CAC_GET_CERTIFICATE:
+ return "get certificate";
+ }
+ return "unknown";
+}
+
/* manage locking */
static inline void
vreader_lock(VReader *reader)
@@ -204,7 +273,15 @@ vreader_xfr_bytes(VReader *reader,
response = vcard_make_response(status);
card_status = VCARD_DONE;
} else {
+ g_debug("%s: CLS=0x%x,INS=0x%x,P1=0x%x,P2=0x%x,Lc=%d,Le=%d %s\n",
+ __func__, apdu->a_cla, apdu->a_ins, apdu->a_p1, apdu->a_p2,
+ apdu->a_Lc, apdu->a_Le, apdu_ins_to_string(apdu->a_ins));
card_status = vcard_process_apdu(card, apdu, &response);
+ if (response) {
+ g_debug("%s: status=%d sw1=0x%x sw2=0x%x len=%d (total=%d)\n",
+ __func__, response->b_status, response->b_sw1,
+ response->b_sw2, response->b_len, response->b_total_len);
+ }
}
assert(card_status == VCARD_DONE);
if (card_status == VCARD_DONE) {
--
1.8.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH v2 08/10] libcacard: move atr setting from macro to function
2013-03-27 20:36 [Qemu-devel] [PATCH v2 00/10] ccid and libcacard fixes for windows/mingw Alon Levy
` (6 preceding siblings ...)
2013-03-27 20:36 ` [Qemu-devel] [PATCH v2 07/10] libcacard/vreader: add debugging messages for apdu Alon Levy
@ 2013-03-27 20:36 ` Alon Levy
2013-03-27 20:36 ` [Qemu-devel] [PATCH v2 09/10] dev-smartcard-reader: empty implementation for Mechanical (fail correctly) Alon Levy
` (2 subsequent siblings)
10 siblings, 0 replies; 13+ messages in thread
From: Alon Levy @ 2013-03-27 20:36 UTC (permalink / raw)
To: qemu-devel; +Cc: mlureau
Only because qemu's checkpatch complains about it.
Signed-off-by: Alon Levy <alevy@redhat.com>
---
Makefile.objs | 1 +
libcacard/vcard_emul_nss.c | 14 +++++++++++---
libcacard/vcardt.c | 40 ++++++++++++++++++++++++++++++++++++++++
libcacard/vcardt.h | 13 -------------
libcacard/vcardt_internal.h | 6 ++++++
5 files changed, 58 insertions(+), 16 deletions(-)
create mode 100644 libcacard/vcardt.c
create mode 100644 libcacard/vcardt_internal.h
diff --git a/Makefile.objs b/Makefile.objs
index f99841c..6d47567 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -41,6 +41,7 @@ libcacard-y += libcacard/vcard.o libcacard/vreader.o
libcacard-y += libcacard/vcard_emul_nss.o
libcacard-y += libcacard/vcard_emul_type.o
libcacard-y += libcacard/card_7816.o
+libcacard-y += libcacard/vcardt.o
######################################################################
# Target independent part of system emulation. The long term path is to
diff --git a/libcacard/vcard_emul_nss.c b/libcacard/vcard_emul_nss.c
index 9ba80fb..1a3e568 100644
--- a/libcacard/vcard_emul_nss.c
+++ b/libcacard/vcard_emul_nss.c
@@ -33,6 +33,9 @@
#include "vreader.h"
#include "vevent.h"
+#include "libcacard/vcardt_internal.h"
+
+
typedef enum {
VCardEmulUnknown = -1,
VCardEmulFalse = 0,
@@ -519,18 +522,23 @@ vcard_emul_reader_get_slot(VReader *vreader)
}
/*
- * Card ATR's map to physical cards. VCARD_ATR_PREFIX will set appropriate
+ * Card ATR's map to physical cards. vcard_alloc_atr will set appropriate
* historical bytes for any software emulated card. The remaining bytes can be
* used to indicate the actual emulator
*/
-static const unsigned char nss_atr[] = { VCARD_ATR_PREFIX(3), 'N', 'S', 'S' };
+static unsigned char *nss_atr;
+static int nss_atr_len;
void
vcard_emul_get_atr(VCard *card, unsigned char *atr, int *atr_len)
{
- int len = MIN(sizeof(nss_atr), *atr_len);
+ int len;
assert(atr != NULL);
+ if (nss_atr == NULL) {
+ nss_atr = vcard_alloc_atr("NSS", &nss_atr_len);
+ }
+ len = MIN(nss_atr_len, *atr_len);
memcpy(atr, nss_atr, len);
*atr_len = len;
}
diff --git a/libcacard/vcardt.c b/libcacard/vcardt.c
new file mode 100644
index 0000000..9ce4648
--- /dev/null
+++ b/libcacard/vcardt.c
@@ -0,0 +1,40 @@
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+
+#include "libcacard/vcardt.h"
+
+#include "libcacard/vcardt_internal.h"
+
+/* create an ATR with appropriate historical bytes */
+#define ATR_TS_DIRECT_CONVENTION 0x3b
+#define ATR_TA_PRESENT 0x10
+#define ATR_TB_PRESENT 0x20
+#define ATR_TC_PRESENT 0x40
+#define ATR_TD_PRESENT 0x80
+
+unsigned char *vcard_alloc_atr(const char *postfix, int *atr_len)
+{
+ int postfix_len;
+ const char prefix[] = "VCARD_";
+ const char default_postfix[] = "DEFAULT";
+ const int prefix_len = sizeof(prefix) - 1;
+ int total_len;
+ unsigned char *atr;
+
+ if (postfix == NULL) {
+ postfix = default_postfix;
+ }
+ postfix_len = strlen(postfix);
+ total_len = 3 + prefix_len + postfix_len;
+ atr = g_malloc(total_len);
+ atr[0] = ATR_TS_DIRECT_CONVENTION;
+ atr[1] = ATR_TD_PRESENT + prefix_len + postfix_len;
+ atr[2] = 0x00;
+ memcpy(&atr[3], prefix, prefix_len);
+ memcpy(&atr[3 + prefix_len], postfix, postfix_len);
+ if (atr_len) {
+ *atr_len = total_len;
+ }
+ return atr;
+}
diff --git a/libcacard/vcardt.h b/libcacard/vcardt.h
index 3b9a619..795e265 100644
--- a/libcacard/vcardt.h
+++ b/libcacard/vcardt.h
@@ -25,19 +25,6 @@ typedef struct VCardEmulStruct VCardEmul;
#define MAX_CHANNEL 4
-/* create an ATR with appropriate historical bytes */
-#define TS_DIRECT_CONVENTION 0x3b
-#define TA_PRESENT 0x10
-#define TB_PRESENT 0x20
-#define TC_PRESENT 0x40
-#define TD_PRESENT 0x80
-
-#define VCARD_ATR_PREFIX(size) \
- TS_DIRECT_CONVENTION, \
- TD_PRESENT + (6 + size), \
- 0x00, \
- 'V', 'C', 'A', 'R', 'D', '_'
-
typedef enum {
VCARD_DONE,
VCARD_NEXT,
diff --git a/libcacard/vcardt_internal.h b/libcacard/vcardt_internal.h
new file mode 100644
index 0000000..e5c8d2d
--- /dev/null
+++ b/libcacard/vcardt_internal.h
@@ -0,0 +1,6 @@
+#ifndef VCARDT_INTERNAL_H
+#define VCARDT_INTERNAL_H
+
+unsigned char *vcard_alloc_atr(const char *postfix, int *atr_len);
+
+#endif
--
1.8.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH v2 09/10] dev-smartcard-reader: empty implementation for Mechanical (fail correctly)
2013-03-27 20:36 [Qemu-devel] [PATCH v2 00/10] ccid and libcacard fixes for windows/mingw Alon Levy
` (7 preceding siblings ...)
2013-03-27 20:36 ` [Qemu-devel] [PATCH v2 08/10] libcacard: move atr setting from macro to function Alon Levy
@ 2013-03-27 20:36 ` Alon Levy
2013-03-27 20:36 ` [Qemu-devel] [PATCH v2 10/10] libcacard/cac: change big switch functions to single return point Alon Levy
2013-04-15 13:31 ` [Qemu-devel] [PATCH v2 00/10] ccid and libcacard fixes for windows/mingw Marc-André Lureau
10 siblings, 0 replies; 13+ messages in thread
From: Alon Levy @ 2013-03-27 20:36 UTC (permalink / raw)
To: qemu-devel; +Cc: mlureau
Signed-off-by: Alon Levy <alevy@redhat.com>
---
hw/usb/dev-smartcard-reader.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c
index 7040e8d..689468b 100644
--- a/hw/usb/dev-smartcard-reader.c
+++ b/hw/usb/dev-smartcard-reader.c
@@ -1051,6 +1051,10 @@ static void ccid_handle_bulk_out(USBCCIDState *s, USBPacket *p)
ccid_reset_error_status(s);
ccid_write_parameters(s, ccid_header);
break;
+ case CCID_MESSAGE_TYPE_PC_to_RDR_Mechanical:
+ ccid_report_error_failed(s, 0);
+ ccid_write_slot_status(s, ccid_header);
+ break;
default:
DPRINTF(s, 1,
"handle_data: ERROR: unhandled message type %Xh\n",
--
1.8.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH v2 10/10] libcacard/cac: change big switch functions to single return point
2013-03-27 20:36 [Qemu-devel] [PATCH v2 00/10] ccid and libcacard fixes for windows/mingw Alon Levy
` (8 preceding siblings ...)
2013-03-27 20:36 ` [Qemu-devel] [PATCH v2 09/10] dev-smartcard-reader: empty implementation for Mechanical (fail correctly) Alon Levy
@ 2013-03-27 20:36 ` Alon Levy
2013-04-15 13:31 ` [Qemu-devel] [PATCH v2 00/10] ccid and libcacard fixes for windows/mingw Marc-André Lureau
10 siblings, 0 replies; 13+ messages in thread
From: Alon Levy @ 2013-03-27 20:36 UTC (permalink / raw)
To: qemu-devel; +Cc: mlureau
Signed-off-by: Alon Levy <alevy@redhat.com>
---
libcacard/cac.c | 73 ++++++++++++++++++++++++++++++++++++++++-----------------
1 file changed, 52 insertions(+), 21 deletions(-)
diff --git a/libcacard/cac.c b/libcacard/cac.c
index 5864539..7a06b5a 100644
--- a/libcacard/cac.c
+++ b/libcacard/cac.c
@@ -40,41 +40,51 @@ static VCardStatus
cac_common_process_apdu(VCard *card, VCardAPDU *apdu, VCardResponse **response)
{
int ef;
+ VCardStatus ret = VCARD_FAIL;
switch (apdu->a_ins) {
case VCARD7816_INS_SELECT_FILE:
if (apdu->a_p1 != 0x02) {
/* let the 7816 code handle applet switches */
- return VCARD_NEXT;
+ ret = VCARD_NEXT;
+ break;
}
/* handle file id setting */
if (apdu->a_Lc != 2) {
*response = vcard_make_response(
VCARD7816_STATUS_ERROR_DATA_INVALID);
- return VCARD_DONE;
+ ret = VCARD_DONE;
+ break;
}
/* CAC 1.0 only supports ef = 0 */
ef = apdu->a_body[0] | (apdu->a_body[1] << 8);
if (ef != 0) {
*response = vcard_make_response(
VCARD7816_STATUS_ERROR_FILE_NOT_FOUND);
- return VCARD_DONE;
+ ret = VCARD_DONE;
+ break;
}
*response = vcard_make_response(VCARD7816_STATUS_SUCCESS);
- return VCARD_DONE;
+ ret = VCARD_DONE;
+ break;
case VCARD7816_INS_GET_RESPONSE:
case VCARD7816_INS_VERIFY:
/* let the 7816 code handle these */
- return VCARD_NEXT;
+ ret = VCARD_NEXT;
+ break;
case CAC_GET_PROPERTIES:
case CAC_GET_ACR:
/* skip these for now, this will probably be needed */
*response = vcard_make_response(VCARD7816_STATUS_ERROR_P1_P2_INCORRECT);
- return VCARD_DONE;
+ ret = VCARD_DONE;
+ break;
+ default:
+ *response = vcard_make_response(
+ VCARD7816_STATUS_ERROR_COMMAND_NOT_SUPPORTED);
+ ret = VCARD_DONE;
+ break;
}
- *response = vcard_make_response(
- VCARD7816_STATUS_ERROR_COMMAND_NOT_SUPPORTED);
- return VCARD_DONE;
+ return ret;
}
/*
@@ -108,6 +118,7 @@ cac_applet_pki_process_apdu(VCard *card, VCardAPDU *apdu,
int size, next;
unsigned char *sign_buffer;
vcard_7816_status_t status;
+ VCardStatus ret = VCARD_FAIL;
applet_private = vcard_get_current_applet_private(card, apdu->a_channel);
assert(applet_private);
@@ -117,7 +128,8 @@ cac_applet_pki_process_apdu(VCard *card, VCardAPDU *apdu,
case CAC_UPDATE_BUFFER:
*response = vcard_make_response(
VCARD7816_STATUS_ERROR_CONDITION_NOT_SATISFIED);
- return VCARD_DONE;
+ ret = VCARD_DONE;
+ break;
case CAC_GET_CERTIFICATE:
if ((apdu->a_p2 != 0) || (apdu->a_p1 != 0)) {
*response = vcard_make_response(
@@ -147,7 +159,8 @@ cac_applet_pki_process_apdu(VCard *card, VCardAPDU *apdu,
*response = vcard_make_response(
VCARD7816_STATUS_EXC_ERROR_MEMORY_FAILURE);
}
- return VCARD_DONE;
+ ret = VCARD_DONE;
+ break;
case CAC_SIGN_DECRYPT:
if (apdu->a_p2 != 0) {
*response = vcard_make_response(
@@ -164,7 +177,8 @@ cac_applet_pki_process_apdu(VCard *card, VCardAPDU *apdu,
pki_applet->sign_buffer_len = 0;
*response = vcard_make_response(
VCARD7816_STATUS_EXC_ERROR_MEMORY_FAILURE);
- return VCARD_DONE;
+ ret = VCARD_DONE;
+ break;
}
memcpy(sign_buffer+pki_applet->sign_buffer_len, apdu->a_body, size);
size += pki_applet->sign_buffer_len;
@@ -175,7 +189,8 @@ cac_applet_pki_process_apdu(VCard *card, VCardAPDU *apdu,
pki_applet->sign_buffer = sign_buffer;
pki_applet->sign_buffer_len = size;
*response = vcard_make_response(VCARD7816_STATUS_SUCCESS);
- return VCARD_DONE;
+ ret = VCARD_DONE;
+ break;
case 0x00:
/* we now have the whole buffer, do the operation, result will be
* in the sign_buffer */
@@ -200,15 +215,20 @@ cac_applet_pki_process_apdu(VCard *card, VCardAPDU *apdu,
g_free(sign_buffer);
pki_applet->sign_buffer = NULL;
pki_applet->sign_buffer_len = 0;
- return VCARD_DONE;
+ ret = VCARD_DONE;
+ break;
case CAC_READ_BUFFER:
/* new CAC call, go ahead and use the old version for now */
/* TODO: implement */
*response = vcard_make_response(
VCARD7816_STATUS_ERROR_COMMAND_NOT_SUPPORTED);
- return VCARD_DONE;
+ ret = VCARD_DONE;
+ break;
+ default:
+ ret = cac_common_process_apdu(card, apdu, response);
+ break;
}
- return cac_common_process_apdu(card, apdu, response);
+ return ret;
}
@@ -216,19 +236,26 @@ static VCardStatus
cac_applet_id_process_apdu(VCard *card, VCardAPDU *apdu,
VCardResponse **response)
{
+ VCardStatus ret = VCARD_FAIL;
+
switch (apdu->a_ins) {
case CAC_UPDATE_BUFFER:
*response = vcard_make_response(
VCARD7816_STATUS_ERROR_CONDITION_NOT_SATISFIED);
- return VCARD_DONE;
+ ret = VCARD_DONE;
+ break;
case CAC_READ_BUFFER:
/* new CAC call, go ahead and use the old version for now */
/* TODO: implement */
*response = vcard_make_response(
VCARD7816_STATUS_ERROR_COMMAND_NOT_SUPPORTED);
- return VCARD_DONE;
+ ret = VCARD_DONE;
+ break;
+ default:
+ ret = cac_common_process_apdu(card, apdu, response);
+ break;
}
- return cac_common_process_apdu(card, apdu, response);
+ return ret;
}
@@ -240,16 +267,20 @@ static VCardStatus
cac_applet_container_process_apdu(VCard *card, VCardAPDU *apdu,
VCardResponse **response)
{
+ VCardStatus ret = VCARD_FAIL;
+
switch (apdu->a_ins) {
case CAC_READ_BUFFER:
case CAC_UPDATE_BUFFER:
*response = vcard_make_response(
VCARD7816_STATUS_ERROR_COMMAND_NOT_SUPPORTED);
- return VCARD_DONE;
+ ret = VCARD_DONE;
+ break;
default:
+ ret = cac_common_process_apdu(card, apdu, response);
break;
}
- return cac_common_process_apdu(card, apdu, response);
+ return ret;
}
/*
--
1.8.1.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH v2 00/10] ccid and libcacard fixes for windows/mingw
2013-03-27 20:36 [Qemu-devel] [PATCH v2 00/10] ccid and libcacard fixes for windows/mingw Alon Levy
` (9 preceding siblings ...)
2013-03-27 20:36 ` [Qemu-devel] [PATCH v2 10/10] libcacard/cac: change big switch functions to single return point Alon Levy
@ 2013-04-15 13:31 ` Marc-André Lureau
2013-04-17 8:54 ` Alon Levy
10 siblings, 1 reply; 13+ messages in thread
From: Marc-André Lureau @ 2013-04-15 13:31 UTC (permalink / raw)
To: Alon Levy; +Cc: Marc-André Lureau, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 821 bytes --]
Hi
On Wed, Mar 27, 2013 at 9:36 PM, Alon Levy <alevy@redhat.com> wrote:
> This series:
> 1. fixes windows guests to show the ccid device
> 2. changes libcacard to use glib
> 3. makes libcacard build under mingw
> 4. does some cleanups
>
> It contains a few patches already posted to the list (the two Jim Meyering
> patches) which were already acked.
>
> I'll make a pull request once this had some time to be reviewed.
>
> Tested with a fedora and windows 7 guest.
>
> The main non cleanup patches are:
> hw/usb/dev-smartcard-reader: support windows guest
> libcacard: correct T0 historical bytes size
>
>
The patch series doesn't do what you describe. Many patches are missing
from the v1:
http://lists.nongnu.org/archive/html/qemu-devel/2013-03/msg02925.html
--
Marc-André Lureau
[-- Attachment #2: Type: text/html, Size: 1288 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH v2 00/10] ccid and libcacard fixes for windows/mingw
2013-04-15 13:31 ` [Qemu-devel] [PATCH v2 00/10] ccid and libcacard fixes for windows/mingw Marc-André Lureau
@ 2013-04-17 8:54 ` Alon Levy
0 siblings, 0 replies; 13+ messages in thread
From: Alon Levy @ 2013-04-17 8:54 UTC (permalink / raw)
To: Marc-André Lureau; +Cc: Marc-André Lureau, qemu-devel
On Mon, 2013-04-15 at 15:31 +0200, Marc-André Lureau wrote:
> Hi
>
>
> On Wed, Mar 27, 2013 at 9:36 PM, Alon Levy <alevy@redhat.com> wrote:
> This series:
> 1. fixes windows guests to show the ccid device
> 2. changes libcacard to use glib
> 3. makes libcacard build under mingw
> 4. does some cleanups
>
> It contains a few patches already posted to the list (the two
> Jim Meyering patches) which were already acked.
>
> I'll make a pull request once this had some time to be
> reviewed.
>
> Tested with a fedora and windows 7 guest.
>
> The main non cleanup patches are:
> hw/usb/dev-smartcard-reader: support windows guest
> libcacard: correct T0 historical bytes size
>
>
> The patch series doesn't do what you describe.
So you want me to update this cover letter that doesn't get committed,
no problem, I will in a follow up message, but meanwhile could you take
a look at the updated patches per your requests from v1?
> Many patches are missing from the v1:
> http://lists.nongnu.org/archive/html/qemu-devel/2013-03/msg02925.html
Many patches are missing on purpose, because they are either yours and
so I acked them implicitly by sending the v1 patch series, or they are
mine and have already been acked by me.
>
>
> --
> Marc-André Lureau
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2013-04-17 8:54 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-27 20:36 [Qemu-devel] [PATCH v2 00/10] ccid and libcacard fixes for windows/mingw Alon Levy
2013-03-27 20:36 ` [Qemu-devel] [PATCH v2 01/10] libcacard: change default ATR Alon Levy
2013-03-27 20:36 ` [Qemu-devel] [PATCH v2 02/10] ccid-card-passthru: add atr check Alon Levy
2013-03-27 20:36 ` [Qemu-devel] [PATCH v2 03/10] ccid-card-passthru, dev-smartcard-reader: add debug environment variables Alon Levy
2013-03-27 20:36 ` [Qemu-devel] [PATCH v2 04/10] dev-smartcard-reader: define structs for CCID_Parameter internals Alon Levy
2013-03-27 20:36 ` [Qemu-devel] [PATCH v2 05/10] dev-smartcard-reader: change default protocol to T=0 Alon Levy
2013-03-27 20:36 ` [Qemu-devel] [PATCH v2 06/10] dev-smartcard-reader: copy atr protocol to ccid parameters Alon Levy
2013-03-27 20:36 ` [Qemu-devel] [PATCH v2 07/10] libcacard/vreader: add debugging messages for apdu Alon Levy
2013-03-27 20:36 ` [Qemu-devel] [PATCH v2 08/10] libcacard: move atr setting from macro to function Alon Levy
2013-03-27 20:36 ` [Qemu-devel] [PATCH v2 09/10] dev-smartcard-reader: empty implementation for Mechanical (fail correctly) Alon Levy
2013-03-27 20:36 ` [Qemu-devel] [PATCH v2 10/10] libcacard/cac: change big switch functions to single return point Alon Levy
2013-04-15 13:31 ` [Qemu-devel] [PATCH v2 00/10] ccid and libcacard fixes for windows/mingw Marc-André Lureau
2013-04-17 8:54 ` Alon Levy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).