aboutsummaryrefslogtreecommitdiff
path: root/NitrokeyManager.cc
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2020-01-06 00:47:13 +0100
committerRobin Krahl <robin.krahl@ireas.org>2020-01-06 00:51:36 +0100
commitdd0cdcd2130699be8dde5dbadcf18cd9c00ef78f (patch)
treeb556f5a012097260508edc01b71c6b14ee1a7e34 /NitrokeyManager.cc
parent1ba9938837a726580728c64bdd77d9676c98a020 (diff)
downloadlibnitrokey-dd0cdcd2130699be8dde5dbadcf18cd9c00ef78f.tar.gz
libnitrokey-dd0cdcd2130699be8dde5dbadcf18cd9c00ef78f.tar.bz2
Also execute GET_DEVICE_STATUS in get_status for Storageget_status
As described in this issue [0], the GET_STATUS command does not work for the Nitrokey Storage. Therefore, NitrokeyManager::get_status does not work either. To fix this, we additionally execute the GET_DEVICE_STATUS command if a Nitrokey Storage is detected to determine the serial number and the firmware version. This also fixes the failing test test_get_status that we introduced in the last patch. Fixes #166. [0] https://github.com/Nitrokey/nitrokey-storage-firmware/issues/96
Diffstat (limited to 'NitrokeyManager.cc')
-rw-r--r--NitrokeyManager.cc14
1 files changed, 13 insertions, 1 deletions
diff --git a/NitrokeyManager.cc b/NitrokeyManager.cc
index 6c26a43..f345692 100644
--- a/NitrokeyManager.cc
+++ b/NitrokeyManager.cc
@@ -401,7 +401,19 @@ using nitrokey::misc::strcpyT;
stick10::GetStatus::ResponsePayload NitrokeyManager::get_status(){
try{
auto response = GetStatus::CommandTransaction::run(device);
- return response.data();
+ auto data = response.data();
+ if (device != nullptr && device->get_device_model() == DeviceModel::STORAGE) {
+ // The GET_STATUS command does not work for the Nitrokey Storage,
+ // see https://github.com/Nitrokey/nitrokey-storage-firmware/issues/96
+ // Therefore, we have to use the GET_DEVICE_STATUS command to query
+ // the correct serial number and firmware version.
+ auto response2 = stick20::GetDeviceStatus::CommandTransaction::run(device);
+ auto data2 = response2.data();
+ data.firmware_version_st.major = data2.versionInfo.major;
+ data.firmware_version_st.minor = data2.versionInfo.minor;
+ data.card_serial_u32 = data2.ActiveSmartCardID_u32;
+ }
+ return data;
}
catch (DeviceSendingFailure &e){
// disconnect();