diff --git a/smart_card_connector_app/src/testing_smart_card_simulation.cc b/smart_card_connector_app/src/testing_smart_card_simulation.cc index cd77d1600..3184775f4 100644 --- a/smart_card_connector_app/src/testing_smart_card_simulation.cc +++ b/smart_card_connector_app/src/testing_smart_card_simulation.cc @@ -72,6 +72,17 @@ LibusbJsDevice MakeLibusbJsDevice( js_device.manufacturer_name = std::string("Gemalto"); js_device.serial_number = std::string("E00E0000"); // redacted return js_device; + case DeviceType::kDellSmartCardReaderKeyboard: + // Numbers are for a real device. + js_device.vendor_id = 0x413c; + js_device.product_id = 0x2101; + js_device.version = 0x201; + // TODO: Remove explicit `std::string` construction after switching to + // feature-complete `std::optional` (after dropping NaCl support). + js_device.product_name = std::string("Dell Smart Card Reader Keyboard"); + js_device.manufacturer_name = std::string("Dell"); + js_device.serial_number = std::string(""); + return js_device; } GOOGLE_SMART_CARD_NOTREACHED; } @@ -122,6 +133,53 @@ MakeLibusbJsConfigurationDescriptors(DeviceType device_type) { return {config}; } + + case DeviceType::kDellSmartCardReaderKeyboard: { + // Values are taken from a real device. + + LibusbJsEndpointDescriptor endpoint1; + endpoint1.endpoint_address = 1; + endpoint1.direction = LibusbJsDirection::kOut; + endpoint1.type = LibusbJsEndpointType::kBulk; + endpoint1.max_packet_size = 64; + + LibusbJsEndpointDescriptor endpoint2; + endpoint2.endpoint_address = 0x82; + endpoint2.direction = LibusbJsDirection::kIn; + endpoint2.type = LibusbJsEndpointType::kBulk; + endpoint2.max_packet_size = 64; + + LibusbJsEndpointDescriptor endpoint3; + endpoint3.endpoint_address = 0x83; + endpoint3.direction = LibusbJsDirection::kIn; + endpoint3.type = LibusbJsEndpointType::kInterrupt; + endpoint3.max_packet_size = 8; + + // Note: in reality the device has another USB interface (with the number + // "0" and the "Human Interface Device" class), but it's normally filtered + // out by the JavaScript counterpart before reaching the C++ code. + LibusbJsInterfaceDescriptor interface; + interface.interface_number = 1; + interface.interface_class = 0xB; + interface.interface_subclass = 0; + interface.interface_protocol = 0; + interface.extra_data = std::vector( + {0x36, 0x21, 0x01, 0x01, 0x00, 0x07, 0x03, 0x00, 0x00, 0x00, 0xC0, + 0x12, 0x00, 0x00, 0xC0, 0x12, 0x00, 0x00, 0x00, 0x67, 0x32, 0x00, + 0x00, 0xCE, 0x99, 0x0C, 0x00, 0x35, 0xFE, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x02, 0x01, 0x00, + 0x0F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x01}); + interface.endpoints.push_back(std::move(endpoint1)); + interface.endpoints.push_back(std::move(endpoint2)); + interface.endpoints.push_back(std::move(endpoint3)); + + LibusbJsConfigurationDescriptor config; + config.active = true; + config.configuration_value = 1; + config.interfaces.push_back(std::move(interface)); + + return {config}; + } } GOOGLE_SMART_CARD_NOTREACHED; } @@ -174,6 +232,29 @@ std::vector MakeGetDataRatesResponse(DeviceType device_type) { 0x01, 0x00, 0x24, 0xF4, 0x00, 0x00, 0xDD, 0x6D, 0x00, 0x00, 0x1B, 0xB7, 0x00, 0x00}; } + case DeviceType::kDellSmartCardReaderKeyboard: { + // Values are taken from a real device. + return {0x67, 0x32, 0x00, 0x00, 0xCE, 0x64, 0x00, 0x00, 0x9D, 0xC9, 0x00, + 0x00, 0x3A, 0x93, 0x01, 0x00, 0x74, 0x26, 0x03, 0x00, 0xE7, 0x4C, + 0x06, 0x00, 0xCE, 0x99, 0x0C, 0x00, 0xD7, 0x5C, 0x02, 0x00, 0x11, + 0xF0, 0x03, 0x00, 0x34, 0x43, 0x00, 0x00, 0x69, 0x86, 0x00, 0x00, + 0xD1, 0x0C, 0x01, 0x00, 0xA2, 0x19, 0x02, 0x00, 0x45, 0x33, 0x04, + 0x00, 0x8A, 0x66, 0x08, 0x00, 0x0B, 0xA0, 0x02, 0x00, 0x73, 0x30, + 0x00, 0x00, 0xE6, 0x60, 0x00, 0x00, 0xCC, 0xC1, 0x00, 0x00, 0x99, + 0x83, 0x01, 0x00, 0x32, 0x07, 0x03, 0x00, 0x63, 0x0E, 0x06, 0x00, + 0xB3, 0x22, 0x01, 0x00, 0x7F, 0xE4, 0x01, 0x00, 0x06, 0x50, 0x01, + 0x00, 0x36, 0x97, 0x00, 0x00, 0x04, 0xFC, 0x00, 0x00, 0x53, 0x28, + 0x00, 0x00, 0xA5, 0x50, 0x00, 0x00, 0x4A, 0xA1, 0x00, 0x00, 0x95, + 0x42, 0x01, 0x00, 0x29, 0x85, 0x02, 0x00, 0xF8, 0x78, 0x00, 0x00, + 0x3E, 0x49, 0x00, 0x00, 0x7C, 0x92, 0x00, 0x00, 0xF8, 0x24, 0x01, + 0x00, 0xF0, 0x49, 0x02, 0x00, 0xE0, 0x93, 0x04, 0x00, 0xC0, 0x27, + 0x09, 0x00, 0x74, 0xB7, 0x01, 0x00, 0x6C, 0xDC, 0x02, 0x00, 0xD4, + 0x30, 0x00, 0x00, 0xA8, 0x61, 0x00, 0x00, 0x50, 0xC3, 0x00, 0x00, + 0xA0, 0x86, 0x01, 0x00, 0x40, 0x0D, 0x03, 0x00, 0x80, 0x1A, 0x06, + 0x00, 0x48, 0xE8, 0x01, 0x00, 0xBA, 0xDB, 0x00, 0x00, 0x36, 0x6E, + 0x01, 0x00, 0x24, 0xF4, 0x00, 0x00, 0xDD, 0x6D, 0x00, 0x00, 0x1B, + 0xB7, 0x00, 0x00}; + } } GOOGLE_SMART_CARD_NOTREACHED; } diff --git a/smart_card_connector_app/src/testing_smart_card_simulation.h b/smart_card_connector_app/src/testing_smart_card_simulation.h index ebbfa3968..9e4382513 100644 --- a/smart_card_connector_app/src/testing_smart_card_simulation.h +++ b/smart_card_connector_app/src/testing_smart_card_simulation.h @@ -51,7 +51,7 @@ namespace google_smart_card { class TestingSmartCardSimulation final { public: // Fake device to simulate. - enum class DeviceType { kGemaltoPcTwinReader }; + enum class DeviceType { kGemaltoPcTwinReader, kDellSmartCardReaderKeyboard }; enum class CardType { kCosmoId70 }; enum class CardProfile { kCharismathicsPiv };