diff options
author | Robin Krahl <robin.krahl@ireas.org> | 2018-05-20 23:06:17 +0000 |
---|---|---|
committer | Robin Krahl <me@robin-krahl.de> | 2018-05-21 01:07:10 +0200 |
commit | 68f1f31595757c5018c5c243a76e94e0af5439ef (patch) | |
tree | 977d857843362ae50de0d2b51de541c4528ad737 | |
parent | 98eaf71502afeb4f14eb4f7bc365e3211b5709fb (diff) | |
download | nitrokey-rs-68f1f31595757c5018c5c243a76e94e0af5439ef.tar.gz nitrokey-rs-68f1f31595757c5018c5c243a76e94e0af5439ef.tar.bz2 |
Add get_minor_firmware_version to Device
Since libnitrokey v3.3, we can also access the minor firmware version.
-rw-r--r-- | TODO.md | 1 | ||||
-rw-r--r-- | src/lib.rs | 28 | ||||
-rw-r--r-- | src/tests/pro.rs | 7 |
3 files changed, 32 insertions, 4 deletions
@@ -1,7 +1,6 @@ - Add support and tests for the Nitrokey Storage. - Add support for the currently unsupported commands: - `NK_login_enum` - - `NK_get_minor_firmware_version` - `NK_set_unencrypted_volume_rorw_pin_type_user` - `NK_lock_device` - `NK_factory_reset` @@ -498,7 +498,11 @@ pub trait Device { /// /// # fn try_main() -> Result<(), CommandError> { /// let device = nitrokey::connect()?; - /// println!("Firmware version: {}.x", device.get_major_firmware_version()); + /// println!( + /// "Firmware version: {}.{}", + /// device.get_major_firmware_version(), + /// device.get_minor_firmware_version(), + /// ); /// # Ok(()) /// # } /// ``` @@ -506,6 +510,28 @@ pub trait Device { unsafe { nitrokey_sys::NK_get_major_firmware_version() } } + /// Returns the minor part of the firmware version (for example 8 for + /// version 0.8). + /// + /// # Example + /// + /// ```no_run + /// use nitrokey::Device; + /// # use nitrokey::CommandError; + /// + /// # fn try_main() -> Result<(), CommandError> { + /// let device = nitrokey::connect()?; + /// println!( + /// "Firmware version: {}.{}", + /// device.get_major_firmware_version(), + /// device.get_minor_firmware_version(), + /// ); + /// # Ok(()) + /// # } + fn get_minor_firmware_version(&self) -> i32 { + unsafe { nitrokey_sys::NK_get_minor_firmware_version() } + } + /// Returns the current configuration of the Nitrokey device. /// /// # Example diff --git a/src/tests/pro.rs b/src/tests/pro.rs index dee7dc6..76d68a0 100644 --- a/src/tests/pro.rs +++ b/src/tests/pro.rs @@ -194,9 +194,12 @@ fn totp_slot_name() { #[test] #[cfg_attr(not(feature = "test-pro"), ignore)] -fn get_major_firmware_version() { +fn get_firmware_version() { set_debug(false); - assert_eq!(0, ::connect().unwrap().get_major_firmware_version()); + let device = ::connect().unwrap(); + assert_eq!(0, device.get_major_firmware_version()); + let minor = device.get_minor_firmware_version(); + assert!(minor == 7 || minor == 8); } fn admin_retry(device: UnauthenticatedDevice, suffix: &str, count: u8) -> UnauthenticatedDevice { |