|
|
0ea42e |
From 6691487cd7433b4ffc3a99124b5ecf92361b8a76 Mon Sep 17 00:00:00 2001
|
|
|
0ea42e |
From: Jakub Jelen <jjelen@redhat.com>
|
|
|
0ea42e |
Date: Tue, 9 Oct 2018 15:10:36 +0200
|
|
|
0ea42e |
Subject: [PATCH 1/3] cac: These functions do not have to be exposed
|
|
|
0ea42e |
|
|
|
0ea42e |
---
|
|
|
0ea42e |
src/libopensc/card-cac.c | 4 ++--
|
|
|
0ea42e |
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
|
0ea42e |
|
|
|
0ea42e |
diff --git a/src/libopensc/card-cac.c b/src/libopensc/card-cac.c
|
|
|
0ea42e |
index eeab07e4f..bd4e03362 100644
|
|
|
0ea42e |
--- a/src/libopensc/card-cac.c
|
|
|
0ea42e |
+++ b/src/libopensc/card-cac.c
|
|
|
0ea42e |
@@ -211,7 +211,7 @@ typedef struct cac_private_data {
|
|
|
0ea42e |
|
|
|
0ea42e |
#define CAC_DATA(card) ((cac_private_data_t*)card->drv_data)
|
|
|
0ea42e |
|
|
|
0ea42e |
-int cac_list_compare_path(const void *a, const void *b)
|
|
|
0ea42e |
+static int cac_list_compare_path(const void *a, const void *b)
|
|
|
0ea42e |
{
|
|
|
0ea42e |
if (a == NULL || b == NULL)
|
|
|
0ea42e |
return 1;
|
|
|
0ea42e |
@@ -220,7 +220,7 @@ int cac_list_compare_path(const void *a, const void *b)
|
|
|
0ea42e |
}
|
|
|
0ea42e |
|
|
|
0ea42e |
/* For SimCList autocopy, we need to know the size of the data elements */
|
|
|
0ea42e |
-size_t cac_list_meter(const void *el) {
|
|
|
0ea42e |
+static size_t cac_list_meter(const void *el) {
|
|
|
0ea42e |
return sizeof(cac_object_t);
|
|
|
0ea42e |
}
|
|
|
0ea42e |
|
|
|
0ea42e |
|
|
|
0ea42e |
From fab79b70ff45d02d99bc05863be57f8ca8f0acda Mon Sep 17 00:00:00 2001
|
|
|
0ea42e |
From: Jakub Jelen <jjelen@redhat.com>
|
|
|
0ea42e |
Date: Tue, 9 Oct 2018 15:58:12 +0200
|
|
|
0ea42e |
Subject: [PATCH 2/3] coolkey: Improve card matching to avoid mismatches in
|
|
|
0ea42e |
muscle
|
|
|
0ea42e |
|
|
|
0ea42e |
---
|
|
|
0ea42e |
src/libopensc/card-coolkey.c | 20 +++++++++++++++++++-
|
|
|
0ea42e |
1 file changed, 19 insertions(+), 1 deletion(-)
|
|
|
0ea42e |
|
|
|
0ea42e |
diff --git a/src/libopensc/card-coolkey.c b/src/libopensc/card-coolkey.c
|
|
|
0ea42e |
index b97559cc3..2cf2362c8 100644
|
|
|
0ea42e |
--- a/src/libopensc/card-coolkey.c
|
|
|
0ea42e |
+++ b/src/libopensc/card-coolkey.c
|
|
|
0ea42e |
@@ -2224,14 +2224,32 @@ static int coolkey_initialize(sc_card_t *card)
|
|
|
0ea42e |
/* NOTE: returns a bool, 1 card matches, 0 it does not */
|
|
|
0ea42e |
static int coolkey_match_card(sc_card_t *card)
|
|
|
0ea42e |
{
|
|
|
0ea42e |
+ sc_apdu_t apdu;
|
|
|
0ea42e |
int r;
|
|
|
0ea42e |
+
|
|
|
0ea42e |
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
|
|
|
0ea42e |
/* Since we send an APDU, the card's logout function may be called...
|
|
|
0ea42e |
* however it may be in dirty memory */
|
|
|
0ea42e |
card->ops->logout = NULL;
|
|
|
0ea42e |
|
|
|
0ea42e |
r = coolkey_select_applet(card);
|
|
|
0ea42e |
- return (r >= SC_SUCCESS);
|
|
|
0ea42e |
+ if (r == SC_SUCCESS) {
|
|
|
0ea42e |
+ /* The GET STATUS INS with P1 = 1 returns invalid instruction (0x6D00)
|
|
|
0ea42e |
+ * on Coolkey applet (reserved for GetMemory function),
|
|
|
0ea42e |
+ * while incorrect P1 (0x9C10) on Muscle applets
|
|
|
0ea42e |
+ */
|
|
|
0ea42e |
+ sc_format_apdu(card, &apdu, SC_APDU_CASE_1, COOLKEY_INS_GET_STATUS, 0x01, 0x00);
|
|
|
0ea42e |
+ apdu.cla = COOLKEY_CLASS;
|
|
|
0ea42e |
+ apdu.le = 0x00;
|
|
|
0ea42e |
+ apdu.resplen = 0;
|
|
|
0ea42e |
+ apdu.resp = NULL;
|
|
|
0ea42e |
+ r = sc_transmit_apdu(card, &apdu);
|
|
|
0ea42e |
+ if (r == SC_SUCCESS && apdu.sw1 == 0x6d && apdu.sw2 == 0x00) {
|
|
|
0ea42e |
+ return 1;
|
|
|
0ea42e |
+ }
|
|
|
0ea42e |
+ return 0;
|
|
|
0ea42e |
+ }
|
|
|
0ea42e |
+ return 0;
|
|
|
0ea42e |
}
|
|
|
0ea42e |
|
|
|
0ea42e |
|
|
|
0ea42e |
|
|
|
0ea42e |
From 98a1716768d11afd6d0e1e73bf8154dddfe915e9 Mon Sep 17 00:00:00 2001
|
|
|
0ea42e |
From: Jakub Jelen <jjelen@redhat.com>
|
|
|
0ea42e |
Date: Tue, 9 Oct 2018 16:01:57 +0200
|
|
|
0ea42e |
Subject: [PATCH 3/3] ctx: Move coolkey driver up after improving the matching
|
|
|
0ea42e |
|
|
|
0ea42e |
Fixes #1483
|
|
|
0ea42e |
---
|
|
|
0ea42e |
src/libopensc/ctx.c | 2 +-
|
|
|
0ea42e |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
0ea42e |
|
|
|
0ea42e |
diff --git a/src/libopensc/ctx.c b/src/libopensc/ctx.c
|
|
|
0ea42e |
index f24a61ca0..98e6038a7 100644
|
|
|
0ea42e |
--- a/src/libopensc/ctx.c
|
|
|
0ea42e |
+++ b/src/libopensc/ctx.c
|
|
|
0ea42e |
@@ -128,6 +128,7 @@ static const struct _sc_driver_entry internal_card_drivers[] = {
|
|
|
0ea42e |
|
|
|
0ea42e |
/* Here should be placed drivers that need some APDU transactions in the
|
|
|
0ea42e |
* driver's `match_card()` function. */
|
|
|
0ea42e |
+ { "coolkey", (void *(*)(void)) sc_get_coolkey_driver },
|
|
|
0ea42e |
/* MUSCLE card applet returns 9000 on whatever AID is selected, see
|
|
|
0ea42e |
* https://github.com/JavaCardOS/MuscleCard-Applet/blob/master/musclecard/src/com/musclecard/CardEdge/CardEdge.java#L326
|
|
|
0ea42e |
* put the muscle driver first to cope with this bug. */
|
|
|
0ea42e |
@@ -144,7 +145,6 @@ static const struct _sc_driver_entry internal_card_drivers[] = {
|
|
|
0ea42e |
#endif
|
|
|
0ea42e |
{ "openpgp", (void *(*)(void)) sc_get_openpgp_driver },
|
|
|
0ea42e |
{ "jpki", (void *(*)(void)) sc_get_jpki_driver },
|
|
|
0ea42e |
- { "coolkey", (void *(*)(void)) sc_get_coolkey_driver },
|
|
|
0ea42e |
{ "npa", (void *(*)(void)) sc_get_npa_driver },
|
|
|
0ea42e |
/* The default driver should be last, as it handles all the
|
|
|
0ea42e |
* unrecognized cards. */
|
|
|
0ea42e |
|