[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 6/7] Enable support for passthru (e.g. direct to
From: |
Jeremy White |
Subject: |
[Qemu-devel] [PATCH v3 6/7] Enable support for passthru (e.g. direct to pcsc) smart cards in the emul_options entry point in libcacard. |
Date: |
Fri, 13 Mar 2015 14:45:23 -0500 |
Signed-off-by: Jeremy White <address@hidden>
---
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 49f0bdf..9b7d54b 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);
@@ -1297,5 +1318,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
- [Qemu-devel] [PATCH v3 0/7] Add support for passthru cards to libcacard, Jeremy White, 2015/03/13
- [Qemu-devel] [PATCH v3 6/7] Enable support for passthru (e.g. direct to pcsc) smart cards in the emul_options entry point in libcacard.,
Jeremy White <=
- [Qemu-devel] [PATCH v3 3/7] Add a configure check for libpcsclite, and an option to enable or disable it., Jeremy White, 2015/03/13
- [Qemu-devel] [PATCH v3 4/7] Add error checking to vcard_emul_options., Jeremy White, 2015/03/13
- [Qemu-devel] [PATCH v3 5/7] Add a VCARD_DIRECT implemention to the libcacard smartcard support., Jeremy White, 2015/03/13
- [Qemu-devel] [PATCH v3 7/7] Remove the (broken) passthru option., Jeremy White, 2015/03/13
- [Qemu-devel] [PATCH v3 1/7] Bug fix: delete the reader entry after queueing an event, not before., Jeremy White, 2015/03/13