From 0262ed2e614e9222b69970289a32ddb3683b3535 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Mon, 14 Jan 2019 15:26:02 +0000 Subject: Add the get_production_info method to the Storage struct The get_production_info method maps to the NK_get_production_info function of libnitrokey. The Storage firmware supports two query modes: with or without a write test. libnitrokey only performs the query without write test, so the fields that are only set for the write test are ignored in our implementation. This affects: - user and admin retry counts - smart card ID - SD card size --- tests/device.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'tests') diff --git a/tests/device.rs b/tests/device.rs index e40ae12..915bd3a 100644 --- a/tests/device.rs +++ b/tests/device.rs @@ -438,6 +438,27 @@ fn get_storage_status(device: Storage) { assert!(status.serial_number_smart_card > 0); } +#[test_device] +fn get_production_info(device: Storage) { + let info = device.get_production_info().unwrap(); + assert_eq!(0, info.firmware_version_major); + assert!(info.firmware_version_minor != 0); + assert!(info.serial_number_cpu != 0); + assert!(info.sd_card.serial_number != 0); + assert!(info.sd_card.size > 0); + assert!(info.sd_card.manufacturing_year > 10); + assert!(info.sd_card.manufacturing_year < 100); + // TODO: month value is not valid atm + // assert!(info.sd_card.manufacturing_month < 12); + assert!(info.sd_card.oem != 0); + assert!(info.sd_card.manufacturer != 0); + + let status = device.get_status().unwrap(); + assert_eq!(status.firmware_version_major, info.firmware_version_major); + assert_eq!(status.firmware_version_minor, info.firmware_version_minor); + assert_eq!(status.serial_number_sd_card, info.sd_card.serial_number); +} + #[test_device] fn export_firmware(device: Storage) { assert_eq!( -- cgit v1.2.1