From 1f425191758e862946d89998316e53f4ce64f142 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Mon, 18 Feb 2019 13:39:05 +0000 Subject: Add simple GetStatus command implementation For debugging purposes, we add a simple GetStatus implementation that just reports the firmware version 0.1. --- README.md | 2 ++ src/device.rs | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2b0a285..3a9512f 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ development and supports: - connecting as a USB device with the Nitrokey Pro’s product and vendor ID - connecting as a HID class device +- using these Nitrokey commands: + - `GET_STATUS` ## Resources diff --git a/src/device.rs b/src/device.rs index 3b6cf46..960f698 100644 --- a/src/device.rs +++ b/src/device.rs @@ -69,8 +69,23 @@ impl Nitrokey { command_id: CommandId, data: &[u8], ) -> Result<[u8; 53], CommandStatus> { - let _ = (command_id, data); - Err(CommandStatus::UnknownCommand) + let _ = data; + match command_id { + CommandId::GetStatus => { + let mut data = [0u8; 53]; + data[0] = 1; // firmware_version_st.minor + data[1] = 0; // firmware_version_st.major + data[2] = 0; // card_serial[0] + data[3] = 0; // card_serial[1] + data[4] = 0; // card_serial[2] + data[5] = 0; // card_serial[3] + data[6] = 0; // numlock + data[7] = 0; // capslock + data[8] = 0; // enable_user_password + data[9] = 0; // delete_user_password + Ok(data) + } + } } } -- cgit v1.2.3