diff options
author | Szczepan Zalega <szczepan@nitrokey.com> | 2017-12-12 17:24:55 +0100 |
---|---|---|
committer | Szczepan Zalega <szczepan@nitrokey.com> | 2018-02-23 15:42:37 +0100 |
commit | 1411b1bd795bcf4a382dd8ed2aa09f94e352f848 (patch) | |
tree | 7e0fa9f83e37e68c11f765c45dcb75568011d7cd | |
parent | 809b618d4d064cedc7070cac5ccc8797e5d89f54 (diff) | |
download | libnitrokey-1411b1bd795bcf4a382dd8ed2aa09f94e352f848.tar.gz libnitrokey-1411b1bd795bcf4a382dd8ed2aa09f94e352f848.tar.bz2 |
Unify unencrypted volume ro/rw switching
For 0.49 run new command, which needs Admin PIN
For 0.48 and lower run old command
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
-rw-r--r-- | NitrokeyManager.cc | 24 | ||||
-rw-r--r-- | include/NitrokeyManager.h | 4 |
2 files changed, 10 insertions, 18 deletions
diff --git a/NitrokeyManager.cc b/NitrokeyManager.cc index d12bf54..eb52eee 100644 --- a/NitrokeyManager.cc +++ b/NitrokeyManager.cc @@ -824,23 +824,19 @@ using nitrokey::misc::strcpyT; } void NitrokeyManager::set_unencrypted_read_only(const char* user_pin) { - //available until 0.48 - misc::execute_password_command<stick20::SendSetReadonlyToUncryptedVolume>(device, user_pin); + //until 0.48 User PIN was sufficient, from 0.49 it needs Admin PIN + if (get_minor_firmware_version()<=48) + misc::execute_password_command<stick20::SendSetReadonlyToUncryptedVolume>(device, user_pin); + else + misc::execute_password_command<stick20::SetUnencryptedVolumeReadOnlyAdmin>(device, user_pin); } void NitrokeyManager::set_unencrypted_read_write(const char* user_pin) { - //available until 0.48 - misc::execute_password_command<stick20::SendSetReadwriteToUncryptedVolume>(device, user_pin); - } - - void NitrokeyManager::set_unencrypted_read_only_admin_pin(const char* admin_pin) { - //available from 0.49 - misc::execute_password_command<stick20::SetUnencryptedVolumeReadOnlyAdmin>(device, admin_pin); - } - - void NitrokeyManager::set_unencrypted_read_write_admin_pin(const char* admin_pin) { - //available from 0.49 - misc::execute_password_command<stick20::SetUnencryptedVolumeReadWriteAdmin>(device, admin_pin); + //until 0.48 User PIN was sufficient, from 0.49 it needs Admin PIN + if (get_minor_firmware_version()<=48) + misc::execute_password_command<stick20::SendSetReadwriteToUncryptedVolume>(device, user_pin); + else + misc::execute_password_command<stick20::SetUnencryptedVolumeReadWriteAdmin>(device, user_pin); } void NitrokeyManager::export_firmware(const char* admin_pin) { diff --git a/include/NitrokeyManager.h b/include/NitrokeyManager.h index f6e02cc..e0aa59f 100644 --- a/include/NitrokeyManager.h +++ b/include/NitrokeyManager.h @@ -207,10 +207,6 @@ char * strndup(const char* str, size_t maxlen); void set_encrypted_volume_read_write(const char *admin_pin); - void set_unencrypted_read_write_admin_pin(const char *admin_pin); - - void set_unencrypted_read_only_admin_pin(const char *admin_pin); - int get_major_firmware_version(); }; } |