| Commit message (Collapse) | Author | Age |
|\
| |
| |
| |
| |
| | |
Return uint8_t from version getters
Fixes #149
|
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
|/
|
|
|
|
|
| |
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.
|
|\
| |
| |
| |
| |
| | |
Improve support for multiple devices
Fixes #138
|
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| | |
NK_connect_with_path corresponds to NitrokeyManager::connect_with_path.
|
|\ \
| | |
| | |
| | |
| | |
| | | |
Add NK_get_SD_usage_data function to C API
Fixes #145
|
| |/
| |
| |
| |
| |
| | |
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.
|
|/
|
|
|
|
|
|
| |
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.
|
|\
| |
| |
| |
| |
| | |
Allow to connect to device with model specified by enum.
Fixes #116
|
| |
| |
| |
| | |
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
| |
| |
| |
| |
| |
| |
| | |
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>
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| | |
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
| |
| |
| |
| | |
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
| |
| |
| |
| |
| |
| | |
device's side
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
|\ \
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Library version getter for C API
Fixes #117
Fixes #35
Fixes #62
|
| |/
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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)
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
| |
Issue #110
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
| |
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
|
|
|
| |
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
|
|
|
|
|
|
| |
Add C API and tests
Add mutexes
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
| |
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
|
|
|
| |
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
| |
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
|
|
|
| |
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
|
|
|
|
|
| |
Remove redundant file
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
|
|
|
| |
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
|
|
|
| |
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
|\ |
|
| | |
|
| | |
|
| | |
|
|/
|
|
|
|
| |
To handle invalid response packets in C API
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
|
|
|
| |
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
|
|
|
|
|
| |
Keep build directory (removed in earlier commit)
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
|
|
|
|
|
|
|
|
| |
Adjust Python tests for new OTP codes return value
Also remove manual 0-filling
Fixes #57
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
|
|
|
| |
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
|
|
|
| |
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
|
|
|
| |
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
|
|
|
| |
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|