aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NitrokeyManager.cc10
-rw-r--r--include/CommandFailedException.h5
-rw-r--r--include/NitrokeyManager.h2
3 files changed, 17 insertions, 0 deletions
diff --git a/NitrokeyManager.cc b/NitrokeyManager.cc
index d4a13d1..fff5d64 100644
--- a/NitrokeyManager.cc
+++ b/NitrokeyManager.cc
@@ -752,6 +752,16 @@ using nitrokey::misc::strcpyT;
return device->get_device_model();
}
+ bool NitrokeyManager::is_smartcard_in_use(){
+ try{
+ stick20::CheckSmartcardUsage::CommandTransaction::run(device);
+ }
+ catch(const CommandFailedException & e){
+ return e.reason_smartcard_busy();
+ }
+ return false;
+ }
+
int NitrokeyManager::get_minor_firmware_version(){
switch(device->get_device_model()){
case DeviceModel::PRO:{
diff --git a/include/CommandFailedException.h b/include/CommandFailedException.h
index 42fad73..32bd6b7 100644
--- a/include/CommandFailedException.h
+++ b/include/CommandFailedException.h
@@ -28,6 +28,7 @@
#include "command_id.h"
using cs = nitrokey::proto::stick10::command_status;
+using cs2 = nitrokey::proto::stick20::device_status;
class CommandFailedException : public std::exception {
public:
@@ -65,6 +66,10 @@ public:
return last_command_status == static_cast<uint8_t>(cs::wrong_password);
}
+ bool reason_smartcard_busy() const throw(){
+ return last_command_status == static_cast<uint8_t>(cs2::smartcard_error);
+ }
+
};
diff --git a/include/NitrokeyManager.h b/include/NitrokeyManager.h
index 67dd128..12aae0d 100644
--- a/include/NitrokeyManager.h
+++ b/include/NitrokeyManager.h
@@ -208,6 +208,8 @@ char * strndup(const char* str, size_t maxlen);
void set_encrypted_volume_read_write(const char *admin_pin);
int get_major_firmware_version();
+
+ bool is_smartcard_in_use();
};
}