10void TOTP(uint8_t* hmacKey, uint8_t keyLength, uint32_t timeStep) {
42 uint8_t _byteArray[8];
47 _byteArray[4] = (uint8_t)((steps >> 24) & 0xFF);
48 _byteArray[5] = (uint8_t)((steps >> 16) & 0xFF);
49 _byteArray[6] = (uint8_t)((steps >> 8) & 0XFF);
50 _byteArray[7] = (uint8_t)((steps & 0XFF));
58 uint32_t _truncatedHash = 0;
59 uint8_t _offset = _hash[20 - 1] & 0xF;
61 for (j = 0; j < 4; ++j) {
63 _truncatedHash |= _hash[_offset + j];
67 _truncatedHash &= 0x7FFFFFFF;
68 _truncatedHash %= 1000000;
70 return _truncatedHash;
void TOTP(uint8_t *hmacKey, uint8_t keyLength, uint32_t timeStep)
TOTP Object, main object for the code generator.
uint32_t getCodeFromSteps(uint32_t steps)
Accepts a number of steps for a HMAC based code, not used for this project From the TOTP library.
uint32_t getCodeFromTimestamp(uint32_t timeStamp)
Accepts a timestamp from uint32_t, returns the code in uint32_t.
uint32_t TimeStruct2Timestamp(struct tm time)
Accepts a time struct from struct tm, returns it as a timestamp.
uint32_t getCodeFromTimeStruct(struct tm time)
Accepts a timestamp from struct tm, returns the code in uint32_t, not used for the current project Fr...
void setTimezone(uint8_t timezone)
Set the timezone from UTC, Arizona is always -7, so this is what is hard encoded into main.
void writeArray(uint8_t *buffer, uint8_t size)
void initHmac(const uint8_t *key, uint8_t keyLength)
uint8_t * resultHmac(void)