| Commit message (Collapse) | Author | Age |
|\
| |
| |
| |
| |
| | |
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.
|
|\ \
| | |
| | |
| | | |
Fixes #124
|
| | |
| | |
| | |
| | | |
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
| | |
| | |
| | |
| | |
| | |
| | | |
Attribute specifiers are a C++-only feature. Therefore this patch
removes the [[deprecated(...)]] attribute from the NK_totp_get_time
method in NK_C_API.h and replaces it with a comment.
|
|\ \ \
| |/ /
|/| |
| | |
| | |
| | | |
Add C minimal offline test
Fixes #125
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| |
| | |
All current tests are written in C++. Therefore C++-only code in the C
API might not be detected by the tests. This patch adds a minimal test
written in C that only includes the C API header. This should make sure
that the C API code is valid.
The new test is called `test_minimal.c` and is added to the CMake
COMPILE_OFFLINE_TESTS option.
|
|\ \
| | |
| | |
| | | |
Handle command for getting production info
|
|/ /
| |
| |
| | |
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
|\ \
| | |
| | |
| | | |
Handle WINK command, introduced in Storage v0.52
|
| | |
| | |
| | |
| | | |
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
|\ \ \
| |/ /
|/| |
| | |
| | |
| | | |
Fix version getter test
Closes #123
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
`git describe` may return a tag name or <tag>-<n>-g<hash>, where <n> is
the number of commits since the last tag <tag> and <hash> is the hash of
the current commit. The current test case only considers the latter
case. This patch adds a regular expression to handle both cases.
|
|\ \ \
| |/ /
|/| |
| | |
| | |
| | | |
Fix connect() return value in offline mode
Fixes #115
|
| | |
| | |
| | |
| | | |
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
| | |
| | |
| | |
| | | |
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
NitrokeyManager::connect() currently returns true if the device pointer
is set. Yet this does not mean that the connection was successful. For
example, NitrokeyManger::connect(const char*) sets the device pointer
even if it was not successful.
This patch introduces a variable that keeps track of the connection
instead of checking the device pointer. This corrects the return value
without changing the behavior of the connect method (returning the
Storage device if both a Pro and a Storage device are present).
|
|\ \ \
| | | |
| | | |
| | | |
| | | |
| | | | |
Cleanup API related to device's TOTP time management
Fixes #114
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
device's side
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
| | | |
| | | |
| | | |
| | | | |
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
|
| | | |
| | | |
| | | |
| | | | |
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
| | | |
| | | |
| | | |
| | | | |
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
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.
|
|\ \ \ \
| |/ / /
|/| | |
| | | |
| | | |
| | | | |
C API: Storage status getter
Closes #118
|
| | | |
| | | |
| | | |
| | | | |
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
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.
|
|\ \ \
| |/ /
|/| |
| | |
| | | |
Add tests for authorization issue
https://github.com/Nitrokey/nitrokey-pro-firmware/issues/45
|
| | |
| | |
| | |
| | | |
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
|/ /
| |
| |
| | |
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
|\ \
| | |
| | |
| | |
| | |
| | | |
Mark unused parameters in TOTP code getter in the C API.
Closes #113
|
|/ /
| |
| |
| |
| |
| |
| |
| | |
According to the GetTOTP class in stick10_commands_0.8.h and after
firmware inspection, the challenge, last_totp_time and last_interval
arguments for the get_TOTP_code method are unused. This patch adds this
information to the doc comment for NK_get_totp_code and
NK_get_totp_code_PIN.
|
|\ \
| |/
|/|
| |
| |
| | |
Fix broken include
Closes #112
|
|/ |
|
|\
| |
| |
| |
| |
| |
| |
| |
| | |
Make sure all C API strings are deallocable.
Tested with Python's 3.6.5 'pytest -sv test_{pro,storage}.py' on Storage v0.50,
Ubuntu 18.04
Closes #110
|
| |
| |
| |
| | |
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
| |
| |
| |
| | |
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>
|
|\
| |
| |
| |
| |
| | |
Update documentation of C API regarding OTP secret length and type.
Closes #106
|
| |
| |
| |
| |
| |
| |
| | |
These were to meant, that the sizes were confirmed for Pro and not for Storage, during library development. Storage has maintained the compatibility, hence there is no need for the mentioned marks.
Issue #106
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
| |
| |
| |
| |
| |
| | |
Same for C-string requirements for fields and sizes
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
|/
|
|
|
|
|
| |
While the actual secret is 20 bytes, the functions accept a hex string.
That means that every byte of the secret is represented by two bytes
(characters) in the hex string. So the argument secret for the
functions NK_write_{hotp,totp}_slot is char[40], not char[20].
|
|\ |
|
|/
|
|
|
|
|
| |
Cleanup CMakeList a bit as well.
Fixes #97
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|
|
|
|
|
|
| |
from another CMake project
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
|