Signed-off-by: Jeremy White <jwh...@codeweavers.com> --- libcacard/vcard.c | 2 +- libcacard/vcard.h | 2 +- libcacard/vcard_emul_nss.c | 29 ++++++++++++++++++++++++++++- libcacard/vcard_emul_type.c | 3 ++- 4 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/libcacard/vcard.c b/libcacard/vcard.c index d140a8e..4a1d91e 100644 --- a/libcacard/vcard.c +++ b/libcacard/vcard.c @@ -95,7 +95,7 @@ vcard_reset(VCard *card, VCardPower power) VCardApplet * vcard_new_applet(VCardProcessAPDU applet_process_function, VCardResetApplet applet_reset_function, - unsigned char *aid, int aid_len) + const unsigned char *aid, int aid_len) { VCardApplet *applet; diff --git a/libcacard/vcard.h b/libcacard/vcard.h index 47dc703..c16b944 100644 --- a/libcacard/vcard.h +++ b/libcacard/vcard.h @@ -30,7 +30,7 @@ void vcard_reset(VCard *card, VCardPower power); */ VCardApplet *vcard_new_applet(VCardProcessAPDU applet_process_function, VCardResetApplet applet_reset_function, - unsigned char *aid, int aid_len); + const unsigned char *aid, int aid_len); /* * destructor for a VCardApplet diff --git a/libcacard/vcard_emul_nss.c b/libcacard/vcard_emul_nss.c index 950edee..5df0958 100644 --- a/libcacard/vcard_emul_nss.c +++ b/libcacard/vcard_emul_nss.c @@ -25,6 +25,7 @@ #include <prthread.h> #include <secerr.h> +#include "config-host.h" #include "qemu-common.h" #include "vcard.h" @@ -34,6 +35,9 @@ #include "vevent.h" #include "libcacard/vcardt_internal.h" +#if defined(CONFIG_SMARTCARD_PCSC) +#include "capcsc.h" +#endif typedef enum { @@ -892,6 +896,23 @@ vcard_emul_init(const VCardEmulOptions *options) options = &default_options; } +#if defined(CONFIG_SMARTCARD_PCSC) + if (options->use_hw && options->hw_card_type == VCARD_EMUL_PASSTHRU) { + if (options->vreader_count > 0) { + fprintf(stderr, "Error: you cannot use a soft card and " + "a passthru card simultaneously.\n"); + return VCARD_EMUL_FAIL; + } + + if (capcsc_init()) { + fprintf(stderr, "Error initializing PCSC interface.\n"); + return VCARD_EMUL_FAIL; + } + + return VCARD_EMUL_OK; + } +#endif + /* first initialize NSS */ if (options->nss_db) { rv = NSS_Init(options->nss_db); @@ -1270,5 +1291,11 @@ vcard_emul_usage(void) "hw_type, and parameters of hw_param.\n" "\n" "If more one or more soft= parameters are specified, these readers will be\n" -"presented to the guest\n"); +"presented to the guest\n" +#if defined(CONFIG_SMARTCARD_PCSC) +"\n" +"If a hw_type of PASSTHRU is given, a connection will be made to the hardware\n" +"using libpcscslite. Note that in that case, no soft cards are permitted.\n" +#endif +); } diff --git a/libcacard/vcard_emul_type.c b/libcacard/vcard_emul_type.c index 59a1458..e8f6a4c 100644 --- a/libcacard/vcard_emul_type.c +++ b/libcacard/vcard_emul_type.c @@ -9,6 +9,7 @@ */ #include <strings.h> +#include "config-host.h" #include "vcardt.h" #include "vcard_emul_type.h" #include "cac.h" @@ -48,7 +49,7 @@ VCardEmulType vcard_emul_type_from_string(const char *type_string) if (strcasecmp(type_string, "CAC") == 0) { return VCARD_EMUL_CAC; } -#ifdef USE_PASSTHRU +#ifdef CONFIG_SMARTCARD_PCSC if (strcasecmp(type_string, "PASSTHRU") == 0) { return VCARD_EMUL_PASSTHRU; } -- 1.7.10.4