Merge counter and lastused.

To prevent replay attacks, HOTP uses a counter, while TOTP keeps track of the time the key was last used.  Since these values have the same type and are never used at the same time, merge them into an anonymous union.
This commit is contained in:
Dag-Erling Smørgrav 2018-11-15 18:17:35 +01:00
parent a439adc68f
commit 4d76b664d2
1 changed files with 4 additions and 2 deletions

View File

@ -47,9 +47,11 @@ typedef struct {
oath_mode mode;
oath_hash hash;
unsigned int digits;
uint64_t counter; /* HOTP only */
union {
uint64_t counter; /* HOTP */
uint64_t lastused; /* TOTP */
};
unsigned int timestep; /* TOTP only - in seconds */
uint64_t lastused; /* TOTP only */
/* housekeeping */
unsigned int dummy:1; /* dummy key, always fail */