usb-ccid (v17)
cover usb-ccid (v17)
This patchset adds three new devices, usb-ccid, ccid-card-passthru and ccid-card-emulated, providing a CCID bus, a simple passthru protocol implementing card requiring a client, and a standalone emulated card.
It also introduces a new directory libcaccard with CAC card emulation, CAC is a type of ISO 7816 smart card.
Tree for pull: git://anongit.freedesktop.org/~alon/qemu usb_ccid.v17
v16-v17 changes:
* merged all the "v15->v16" patches
* merged some more wherever it was easy (all same file commits).
* added signed off by to first four patches
* ccid.h: added copyright, removed underscore in defines, and replaced non C89 comments
v15-v16 changes:
* split vscard_common introducing patch for ease of review
* sum of commit logs for the v15-v16 commits: (whitespace fixes
removed for space, see original commit messages in later patches)
* usb-ccid:
* fix abort on client answer after card remove
* enable migration
* remove side affect code from asserts
* return consistent self-powered state
* mask out reserved bits in ccid_set_parameters
* add missing abRFU in SetParameters (no affect on linux guest)
* vscard_common.h protocol change:
* VSCMsgInit capabilities and magic
* removed ReaderResponse, will use Error instead with code==VSC_SUCCESS.
* added Flush and FlushComplete, remove Reconnect.
* define VSCARD_MAGIC
* added error code VSC_SUCCESS.
* ccid-card-passthru
* return correct size
* return error instead of assert if client sent too large ATR
* don't assert if client sent too large a size, but add asserts for indices to buffer
* reset vscard_in indices on chardev disconnect
* handle init from client
* error if no chardev supplied
* use ntoh, hton
* eradicate reader_id_t
* remove Reconnect usage (removed from VSCARD protocol)
* send VSC_SUCCESS on card insert/remove and reader add/remove
* ccid-card-emulated
* fix error reporting in initfn
v14-v15 changes:
* add patch with --enable-smartcard and --disable-smartcard and only disable ccid-card-emulated if nss not found.
* add patch with description strings
* s/libcaccard/libcacard/ in docs/ccid.txt
v13-v14 changes:
- support device_del/device_add on ccid-card-* and usb-ccid
* usb-ccid:
* lose card reference when card device deleted
* check slot number and deny adding a slot if one is already added.
* ccid-card-*: use qdev_simple_unplug_cb in both emulated and passthru ccid cards, the exitfn already takes care of triggering card removal in the usb dev.
* libcacard:
* remove double include of config-host.mak
* add replay of card events to libcacard to support second and more emulation
* don't initialize more then once (doesn't support it right now, so one thread, NSS thread, is left when device_del is done)
* add VCARD_EMUL_INIT_ALREADY_INITED
* ccid-card-emulated:
* take correct mutexes on signaling to fix deadlocks on device_del
* allow card insertion/removal event without proper reader insertion event
v12-v13 changes:
* libcacard:
* fix Makefile clean to remove vscclient
* fix double include of config-host in Makefile
* usb-ccid: remove attach/detach logic, usb is always attached. Guest doesn't care if there is a reader attached with no card anyway.
* ccid-card-passthru: don't close chr_dev on removal, makes it possible to use device_del/device_add to create remove/insertion for debugging.
v11-v12 changes:
* fix out of tree build
v10-v11 changes:
* fix last patch that removed one of the doc files.
* updated flow table in docs/ccid.txt
v8-v10 changes:
* usb-ccid:
* add slot for future use (Gerd)
* ifdef ENABLE_MIGRATION for migration support on account of usb migration not being ready in general. (Gerd)
* verbosified commit messages. (Gerd)
* put libcacard docs in libcacard commit. (Gerd)
v8-v9 changes:
* Blue Swirl comments:
* white space fixes
* enabled by default, disabled only if missing nss
* forgotten fix from v8 (don't build libcacard.so)
* added a note about device being little endian
* library renamed from libcaccard to libcacard
* squashed both of libcacard patches, they touched different files anyway.
v7-v8 changes:
* Blue Swirl comments:
* usb-ccid: deannonymize some structs
* usb-ccid: coding style change - answer_t and bulk_in_t fixed
* usb-ccid: handle endianess conversion between guest and host
* usb-ccid: s/ccid_bulk_in_copy_out/ccid_bulk_in_copy_to_guest/
* ccid-card-emulated: fix segfault if backend not specified
* ccid-card-emulated: let last reader inserted win
* libcaccard: remove double vscard_common.h
v6->v7 changes:
* external libcaccard became internal directory libcaccard
* statically link object files into qemu
* produce libcaccard.so for usage by external projects
* applied coding style to new code (please check me)
- did not use the qemu options parsing for libcaccard, since it seems to draw large amounts of qemu code (monitor for instance).
v5->v6 changes:
* really remove static debug (I apologize for claiming to have done so before)
v4->v5 changes:
* rebased to latest
* remove static debug in card devices
* fix --enable-smartcard to link
* stall instead of assert when exceeding BULK_OUT_DATA_SIZE
* make ccid_reserve_recv_buf for too large len discard message, not exit
* make ccid_reserve_recv_buf return void*
* fix typo
* remove commented code in VMState
v3->v4:
* remove ccid field in CCIDBus
* remove static debug in bus
* add back docs
v2->v3:
* split into bus (usb-ccid.c, uses ccid.h) and card (ccid-card-passthru.c).
* removed documentation (being revised).
v1->v2:
* all QSIMPLEQ turned into fixed sized rings
* all allocated buffers turned into fixed size buffers
* added migration support
* added a message to tell client qemu has migrated to ip:port
* for lack of monitor commands ip:port are 0:0, which causes the updated vscclient to connect to one port higher on the same host. will add monitor commands in a separate patch. tested with current setup.
Alon Levy (16):
qdev: add print_options callback
qdev: add data pointer to Property
qdev-properties: add PROP_TYPE_ENUM
qdev-properties: parse_enum: don't cast a void*
usb-ccid: add CCID bus
introduce libcacard/vscard_common.h libcacard/vscard_common.h update (v15->v16)
ccid: add passthru card device
ccid: add ccid-card-emulated device (v2)
ccid: add docs
ccid: configure: add --enable/disable and nss only disable
ccid: add qdev description strings
smartcard,configure: add --enable-smartcard-nss, report only nss smartcard,configure: report only nss
ccid-card-emulated: don't link with NSS if --disable-smartcard-nss ccid.h: add copyright, fix define and remove non C89 comments
Robert Relyea (1):
libcacard: initial commit
Makefile | 6 +- Makefile.objs | 7 + Makefile.target | 2 + configure | 60 ++ docs/ccid.txt | 135 +++++ docs/libcacard.txt | 483 +++++++++++++++ hw/ccid-card-emulated.c | 551 ++++++++++++++++++ hw/ccid-card-passthru.c | 329 +++++++++++ hw/ccid.h | 51 ++ hw/qdev-properties.c | 60 ++ hw/qdev.c | 10 +- hw/qdev.h | 17 + hw/usb-ccid.c | 1353 +++++++++++++++++++++++++++++++++++++++++++ libcacard/Makefile | 14 + libcacard/cac.c | 411 +++++++++++++ libcacard/cac.h | 20 + libcacard/card_7816.c | 780 +++++++++++++++++++++++++ libcacard/card_7816.h | 60 ++ libcacard/card_7816t.h | 163 ++++++ libcacard/event.c | 112 ++++ libcacard/eventt.h | 28 + libcacard/link_test.c | 20 + libcacard/mutex.h | 59 ++ libcacard/passthru.c | 612 +++++++++++++++++++ libcacard/passthru.h | 50 ++ libcacard/vcard.c | 350 +++++++++++ libcacard/vcard.h | 85 +++ libcacard/vcard_emul.h | 62 ++ libcacard/vcard_emul_nss.c | 1192 +++++++++++++++++++++++++++++++++++++ libcacard/vcard_emul_type.c | 60 ++ libcacard/vcard_emul_type.h | 29 + libcacard/vcardt.h | 66 +++ libcacard/vevent.h | 26 + libcacard/vreader.c | 526 +++++++++++++++++ libcacard/vreader.h | 54 ++ libcacard/vreadert.h | 23 + libcacard/vscard_common.h | 167 ++++++ libcacard/vscclient.c | 743 ++++++++++++++++++++++++ 38 files changed, 8773 insertions(+), 3 deletions(-) create mode 100644 docs/ccid.txt create mode 100644 docs/libcacard.txt create mode 100644 hw/ccid-card-emulated.c create mode 100644 hw/ccid-card-passthru.c create mode 100644 hw/ccid.h create mode 100644 hw/usb-ccid.c create mode 100644 libcacard/Makefile create mode 100644 libcacard/cac.c create mode 100644 libcacard/cac.h create mode 100644 libcacard/card_7816.c create mode 100644 libcacard/card_7816.h create mode 100644 libcacard/card_7816t.h create mode 100644 libcacard/event.c create mode 100644 libcacard/eventt.h create mode 100644 libcacard/link_test.c create mode 100644 libcacard/mutex.h create mode 100644 libcacard/passthru.c create mode 100644 libcacard/passthru.h create mode 100644 libcacard/vcard.c create mode 100644 libcacard/vcard.h create mode 100644 libcacard/vcard_emul.h create mode 100644 libcacard/vcard_emul_nss.c create mode 100644 libcacard/vcard_emul_type.c create mode 100644 libcacard/vcard_emul_type.h create mode 100644 libcacard/vcardt.h create mode 100644 libcacard/vevent.h create mode 100644 libcacard/vreader.c create mode 100644 libcacard/vreader.h create mode 100644 libcacard/vreadert.h create mode 100644 libcacard/vscard_common.h create mode 100644 libcacard/vscclient.c
Signature · 1 line
1.7.4
PATCH 1/17 qdev: add print_options callback
another callback added to PropertyInfo, for later use by PROP_TYPE_ENUM. Allows printing of runtime computed options when doing:
qemu -device foo,?
--- hw/qdev.c | 10 +++++++++- hw/qdev.h | 1 + 2 files changed, 10 insertions(+), 1 deletions(-)
hw/qdev.c +9 -1
@@ -187,7 +187,15 @@ int qdev_device_help(QemuOpts *opts)if (!prop->info->parse) {continue ;/* no way to set it, don't show */ } -error_printf ("%s.%s=%s\n" , info->name, prop->name, prop->info->name); +if (prop->info->print_options) { +char buf[256 ]; +int ret; + ret = prop->info->print_options (info, prop, buf,sizeof (buf) -3 ); +error_printf ("%s.%s=%s%s\n" , info->name, prop->name, buf, + ret ==sizeof (buf) -3 ?"..." :"" ); + }else { +error_printf ("%s.%s=%s\n" , info->name, prop->name, prop->info->name); + } }return 1 ; }
hw/qdev.h +1 -0
@@ -109,6 +109,7 @@ struct PropertyInfo {enum PropertyType type;int (*parse)(DeviceState *dev,Property *prop,const char *str);int (*print)(DeviceState *dev,Property *prop,char *dest,size_t len); +int (*print_options)(DeviceInfo *info,Property *prop,char *dest,size_t len);void (*free)(DeviceState *dev,Property *prop); };
Signature · 1 line
1.7.4
PATCH 2/17 qdev: add data pointer to Property
In reply to Alon LevyFor later use by PROP_TYPE_ENUM, will store enumeration name/value table there.
--- hw/qdev.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
hw/qdev.h +1 -0
@@ -83,6 +83,7 @@ struct Property {int offset;int bitnr;void *defval; +void *data; };enum PropertyType {
Signature · 1 line
1.7.4
PATCH 3/17 qdev-properties: add PROP_TYPE_ENUM
In reply to Alon LevyExample usage:
EnumTable foo_enum_table[] = {
{"bar", 1},
{"buz", 2},
{NULL, 0},
};DEFINE_PROP_ENUM("foo", State, foo, 1, foo_enum_table)
When using qemu -device foodev,? it will appear as:
foodev.foo=bar/buz
--- hw/qdev-properties.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ hw/qdev.h | 15 ++++++++++++ 2 files changed, 75 insertions(+), 0 deletions(-)
hw/qdev-properties.c +60 -0
@@ -63,6 +63,66 @@ PropertyInfo qdev_prop_bit = { .print = print_bit, }; +/* --- Enumeration --- */ +/* Example usage: +EnumTable foo_enum_table[] = { +{"bar", 1}, +{"buz", 2}, +{NULL, 0}, +}; +DEFINE_PROP_ENUM("foo", State, foo, 1, foo_enum_table), +*/ +static int parse_enum (DeviceState *dev,Property *prop,const char *str) +{ +uint8_t *ptr =qdev_get_prop_ptr (dev, prop); +EnumTable *option = (EnumTable *)prop->data; + +while (option->name !=NULL ) { +if (!strncmp (str, option->name,strlen (option->name))) { + *ptr = option->value; +return 0 ; + } + option++; + } +return -EINVAL ; +} + +static int print_enum (DeviceState *dev,Property *prop,char *dest,size_t len) +{ +uint32_t *p =qdev_get_prop_ptr (dev, prop); +EnumTable *option = (EnumTable *)prop->data; +while (option->name !=NULL ) { +if (*p == option->value) { +return snprintf (dest, len,"%s" , option->name); + } + option++; + } +return 0 ; +} + +static int print_enum_options (DeviceInfo *info,Property *prop,char *dest,size_t len) +{ +int ret =0 ; +EnumTable *option = (EnumTable *)prop->data; +while (option->name !=NULL ) { + ret +=snprintf (dest + ret, len - ret,"%s" , option->name); +if (option[1 ].name !=NULL ) { + ret +=snprintf (dest + ret, len - ret,"/" ); + } + option++; + } +return ret; +} + +PropertyInfo qdev_prop_enum = { + .name ="enum" , + .type =PROP_TYPE_ENUM , + .size =sizeof (uint32_t ), + .parse = parse_enum, + .print = print_enum, + .print_options = print_enum_options, +}; +/* --- 8bit integer --- */ static int parse_uint8 (DeviceState *dev,Property *prop,const char *str)
hw/qdev.h +15 -0
@@ -102,6 +102,7 @@ enum PropertyType {PROP_TYPE_VLAN ,PROP_TYPE_PTR ,PROP_TYPE_BIT , + PROP_TYPE_ENUM, }; struct PropertyInfo {
@@ -121,6 +122,11 @@ typedef struct GlobalProperty {QTAILQ_ENTRY (GlobalProperty) next; } GlobalProperty; +typedef struct EnumTable { +const char *name; +uint32_t value; +}EnumTable ; +/*** Board API. This should go away once we have a machine config file. ***/ DeviceState *qdev_create (BusState *bus,const char *name);
@@ -235,6 +241,7 @@ extern PropertyInfo qdev_prop_drive;extern PropertyInfo qdev_prop_netdev;extern PropertyInfo qdev_prop_vlan;extern PropertyInfo qdev_prop_pci_devfn; +extern PropertyInfo qdev_prop_enum;#define DEFINE_PROP (_name, _state, _field, _prop, _type) { \ .name = (_name), \
@@ -257,6 +264,14 @@ extern PropertyInfo qdev_prop_pci_devfn; + type_check(uint32_t,typeof_field(_state, _field)), \ .defval = (bool[]) { (_defval) }, \ } +#define DEFINE_PROP_ENUM (_name, _state, _field, _defval, _options) { \ + .name = (_name), \ + .info = &(qdev_prop_enum), \ + .offset = offsetof(_state, _field) \ + + type_check(uint32_t,typeof_field(_state, _field)), \ + .defval = (uint32_t[]) { (_defval) }, \ + .data = (void*)(_options), \ + }#define DEFINE_PROP_UINT8 (_n, _s, _f, _d) \ DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint8, uint8_t)
Signature · 1 line
1.7.4
PATCH 4/17 qdev-properties: parse_enum: don't cast a void*
In reply to Alon Levy--- hw/qdev-properties.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
hw/qdev-properties.c +1 -1
@@ -75,7 +75,7 @@ DEFINE_PROP_ENUM("foo", State, foo, 1, foo_enum_table),static int parse_enum (DeviceState *dev,Property *prop,const char *str) {uint8_t *ptr =qdev_get_prop_ptr (dev, prop); -EnumTable *option = (EnumTable *)prop->data; +EnumTable *option = prop->data;while (option->name !=NULL ) {if (!strncmp (str, option->name,strlen (option->name))) {
Signature · 1 line
1.7.4
PATCH 7/17 libcacard/vscard_common.h update (v15->v16)
In reply to Alon LevyProtocol change:
* VSCMsgInit capabilities and magic
* removed ReaderResponse, will use Error instead with code==VSC_SUCCESS.
* adaded Flush and FlushComplete, remove Reconnect.
* define VSCARD_MAGIC
* added error code VSC_SUCCESS.
Fixes:
* update VSCMsgInit comment
* fix message type enum
* remove underscore from wrapping define
* update copyright
* updated comments.
* Header comment updated
* remove C++ style comment
* fix comment for VSCMsgError
* give names to enums in typedefs
--- libcacard/vscard_common.h | 103 ++++++++++++++++++++++++++++++-------------- 1 files changed, 70 insertions(+), 33 deletions(-)
libcacard/vscard_common.h +70 -33
@@ -1,20 +1,25 @@/* Virtual Smart Card protocol definition * -* This protocol is between a host implementing a group of virtual smart card -* reader, and a client implementing a virtual smart card, or passthrough to -* a real card. +* This protocol is between a host using virtual smart card readers, +* and a client providing the smart cards, perhaps by emulating them or by +* access to real cards. +* +* Definitions for this protocol: +* Host - user of the card +* Client - owner of the card * * The current implementation passes the raw APDU's from 7816 and additionally * contains messages to setup and teardown readers, handle insertion and -* removal of cards, negotiate the protocol and provide for error responses. +* removal of cards, negotiate the protocol via capabilities and provide +* for error responses. * -* Copyright (c) 2010 Red Hat. +* Copyright (c) 2011 Red Hat. * * This code is licensed under the LGPL. */ -#ifndef _VSCARD_COMMON_H -#define _VSCARD_COMMON_H +#ifndef VSCARD_COMMON_H +#define VSCARD_COMMON_H #include <stdint.h>
@@ -40,91 +45,123 @@* something that cannot be accomodated with the existing protocol. */ -#define VSCARD_VERSION MAKE_VERSION(0,0,1) +#define VSCARD_VERSION MAKE_VERSION(0,0,2) -typedef enum { - VSC_Init, +typedef enum VSCMsgType { + VSC_Init =1 , VSC_Error, VSC_ReaderAdd, - VSC_ReaderAddResponse, VSC_ReaderRemove,VSC_ATR , VSC_CardRemove,VSC_APDU , - VSC_Reconnect + VSC_Flush, + VSC_FlushComplete }VSCMsgType ; -typedef enum { +typedef enum VSCErrorCode { +VSC_SUCCESS =0 ,VSC_GENERAL_ERROR =1 ,VSC_CANNOT_ADD_MORE_READERS , +VSC_CARD_ALREAY_INSERTED , }VSCErrorCode ; -typedef uint32_t reader_id_t ; -#define VSCARD_UNDEFINED_READER_ID 0xffffffff +#define VSCARD_UNDEFINED_READER_ID 0xffffffff#define VSCARD_MINIMAL_READER_ID 0 +#define VSCARD_MAGIC (*(uint32_t*)"VSCD") + +/* Header +* Each message starts with the header. +* type - message type +* reader_id - used by messages that are reader specific +* length - length of payload (not including header, i.e. zero for +* messages containing empty payloads) +*/ typedef struct VSCMsgHeader { -VSCMsgType type; -reader_id_t reader_id; +uint32_t type; +uint32_t reader_id;uint32_t length;uint8_t data[0 ]; }VSCMsgHeader ;/* VSCMsgInit Client <-> Host -* Host replies with allocated reader id in ReaderAddResponse +* Client sends it on connection, with its own capabilities. +* Host replies with VSCMsgInit filling in its capabilities. +* +* It is not meant to be used for negotiation, i.e. sending more then +* once from any side, but could be used for that in the future. * */ typedef struct VSCMsgInit { +uint32_t magic;uint32_t version; +uint32_t capabilities[1 ];/* receiver must check length, +array may grow in the future*/ }VSCMsgInit ;/* VSCMsgError Client <-> Host +* This message is a response to any of: +* Reader Add +* Reader Remove +* Card Remove +* If the operation was successful then VSC_SUCCESS +* is returned, other wise a specific error code. * */ typedef struct VSCMsgError {uint32_t code; }VSCMsgError ;/* VSCMsgReaderAdd Client -> Host -* Host replies with allocated reader id in ReaderAddResponse -* name - name of the reader on client side. +* Host replies with allocated reader id in VSCMsgError with code==SUCCESS. +* +* name - name of the reader on client side, UTF-8 encoded. Only used +* for client presentation (may be translated to the device presented to the +* guest), protocol wise only reader_id is important. * */ typedef struct VSCMsgReaderAdd {uint8_t name[0 ]; }VSCMsgReaderAdd ; -/* VSCMsgReaderAddResponse Host -> Client -* Reply to ReaderAdd -* */ -typedef struct VSCMsgReaderAddResponse { -}VSCMsgReaderAddResponse ; -/* VSCMsgReaderRemove Client -> Host +* The client's reader has been removed. * */ typedef struct VSCMsgReaderRemove { }VSCMsgReaderRemove ;/* VSCMsgATR Client -> Host -* Answer to reset. Sent for card insertion or card reset. +* Answer to reset. Sent for card insertion or card reset. The reset/insertion +* happens on the client side, they do not require any action from the host. * */ typedef struct VSCMsgATR {uint8_t atr[0 ]; }VSCMsgATR ;/* VSCMsgCardRemove Client -> Host +* The client card has been removed. * */ typedef struct VSCMsgCardRemove { }VSCMsgCardRemove ;/* VSCMsgAPDU Client <-> Host +* Main reason of existance. Transfer a single APDU in either direction. * */ typedef struct VSCMsgAPDU {uint8_t data[0 ]; }VSCMsgAPDU ; -/* VSCMsgReconnect Host -> Client +/* VSCMsgFlush Host -> Client +* Request client to send a FlushComplete message when it is done +* servicing all outstanding APDUs * */ -typedef struct VSCMsgReconnect { -uint32_t ip; -uint16_t port; -}VSCMsgReconnect ; +typedef struct VSCMsgFlush { +}VSCMsgFlush ; + +/* VSCMsgFlush Client -> Host +* Client response to Flush after all APDUs have been processed and +* responses sent. +* */ +typedef struct VSCMsgFlushComplete { +}VSCMsgFlushComplete ; + +#endif /* VSCARD_COMMON_H */ -#endif
Signature · 1 line
1.7.4
PATCH 6/17 introduce libcacard/vscard_common.h
In reply to Alon Levy--- libcacard/vscard_common.h | 130 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 130 insertions(+), 0 deletions(-) create mode 100644 libcacard/vscard_common.h
libcacard/vscard_common.h new file +130 -0
@@ -0,0 +1,130 @@ +/* Virtual Smart Card protocol definition +* +* This protocol is between a host implementing a group of virtual smart card +* reader, and a client implementing a virtual smart card, or passthrough to +* a real card. +* +* The current implementation passes the raw APDU's from 7816 and additionally +* contains messages to setup and teardown readers, handle insertion and +* removal of cards, negotiate the protocol and provide for error responses. +* +* Copyright (c) 2010 Red Hat. +* +* This code is licensed under the LGPL. +*/ + +#ifndef _VSCARD_COMMON_H +#define _VSCARD_COMMON_H + +#include <stdint.h> + +#define VERSION_MAJOR_BITS 11 +#define VERSION_MIDDLE_BITS 11 +#define VERSION_MINOR_BITS 10 + +#define MAKE_VERSION (major, middle, minor) \ + ( (major << (VERSION_MINOR_BITS + VERSION_MIDDLE_BITS)) \ + | (middle << VERSION_MINOR_BITS) \ + | (minor) ) + +/** IMPORTANT NOTE on VERSION +* +* The version below MUST be changed whenever a change in this file is made. +* +* The last digit, the minor, is for bug fix changes only. +* +* The middle digit is for backward / forward compatible changes, updates +* to the existing messages, addition of fields. +* +* The major digit is for a breaking change of protocol, presumably +* something that cannot be accomodated with the existing protocol. +*/ + +#define VSCARD_VERSION MAKE_VERSION(0,0,1) + +typedef enum { + VSC_Init, + VSC_Error, + VSC_ReaderAdd, + VSC_ReaderAddResponse, + VSC_ReaderRemove, +VSC_ATR , + VSC_CardRemove, +VSC_APDU , + VSC_Reconnect +}VSCMsgType ; + +typedef enum { +VSC_GENERAL_ERROR =1 , +VSC_CANNOT_ADD_MORE_READERS , +}VSCErrorCode ; + +typedef uint32_t reader_id_t ; +#define VSCARD_UNDEFINED_READER_ID 0xffffffff +#define VSCARD_MINIMAL_READER_ID 0 + +typedef struct VSCMsgHeader { +VSCMsgType type; +reader_id_t reader_id; +uint32_t length; +uint8_t data[0 ]; +}VSCMsgHeader ; + +/* VSCMsgInit Client <-> Host +* Host replies with allocated reader id in ReaderAddResponse +* */ +typedef struct VSCMsgInit { +uint32_t version; +}VSCMsgInit ; + +/* VSCMsgError Client <-> Host +* */ +typedef struct VSCMsgError { +uint32_t code; +}VSCMsgError ; + +/* VSCMsgReaderAdd Client -> Host +* Host replies with allocated reader id in ReaderAddResponse +* name - name of the reader on client side. +* */ +typedef struct VSCMsgReaderAdd { +uint8_t name[0 ]; +}VSCMsgReaderAdd ; + +/* VSCMsgReaderAddResponse Host -> Client +* Reply to ReaderAdd +* */ +typedef struct VSCMsgReaderAddResponse { +}VSCMsgReaderAddResponse ; + +/* VSCMsgReaderRemove Client -> Host +* */ +typedef struct VSCMsgReaderRemove { +}VSCMsgReaderRemove ; + +/* VSCMsgATR Client -> Host +* Answer to reset. Sent for card insertion or card reset. +* */ +typedef struct VSCMsgATR { +uint8_t atr[0 ]; +}VSCMsgATR ; + +/* VSCMsgCardRemove Client -> Host +* */ +typedef struct VSCMsgCardRemove { +}VSCMsgCardRemove ; + +/* VSCMsgAPDU Client <-> Host +* */ +typedef struct VSCMsgAPDU { +uint8_t data[0 ]; +}VSCMsgAPDU ; + +/* VSCMsgReconnect Host -> Client +* */ +typedef struct VSCMsgReconnect { +uint32_t ip; +uint16_t port; +}VSCMsgReconnect ; + +#endif
Signature · 1 line
1.7.4
PATCH 8/17 ccid: add passthru card device
In reply to Alon LevyThe passthru ccid card is a device sitting on the usb-ccid bus and using a chardevice to communicate with a remote device using the VSCard protocol defined in libcacard/vscard_common.h
Usage docs available in following patch in docs/ccid.txt
---
Changes from v16->v17:
* fix wrong cast when receiving VSC_Error
* ccid-card-passthru: force chardev user wakeup by sending Init see lengthy comment below.
Changes from v15->v16:
Behavioral changes:
* return correct size
* return error instead of assert if client sent too large ATR
* don't assert if client sent too large a size, but add asserts for indices to buffer
* reset vscard_in indices on chardev disconnect
* handle init from client
* error if no chardev supplied
* use ntoh, hton
* eradicate reader_id_t
* remove Reconnect usage (removed from VSCARD protocol)
* send VSC_SUCCESS on card insert/remove and reader add/remove
Style fixes:
* width of line fix
* update copyright
* remove old TODO's
* update file header comment
* use macros for debug levels
* c++ style comment replacement
* update copyright license
* fix ATR size comment
* fix whitespace in struct def
* fix DPRINTF prefix
* line width fix
ccid-card-passthru: force chardev user wakeup by sending Init
The problem: how to wakeup the user of the smartcard when the smartcard device is initialized?
Long term solution: have a callback interface. This was done via the deprecated so called chardev ioctl interface.
Short term solution: do a write. Specifically we write an Init message. And we change the client to send it's own Init message regardless of receiving this one. Additional Init messages will be regarded as acceptable, the first one received after connection establishment is the determining one wrt capabilities.
--- Makefile.objs | 2 +- hw/ccid-card-passthru.c | 329 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 330 insertions(+), 1 deletions(-) create mode 100644 hw/ccid-card-passthru.c
Makefile.objs +1 -1
@@ -195,7 +195,7 @@ hw-obj-$(CONFIG_FDC) += fdc.o hw-obj-$(CONFIG_ACPI) += acpi.o acpi_piix4.o hw-obj-$(CONFIG_APM) += pm_smbus.o apm.o hw-obj-$(CONFIG_DMA) += dma.o -hw-obj-$(CONFIG_SMARTCARD) += usb-ccid.o +hw-obj-$(CONFIG_SMARTCARD) += usb-ccid.o ccid-card-passthru.o # PPC devices hw-obj-$(CONFIG_OPENPIC) += openpic.o
hw/ccid-card-passthru.c new file +329 -0
329 lines not on this page · raw message
Signature · 1 line
1.7.4
PATCH 5/17 usb-ccid: add CCID bus
In reply to Alon LevyA CCID device is a smart card reader. It is a USB device, defined at [1]. This patch introduces the usb-ccid device that is a ccid bus. Next patches will introduce two card types to use it, a passthru card and an emulated card.
[1] http://www.usb.org/developers/devclass_docs/DWG_Smart-Card_CCID_Rev110.
---
changes from v15->v16:
Behavioral changes:
* fix abort on client answer after card remove
* enable migration
* remove side affect code from asserts
* return consistent self-powered state
* mask out reserved bits in ccid_set_parameters
* add missing abRFU in SetParameters (no affect on linux guest)
whitefixes / comments / consts defines:
* remove stale comment
* remove ccid_print_pending_answers if no DEBUG_CCID
* replace printf's with DPRINTF, remove DEBUG_CCID, add verbosity defines
* use error_report
* update copyright (most of the code is not original)
* reword known bug comment
* add missing closing quote in comment
* add missing whitespace on one line
* s/CCID_SetParameter/CCID_SetParameters/
* add comments
* use define for max packet size
Comment for "return consistent self-powered state":
the Configuration Descriptor bmAttributes claims we are self powered, but we were returning not self powered to USB_REQ_GET_STATUS control message.
In practice, this message is not sent by a linux 2.6.35.10-74.fc14.x86_64 guest (not tested on other guests), unless you issue lsusb -v as root (for example).
--- Makefile.objs | 1 + configure | 6 + hw/ccid.h | 42 ++ hw/usb-ccid.c | 1352 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 1401 insertions(+), 0 deletions(-) create mode 100644 hw/ccid.h create mode 100644 hw/usb-ccid.c
Makefile.objs +1 -0
@@ -195,6 +195,7 @@ hw-obj-$(CONFIG_FDC) += fdc.o hw-obj-$(CONFIG_ACPI) += acpi.o acpi_piix4.o hw-obj-$(CONFIG_APM) += pm_smbus.o apm.o hw-obj-$(CONFIG_DMA) += dma.o +hw-obj-$(CONFIG_SMARTCARD) += usb-ccid.o # PPC devices hw-obj-$(CONFIG_OPENPIC) += openpic.o
configure +6 -0
@@ -174,6 +174,7 @@ trace_backend="nop" trace_file="trace" spice="" rbd="" +smartcard="yes" # parse CC options first for opt do
@@ -2472,6 +2473,7 @@ echo "Trace output file $trace_file-<pid>" echo "spice support $spice" echo "rbd support $rbd" echo "xfsctl support $xfs" +echo "smartcard support $smartcard" if test $sdl_too_old = "yes"; then echo "-> Your SDL version is too old - please upgrade to have SDL support"
@@ -2744,6 +2746,10 @@ if test "$spice" = "yes" ; then echo "CONFIG_SPICE=y" >> $config_host_mak fi +if test "$smartcard" = "yes" ; then + echo "CONFIG_SMARTCARD=y" >> $config_host_mak +fi + # XXX: suppress that if [ "$bsd" = "yes" ] ; then echo "CONFIG_BSD=y" >> $config_host_mak
hw/ccid.h new file +42 -0
42 lines not on this page · raw message
hw/usb-ccid.c new file +1352 -0
1,352 lines not on this page · raw message
Signature · 1 line
1.7.4
PATCH 10/17 ccid: add ccid-card-emulated device (v2)
In reply to Alon LevyThis devices uses libcacard (internal) to emulate a smartcard conforming to the CAC standard. It attaches to the usb-ccid bus. Usage instructions (example command lines) are in the following patch in docs/ccid.txt. It uses libcacard which uses nss, so it can work with both hw cards and certificates (files).
---
changes from v16->v17:
* use PROP_TYPE_ENUM for backend
changes from v15->v16:
* fix error reporting in initfn
* bump copyright year
* update copyright license
changes from v1:
* remove stale comments, use only c-style comments
* bugfix, forgot to set recv_len
* change reader name to 'Virtual Reader'
--- Makefile.objs | 2 +- hw/ccid-card-emulated.c | 550 +++++++++++++++++++++++++++++++++++++++++++++++ hw/ccid-card-passthru.c | 1 - 3 files changed, 551 insertions(+), 2 deletions(-) create mode 100644 hw/ccid-card-emulated.c
Makefile.objs +1 -1
@@ -195,7 +195,7 @@ hw-obj-$(CONFIG_FDC) += fdc.o hw-obj-$(CONFIG_ACPI) += acpi.o acpi_piix4.o hw-obj-$(CONFIG_APM) += pm_smbus.o apm.o hw-obj-$(CONFIG_DMA) += dma.o -hw-obj-$(CONFIG_SMARTCARD) += usb-ccid.o ccid-card-passthru.o +hw-obj-$(CONFIG_SMARTCARD) += usb-ccid.o ccid-card-passthru.o ccid-card-emulated.o # PPC devices hw-obj-$(CONFIG_OPENPIC) += openpic.o
hw/ccid-card-emulated.c new file +550 -0
550 lines not on this page · raw message
hw/ccid-card-passthru.c +0 -1
@@ -313,7 +313,6 @@ static CCIDCardInfo passthru_card_info = { .exitfn = passthru_exitfn, .get_atr = passthru_get_atr, .apdu_from_guest = passthru_apdu_from_guest, - .qdev.unplug = qdev_simple_unplug_cb, .qdev.props = (Property []) {DEFINE_PROP_CHR ("chardev" , PassthruState, cs),DEFINE_PROP_UINT8 ("debug" , PassthruState, debug,0 ),
Signature · 1 line
1.7.4
PATCH 11/17 ccid: add docs
In reply to Alon LevyAdd documentation for the usb-ccid device and accompanying two card devices, ccid-card-emulated and ccid-card-passthru.
--- docs/ccid.txt | 135 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 135 insertions(+), 0 deletions(-) create mode 100644 docs/ccid.txt
docs/ccid.txt new file +135 -0
@@ -0,0 +1,135 @@ +Qemu CCID Device Documentation. + +Contents +1. USB CCID device +2. Building +3. Using ccid-card-emulated with hardware +4. Using ccid-card-emulated with certificates +5. Using ccid-card-passthru with client side hardware +6. Using ccid-card-passthru with client side certificates +7. Passthrough protocol scenario +8. libcacard + +1. USB CCID device + +The USB CCID device is a USB device implementing the CCID specification, which +lets one connect smart card readers that implement the same spec. For more +information see the specification: + + Universal Serial Bus + Device Class: Smart Card + CCID + Specification for + Integrated Circuit(s) Cards Interface Devices + Revision 1.1 + April 22rd, 2005 + +Smartcard are used for authentication, single sign on, decryption in +public/private schemes and digital signatures. A smartcard reader on the client +cannot be used on a guest with simple usb passthrough since it will then not be +available on the client, possibly locking the computer when it is "removed". On +the other hand this device can let you use the smartcard on both the client and +the guest machine. It is also possible to have a completely virtual smart card +reader and smart card (i.e. not backed by a physical device) using this device. + +2. Building + +The cryptographic functions and access to the physical card is done via NSS. + +Installing NSS: + +In redhat/fedora: + yum install nss-devel +In ubuntu/debian: + apt-get install libnss3-dev + (not tested on ubuntu) + +Configuring and building: + ./configure --enable-smartcard && make + +3. Using ccid-card-emulated with hardware + +Assuming you have a working smartcard on the host with the current +user, using NSS, qemu acts as another NSS client using ccid-card-emulated: + + qemu -usb -device usb-ccid -device ccid-card-emualated + +4. Using ccid-card-emulated with certificates + +You must create the certificates. This is a one time process. We use NSS +certificates: + + certutil -d /etc/pki/nssdb -x -t "CT,CT,CT" -S -s "CN=cert1" -n cert1 + +Note: you must have exactly three certificates. + +Assuming the current user can access the certificates (use certutil -L to +verify), you can use the emulated card type with the certificates backend: + + qemu -usb -device usb-ccid -device ccid-card-emulated,backend=certificates,cert1=cert1,cert2=cert2,cert3=cert3 + +5. Using ccid-card-passthru with client side hardware + +on the host specify the ccid-card-passthru device with a suitable chardev: + + qemu -chardev socket,server,host=0.0.0.0,port=2001,id=ccid,nowait -usb -device usb-ccid -device ccid-card-passthru,chardev=ccid + +on the client run vscclient, built when you built the libcacard library: + libcacard/vscclient <qemu-host> 2001 + +6. Using ccid-card-passthru with client side certificates + +Run qemu as per #5, and run vscclient as follows: +(Note: vscclient command line interface is in a state of change) + + libcacard/vscclient -e "db=\"/etc/pki/nssdb\" use_hw=no soft=(,Test,CAC,,cert1,cert2,cert3)" <qemu-host> 2001 + +7. Passthrough protocol scenario + +This is a typical interchange of messages when using the passthru card device. +usb-ccid is a usb device. It defaults to an unattached usb device on startup. +usb-ccid expects a chardev and expects the protocol defined in +cac_card/vscard_common.h to be passed over that. +The usb-ccid device can be in one of three modes: + * detached + * attached with no card + * attached with card + +A typical interchange is: (the arrow shows who started each exchange, it can be client +originated or guest originated) + +client event | vscclient | passthru | usb-ccid | guest event +---------------------------------------------------------------------------------------------- + | VSC_Init | | | + | VSC_ReaderAdd | | attach | + | | | | sees new usb device. +card inserted -> | | | | + | VSC_ATR | insert | insert | see new card + | | | | + | VSC_APDU | VSC_APDU | | <- guest sends APDU +client<->physical | | | | +card APDU exchange| | | | +client response ->| VSC_APDU | VSC_APDU | | receive APDU response + ... + [APDU<->APDU repeats several times] + ... +card removed -> | | | | + | VSC_CardRemove | remove | remove | card removed + ... + [(card insert, apdu's, card remove) repeat] + ... +kill/quit | | | | + vscclient | | | | + | VSC_ReaderRemove | | detach | + | | | | usb device removed. + + +8. libcacard + +ccid-card-passthru and vscclient use libcacard as the card emulator. +libcacard implements a completely virtual CAC (DoD standard for smart cards) +compliant card and uses NSS to actually retrive certificates and do any +encryption using the backend (real reader + card or file backed certificates). + +For documentation of cac_card see README in libcacard subdirectory. +
Signature · 1 line
1.7.4
PATCH 12/17 ccid: configure: add --enable/disable and nss only disable
In reply to Alon Levyadd --enable-smartcard and --disable-smartcard flags, and let the nss check only disable building the ccid-card-emulated device, since both the usb-ccid and ccid-card-passthru don't depend on it.
--- Makefile.objs | 3 ++- Makefile.target | 2 +- configure | 41 +++++++++++++++++++++++++++++------------ 3 files changed, 32 insertions(+), 14 deletions(-)
Makefile.objs +2 -1
@@ -195,7 +195,8 @@ hw-obj-$(CONFIG_FDC) += fdc.o hw-obj-$(CONFIG_ACPI) += acpi.o acpi_piix4.o hw-obj-$(CONFIG_APM) += pm_smbus.o apm.o hw-obj-$(CONFIG_DMA) += dma.o -hw-obj-$(CONFIG_SMARTCARD) += usb-ccid.o ccid-card-passthru.o ccid-card-emulated.o +hw-obj-$(CONFIG_SMARTCARD) += usb-ccid.o ccid-card-passthru.o +hw-obj-$(CONFIG_SMARTCARD_NSS) += ccid-card-emulated.o # PPC devices hw-obj-$(CONFIG_OPENPIC) += openpic.o
Makefile.target +1 -1
@@ -340,7 +340,7 @@ obj-y += $(addprefix $(HWDIR)/, $(hw-obj-y)) endif # CONFIG_SOFTMMU -obj-y += $(addprefix ../libcacard/, $(libcacard-$(CONFIG_SMARTCARD))) +obj-y += $(addprefix ../libcacard/, $(libcacard-$(CONFIG_SMARTCARD_NSS))) obj-y += $(addprefix ../, $(trace-obj-y)) obj-$(CONFIG_GDBSTUB_XML) += gdbstub-xml.o
configure +29 -12
89 lines not on this page · raw message
Signature · 1 line
1.7.4
PATCH 13/17 ccid: add qdev description strings
In reply to Alon Levy--- hw/ccid-card-emulated.c | 1 + hw/ccid-card-passthru.c | 1 + hw/usb-ccid.c | 1 + 3 files changed, 3 insertions(+), 0 deletions(-)
hw/ccid-card-emulated.c +1 -0
@@ -525,6 +525,7 @@ EnumTable backend_enum_table[] = {static CCIDCardInfo emulated_card_info = { .qdev.name =EMULATED_DEV_NAME , + .qdev.desc ="emulated smartcard" , .qdev.size =sizeof (EmulatedState), .initfn = emulated_initfn, .exitfn = emulated_exitfn,
hw/ccid-card-passthru.c +1 -0
@@ -307,6 +307,7 @@ static VMStateDescription passthru_vmstate = {static CCIDCardInfo passthru_card_info = { .qdev.name =PASSTHRU_DEV_NAME , + .qdev.desc ="passthrough smartcard" , .qdev.size =sizeof (PassthruState), .qdev.vmsd = &passthru_vmstate, .initfn = passthru_initfn,
hw/usb-ccid.c +1 -0
@@ -1330,6 +1330,7 @@ static VMStateDescription ccid_vmstate = {static struct USBDeviceInfo ccid_info = { .product_desc ="QEMU USB CCID" , .qdev.name =CCID_DEV_NAME , + .qdev.desc ="CCID Rev 1.1 smartcard reader" , .qdev.size =sizeof (USBCCIDState), .init = ccid_initfn, .handle_packet = usb_generic_handle_packet,
Signature · 1 line
1.7.4
PATCH 14/17 smartcard, configure: add --enable-smartcard-nss, report only nss
In reply to Alon Levy--- configure | 28 ++++++++++++++++++++-------- 1 files changed, 20 insertions(+), 8 deletions(-)
configure +20 -8
@@ -174,8 +174,8 @@ trace_backend="nop" trace_file="trace" spice="" rbd="" -smartcard="yes" -smartcard_nss="yes" +smartcard="" +smartcard_nss="" # parse CC options first for opt do
@@ -725,6 +725,10 @@ for opt do ;; --enable-smartcard) smartcard="yes" ;; + --disable-smartcard-nss) smartcard_nss="no" + ;; + --enable-smartcard-nss) smartcard_nss="yes" + ;; *) echo "ERROR: unknown option $opt"; show_help="yes" ;; esac
@@ -922,6 +926,8 @@ echo " --enable-spice enable spice" echo " --enable-rbd enable building the rados block device (rbd)" echo " --disable-smartcard disable smartcard support" echo " --enable-smartcard enable smartcard support" +echo " --disable-smartcard-nss disable smartcard nss support" +echo " --enable-smartcard-nss enable smartcard nss support" echo "" echo "NOTE: The object files are built at the place where configure is launched" exit 1
@@ -2249,16 +2255,22 @@ fi # check for libcacard for smartcard support if test "$smartcard" != "no" ; then + smartcard="yes" smartcard_cflags="-I\$(SRC_PATH)/libcacard" libcacard_libs=$($pkg_config --libs nss 2>/dev/null) libcacard_cflags=$($pkg_config --cflags nss 2>/dev/null) # TODO - what's the minimal nss version we support? - if $pkg_config --atleast-version=3.12.8 nss >/dev/null 2>&1 ; then - smartcard_nss="yes" - QEMU_CFLAGS="$QEMU_CFLAGS $smartcard_cflags $libcacard_cflags" - LIBS="$libcacard_libs $LIBS" - else - smartcard_nss="no" + if test "$smartcard_nss" != "no"; then + if $pkg_config --atleast-version=3.12.8 nss >/dev/null 2>&1 ; then + smartcard_nss="yes" + QEMU_CFLAGS="$QEMU_CFLAGS $smartcard_cflags $libcacard_cflags" + LIBS="$libcacard_libs $LIBS" + else + if test "$smartcard_nss" == "yes"; then + feature_not_found "nss" + fi + smartcard_nss="no" + fi fi fi if test "$smartcard" == "no" ; then
Signature · 1 line
1.7.4
PATCH 15/17 smartcard,configure: report only nss
In reply to Alon Levy--- configure | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
configure +1 -2
@@ -2510,8 +2510,7 @@ echo "Trace output file $trace_file-<pid>" echo "spice support $spice" echo "rbd support $rbd" echo "xfsctl support $xfs" -echo "smartcard support $smartcard" -echo " \_ nss support $smartcard_nss" +echo "nss used $smartcard_nss" if test $sdl_too_old = "yes"; then echo "-> Your SDL version is too old - please upgrade to have SDL support"
Signature · 1 line
1.7.4
PATCH 16/17 ccid-card-emulated: don't link with NSS if --disable-smartcard-nss
In reply to Alon Levy--- configure | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
configure +4 -3
@@ -2256,13 +2256,14 @@ fi # check for libcacard for smartcard support if test "$smartcard" != "no" ; then smartcard="yes" - smartcard_cflags="-I\$(SRC_PATH)/libcacard" - libcacard_libs=$($pkg_config --libs nss 2>/dev/null) - libcacard_cflags=$($pkg_config --cflags nss 2>/dev/null) + smartcard_cflags="" # TODO - what's the minimal nss version we support? if test "$smartcard_nss" != "no"; then if $pkg_config --atleast-version=3.12.8 nss >/dev/null 2>&1 ; then smartcard_nss="yes" + smartcard_cflags="-I\$(SRC_PATH)/libcacard" + libcacard_libs=$($pkg_config --libs nss 2>/dev/null) + libcacard_cflags=$($pkg_config --cflags nss 2>/dev/null) QEMU_CFLAGS="$QEMU_CFLAGS $smartcard_cflags $libcacard_cflags" LIBS="$libcacard_libs $LIBS" else
Signature · 1 line
1.7.4
PATCH 17/17 ccid.h: add copyright, fix define and remove non C89 comments
In reply to Alon Levy--- hw/ccid.h | 17 +++++++++++++---- 1 files changed, 13 insertions(+), 4 deletions(-)
hw/ccid.h +13 -4
@@ -1,5 +1,14 @@ -#ifndef __CCID_H__ -#define __CCID_H__ +/* +* CCID Passthru Card Device emulation +* +* Copyright (c) 2011 Red Hat. +* Written by Alon Levy. +* +* This code is licenced under the GNU LGPL, version 2 or later. +*/ + +#ifndef CCID_H +#define CCID_H #include "qdev.h"
@@ -10,7 +19,7 @@ typedef struct CCIDCardInfo CCIDCardInfo;*/ struct CCIDCardState {DeviceState qdev; -uint32_t slot;// For future use with multiple slot reader. +uint32_t slot;/* For future use with multiple slot reader. */ };/* callbacks to be used by the CCID device (hw/usb-ccid.c) to call
@@ -38,5 +47,5 @@ void ccid_card_qdev_register(CCIDCardInfo *card);int ccid_card_ccid_attach (CCIDCardState *card);void ccid_card_ccid_detach (CCIDCardState *card); -#endif // __CCID_H__ +#endif /* CCID_H */
Signature · 1 line
1.7.4
PATCH 9/17 libcacard: initial commit
In reply to Alon LevyFrom: Robert Relyea <[email protected]>
libcacard emulates a Common Access Card (CAC) which is a standard for smartcards. It is used by the emulated ccid card introduced in a following patch. Docs are available in docs/libcacard.txt
---
changes from v15->v16:
Build:
* don't erase self with distclean
* fix make clean after make distclean
* Makefile: make vscclient link quiet
Behavioral:
* vcard_emul_nss: load coolkey in more situations
* vscclient:
* use hton,ntoh
* send init on connect, only start vevent thread on response
* read payload after header check, before type switch
* remove Reconnect
* update for vscard_common changes, empty Flush implementation
Style/Whitespace:
* fix wrong variable usage
* remove unused variable
* use only C style comments
* add copyright header
* fix tabulation
--- Makefile | 6 +- Makefile.objs | 5 + Makefile.target | 2 + configure | 25 + docs/libcacard.txt | 483 +++++++++++++++++ libcacard/Makefile | 14 + libcacard/cac.c | 411 +++++++++++++++ libcacard/cac.h | 20 + libcacard/card_7816.c | 780 ++++++++++++++++++++++++++++ libcacard/card_7816.h | 60 +++ libcacard/card_7816t.h | 163 ++++++ libcacard/event.c | 112 ++++ libcacard/eventt.h | 28 + libcacard/link_test.c | 20 + libcacard/mutex.h | 59 +++ libcacard/passthru.c | 612 ++++++++++++++++++++++ libcacard/passthru.h | 50 ++ libcacard/vcard.c | 350 +++++++++++++ libcacard/vcard.h | 85 +++ libcacard/vcard_emul.h | 62 +++ libcacard/vcard_emul_nss.c | 1192 +++++++++++++++++++++++++++++++++++++++++++ libcacard/vcard_emul_type.c | 60 +++ libcacard/vcard_emul_type.h | 29 + libcacard/vcardt.h | 66 +++ libcacard/vevent.h | 26 + libcacard/vreader.c | 526 +++++++++++++++++++ libcacard/vreader.h | 54 ++ libcacard/vreadert.h | 23 + libcacard/vscclient.c | 743 +++++++++++++++++++++++++++ 29 files changed, 6064 insertions(+), 2 deletions(-) create mode 100644 docs/libcacard.txt create mode 100644 libcacard/Makefile create mode 100644 libcacard/cac.c create mode 100644 libcacard/cac.h create mode 100644 libcacard/card_7816.c create mode 100644 libcacard/card_7816.h create mode 100644 libcacard/card_7816t.h create mode 100644 libcacard/event.c create mode 100644 libcacard/eventt.h create mode 100644 libcacard/link_test.c create mode 100644 libcacard/mutex.h create mode 100644 libcacard/passthru.c create mode 100644 libcacard/passthru.h create mode 100644 libcacard/vcard.c create mode 100644 libcacard/vcard.h create mode 100644 libcacard/vcard_emul.h create mode 100644 libcacard/vcard_emul_nss.c create mode 100644 libcacard/vcard_emul_type.c create mode 100644 libcacard/vcard_emul_type.h create mode 100644 libcacard/vcardt.h create mode 100644 libcacard/vevent.h create mode 100644 libcacard/vreader.c create mode 100644 libcacard/vreader.h create mode 100644 libcacard/vreadert.h create mode 100644 libcacard/vscclient.c
Makefile +4 -2
@@ -173,6 +173,8 @@ check-qlist: check-qlist.o qlist.o qint.o $(CHECK_PROG_DEPS) check-qfloat: check-qfloat.o qfloat.o $(CHECK_PROG_DEPS) check-qjson: check-qjson.o qfloat.o qint.o qdict.o qstring.o qlist.o qbool.o qjson.o json-streamer.o json-lexer.o json-parser.o $(CHECK_PROG_DEPS) +QEMULIBS=libhw32 libhw64 libuser libdis libdis-user + clean: # avoid old build problems by removing potentially incorrect old files rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h
@@ -184,7 +186,7 @@ clean: rm -f trace-dtrace.dtrace trace-dtrace.dtrace-timestamp rm -f trace-dtrace.h trace-dtrace.h-timestamp $(MAKE) -C tests clean - for d in $(ALL_SUBDIRS) libhw32 libhw64 libuser libdis libdis-user; do \ + for d in $(ALL_SUBDIRS) $(QEMULIBS) libcacard; do \ if test -d $$d; then $(MAKE) -C $$d $@ || exit 1; fi; \ rm -f $$d/qemu-options.def; \ done
@@ -195,7 +197,7 @@ distclean: clean rm -f roms/seabios/config.mak roms/vgabios/config.mak rm -f qemu-doc.info qemu-doc.aux qemu-doc.cp qemu-doc.dvi qemu-doc.fn qemu-doc.info qemu-doc.ky qemu-doc.log qemu-doc.pdf qemu-doc.pg qemu-doc.toc qemu-doc.tp qemu-doc.vr rm -f qemu-tech.info qemu-tech.aux qemu-tech.cp qemu-tech.dvi qemu-tech.fn qemu-tech.info qemu-tech.ky qemu-tech.log qemu-tech.pdf qemu-tech.pg qemu-tech.toc qemu-tech.tp qemu-tech.vr - for d in $(TARGET_DIRS) libhw32 libhw64 libuser libdis libdis-user; do \ + for d in $(TARGET_DIRS) $(QEMULIBS); do \ rm -rf $$d || exit 1 ; \ done
Makefile.objs +5 -0
@@ -313,6 +313,11 @@ user-obj-y += qemu-timer-common.o endif endif +###################################################################### +# smartcard + +libcacard-y = cac.o event.o passthru.o vcard.o vreader.o vcard_emul_nss.o vcard_emul_type.o card_7816.o + vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS) vl.o: QEMU_CFLAGS+=$(SDL_CFLAGS)
Makefile.target +2 -0
@@ -340,6 +340,8 @@ obj-y += $(addprefix $(HWDIR)/, $(hw-obj-y)) endif # CONFIG_SOFTMMU +obj-y += $(addprefix ../libcacard/, $(libcacard-$(CONFIG_SMARTCARD))) + obj-y += $(addprefix ../, $(trace-obj-y)) obj-$(CONFIG_GDBSTUB_XML) += gdbstub-xml.o
configure +25 -0
@@ -2240,6 +2240,19 @@ EOF fi fi +# check for libcacard for smartcard support +smartcard_cflags="-I\$(SRC_PATH)/libcacard" +libcacard_libs=$($pkgconfig --libs nss 2>/dev/null) +libcacard_cflags=$($pkgconfig --cflags nss) +# TODO - what's the minimal nss version we support? +if $pkgconfig --atleast-version=3.12.8 nss; then + smartcard="yes" + QEMU_CFLAGS="$QEMU_CFLAGS $smartcard_cflags $libcacard_cflags" + LIBS="$libcacard_libs $LIBS" +else + smartcard="no" +fi + ########################################## ##########################################
@@ -3075,6 +3088,11 @@ fi if test "$target_darwin_user" = "yes" ; then echo "CONFIG_DARWIN_USER=y" >> $config_target_mak fi +if test "$smartcard" = "yes" ; then + echo "subdir-$target: subdir-libcacard" >> $config_host_mak + echo "libcacard_libs=$libcacard_libs" >> $config_host_mak + echo "libcacard_cflags=$libcacard_cflags" >> $config_host_mak +fi list="" if test ! -z "$gdb_xml_files" ; then for x in $gdb_xml_files; do
@@ -3288,6 +3306,13 @@ for hwlib in 32 64; do echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" > $d/config.mak done +if [ $source_path != $workdir ]; then + # out of tree build + mkdir -p libcacard + rm -f libcacard/Makefile + ln -s $source_path/libcacard/Makefile libcacard/Makefile +fi + d=libuser mkdir -p $d symlink $source_path/Makefile.user $d/Makefile
docs/libcacard.txt new file +483 -0
483 lines not on this page · raw message
libcacard/Makefile new file +14 -0
@@ -0,0 +1,14 @@ +-include ../config-host.mak +-include $(SRC_PATH)/Makefile.objs +-include $(SRC_PATH)/rules.mak + +$(call set-vpath, $(SRC_PATH):$(SRC_PATH)/libcacard) + +vscclient: $(libcacard-y) vscclient.o + $(call quiet-command,$(CC) $(libcacard_libs) -o $@ $^," LINK $(TARGET_DIR)$@") + +all: vscclient + +clean: + rm -f *.o */*.o *.d */*.d *.a */*.a *~ */*~ vscclient +
libcacard/cac.c new file +411 -0
411 lines not on this page · raw message
libcacard/cac.h new file +20 -0
@@ -0,0 +1,20 @@ +/* +* defines the entry point for the cac card. Only used by cac.c anc +* vcard_emul_type.c +*/ +#ifndef CAC_H +#define CAC_H 1 +#include "vcard.h" +#include "vreader.h" +/* +* Initialize the cac card. This is the only public function in this file. All +* the rest are connected through function pointers. +*/ +VCardStatus cac_card_init (VReader *reader,VCard *card,const char *params, +unsigned char *const *cert,int cert_len[], +VCardKey *key[]/* adopt the keys*/ , +int cert_count); + +/* not yet implemented */ +VCardStatus cac_is_cac_card (VReader *reader); +#endif
libcacard/card_7816.c new file +780 -0
780 lines not on this page · raw message
libcacard/card_7816.h new file +60 -0
60 lines not on this page · raw message
libcacard/card_7816t.h new file +163 -0
163 lines not on this page · raw message
libcacard/event.c new file +112 -0
112 lines not on this page · raw message
libcacard/eventt.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* +*/ + +#ifndef EVENTT_H +#define EVENTT_H 1 +#include "vreadert.h" +#include "vcardt.h" + +typedef struct VEventStruct VEvent ; + +typedef enum { +VEVENT_READER_INSERT , +VEVENT_READER_REMOVE , +VEVENT_CARD_INSERT , +VEVENT_CARD_REMOVE , +VEVENT_LAST , +}VEventType ; + +struct VEventStruct { +VEvent *next; +VEventType type; +VReader *reader; +VCard *card; +}; +#endif + +
libcacard/link_test.c new file +20 -0
@@ -0,0 +1,20 @@ +/* +* +*/ +#include <stdio.h> +#include "vcard.h" + +VCardStatus cac_card_init (const char *flags,VCard *card, +const unsigned char *cert[], +int cert_len[],VCardKey *key[]/* adopt the keys*/ , +int cert_count); +/* +* this will crash... just test the linkage right now +*/ + +main(int argc, char **argv) +{ + VCard *card; /* no constructor yet */ +cac_card_init ("" , card,NULL ,0 ,NULL ,0 ); +} +
libcacard/mutex.h new file +59 -0
59 lines not on this page · raw message
libcacard/passthru.c new file +612 -0
612 lines not on this page · raw message
libcacard/passthru.h new file +50 -0
50 lines not on this page · raw message
libcacard/vcard.c new file +350 -0
102 lines not on this page · raw message
libcacard/vcard.h new file +85 -0
85 lines not on this page · raw message
libcacard/vcard_emul.h new file +62 -0
62 lines not on this page · raw message
libcacard/vcard_emul_nss.c new file +1192 -0
1,192 lines not on this page · raw message
libcacard/vcard_emul_type.c new file +60 -0
60 lines not on this page · raw message
libcacard/vcardt.h new file +66 -0
66 lines not on this page · raw message
libcacard/vreader.c new file +526 -0
526 lines not on this page · raw message
libcacard/vreader.h new file +54 -0
54 lines not on this page · raw message
libcacard/vscclient.c new file +743 -0
743 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.4
Part of the diff is not shown here. View the raw message.
The copy should say 00/17, copy paste error.
Quoted 248 lines · Alon Levy
This patchset adds three new devices, usb-ccid, ccid-card-passthru and ccid-card-emulated, providing a CCID bus, a simple passthru protocol implementing card requiring a client, and a standalone emulated card.
It also introduces a new directory libcaccard with CAC card emulation, CAC is a type of ISO 7816 smart card.
Tree for pull:
git://anongit.freedesktop.org/~alon/qemuusb_ccid.v17v16-v17 changes:
* merged all the "v15->v16" patches
* merged some more wherever it was easy (all same file commits).
* added signed off by to first four patches
*ccid.h: added copyright, removed underscore in defines, and replaced non C89 commentsv15-v16 changes:
* splitvscard_commonintroducing patch for ease of review
* sum of commit logs for the v15-v16 commits: (whitespace fixes
removed for space, see original commit messages in later patches)
* usb-ccid:
* fix abort on client answer after card remove
* enable migration
* remove side affect code from asserts
* return consistent self-powered state
* mask out reserved bits inccid_set_parameters
* add missing abRFU in SetParameters (no affect on linux guest)
*vscard_common.hprotocol change:
* VSCMsgInit capabilities and magic
* removed ReaderResponse, will use Error instead with code==VSC_SUCCESS.
* added Flush and FlushComplete, remove Reconnect.
* defineVSCARD_MAGIC
* added error codeVSC_SUCCESS.
* ccid-card-passthru
* return correct size
* return error instead of assert if client sent too large ATR
* don't assert if client sent too large a size, but add asserts for indices to buffer
* resetvscard_inindices on chardev disconnect
* handle init from client
* error if no chardev supplied
* use ntoh, hton
* eradicatereader_id_t
* remove Reconnect usage (removed from VSCARD protocol)
* sendVSC_SUCCESSon card insert/remove and reader add/remove
* ccid-card-emulated
* fix error reporting in initfnv14-v15 changes:
* add patch with --enable-smartcard and --disable-smartcard and only disable ccid-card-emulated if nss not found.
* add patch with description strings
* s/libcaccard/libcacard/ indocs/ccid.txtv13-v14 changes:
- support device_del/device_add on ccid-card-* and usb-ccid
* usb-ccid:
* lose card reference when card device deleted
* check slot number and deny adding a slot if one is already added.
* ccid-card-*: useqdev_simple_unplug_cbin both emulated and passthru ccid cards, the exitfn already takes care of triggering card removal in the usb dev.
* libcacard:
* remove double include of config-host.mak
* add replay of card events to libcacard to support second and more emulation
* don't initialize more then once (doesn't support it right now, so one thread, NSS thread, is left whendevice_delis done)
* addVCARD_EMUL_INIT_ALREADY_INITED
* ccid-card-emulated:
* take correct mutexes on signaling to fix deadlocks ondevice_del
* allow card insertion/removal event without proper reader insertion eventv12-v13 changes:
* libcacard:
* fixMakefileclean to remove vscclient
* fix double include of config-host inMakefile
* usb-ccid: remove attach/detach logic, usb is always attached. Guest doesn't care if there is a reader attached with no card anyway.
* ccid-card-passthru: don't closechr_devon removal, makes it possible to use device_del/device_add to create remove/insertion for debugging.v11-v12 changes:
* fix out of tree buildv10-v11 changes:
* fix last patch that removed one of the doc files.
* updated flow table indocs/ccid.txtv8-v10 changes:
* usb-ccid:
* add slot for future use (Gerd)
* ifdefENABLE_MIGRATIONfor migration support on account of usb migration not being ready in general. (Gerd)
* verbosified commit messages. (Gerd)
* put libcacard docs in libcacard commit. (Gerd)v8-v9 changes:
* Blue Swirl comments:
* white space fixes
* enabled by default, disabled only if missing nss
* forgotten fix from v8 (don't build libcacard.so)
* added a note about device being little endian
* library renamed from libcaccard to libcacard
* squashed both of libcacard patches, they touched different files anyway.v7-v8 changes:
* Blue Swirl comments:
* usb-ccid: deannonymize some structs
* usb-ccid: coding style change -answer_tandbulk_in_tfixed
* usb-ccid: handle endianess conversion between guest and host
* usb-ccid: s/ccid_bulk_in_copy_out/ccid_bulk_in_copy_to_guest/
* ccid-card-emulated: fix segfault if backend not specified
* ccid-card-emulated: let last reader inserted win
* libcaccard: remove doublevscard_common.h
v6->v7changes:
* external libcaccard became internal directory libcaccard
* statically link object files into qemu
* produce libcaccard.so for usage by external projects
* applied coding style to new code (please check me)
- did not use the qemu options parsing for libcaccard, since it seems to draw large amounts of qemu code (monitor for instance).
v5->v6changes:
* really remove static debug (I apologize for claiming to have done so before)
v4->v5changes:
* rebased to latest
* remove static debug in card devices
* fix --enable-smartcard to link
* stall instead of assert when exceedingBULK_OUT_DATA_SIZE
* makeccid_reserve_recv_buffor too large len discard message, not exit
* makeccid_reserve_recv_bufreturn void*
* fix typo
* remove commented code in VMState
v3->v4:
* remove ccid field in CCIDBus
* remove static debug in bus
* add back docs
v2->v3:
* split into bus (usb-ccid.c, usesccid.h) and card (ccid-card-passthru.c).
* removed documentation (being revised).
v1->v2:
* all QSIMPLEQ turned into fixed sized rings
* all allocated buffers turned into fixed size buffers
* added migration support
* added a message to tell client qemu has migrated to ip:port
* for lack of monitor commands ip:port are 0:0, which causes the updated vscclient to connect to one port higher on the same host. will add monitor commands in a separate patch. tested with current setup.Alon Levy (16):
qdev: addprint_optionscallback
qdev: add data pointer to Property
qdev-properties: addPROP_TYPE_ENUM
qdev-properties:parse_enum: don't cast a void*
usb-ccid: add CCID bus
introducelibcacard/vscard_common.hlibcacard/vscard_common.hupdate (v15->v16)
ccid: add passthru card device
ccid: add ccid-card-emulated device (v2)
ccid: add docs
ccid: configure: add --enable/disable and nss only disable
ccid: add qdev description strings
smartcard,configure: add --enable-smartcard-nss, report only nss smartcard,configure: report only nss
ccid-card-emulated: don't link with NSS if --disable-smartcard-nssccid.h: add copyright, fix define and remove non C89 commentsRobert Relyea (1):
libcacard: initial commitMakefile | 6 +- Makefile.objs | 7 + Makefile.target | 2 + configure | 60 ++ docs/ccid.txt | 135 +++++ docs/libcacard.txt | 483 +++++++++++++++ hw/ccid-card-emulated.c | 551 ++++++++++++++++++ hw/ccid-card-passthru.c | 329 +++++++++++ hw/ccid.h | 51 ++ hw/qdev-properties.c | 60 ++ hw/qdev.c | 10 +- hw/qdev.h | 17 + hw/usb-ccid.c | 1353 +++++++++++++++++++++++++++++++++++++++++++ libcacard/Makefile | 14 + libcacard/cac.c | 411 +++++++++++++ libcacard/cac.h | 20 + libcacard/card_7816.c | 780 +++++++++++++++++++++++++ libcacard/card_7816.h | 60 ++ libcacard/card_7816t.h | 163 ++++++ libcacard/event.c | 112 ++++ libcacard/eventt.h | 28 + libcacard/link_test.c | 20 + libcacard/mutex.h | 59 ++ libcacard/passthru.c | 612 +++++++++++++++++++ libcacard/passthru.h | 50 ++ libcacard/vcard.c | 350 +++++++++++ libcacard/vcard.h | 85 +++ libcacard/vcard_emul.h | 62 ++ libcacard/vcard_emul_nss.c | 1192 +++++++++++++++++++++++++++++++++++++ libcacard/vcard_emul_type.c | 60 ++ libcacard/vcard_emul_type.h | 29 + libcacard/vcardt.h | 66 +++ libcacard/vevent.h | 26 + libcacard/vreader.c | 526 +++++++++++++++++ libcacard/vreader.h | 54 ++ libcacard/vreadert.h | 23 + libcacard/vscard_common.h | 167 ++++++ libcacard/vscclient.c | 743 ++++++++++++++++++++++++ 38 files changed, 8773 insertions(+), 3 deletions(-) create mode 100644 docs/ccid.txt create mode 100644 docs/libcacard.txt create mode 100644 hw/ccid-card-emulated.c create mode 100644 hw/ccid-card-passthru.c create mode 100644 hw/ccid.h create mode 100644 hw/usb-ccid.c create mode 100644 libcacard/Makefile create mode 100644 libcacard/cac.c create mode 100644 libcacard/cac.h create mode 100644 libcacard/card_7816.c create mode 100644 libcacard/card_7816.h create mode 100644 libcacard/card_7816t.h create mode 100644 libcacard/event.c create mode 100644 libcacard/eventt.h create mode 100644 libcacard/link_test.c create mode 100644 libcacard/mutex.h create mode 100644 libcacard/passthru.c create mode 100644 libcacard/passthru.h create mode 100644 libcacard/vcard.c create mode 100644 libcacard/vcard.h create mode 100644 libcacard/vcard_emul.h create mode 100644 libcacard/vcard_emul_nss.c create mode 100644 libcacard/vcard_emul_type.c create mode 100644 libcacard/vcard_emul_type.h create mode 100644 libcacard/vcardt.h create mode 100644 libcacard/vevent.h create mode 100644 libcacard/vreader.c create mode 100644 libcacard/vreader.h create mode 100644 libcacard/vreadert.h create mode 100644 libcacard/vscard_common.h create mode 100644 libcacard/vscclient.cSignature · 1 line
1.7.4
self NACK, I'll resend this merging vscard_common which I missed, and hopefully a correct subject too.
Quoted 248 lines · Alon Levy
This patchset adds three new devices, usb-ccid, ccid-card-passthru and ccid-card-emulated, providing a CCID bus, a simple passthru protocol implementing card requiring a client, and a standalone emulated card.
It also introduces a new directory libcaccard with CAC card emulation, CAC is a type of ISO 7816 smart card.
Tree for pull:
git://anongit.freedesktop.org/~alon/qemuusb_ccid.v17v16-v17 changes:
* merged all the "v15->v16" patches
* merged some more wherever it was easy (all same file commits).
* added signed off by to first four patches
*ccid.h: added copyright, removed underscore in defines, and replaced non C89 commentsv15-v16 changes:
* splitvscard_commonintroducing patch for ease of review
* sum of commit logs for the v15-v16 commits: (whitespace fixes
removed for space, see original commit messages in later patches)
* usb-ccid:
* fix abort on client answer after card remove
* enable migration
* remove side affect code from asserts
* return consistent self-powered state
* mask out reserved bits inccid_set_parameters
* add missing abRFU in SetParameters (no affect on linux guest)
*vscard_common.hprotocol change:
* VSCMsgInit capabilities and magic
* removed ReaderResponse, will use Error instead with code==VSC_SUCCESS.
* added Flush and FlushComplete, remove Reconnect.
* defineVSCARD_MAGIC
* added error codeVSC_SUCCESS.
* ccid-card-passthru
* return correct size
* return error instead of assert if client sent too large ATR
* don't assert if client sent too large a size, but add asserts for indices to buffer
* resetvscard_inindices on chardev disconnect
* handle init from client
* error if no chardev supplied
* use ntoh, hton
* eradicatereader_id_t
* remove Reconnect usage (removed from VSCARD protocol)
* sendVSC_SUCCESSon card insert/remove and reader add/remove
* ccid-card-emulated
* fix error reporting in initfnv14-v15 changes:
* add patch with --enable-smartcard and --disable-smartcard and only disable ccid-card-emulated if nss not found.
* add patch with description strings
* s/libcaccard/libcacard/ indocs/ccid.txtv13-v14 changes:
- support device_del/device_add on ccid-card-* and usb-ccid
* usb-ccid:
* lose card reference when card device deleted
* check slot number and deny adding a slot if one is already added.
* ccid-card-*: useqdev_simple_unplug_cbin both emulated and passthru ccid cards, the exitfn already takes care of triggering card removal in the usb dev.
* libcacard:
* remove double include of config-host.mak
* add replay of card events to libcacard to support second and more emulation
* don't initialize more then once (doesn't support it right now, so one thread, NSS thread, is left whendevice_delis done)
* addVCARD_EMUL_INIT_ALREADY_INITED
* ccid-card-emulated:
* take correct mutexes on signaling to fix deadlocks ondevice_del
* allow card insertion/removal event without proper reader insertion eventv12-v13 changes:
* libcacard:
* fixMakefileclean to remove vscclient
* fix double include of config-host inMakefile
* usb-ccid: remove attach/detach logic, usb is always attached. Guest doesn't care if there is a reader attached with no card anyway.
* ccid-card-passthru: don't closechr_devon removal, makes it possible to use device_del/device_add to create remove/insertion for debugging.v11-v12 changes:
* fix out of tree buildv10-v11 changes:
* fix last patch that removed one of the doc files.
* updated flow table indocs/ccid.txtv8-v10 changes:
* usb-ccid:
* add slot for future use (Gerd)
* ifdefENABLE_MIGRATIONfor migration support on account of usb migration not being ready in general. (Gerd)
* verbosified commit messages. (Gerd)
* put libcacard docs in libcacard commit. (Gerd)v8-v9 changes:
* Blue Swirl comments:
* white space fixes
* enabled by default, disabled only if missing nss
* forgotten fix from v8 (don't build libcacard.so)
* added a note about device being little endian
* library renamed from libcaccard to libcacard
* squashed both of libcacard patches, they touched different files anyway.v7-v8 changes:
* Blue Swirl comments:
* usb-ccid: deannonymize some structs
* usb-ccid: coding style change -answer_tandbulk_in_tfixed
* usb-ccid: handle endianess conversion between guest and host
* usb-ccid: s/ccid_bulk_in_copy_out/ccid_bulk_in_copy_to_guest/
* ccid-card-emulated: fix segfault if backend not specified
* ccid-card-emulated: let last reader inserted win
* libcaccard: remove doublevscard_common.h
v6->v7changes:
* external libcaccard became internal directory libcaccard
* statically link object files into qemu
* produce libcaccard.so for usage by external projects
* applied coding style to new code (please check me)
- did not use the qemu options parsing for libcaccard, since it seems to draw large amounts of qemu code (monitor for instance).
v5->v6changes:
* really remove static debug (I apologize for claiming to have done so before)
v4->v5changes:
* rebased to latest
* remove static debug in card devices
* fix --enable-smartcard to link
* stall instead of assert when exceedingBULK_OUT_DATA_SIZE
* makeccid_reserve_recv_buffor too large len discard message, not exit
* makeccid_reserve_recv_bufreturn void*
* fix typo
* remove commented code in VMState
v3->v4:
* remove ccid field in CCIDBus
* remove static debug in bus
* add back docs
v2->v3:
* split into bus (usb-ccid.c, usesccid.h) and card (ccid-card-passthru.c).
* removed documentation (being revised).
v1->v2:
* all QSIMPLEQ turned into fixed sized rings
* all allocated buffers turned into fixed size buffers
* added migration support
* added a message to tell client qemu has migrated to ip:port
* for lack of monitor commands ip:port are 0:0, which causes the updated vscclient to connect to one port higher on the same host. will add monitor commands in a separate patch. tested with current setup.Alon Levy (16):
qdev: addprint_optionscallback
qdev: add data pointer to Property
qdev-properties: addPROP_TYPE_ENUM
qdev-properties:parse_enum: don't cast a void*
usb-ccid: add CCID bus
introducelibcacard/vscard_common.hlibcacard/vscard_common.hupdate (v15->v16)
ccid: add passthru card device
ccid: add ccid-card-emulated device (v2)
ccid: add docs
ccid: configure: add --enable/disable and nss only disable
ccid: add qdev description strings
smartcard,configure: add --enable-smartcard-nss, report only nss smartcard,configure: report only nss
ccid-card-emulated: don't link with NSS if --disable-smartcard-nssccid.h: add copyright, fix define and remove non C89 commentsRobert Relyea (1):
libcacard: initial commitMakefile | 6 +- Makefile.objs | 7 + Makefile.target | 2 + configure | 60 ++ docs/ccid.txt | 135 +++++ docs/libcacard.txt | 483 +++++++++++++++ hw/ccid-card-emulated.c | 551 ++++++++++++++++++ hw/ccid-card-passthru.c | 329 +++++++++++ hw/ccid.h | 51 ++ hw/qdev-properties.c | 60 ++ hw/qdev.c | 10 +- hw/qdev.h | 17 + hw/usb-ccid.c | 1353 +++++++++++++++++++++++++++++++++++++++++++ libcacard/Makefile | 14 + libcacard/cac.c | 411 +++++++++++++ libcacard/cac.h | 20 + libcacard/card_7816.c | 780 +++++++++++++++++++++++++ libcacard/card_7816.h | 60 ++ libcacard/card_7816t.h | 163 ++++++ libcacard/event.c | 112 ++++ libcacard/eventt.h | 28 + libcacard/link_test.c | 20 + libcacard/mutex.h | 59 ++ libcacard/passthru.c | 612 +++++++++++++++++++ libcacard/passthru.h | 50 ++ libcacard/vcard.c | 350 +++++++++++ libcacard/vcard.h | 85 +++ libcacard/vcard_emul.h | 62 ++ libcacard/vcard_emul_nss.c | 1192 +++++++++++++++++++++++++++++++++++++ libcacard/vcard_emul_type.c | 60 ++ libcacard/vcard_emul_type.h | 29 + libcacard/vcardt.h | 66 +++ libcacard/vevent.h | 26 + libcacard/vreader.c | 526 +++++++++++++++++ libcacard/vreader.h | 54 ++ libcacard/vreadert.h | 23 + libcacard/vscard_common.h | 167 ++++++ libcacard/vscclient.c | 743 ++++++++++++++++++++++++ 38 files changed, 8773 insertions(+), 3 deletions(-) create mode 100644 docs/ccid.txt create mode 100644 docs/libcacard.txt create mode 100644 hw/ccid-card-emulated.c create mode 100644 hw/ccid-card-passthru.c create mode 100644 hw/ccid.h create mode 100644 hw/usb-ccid.c create mode 100644 libcacard/Makefile create mode 100644 libcacard/cac.c create mode 100644 libcacard/cac.h create mode 100644 libcacard/card_7816.c create mode 100644 libcacard/card_7816.h create mode 100644 libcacard/card_7816t.h create mode 100644 libcacard/event.c create mode 100644 libcacard/eventt.h create mode 100644 libcacard/link_test.c create mode 100644 libcacard/mutex.h create mode 100644 libcacard/passthru.c create mode 100644 libcacard/passthru.h create mode 100644 libcacard/vcard.c create mode 100644 libcacard/vcard.h create mode 100644 libcacard/vcard_emul.h create mode 100644 libcacard/vcard_emul_nss.c create mode 100644 libcacard/vcard_emul_type.c create mode 100644 libcacard/vcard_emul_type.h create mode 100644 libcacard/vcardt.h create mode 100644 libcacard/vevent.h create mode 100644 libcacard/vreader.c create mode 100644 libcacard/vreader.h create mode 100644 libcacard/vreadert.h create mode 100644 libcacard/vscard_common.h create mode 100644 libcacard/vscclient.cSignature · 1 line
1.7.4