aboutsummaryrefslogtreecommitdiff
path: root/NitrokeyManager.cc
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2016-08-05 10:39:05 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2016-08-05 10:39:18 +0200
commit42446e1a384d3391e4240afe349c34958e5fabed (patch)
treee69ec2a1772e53b4222322195a47343d5f36126c /NitrokeyManager.cc
parentb038eabe137af6187c41344aa2f554cd5d72baad (diff)
downloadlibnitrokey-42446e1a384d3391e4240afe349c34958e5fabed.tar.gz
libnitrokey-42446e1a384d3391e4240afe349c34958e5fabed.tar.bz2
Support writing token id to OTP slots in API
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'NitrokeyManager.cc')
-rw-r--r--NitrokeyManager.cc16
1 files changed, 9 insertions, 7 deletions
diff --git a/NitrokeyManager.cc b/NitrokeyManager.cc
index e56f03f..84a769b 100644
--- a/NitrokeyManager.cc
+++ b/NitrokeyManager.cc
@@ -6,6 +6,7 @@ namespace nitrokey{
template <typename T>
void strcpyT(T& dest, const char* src){
+ assert(src != nullptr);
const int s = sizeof dest;
assert(strlen(src) <= s);
strncpy((char*) &dest, src, s);
@@ -138,9 +139,9 @@ namespace nitrokey{
}
- bool NitrokeyManager::write_HOTP_slot(uint8_t slot_number, const char *slot_name, const char *secret,
- uint8_t hotp_counter, bool use_8_digits,
- bool use_enter, bool use_tokenID, const char *temporary_password) {
+ bool NitrokeyManager::write_HOTP_slot(uint8_t slot_number, const char *slot_name, const char *secret, uint8_t hotp_counter,
+ bool use_8_digits, bool use_enter, bool use_tokenID, const char *token_ID,
+ const char *temporary_password) {
assert(is_valid_hotp_slot_number(slot_number));
assert(strlen(secret)==20); //160 bits
assert(strlen(slot_name)<=15);
@@ -150,6 +151,7 @@ namespace nitrokey{
payload.slot_number = slot_number;
strcpyT(payload.slot_secret, secret);
strcpyT(payload.slot_name, slot_name);
+ strcpyT(payload.slot_token_id, token_ID);
payload.slot_counter = hotp_counter;
payload.use_8_digits = use_8_digits;
payload.use_enter = use_enter;
@@ -164,9 +166,9 @@ namespace nitrokey{
return true;
}
- bool NitrokeyManager::write_TOTP_slot(uint8_t slot_number, const char *slot_name, const char *secret,
- uint16_t time_window, bool use_8_digits,
- bool use_enter, bool use_tokenID, const char *temporary_password) {
+ bool NitrokeyManager::write_TOTP_slot(uint8_t slot_number, const char *slot_name, const char *secret, uint16_t time_window,
+ bool use_8_digits, bool use_enter, bool use_tokenID, const char *token_ID,
+ const char *temporary_password) {
auto payload = get_payload<WriteToTOTPSlot>();
assert(is_valid_totp_slot_number(slot_number));
assert(strlen(secret) == sizeof payload.slot_secret); //160 bits
@@ -176,11 +178,11 @@ namespace nitrokey{
payload.slot_number = slot_number;
strcpyT(payload.slot_secret, secret);
strcpyT(payload.slot_name, slot_name);
+ strcpyT(payload.slot_token_id, token_ID);
payload.slot_interval = time_window; //FIXME naming
payload.use_8_digits = use_8_digits;
payload.use_enter = use_enter;
payload.use_tokenID = use_tokenID;
- payload.slot_token_id; //FIXME add slot token id to function headers
auto auth = get_payload<Authorize>();
strcpyT(auth.temporary_password, temporary_password);