[Gnuk-users] Gnuk 1.1.4/Win7 64bit
NIIBE Yutaka
gniibe at fsij.org
Sat Apr 11 13:19:13 UTC 2015
On 04/11/2015 08:09 PM, Yuji -UG- Imai wrote:
> I found something strange. In order to report with GUI output,
> I posted message on facebook.
> https://www.facebook.com/yuji.imai.754/posts/1143888392304077
>
> With factory shipped token(Gnuk 1.0.1), gpg4win on Win7 works well.
> In this case, token looks recognized as WUDF card reader as well
> as unknown smartcard. Win7 complains driver for the smartcard not
> found. Nevertheless gpg4win can drive FST-01. Attached snapshots are
> diagnosing message, device manager with unknown smartcard entry
> and smartcard property.
>
> On the other hand, token with 1.1.4 looks recognized simply as a card
> reader without smartcard. In the last snapshot, no unknown smartcard
> entry appeared.
>
> I guess gpg4win does not find smartcard, does it.
Frankly, I don't understand the situation well, but I understand there
is something wrong.
Basically, there are two things:
smartcard reader driver
smartcard application or smartcard driver+application
For GnuPG+SCDaemon on Windows, we don't need specific smartcard driver
since SCDaemon handles it directly, and we only need smartcard reader
driver.
A change in 1.1.4 for USB is: Interrupt transfer endpoint is added.
It would be helpful to apply following change to 1.1.4 (or current
master).
It is not tested by me yet.
diff --git a/src/gnuk.h b/src/gnuk.h
index cb58636..da55169 100644
--- a/src/gnuk.h
+++ b/src/gnuk.h
@@ -62,6 +62,8 @@ enum icc_state {
ICC_STATE_EXEC_REQUESTED, /* Exec requested */
};
+#define CCID_INITIAL_STATE CARD_CHANGE_INSERT
+
extern enum icc_state *icc_state_p;
extern volatile uint8_t auth_status;
diff --git a/src/usb-icc.c b/src/usb-icc.c
index 2d6d62c..7547c42 100644
--- a/src/usb-icc.c
+++ b/src/usb-icc.c
@@ -1336,6 +1336,8 @@ ccid_card_change_signal (int how)
}
+#define NOTIFY_SLOT_CHANGE 0x50
+
static void * __attribute__ ((noinline))
ccid_thread (chopstx_t thd)
{
@@ -1343,7 +1345,7 @@ ccid_thread (chopstx_t thd)
struct ep_out *epo = &endpoint_out;
struct ccid *c = &ccid;
struct apdu *a = &apdu;
- int card_change_requested = 0;
+ uint8_t int_msg[2] = { NOTIFY_SLOT_CHANGE, 0x02 };
epi_init (epi, ENDP1, notify_tx, c);
epo_init (epo, ENDP1, notify_icc, c);
@@ -1359,34 +1361,27 @@ ccid_thread (chopstx_t thd)
if (m == EV_CARD_CHANGE)
{
- if (card_change_requested)
- {
- uint8_t notify_slot_change[2] = { 0x50, 0x02 };
+ led_blink (LED_TWOSHOTS);
- led_blink (LED_TWOSHOTS);
-
- if (c->icc_state == ICC_STATE_NOCARD)
- { /* Inserted! */
- c->icc_state = ICC_STATE_START;
- notify_slot_change[1] |= 1;
- }
- else
+ if (c->icc_state == ICC_STATE_NOCARD)
+ { /* Inserted! */
+ c->icc_state = ICC_STATE_START;
+ int_msg[1] |= 1;
+ }
+ else
+ {
+ if (c->application)
{
- if (c->application)
- {
- eventflag_signal (&c->openpgp_comm, EV_EXIT);
- chopstx_join (c->application, NULL);
- c->application = 0;
- }
-
- c->icc_state = ICC_STATE_NOCARD;
+ eventflag_signal (&c->openpgp_comm, EV_EXIT);
+ chopstx_join (c->application, NULL);
+ c->application = 0;
}
- card_change_requested = 0;
- usb_lld_write (ENDP2, notify_slot_change, 2);
+ c->icc_state = ICC_STATE_NOCARD;
+ int_msg[1] &= ~1;
}
- else
- card_change_requested = 1;
+
+ usb_lld_write (ENDP2, int_msg, sizeof int_msg);
}
else if (m == EV_RX_DATA_READY)
c->icc_state = icc_handle_data (c);
@@ -1444,10 +1439,7 @@ ccid_thread (chopstx_t thd)
icc_prepare_receive (c);
}
else /* Timeout */
- {
- c->icc_state = icc_handle_timeout (c);
- card_change_requested = 0;
- }
+ c->icc_state = icc_handle_timeout (c);
}
if (c->application)
diff --git a/src/usb_ctrl.c b/src/usb_ctrl.c
index 00979dc..910e321 100644
--- a/src/usb_ctrl.c
+++ b/src/usb_ctrl.c
@@ -139,6 +139,7 @@ gnuk_setup_endpoints_for_interface (uint16_t interface, int stop)
usb_lld_setup_endpoint (ENDP1, EP_BULK, 0, ENDP1_RXADDR,
ENDP1_TXADDR, GNUK_MAX_PACKET_SIZE);
usb_lld_setup_endpoint (ENDP2, EP_INTERRUPT, 0, 0, ENDP2_TXADDR, 0);
+ ccid_card_change_signal (CCID_INITIAL_STATE);
}
else
{
--
More information about the gnuk-users
mailing list