aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NitrokeyManager.cc22
-rw-r--r--include/NitrokeyManager.h7
-rw-r--r--include/stick10_commands.h38
3 files changed, 59 insertions, 8 deletions
diff --git a/NitrokeyManager.cc b/NitrokeyManager.cc
index 09a0def..b12895d 100644
--- a/NitrokeyManager.cc
+++ b/NitrokeyManager.cc
@@ -468,6 +468,7 @@ namespace nitrokey{
auto response = GetUserPasswordRetryCount::CommandTransaction::run(*device);
return response.data().password_retry_count;
}
+
uint8_t NitrokeyManager::get_admin_retry_count() {
if(device->get_device_model() == DeviceModel::STORAGE){
stick20::GetDeviceStatus::CommandTransaction::run(*device);
@@ -728,4 +729,23 @@ namespace nitrokey{
}
}
- }
+ uint32_t NitrokeyManager::get_TOTP_code(uint8_t slot_number, const char *user_temporary_password) {
+ return get_TOTP_code(slot_number, 0, 0, 0, user_temporary_password);
+ }
+
+ stick10::ReadSlot::ResponsePayload NitrokeyManager::get_OTP_slot_data(const uint8_t slot_number) {
+ auto p = get_payload<stick10::ReadSlot>();
+ p.slot_number = slot_number;
+ auto data = stick10::ReadSlot::CommandTransaction::run(*device, p);
+ return data.data();
+ }
+
+ stick10::ReadSlot::ResponsePayload NitrokeyManager::get_TOTP_slot_data(const uint8_t slot_number) {
+ return get_OTP_slot_data(get_internal_slot_number_for_totp(slot_number));
+ }
+
+ stick10::ReadSlot::ResponsePayload NitrokeyManager::get_HOTP_slot_data(const uint8_t slot_number) {
+ return get_OTP_slot_data(get_internal_slot_number_for_hotp(slot_number));
+ }
+
+}
diff --git a/include/NitrokeyManager.h b/include/NitrokeyManager.h
index c7d7704..03f1a86 100644
--- a/include/NitrokeyManager.h
+++ b/include/NitrokeyManager.h
@@ -32,6 +32,10 @@ namespace nitrokey {
uint32_t get_HOTP_code(uint8_t slot_number, const char *user_temporary_password);
uint32_t get_TOTP_code(uint8_t slot_number, uint64_t challenge, uint64_t last_totp_time, uint8_t last_interval,
const char *user_temporary_password);
+ uint32_t get_TOTP_code(uint8_t slot_number, const char *user_temporary_password);
+ stick10::ReadSlot::ResponsePayload get_TOTP_slot_data(const uint8_t slot_number);
+ stick10::ReadSlot::ResponsePayload get_HOTP_slot_data(const uint8_t slot_number);
+
bool set_time(uint64_t time);
bool get_time();
bool erase_totp_slot(uint8_t slot_number, const char *temporary_password);
@@ -127,7 +131,8 @@ namespace nitrokey {
static shared_ptr <NitrokeyManager> _instance;
std::shared_ptr<Device> device;
- bool is_valid_hotp_slot_number(uint8_t slot_number) const;
+ stick10::ReadSlot::ResponsePayload get_OTP_slot_data(const uint8_t slot_number);
+ bool is_valid_hotp_slot_number(uint8_t slot_number) const;
bool is_valid_totp_slot_number(uint8_t slot_number) const;
bool is_valid_password_safe_slot_number(uint8_t slot_number) const;
uint8_t get_internal_slot_number_for_hotp(uint8_t slot_number) const;
diff --git a/include/stick10_commands.h b/include/stick10_commands.h
index fb362fb..b66a9b4 100644
--- a/include/stick10_commands.h
+++ b/include/stick10_commands.h
@@ -293,18 +293,44 @@ class ReadSlot : Command<CommandID::READ_SLOT> {
struct ResponsePayload {
uint8_t slot_name[15];
- uint8_t config;
- uint8_t token_id[13];
- uint64_t counter;
+ union{
+ uint8_t _slot_config;
+ struct{
+ bool use_8_digits : 1;
+ bool use_enter : 1;
+ bool use_tokenID : 1;
+ };
+ };
+ union{
+ uint8_t slot_token_id[13]; /** OATH Token Identifier */
+ struct{ /** @see https://openauthentication.org/token-specs/ */
+ uint8_t omp[2];
+ uint8_t tt[2];
+ uint8_t mui[8];
+ uint8_t keyboard_layout; //disabled feature in nitroapp as of 20160805
+ } slot_token_fields;
+ };
+ union{
+ uint64_t slot_counter;
+ uint8_t slot_counter_s[8];
+ } __packed;
bool isValid() const { return true; }
std::string dissect() const {
std::stringstream ss;
ss << "slot_name:\t" << slot_name << std::endl;
- ss << "config:\t" << config << std::endl;
- ss << "token_id:\t" << token_id << std::endl;
- ss << "counter:\t" << counter << std::endl;
+ ss << "slot_config:\t" << std::bitset<8>((int)_slot_config) << std::endl;
+ ss << "\tuse_8_digits(0):\t" << use_8_digits << std::endl;
+ ss << "\tuse_enter(1):\t" << use_enter << std::endl;
+ ss << "\tuse_tokenID(2):\t" << use_tokenID << std::endl;
+
+ ss << "slot_token_id:\t";
+ for (auto i : slot_token_id)
+ ss << std::hex << std::setw(2) << std::setfill('0')<< (int) i << " " ;
+ ss << std::endl;
+ ss << "slot_counter:\t[" << (int)slot_counter << "]\t"
+ << ::nitrokey::misc::hexdump((const char *)(&slot_counter), sizeof slot_counter, false);
return ss.str();
}
} __packed;