summaryrefslogtreecommitdiff
path: root/NK_C_API.cc
Commit message (Collapse)AuthorAge
* Merge branch 'read-config-struct'Szczepan Zalega2020-06-13
|\ | | | | | | | | | | Add NK_config struct and read/write functions Fixes #176
| * Add NK_config struct and read/write functionsRobin Krahl2020-04-02
| | | | | | | | | | | | | | | | | | | | | | | | This patch adds the NK_config struct to the C API that stores the general configuration of a Nitrokey device. It also adds the NK_read_config_struct and NK_write_config_struct functions to make the API easier to use. While NK_write_config_struct is only a convenience method, NK_read_config_struct makes the API more safe as the user no longer has to read the data from a pointer to an array. This patch also extends the test_read_write_config test case with the two new functions.
* | Merge branch 'free'Szczepan Zalega2020-06-13
|\ \ | | | | | | | | | | | | | | | Add functions for freeing memory of some C API results Fixes #175
| * | Add missing free functions to C APIRobin Krahl2020-04-02
| |/ | | | | | | | | | | | | | | This patch adds two missing free functions, NK_free_config and NK_free_password_safe_slot_status, to enable memory-safe use of the C API. Fixes #173.
* | Merge branch 'serial-number-u32'Szczepan Zalega2020-06-13
|\ \ | | | | | | | | | | | | | | | Return serial number as uint32_t Fixes #174
| * | Return serial number as uint32_t from C APIRobin Krahl2020-04-02
| |/ | | | | | | | | | | | | | | | | This patch adds the function NK_device_serial_number_as_u32 to the C API. It is similar to NK_device_serial_number but returns the raw unsigned integer instead of a formatted string. This patch also adds a simple test case that ensures that the number is not zero. Fixes #172.
* / Identify Librem Key, behaving like Nitrokey Pro deviceAmit Aronovitch2019-10-03
|/
* Add function reading HOTP slot detailsSzczepan Zalega2019-06-19
| | | | Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
* Add calls to commands in C APISzczepan Zalega2019-06-13
| | | | Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
* Correct version header in C APIpre-v3.5-2Szczepan Zalega2019-03-19
| | | | Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
* Replace NK_status with NK_get_status_as_stringRobin Krahl2019-01-29
| | | | | For naming consistency, this patch adds the NK_get_status_as_string function to replace NK_status and marks NK_status as deprecated.
* Add NK_get_status function to get status structRobin Krahl2019-01-29
| | | | | | | | | Currently, the C API provides access to the device status using the NK_get_{major,minor}_firmware_version, NK_device_serial_number and NK_read_config functions. Each function sends a command to the device, although the data is returned in a single response. This patch adds a NK_status struct and a NK_get_status function that provide access to this data with a single command.
* Merge branch 'pr_149'Szczepan Zalega2019-01-24
|\ | | | | | | | | | | Return uint8_t from version getters Fixes #149
| * Return firmware version parts as uint8_t instead of intRobin Krahl2019-01-17
| | | | | | | | | | | | | | | | The firmware version parts returned by the Nitrokey devices are uint8_t values. This is part of the public API as part of the NK_storage_status struct. For consistency with this API, this patch changes the functions NK_get_major_firmware_version and NK_get_minor_firmware_version to return uint8_t instead of int.
* | Export PWS slot count in C APIRobin Krahl2019-01-24
|/ | | | | | | The C++ API already defines the number of slots in device_proto.h. This patch adds it to the C API. It is especially important to have this constant in the C API as it is the length of the array returned by NK_get_password_safe_slot_status.
* Merge branch 'pr_138' into contributionsSzczepan Zalega2019-01-15
|\ | | | | | | | | | | Improve support for multiple devices Fixes #138
| * Add NK_device_info, NK_list_devices and NK_free_device_infoRobin Krahl2019-01-13
| | | | | | | | | | | | NK_list_devices corresponds to NitrokeyManager::list_devices. It returns a linked list of NK_device_info, which has to be freed using the NK_free_device_info function.
| * Add NK_connect_with_path to C APIRobin Krahl2019-01-13
| | | | | | | | NK_connect_with_path corresponds to NitrokeyManager::connect_with_path.
* | Merge branch 'pr_145' into contributionsSzczepan Zalega2019-01-15
|\ \ | | | | | | | | | | | | | | | Add NK_get_SD_usage_data function to C API Fixes #145
| * | Add NK_get_SD_usage_data function to C APIRobin Krahl2019-01-14
| |/ | | | | | | | | | | The NK_get_SD_usage_data function returns the minimum and maximum write level for the SD card. This function cannot be tested due to the missing struct support in the Python tests.
* / Return -2 if an error occured in NK_get_progress_bar_valueRobin Krahl2019-01-14
|/ | | | | | | | NK_get_progress_bar_value returns the progress value from 0 to 100 or -1 if there is no pending operation. In the previous implementation, it also returned zero if an error occurred, making it impossible to distinguish progress zero and an error. Therefore, we change the return value to -2 if an error occured.
* Merge branch 'pr_116'v3.4Szczepan Zalega2018-07-07
|\ | | | | | | | | | | Allow to connect to device with model specified by enum. Fixes #116
| * Handle new enum model value in NK_login_enumpr_116Szczepan Zalega2018-07-07
| | | | | | | | Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
| * Replace *out function parameter with return valueSzczepan Zalega2018-06-20
| | | | | | | | | | | | | | Using return value instead of memory manipulation seem to be cleaner solution and less error prone due to avoiding pointer usage. Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
| * Expose device model in C APIRobin Krahl2018-05-25
| | | | | | | | | | | | | | | | | | The C++ API already provides access to the model of the connected device in NitrokeyManager::get_connected_device_model(). This patch also exposes this information in the C API by adding NK_get_device_model. As there might be no device connected, the function returns a boolean indicating the connection status and writes the model of the connected device to a pointer passed as an argument.
* | Handle command for getting production dataSzczepan Zalega2018-06-28
| | | | | | | | Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
* | Handle WINK commandSzczepan Zalega2018-06-23
| | | | | | | | Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
* | Remove NK_totp_get_time implementation, since it always results in error on ↵Szczepan Zalega2018-06-19
| | | | | | | | | | | | device's side Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
* | Add set_time_soft to replace get_timeRobin Krahl2018-06-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The SetTime command supports two modes: set the time without checking the currently set time, or verify that the currently set time is not zero and not larger than the new time (see cmd_set_time(uint8_t*, uint8_t*) in src/keyboard/report_protocol.c, lines 678--710, in the Nitrokey Pro firmware). NitrokeyManager called these two modes set_time(uint64_t) and get_time(uint64_t), which is highly misleading -- the command does never get the time. Furthermore, the get_time method per default calls the command with the time zero, which will always result in an error. The C API has the methods NK_totp_set_time(uint64_t) and NK_totp_get_time(). NK_totp_get_time() calls get_time(uint64_t) with the time zero, leading to an error, and is therefore useless. This patch proposes a new wording. While it would make sense to call the first mode “reset” and the second mode “set”, this would break compatibility. Therefore, new methods set_time_soft(uint64_t) and NK_totp_set_time_soft(uint64_t) are introduced to represent the difference between a hard and a soft setting of the time. The old methods, get_time(uint64_t) and NK_totp_get_time(), are not removed but marked as deprecated. They should be removed in an upcoming major release.
* | Merge branch 'pr_117'Szczepan Zalega2018-06-19
|\ \ | | | | | | | | | | | | | | | | | | | | | Library version getter for C API Fixes #117 Fixes #35 Fixes #62
| * | Add getters for the library versionRobin Krahl2018-05-25
| |/ | | | | | | | | | | | | CMake generates version.h from version.h.in and sets the major and minor version as specified in CMakeLists.txt and the current git version as returned by `git describe --always`. These values are also added to the C API as NK_get{_major,_minor,}_library_version.
* | Add getter for Storage status to C APIRobin Krahl2018-05-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The C++ API currently provides the Storage status in NitrokeyManager::get_status_storage(). The C API only provides a string version of this data (NK_get_status_storage_as_string). This patch adds a struct to the C API that can store the storage status and a function that can retrieve it. The interpretation of the fields of the internal struct is based on the following code in the Nitrokey Storage firmware: - src/HighLevelFunctions/FlashStorage.h, lines 73 to 90 (struct definition with comments) - src/OTP/report_protocol.c, lines 241 to 376 (debug output of the data)
* | Refactor result retrieval in C APIRobin Krahl2018-05-25
|/ | | | | | | | | | | | | | | The result retrieval functions get_with_array_result, get_with_string_result, get_with_result and get_without_result currently contain much duplicated code: the error handling. This patch tries to simplify this code by introducing a new function, get_with_status, that executes a function, catches errors and returns the error code together with the result of the function or a fallback value passed by the user if the function failed. get_with_array_result, get_with_string_result and get_with_result are adapted to use this function. get_without_result is not changed as it has a different error handling logic than the other functions: It ignores any InvalidCRCReceived exceptions.
* Correct NK_status() reply lengthSzczepan Zalega2018-04-19
| | | | Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
* Change const char* to char* for functions returning duplicated strings.Szczepan Zalega2018-04-19
| | | | | | | All functions returning duplicated C-strings, which needs to be deallocated on caller side, are typed char* instead of const char* Issue #110 Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
* Return allocated string instead of pointer to a string literalSzczepan Zalega2018-04-19
| | | | | | Issue #110 Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
* Add NK_login_enum to the C APIRobin Krahl2018-04-10
| | | | | | | | As with the C++ API, identifying the model by the first character of a string is not intuitive. This patch adds the NK_login_enum function to the C API that accepts an enum value instead of a string. It also adds a new enum NK_device_model as device::DeviceModel is an enum class and therefore cannot be used in C.
* Make unbundling easierDavid Seifert2018-03-13
|
* C API wrapper for NK_set_unencrypted_volume_rorw_pin_type_userSzczepan Zalega2018-03-09
| | | | Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
* Increase buffer size for listing connected devices IDsSzczepan Zalega2018-03-01
| | | | Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
* List devices by unique SC:SD idSzczepan Zalega2018-02-28
| | | | | | | Add C API and tests Add mutexes Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
* Divide unencrypted volume ro/rw commands for backward compatibilitySzczepan Zalega2018-02-23
| | | | | | | | | | Unencrypted volume ro/rw: rename user_admin_pin -> admin_pin to be consistent with latest API. Update description. Document PIN requirements in C++ API Extract pin type function Add C API for separate unencrypted volume read write handling Use correct commands to set ro/rw mode of unencrypted volume Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
* Correct variable name for unencrypted ro/rw switchSzczepan Zalega2018-02-23
| | | | Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
* C API for Encrypted volume ro/rw switchSzczepan Zalega2018-02-23
| | | | Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
* Correct getting minor and major from firmware versionSzczepan Zalega2018-02-23
| | | | | | | | | Add get_minor_firmware_version Correct get_major_firmware version (was returning minor instead) Name 3rd version field for test builds Use minor firmware version in tests Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
* Expose enabling firmware update in C APISzczepan Zalega2018-02-01
| | | | Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
* Catch DeviceCommunication exceptions in C APISzczepan Zalega2018-01-16
| | | | Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
* Update license/copyright linesSzczepan Zalega2018-01-16
| | | | | | Remove redundant file Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
* Add DEBUG_L1 level and set it as default for Python testsSzczepan Zalega2017-10-10
| | | | Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
* Return exception type when DeviceCommunicationException is encounteredSzczepan Zalega2017-10-10
| | | | Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>