Skip to content

Commit

Permalink
Also execute GET_DEVICE_STATUS in get_status for Storage
Browse files Browse the repository at this point in the history
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 Nitrokey#166.

[0] Nitrokey/nitrokey-storage-firmware#96
  • Loading branch information
robinkrahl committed Jan 5, 2020
1 parent 1ba9938 commit dd0cdcd
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion NitrokeyManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit dd0cdcd

Please sign in to comment.