diff options
author | Robin Krahl <robin.krahl@ireas.org> | 2019-02-18 13:39:05 +0000 |
---|---|---|
committer | Robin Krahl <robin.krahl@ireas.org> | 2019-02-18 15:53:53 +0100 |
commit | 1f425191758e862946d89998316e53f4ce64f142 (patch) | |
tree | 93011672c1ada0dbd16679326225fdebd9e9efe7 /src | |
parent | 7f3cc787d03423aa982ade0fa054bb79be18f6ae (diff) | |
download | ntw-1f425191758e862946d89998316e53f4ce64f142.tar.gz ntw-1f425191758e862946d89998316e53f4ce64f142.tar.bz2 |
Add simple GetStatus command implementation
For debugging purposes, we add a simple GetStatus implementation that
just reports the firmware version 0.1.
Diffstat (limited to 'src')
-rw-r--r-- | src/device.rs | 19 |
1 files changed, 17 insertions, 2 deletions
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) + } + } } } |