summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2018-02-23 14:02:06 +0100
committerSzczepan Zalega <szczepan@nitrokey.com>2018-02-23 15:42:39 +0100
commita262472826830ea0a98a4da2fa8f665d359b8789 (patch)
tree7f2df53da4c018fbfa6ec57809bcd2fcefaf0624
parentbca1d0c3e458b3a12fe0117d1c7bd50548bef777 (diff)
downloadlibnitrokey-a262472826830ea0a98a4da2fa8f665d359b8789.tar.gz
libnitrokey-a262472826830ea0a98a4da2fa8f665d359b8789.tar.bz2
Handle getting firmware version internally
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
-rw-r--r--NitrokeyManager.cc11
-rw-r--r--include/NitrokeyManager.h2
2 files changed, 7 insertions, 6 deletions
diff --git a/NitrokeyManager.cc b/NitrokeyManager.cc
index f912c7c..d563b26 100644
--- a/NitrokeyManager.cc
+++ b/NitrokeyManager.cc
@@ -838,7 +838,7 @@ using nitrokey::misc::strcpyT;
void NitrokeyManager::set_unencrypted_read_only_admin(const char* admin_pin) {
//from v0.49, v0.51+ it needs Admin PIN
- if (set_unencrypted_volume_rorw_pin_type_user(get_minor_firmware_version())){
+ if (set_unencrypted_volume_rorw_pin_type_user()){
LOG("set_unencrypted_read_only_admin is not supported for this version of Storage device. "
"Please update firmware to v0.51+", nitrokey::log::Loglevel::WARNING);
return;
@@ -850,7 +850,7 @@ using nitrokey::misc::strcpyT;
//until v0.48 (incl. v0.50) User PIN was sufficient
LOG("set_unencrypted_read_only is deprecated. Use set_unencrypted_read_only_admin instead.",
nitrokey::log::Loglevel::WARNING);
- if (!set_unencrypted_volume_rorw_pin_type_user(get_minor_firmware_version())){
+ if (!set_unencrypted_volume_rorw_pin_type_user()){
LOG("set_unencrypted_read_only is not supported for this version of Storage device. Doing nothing.",
nitrokey::log::Loglevel::WARNING);
return;
@@ -860,7 +860,7 @@ using nitrokey::misc::strcpyT;
void NitrokeyManager::set_unencrypted_read_write_admin(const char* admin_pin) {
//from v0.49, v0.51+ it needs Admin PIN
- if (set_unencrypted_volume_rorw_pin_type_user(get_minor_firmware_version())){
+ if (set_unencrypted_volume_rorw_pin_type_user()){
LOG("set_unencrypted_read_write_admin is not supported for this version of Storage device. "
"Please update firmware to v0.51+.", nitrokey::log::Loglevel::WARNING);
return;
@@ -872,7 +872,7 @@ using nitrokey::misc::strcpyT;
//until v0.48 (incl. v0.50) User PIN was sufficient
LOG("set_unencrypted_read_write is deprecated. Use set_unencrypted_read_write_admin instead.",
nitrokey::log::Loglevel::WARNING);
- if (!set_unencrypted_volume_rorw_pin_type_user(get_minor_firmware_version())){
+ if (!set_unencrypted_volume_rorw_pin_type_user()){
LOG("set_unencrypted_read_write is not supported for this version of Storage device. Doing nothing.",
nitrokey::log::Loglevel::WARNING);
return;
@@ -880,7 +880,8 @@ using nitrokey::misc::strcpyT;
misc::execute_password_command<stick20::SendSetReadwriteToUncryptedVolume>(device, user_pin);
}
- bool NitrokeyManager::set_unencrypted_volume_rorw_pin_type_user(const int minor_firmware_version) const {
+ bool NitrokeyManager::set_unencrypted_volume_rorw_pin_type_user(){
+ auto minor_firmware_version = get_minor_firmware_version();
return minor_firmware_version <= 48 || minor_firmware_version == 50;
}
diff --git a/include/NitrokeyManager.h b/include/NitrokeyManager.h
index 08da8ba..0db0856 100644
--- a/include/NitrokeyManager.h
+++ b/include/NitrokeyManager.h
@@ -254,7 +254,7 @@ char * strndup(const char* str, size_t maxlen);
* @param minor_firmware_version
* @return Returns true, if set unencrypted volume ro/rw pin type is User, false otherwise.
*/
- bool set_unencrypted_volume_rorw_pin_type_user(int minor_firmware_version) const;
+ bool set_unencrypted_volume_rorw_pin_type_user();
};
}