diff options
author | Robin Krahl <me@robin-krahl.de> | 2018-05-18 09:26:56 +0200 |
---|---|---|
committer | Szczepan Zalega <szczepan@nitrokey.com> | 2018-06-19 19:55:18 +0200 |
commit | 81a288088c4e54ffce81e1971c4ccdfe2ec80b8a (patch) | |
tree | 4811c6af860507f723571999d5fb879ff7a8a6e3 /NK_C_API.cc | |
parent | b46dbfa63f344cd7e5323139cf71cd100a179682 (diff) | |
download | libnitrokey-81a288088c4e54ffce81e1971c4ccdfe2ec80b8a.tar.gz libnitrokey-81a288088c4e54ffce81e1971c4ccdfe2ec80b8a.tar.bz2 |
Add set_time_soft to replace get_time
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.
Diffstat (limited to 'NK_C_API.cc')
-rw-r--r-- | NK_C_API.cc | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/NK_C_API.cc b/NK_C_API.cc index 00694c7..c679597 100644 --- a/NK_C_API.cc +++ b/NK_C_API.cc @@ -358,6 +358,13 @@ extern "C" { }); } + NK_C_API int NK_totp_set_time_soft(uint64_t time) { + auto m = NitrokeyManager::instance(); + return get_without_result([&]() { + m->set_time_soft(time); + }); + } + NK_C_API int NK_totp_get_time() { auto m = NitrokeyManager::instance(); return get_without_result([&]() { |