aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzczepan Zalega <szczepan@nitrokey.com>2018-04-10 07:55:38 +0200
committerSzczepan Zalega <szczepan@nitrokey.com>2018-04-10 07:55:38 +0200
commit7f3d4ce81a0a38d9591dc4c746bcb75edfe80caa (patch)
treeff7646fe1c8861cfeeaba578cb1c453b62149706
parent090af48ee1c49c8655610c7b529b2ca256d9e8ae (diff)
downloadlibnitrokey-7f3d4ce81a0a38d9591dc4c746bcb75edfe80caa.tar.gz
libnitrokey-7f3d4ce81a0a38d9591dc4c746bcb75edfe80caa.tar.bz2
Name magic numbers in validation functions
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
-rw-r--r--libnitrokey/stick10_commands.h4
-rw-r--r--libnitrokey/stick10_commands_0.8.h4
2 files changed, 6 insertions, 2 deletions
diff --git a/libnitrokey/stick10_commands.h b/libnitrokey/stick10_commands.h
index 755b651..f2ffba2 100644
--- a/libnitrokey/stick10_commands.h
+++ b/libnitrokey/stick10_commands.h
@@ -389,7 +389,9 @@ class GetStatus : Command<CommandID::GET_STATUS> {
} __packed;
} __packed;
- bool isValid() const { return numlock < 2 && capslock < 2 && scrolllock < 2 && enable_user_password < 2; }
+ static constexpr uint8_t special_HOTP_slots = 2;
+ bool isValid() const { return numlock < special_HOTP_slots && capslock < special_HOTP_slots
+ && scrolllock < special_HOTP_slots && enable_user_password < 2; }
std::string get_card_serial_hex() const {
return nitrokey::misc::toHex(card_serial_u32);
diff --git a/libnitrokey/stick10_commands_0.8.h b/libnitrokey/stick10_commands_0.8.h
index 4614f16..9477890 100644
--- a/libnitrokey/stick10_commands_0.8.h
+++ b/libnitrokey/stick10_commands_0.8.h
@@ -322,7 +322,9 @@ namespace nitrokey {
};
uint8_t temporary_admin_password[25];
- bool isValid() const { return numlock < 2 && capslock < 2 && scrolllock < 2 && enable_user_password < 2; }
+ static constexpr uint8_t special_HOTP_slots = 3;
+ bool isValid() const { return numlock < special_HOTP_slots && capslock < special_HOTP_slots
+ && scrolllock < special_HOTP_slots && enable_user_password < 2; }
std::string dissect() const {
std::stringstream ss;