conditionalize HID_CARD_CHANGE_SUPPORT
This commit is contained in:
10
ChangeLog
10
ChangeLog
@@ -1,3 +1,13 @@
|
||||
2013-12-19 Niibe Yutaka <gniibe@fsij.org>
|
||||
|
||||
* src/configure (--enable-hid-card-change): New (experimental).
|
||||
* src/config.h.in (HID_CARD_CHANGE_DEFINE): New.
|
||||
* src/usb_ctrl.c (gnuk_setup_endpoints_for_interface)
|
||||
(usb_cb_setup, usb_cb_ctrl_write_finish): Conditionalize
|
||||
HID_CARD_CHANGE_SUPPORT.
|
||||
* src/usb_desc.c (gnukDeviceDescriptor, usb_cb_get_descriptor):
|
||||
Likewise.
|
||||
|
||||
2013-12-19 Niibe Yutaka <gniibe@fsij.org>
|
||||
|
||||
* src/openpgp.c (S2KCOUNT): It's now 192, as the threat model
|
||||
|
||||
@@ -6,4 +6,5 @@
|
||||
@PINPAD_DEFINE@
|
||||
@PINPAD_MORE_DEFINE@
|
||||
@CERTDO_DEFINE@
|
||||
@HID_CARD_CHANGE_DEFINE@
|
||||
@SERIALNO_STR_LEN@
|
||||
|
||||
15
src/configure
vendored
15
src/configure
vendored
@@ -30,6 +30,7 @@ pinpad=no
|
||||
certdo=no
|
||||
keygen=no
|
||||
sys1_compat=yes
|
||||
hid_card_change=no
|
||||
|
||||
# Process each option
|
||||
for option; do
|
||||
@@ -67,6 +68,10 @@ for option; do
|
||||
sys1_compat = yes ;;
|
||||
--disable-sys1-compat)
|
||||
sys1_compat = no ;;
|
||||
--enable-hid-card-change)
|
||||
hid_card_change = yes ;;
|
||||
--disable-hid-card-change)
|
||||
hid_card_change = no ;;
|
||||
--with-dfu)
|
||||
with_dfu=yes ;;
|
||||
--without-dfu)
|
||||
@@ -217,6 +222,15 @@ else
|
||||
echo "Key generation on device is NOT supported"
|
||||
fi
|
||||
|
||||
# --enable-hid-card-change option
|
||||
if test "$hid_card_change" = "yes"; then
|
||||
HID_CARD_CHANGE_DEFINE="#define HID_CARD_CHANGE_SUPPORT 1"
|
||||
echo "Card insert/removal by HID device is supported"
|
||||
else
|
||||
HID_CARD_CHANGE_DEFINE="#undef HID_CARD_CHANGE_SUPPORT"
|
||||
echo "Card insert/removal by HID device is NOT supported"
|
||||
fi
|
||||
|
||||
if test -d ../.git; then
|
||||
REVISION=`git describe --dirty="-modified"`
|
||||
else
|
||||
@@ -323,6 +337,7 @@ sed -e "s/@DEBUG_DEFINE@/$DEBUG_DEFINE/" \
|
||||
-e "s/@PINPAD_DEFINE@/$PINPAD_DEFINE/" \
|
||||
-e "s/@PINPAD_MORE_DEFINE@/$PINPAD_MORE_DEFINE/" \
|
||||
-e "s/@CERTDO_DEFINE@/$CERTDO_DEFINE/" \
|
||||
-e "s/@HID_CARD_CHANGE_DEFINE@/$HID_CARD_CHANGE_DEFINE/" \
|
||||
-e "s/@SERIALNO_STR_LEN@/$SERIALNO_STR_LEN_DEFINE/" \
|
||||
< config.h.in > config.h
|
||||
exit 0
|
||||
|
||||
@@ -133,9 +133,11 @@ uint32_t bDeviceState = UNCONNECTED; /* USB device status */
|
||||
#define HID_LED_STATUS_CARDCHANGE 0x04
|
||||
#endif
|
||||
|
||||
#ifdef HID_CARD_CHANGE_SUPPORT
|
||||
static uint8_t hid_idle_rate; /* in 4ms */
|
||||
static uint8_t hid_report_saved;
|
||||
static uint16_t hid_report;
|
||||
#endif
|
||||
|
||||
static void
|
||||
gnuk_setup_endpoints_for_interface (uint16_t interface, int stop)
|
||||
@@ -155,6 +157,7 @@ gnuk_setup_endpoints_for_interface (uint16_t interface, int stop)
|
||||
usb_lld_stall_tx (ENDP2);
|
||||
}
|
||||
}
|
||||
#ifdef HID_CARD_CHANGE_SUPPORT
|
||||
else if (interface == 1)
|
||||
{
|
||||
if (!stop)
|
||||
@@ -162,6 +165,7 @@ gnuk_setup_endpoints_for_interface (uint16_t interface, int stop)
|
||||
else
|
||||
usb_lld_stall_tx (ENDP7);
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_VIRTUAL_COM_PORT
|
||||
else if (interface == 2)
|
||||
{
|
||||
@@ -339,6 +343,7 @@ usb_cb_setup (uint8_t req, uint8_t req_no,
|
||||
return USB_UNSUPPORT;
|
||||
}
|
||||
}
|
||||
#ifdef HID_CARD_CHANGE_SUPPORT
|
||||
else if (index == 1)
|
||||
{
|
||||
switch (req_no)
|
||||
@@ -370,6 +375,7 @@ usb_cb_setup (uint8_t req, uint8_t req_no,
|
||||
return USB_UNSUPPORT;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_VIRTUAL_COM_PORT
|
||||
else if (index == 2)
|
||||
return vcom_port_data_setup (req, req_no, value);
|
||||
@@ -415,6 +421,7 @@ usb_cb_ctrl_write_finish (uint8_t req, uint8_t req_no, uint16_t value,
|
||||
*icc_state_p = ICC_STATE_EXEC_REQUESTED;
|
||||
}
|
||||
}
|
||||
#ifdef HID_CARD_CHANGE_SUPPORT
|
||||
else if (type_rcp == (CLASS_REQUEST | INTERFACE_RECIPIENT))
|
||||
{
|
||||
if (index == 1 && req_no == USB_HID_REQ_SET_REPORT)
|
||||
@@ -425,6 +432,7 @@ usb_cb_ctrl_write_finish (uint8_t req, uint8_t req_no, uint16_t value,
|
||||
hid_report_saved = hid_report;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "usb-cdc.h"
|
||||
|
||||
|
||||
#ifdef HID_CARD_CHANGE_SUPPORT
|
||||
/* HID report descriptor. */
|
||||
#define HID_REPORT_DESC_SIZE (sizeof (hid_report_desc))
|
||||
|
||||
@@ -50,6 +51,7 @@ static const uint8_t hid_report_desc[] = {
|
||||
0x81, 0x00, /* INPUT (Data,Ary,Abs); Key arrays (1 bytes) */
|
||||
0xc0 /* END_COLLECTION */
|
||||
};
|
||||
#endif
|
||||
|
||||
#define USB_ICC_INTERFACE_CLASS 0x0B
|
||||
#define USB_ICC_INTERFACE_SUBCLASS 0x00
|
||||
@@ -75,14 +77,19 @@ static const uint8_t gnukDeviceDescriptor[] = {
|
||||
#define ICC_TOTAL_LENGTH (9+9+54+7+7+7)
|
||||
#define ICC_NUM_INTERFACES 1
|
||||
|
||||
#ifdef HID_CARD_CHANGE_SUPPORT
|
||||
#define HID_TOTAL_LENGTH (9+9+7)
|
||||
#define HID_NUM_INTERFACES 1
|
||||
#else
|
||||
#define HID_TOTAL_LENGTH 0
|
||||
#define HID_NUM_INTERFACES 0
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_VIRTUAL_COM_PORT
|
||||
#define VCOM_TOTAL_LENGTH (9+5+5+4+5+7+9+7+7)
|
||||
#define VCOM_NUM_INTERFACES 2
|
||||
#else
|
||||
#define VCOM_TOTAL_LENGTH 0
|
||||
#define VCOM_TOTAL_LENGTH 0
|
||||
#define VCOM_NUM_INTERFACES 0
|
||||
#endif
|
||||
|
||||
@@ -90,7 +97,7 @@ static const uint8_t gnukDeviceDescriptor[] = {
|
||||
#define MSC_TOTAL_LENGTH (9+7+7)
|
||||
#define MSC_NUM_INTERFACES 1
|
||||
#else
|
||||
#define MSC_TOTAL_LENGTH 0
|
||||
#define MSC_TOTAL_LENGTH 0
|
||||
#define MSC_NUM_INTERFACES 0
|
||||
#endif
|
||||
|
||||
@@ -196,6 +203,7 @@ static const uint8_t gnukConfigDescriptor[] = {
|
||||
4, 0x00, /* wMaxPacketSize: */
|
||||
0xFF, /* bInterval (255ms) */
|
||||
|
||||
#ifdef HID_CARD_CHANGE_SUPPORT
|
||||
/* Interface Descriptor */
|
||||
9, /* bLength: Interface Descriptor size */
|
||||
USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType: Interface */
|
||||
@@ -222,6 +230,7 @@ static const uint8_t gnukConfigDescriptor[] = {
|
||||
0x03, /* bmAttributes: Interrupt */
|
||||
0x02, 0x00, /* wMaxPacketSize: 2 */
|
||||
0x20, /* bInterval (32ms) */
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_VIRTUAL_COM_PORT
|
||||
/* Interface Descriptor */
|
||||
@@ -385,6 +394,7 @@ usb_cb_get_descriptor (uint8_t rcp, uint8_t desc_type, uint8_t desc_index,
|
||||
}
|
||||
else if (rcp == INTERFACE_RECIPIENT)
|
||||
{
|
||||
#ifdef HID_CARD_CHANGE_SUPPORT
|
||||
if (index == 1)
|
||||
{
|
||||
if (desc_type == USB_DT_HID)
|
||||
@@ -399,7 +409,11 @@ usb_cb_get_descriptor (uint8_t rcp, uint8_t desc_type, uint8_t desc_index,
|
||||
return USB_SUCCESS;
|
||||
}
|
||||
}
|
||||
else if (desc_type == STRING_DESCRIPTOR)
|
||||
else
|
||||
#else
|
||||
(void)index;
|
||||
#endif
|
||||
if (desc_type == STRING_DESCRIPTOR)
|
||||
{
|
||||
if (desc_index < NUM_STRING_DESC)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user