From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38538) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDatD-0006RX-Sd for qemu-devel@nongnu.org; Tue, 20 Jan 2015 10:38:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YDat8-0000qT-RL for qemu-devel@nongnu.org; Tue, 20 Jan 2015 10:38:47 -0500 Received: from mail.codeweavers.com ([216.251.189.131]:46815) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDat8-0000jy-Mw for qemu-devel@nongnu.org; Tue, 20 Jan 2015 10:38:42 -0500 Received: from jwhite.mn.codeweavers.com ([10.69.137.101] helo=jwhite.mn.codeweavers.com.) by mail.codeweavers.com with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YDat1-0003BM-Gt for qemu-devel@nongnu.org; Tue, 20 Jan 2015 09:38:35 -0600 From: Jeremy White Date: Tue, 20 Jan 2015 09:38:30 -0600 Message-Id: <1421768311-9864-4-git-send-email-jwhite@codeweavers.com> In-Reply-To: <1421768311-9864-1-git-send-email-jwhite@codeweavers.com> References: <1421768311-9864-1-git-send-email-jwhite@codeweavers.com> Subject: [Qemu-devel] [PATCH v2 3/4] Enable support for passthru (e.g. direct to pcsc) smart cards in the emul_options entry point in libcacard. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Signed-off-by: Jeremy White --- 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 #include +#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 +#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