Blink LED rapidly when asking ACK from user.
authorNIIBE Yutaka <gniibe@fsij.org>
Thu, 27 Sep 2018 03:58:06 +0000 (12:58 +0900)
committerNIIBE Yutaka <gniibe@fsij.org>
Thu, 27 Sep 2018 04:16:51 +0000 (13:16 +0900)
ChangeLog
chopstx
src/gnuk.h
src/main.c
src/openpgp.c
src/usb-ccid.c

index af1a041..87c6cb9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2018-09-27  NIIBE Yutaka  <gniibe@fsij.org>
+
+       * src/gnuk.h (LED_WAIT_FOR_BUTTON): New.
+       * src/main.c (main): Blink rapidly when asking ACK.
+       * src/usb-ccid.c (ccid_thread): Use LED_WAIT_FOR_BUTTON.
+
+2018-09-27  NIIBE Yutaka  <gniibe@fsij.org>
+
+       * src/config.h.in: Add @ACKBTN_DEFINE@.
+       * src/configure: Add ACKBTN_SUPPORT.
+       * src/gnuk.h (EV_EXEC_FINISHED_ACK): New.
+       (CCID_STATE_CONFIRM_ACK): New.
+       * src/openpgp.c (process_command_apdu): Change for cmd_pso, and
+       cmd_internal_authenticate.
+       * src/usb-ccid.c (ccid_send_data_block_time_extension): Report
+       time extension differently when waiting ack button.
+       (ccid_handle_data): Support case of CCID_STATE_CONFIRM_ACK.
+       (ccid_handle_timeout): Likewise.
+       (ack_intr) [ACKBTN_SUPPORT]: New.
+       (ccid_thread) [ACKBTN_SUPPORT]: Add ack button handling.
+
 2018-09-26  NIIBE Yutaka  <gniibe@fsij.org>
 
        * chopstx: Update.
diff --git a/chopstx b/chopstx
index 49b0556..7dc67d2 160000 (submodule)
--- a/chopstx
+++ b/chopstx
@@ -1 +1 @@
-Subproject commit 49b0556a24a9133ee55b06011fd288e264aefc72
+Subproject commit 7dc67d2210fb566bc370f0eea7ce9d9c5744760b
index 8053cbe..2084026 100644 (file)
@@ -445,6 +445,7 @@ extern const uint8_t gnuk_string_serial[];
 #define LED_GNUK_EXEC           32
 #define LED_START_COMMAND       64
 #define LED_FINISH_COMMAND     128
+#define LED_WAIT_FOR_BUTTON    256
 #define LED_OFF         LED_FINISH_COMMAND
 void led_blink (int spec);
 
index 63f75f2..17feab0 100644 (file)
@@ -238,6 +238,7 @@ main (int argc, const char *argv[])
   uintptr_t entry;
 #endif
   chopstx_t ccid_thd;
+  int wait_for_ack = 0;
 
   chopstx_conf_idle (1);
 
@@ -354,7 +355,11 @@ main (int argc, const char *argv[])
     {
       eventmask_t m;
 
-      m = eventflag_wait (&led_event);
+      if (wait_for_ack)
+       m = eventflag_wait_timeout (&led_event, LED_TIMEOUT_INTERVAL);
+      else
+       m = eventflag_wait (&led_event);
+
       switch (m)
        {
        case LED_ONESHOT:
@@ -371,12 +376,16 @@ main (int argc, const char *argv[])
          display_fatal_code ();
          break;
        case LED_SYNC:
+         wait_for_ack = 0;
          set_led (led_inverted);
          break;
        case LED_GNUK_EXEC:
          goto exec;
+       case LED_WAIT_FOR_BUTTON:
+         wait_for_ack = 1;
+         /* fall through */
        default:
-         emit_led (LED_TIMEOUT_ZERO, LED_TIMEOUT_STOP);
+         emit_led (LED_TIMEOUT_ONE, LED_TIMEOUT_ZERO);
          break;
        }
     }
index 15c024c..73cbc05 100644 (file)
@@ -1644,8 +1644,7 @@ openpgp_card_thread (void *arg)
 
       led_blink (LED_START_COMMAND);
       r = process_command_apdu ();
-      if (!r)
-       led_blink (LED_FINISH_COMMAND);
+      led_blink (LED_FINISH_COMMAND);
     done:
       eventflag_signal (ccid_comm, r? EV_EXEC_FINISHED_ACK : EV_EXEC_FINISHED);
     }
index 6c7a889..941a227 100644 (file)
 
 #include "config.h"
 
+#ifdef ACKBTN_SUPPORT
+#include <contrib/ackbtn.h>
+#endif
+
 #ifdef DEBUG
 #include "usb-cdc.h"
 #include "debug.h"
@@ -1844,6 +1848,7 @@ ccid_thread (void *arg)
        if (c->ccid_state == CCID_STATE_EXECUTE)
          {
            ackbtn_enable ();
+           led_blink (LED_WAIT_FOR_BUTTON);
            c->ccid_state = CCID_STATE_CONFIRM_ACK;
          }
        else