aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2018-02-01 12:12:13 +0100
committerSzczepan Zalega <szczepan@nitrokey.com>2018-02-01 12:12:13 +0100
commite2e009d7d55b75da4537b1fbecb6759c0aabb63c (patch)
tree5afe04af8bf4eecbfb6d007b1fa77aab85121fa2
parent3e37da97c7b2417251585c1d985b54c9a71561e7 (diff)
parent2df8bb7f9da3231cb5a7153401d524feb7409642 (diff)
downloadlibnitrokey-e2e009d7d55b75da4537b1fbecb6759c0aabb63c.tar.gz
libnitrokey-e2e009d7d55b75da4537b1fbecb6759c0aabb63c.tar.bz2
Merge branch 'expose_firmware_update'
-rw-r--r--NK_C_API.cc7
-rw-r--r--NK_C_API.h15
-rw-r--r--unittest/test_storage.py9
3 files changed, 31 insertions, 0 deletions
diff --git a/NK_C_API.cc b/NK_C_API.cc
index 6afce74..33a5fbb 100644
--- a/NK_C_API.cc
+++ b/NK_C_API.cc
@@ -538,6 +538,13 @@ extern "C" {
});
}
+ NK_C_API int NK_enable_firmware_update(const char* update_password){
+ auto m = NitrokeyManager::instance();
+ return get_without_result([&]() {
+ m->enable_firmware_update(update_password);
+ });
+ }
+
NK_C_API const char* NK_get_status_storage_as_string() {
auto m = NitrokeyManager::instance();
return get_with_string_result([&]() {
diff --git a/NK_C_API.h b/NK_C_API.h
index aa89ece..01290d8 100644
--- a/NK_C_API.h
+++ b/NK_C_API.h
@@ -475,6 +475,21 @@ extern "C" {
const char* new_update_password);
/**
+ * Enter update mode. Needs update password.
+ * When device is in update mode it no longer accepts any HID commands until
+ * firmware is launched (regardless of being updated or not).
+ * Smartcard (through CCID interface) and its all volumes are not visible as well.
+ * Its VID and PID are changed to factory-default (03eb:2ff1 Atmel Corp.)
+ * to be detected by flashing software. Result of this command can be reversed
+ * by using 'launch' command.
+ * For dfu-programmer it would be: 'dfu-programmer at32uc3a3256s launch'.
+ * Storage only
+ * @param update_password 20 characters
+ * @return command processing error code
+ */
+ NK_C_API int NK_enable_firmware_update(const char* update_password);
+
+ /**
* Get Storage stick status as string.
* Storage only
* @return string with devices attributes
diff --git a/unittest/test_storage.py b/unittest/test_storage.py
index 0f3e04e..67bbf8b 100644
--- a/unittest/test_storage.py
+++ b/unittest/test_storage.py
@@ -318,6 +318,15 @@ def test_change_update_password(C):
assert C.NK_change_update_password(DefaultPasswords.UPDATE_TEMP, DefaultPasswords.UPDATE) == DeviceErrorCode.STATUS_OK
+@pytest.mark.skip(reason='no reversing method added yet')
+@pytest.mark.update
+def test_enable_firmware_update(C):
+ skip_if_device_version_lower_than({'S': 50})
+ wrong_password = b'aaaaaaaaaaa'
+ assert C.NK_enable_firmware_update(wrong_password) == DeviceErrorCode.WRONG_PASSWORD
+ assert C.NK_enable_firmware_update(DefaultPasswords.UPDATE) == DeviceErrorCode.STATUS_OK
+
+
@pytest.mark.other
def test_send_startup(C):
skip_if_device_version_lower_than({'S': 43})