diff options
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | src/device.rs | 16 |
2 files changed, 16 insertions, 1 deletions
@@ -12,6 +12,7 @@ development and supports: - connecting as a HID class device - using these Nitrokey commands: - `GET_STATUS` + - `READ_SLOT_NAME` ## Resources diff --git a/src/device.rs b/src/device.rs index 960f698..9ffc39a 100644 --- a/src/device.rs +++ b/src/device.rs @@ -50,6 +50,7 @@ enum_u8! { #[derive(Clone, Copy, Debug, PartialEq)] pub enum CommandId { GetStatus = 0, + ReadSlotName = 2, } } @@ -69,7 +70,6 @@ impl Nitrokey { command_id: CommandId, data: &[u8], ) -> Result<[u8; 53], CommandStatus> { - let _ = data; match command_id { CommandId::GetStatus => { let mut data = [0u8; 53]; @@ -85,6 +85,20 @@ impl Nitrokey { data[9] = 0; // delete_user_password Ok(data) } + CommandId::ReadSlotName => { + assert!(data.len() > 1); + let slot_number = data[0]; + if slot_number != 0x20 { + Err(CommandStatus::SlotNotProgrammed) + } else { + let mut data = [0u8; 53]; + data[0] = 0x74; // t + data[1] = 0x65; // e + data[2] = 0x73; // s + data[3] = 0x74; // t + Ok(data) + } + } } } } |