summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJakub Jelen <jjelen@redhat.com>2019-04-16 11:53:03 +0200
committerJakub Jelen <jjelen@redhat.com>2019-07-04 16:05:09 +0200
commit1c00b79c9e6e616b27169fc296ce542b69fb3634 (patch)
tree80b15c84542b0431ad9e1dd40d7f1e89653536f5 /src
parent7e2cbd9e89508e9567378f358e0c6b1c82ea2103 (diff)
cac: Clone also ATR to match one from the official list
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/cac.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/cac.c b/src/cac.c
index 01ec104..cc9cf2a 100644
--- a/src/cac.c
+++ b/src/cac.c
@@ -26,6 +26,7 @@
#include "cac-aca.h"
#include "vcard.h"
#include "vcard_emul.h"
+#include "vcardt_internal.h"
#include "card_7816.h"
#include "simpletlv.h"
#include "common.h"
@@ -2233,6 +2234,27 @@ failure:
}
/*
+ * Get ATR of CAC card since some application might be picky about out
+ * virtual one
+ */
+static unsigned char cac_atr[] = {
+ /* The older CAC card from official CAC document */
+ 0x3B, 0x7A, 0x18, 0x00, 0x00, 0x73, 0x66, 0x74, 0x65, 0x20, 0x63, 0x64, 0x31, 0x34, 0x34
+};
+static int cac_atr_len = sizeof(cac_atr);
+
+static void
+cac_get_atr(G_GNUC_UNUSED VCard *card, unsigned char *atr, int *atr_len)
+{
+ int len;
+ assert(atr != NULL);
+
+ len = MIN(cac_atr_len, *atr_len);
+ memcpy(atr, cac_atr, len);
+ *atr_len = len;
+}
+
+/*
* Initialize the cac card. This is the only public function in this file. All
* the rest are connected through function pointers.
*/
@@ -2389,6 +2411,9 @@ cac_card_init(G_GNUC_UNUSED VReader *reader, VCard *card,
/* GP applet is created from vcard_emul_type() */
+ /* Modify ATR to match existing cards */
+ vcard_set_atr_func(card, cac_get_atr);
+
return VCARD_DONE;
failure: