diff --git a/ChangeLog b/ChangeLog index 06e3b04..17dedf1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2011-12-20 Niibe Yutaka + + * src/usb_msc.c (msc_handle_command): SCSI_START_STOP_UNIT command + with stop/eject/close means cancelling pinentry. + + * src/pin-dnd.c (pinpad_finish_entry, parse_directory_sector): + Implement "cancel". + (pinpad_getline): Likewise. + (msc_scsi_stop): New. + 2011-12-16 Niibe Yutaka * tool/gnuk_put_binary_libusb.py (gnuk_token.cmd_select_openpgp): diff --git a/NEWS b/NEWS index bdc1a4c..3b60b77 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,18 @@ Gnuk NEWS - User visible changes +* Major changes in Gnuk 0.17 + + Released 2012-01-XX, by NIIBE Yutaka + +** With DnD pinentry, user can cancel pin input +Now, user can cancel pin input by unmounting device before finishing +DnD. + +** New tool: pinpad-test.py +The tool pinpad-test.py is PC/SC test tool for pinentry of pinpad with +OpenPGP card v2. + + * Major changes in Gnuk 0.16 Released 2011-12-14, by NIIBE Yutaka diff --git a/src/gnuk.h b/src/gnuk.h index 6bf3493..e0d72d6 100644 --- a/src/gnuk.h +++ b/src/gnuk.h @@ -362,6 +362,7 @@ extern void msc_init (void); extern void msc_media_insert_change (int available); extern int msc_scsi_write (uint32_t lba, const uint8_t *buf, size_t size); extern int msc_scsi_read (uint32_t lba, const uint8_t **sector_p); +extern void msc_scsi_stop (uint8_t code); # endif #define PIN_INPUT_CURRENT 1 #define PIN_INPUT_NEW 2 diff --git a/src/pin-dnd.c b/src/pin-dnd.c index 3cd1c8d..70d1de9 100644 --- a/src/pin-dnd.c +++ b/src/pin-dnd.c @@ -72,13 +72,16 @@ pinpad_getline (int msg_code, systime_t timeout) chSysUnlock (); led_blink (0); - if (msg == 1) + if (msg != 0) break; } msc_media_insert_change (0); - return pin_input_len; + if (msg == 1) + return pin_input_len; + else + return -1; /* cancel */ } static void pinpad_input (void) @@ -89,10 +92,13 @@ static void pinpad_input (void) chSysUnlock (); } -static void pinpad_finish_entry (void) +static void pinpad_finish_entry (int cancel) { chSysLock (); - pin_thread->p_u.rdymsg = 1; + if (cancel) + pin_thread->p_u.rdymsg = 2; + else + pin_thread->p_u.rdymsg = 1; chSchReadyI (pin_thread); chSysUnlock (); } @@ -328,7 +334,7 @@ static void parse_directory_sector (const uint8_t *p, uint8_t index) } if (index == 0 && num_children == 1) - pinpad_finish_entry (); + pinpad_finish_entry (0); else if (input) pinpad_input (); } @@ -357,3 +363,10 @@ msc_scsi_write (uint32_t lba, const uint8_t *buf, size_t size) return 0; } } + +void +msc_scsi_stop (uint8_t code) +{ + (void)code; + pinpad_finish_entry (1); +} diff --git a/src/usb_msc.c b/src/usb_msc.c index 4262825..77836b9 100644 --- a/src/usb_msc.c +++ b/src/usb_msc.c @@ -388,6 +388,17 @@ void msc_handle_command (void) buf[11] = (uint8_t)(secsize >> 0); msc_send_result (buf, 12); return; + case SCSI_START_STOP_UNIT: + if (CBW.CBWCB[4] == 0x00 /* stop */ + || CBW.CBWCB[4] == 0x02 /* eject */ || CBW.CBWCB[4] == 0x03 /* close */) + { + msc_scsi_stop (CBW.CBWCB[4]); + set_scsi_sense_data (0x05, 0x24); /* ILLEGAL_REQUEST */ + contingent_allegiance = 1; + keep_contingent_allegiance = 1; + } + /* CBW.CBWCB[4] == 0x01 *//* start */ + goto success; case SCSI_TEST_UNIT_READY: if (contingent_allegiance) { @@ -397,9 +408,9 @@ void msc_handle_command (void) return; } /* fall through */ + success: case SCSI_SYNCHRONIZE_CACHE: case SCSI_VERIFY10: - case SCSI_START_STOP_UNIT: case SCSI_ALLOW_MEDIUM_REMOVAL: CSW.bCSWStatus = MSC_CSW_STATUS_PASSED; CSW.dCSWDataResidue = CBW.dCBWDataTransferLength;