1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 07:28:10 +00:00

firmware: disable WebUSB landing page (#174)

This commit is contained in:
Pavol Rusnak 2018-06-04 13:50:23 +02:00 committed by GitHub
parent bc2f371886
commit 68669dd8e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 13 additions and 2 deletions

View File

@ -64,6 +64,7 @@ static void usb_init_all(void) {
.serial_number = "000000000000000000000000",
.interface = "TREZOR Interface",
.usb21_enabled = sectrue,
.usb21_landing = sectrue,
};
static uint8_t rx_buffer[USB_PACKET_SIZE];

View File

@ -60,7 +60,8 @@ static const char *get_0str(mp_obj_t o, size_t min_len, size_t max_len) {
/// product: str='',
/// serial_number: str='',
/// interface: str='',
/// usb21_enabled: bool=True) -> None:
/// usb21_enabled: bool=True,
/// usb21_landing: bool=True) -> None:
/// '''
/// '''
STATIC mp_obj_t mod_trezorio_USB_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
@ -77,6 +78,7 @@ STATIC mp_obj_t mod_trezorio_USB_make_new(const mp_obj_type_t *type, size_t n_ar
{ MP_QSTR_serial_number, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_empty_bytes} },
{ MP_QSTR_interface, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_empty_bytes} },
{ MP_QSTR_usb21_enabled, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = true} },
{ MP_QSTR_usb21_landing, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = true} },
};
mp_arg_val_t vals[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all_kw_array(n_args, n_kw, args, MP_ARRAY_SIZE(allowed_args), allowed_args, vals);
@ -92,6 +94,7 @@ STATIC mp_obj_t mod_trezorio_USB_make_new(const mp_obj_type_t *type, size_t n_ar
const char *serial_number = get_0str(vals[8].u_obj, 0, 32);
const char *interface = get_0str(vals[9].u_obj, 0, 32);
const secbool usb21_enabled = vals[10].u_bool ? sectrue : secfalse;
const secbool usb21_landing = vals[11].u_bool ? sectrue : secfalse;
CHECK_PARAM_RANGE(device_class, 0, 255)
CHECK_PARAM_RANGE(device_subclass, 0, 255)
@ -128,6 +131,7 @@ STATIC mp_obj_t mod_trezorio_USB_make_new(const mp_obj_type_t *type, size_t n_ar
o->info.serial_number = serial_number;
o->info.interface = interface;
o->info.usb21_enabled = usb21_enabled;
o->info.usb21_landing = usb21_landing;
mp_obj_list_init(&o->ifaces, 0);

View File

@ -109,6 +109,7 @@ static void usb_init_all(void)
.serial_number = "000000000000",
.interface = "TREZOR Interface",
.usb21_enabled = secfalse,
.usb21_landing = secfalse,
};
static uint8_t tx_packet[VCP_PACKET_LEN];

View File

@ -61,6 +61,7 @@ static const USBD_DescriptorsTypeDef usb_descriptors;
static const USBD_ClassTypeDef usb_class;
static secbool usb21_enabled = secfalse;
static secbool usb21_landing = secfalse;
static secbool __wur check_desc_str(const char *s) {
if (NULL == s) return secfalse;
@ -72,6 +73,7 @@ void usb_init(const usb_dev_info_t *dev_info) {
// enable/disable USB 2.1 features
usb21_enabled = dev_info->usb21_enabled;
usb21_landing = dev_info->usb21_landing;
// Device descriptor
usb_dev_desc.bLength = sizeof(usb_device_descriptor_t);
@ -226,7 +228,7 @@ static uint8_t *usb_get_interface_str_descriptor(USBD_SpeedTypeDef speed, uint16
static uint8_t *usb_get_bos_descriptor(USBD_SpeedTypeDef speed, uint16_t *length) {
if (sectrue == usb21_enabled) {
static const uint8_t bos[] = {
static uint8_t bos[] = {
// usb_bos_descriptor {
0x05, // uint8_t bLength
USB_DESC_TYPE_BOS, // uint8_t bDescriptorType
@ -244,6 +246,7 @@ static uint8_t *usb_get_bos_descriptor(USBD_SpeedTypeDef speed, uint16_t *length
USB_WEBUSB_LANDING_PAGE, // uint8_t iLandingPage
// }
};
bos[28] = (sectrue == usb21_landing) ? USB_WEBUSB_LANDING_PAGE : 0;
*length = sizeof(bos);
return UNCONST(bos);
} else {

View File

@ -116,6 +116,7 @@ typedef struct {
const char *serial_number;
const char *interface;
secbool usb21_enabled;
secbool usb21_landing;
} usb_dev_info_t;
typedef enum {

View File

@ -60,6 +60,7 @@ bus = io.USB(
product="TREZOR",
interface="TREZOR Interface",
serial_number=get_device_id(),
usb21_landing=False,
)
bus.add(iface_wire)
if __debug__: