summaryrefslogtreecommitdiff
path: root/NitrokeyManager.cc
diff options
context:
space:
mode:
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);