-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtotp.hpp
35 lines (31 loc) · 831 Bytes
/
totp.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
* @file totp.hpp
* @author Kirill Tregubov (KirillTregubov)
* @author Philip Cai (Gadnalf)
* @copyright Copyright (c) 2022 Kirill Tregubov & Philip Cai
*
* @brief This header file exports TOTP validation.
* @bug No known bugs.
*/
#ifndef TOTP_H
#define TOTP_H
#include <assert.h>
#include <cstdint>
#include <mbed.h>
#include <ppp_opts.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SHA1_DIGEST_LENGTH 20
#define SHA1_BLOCKSIZE 64
/**
* @brief Validates a single TOTP value for a given secret at the device's
* current RTC time +-30.
*
* @param secret_hex The private secret as a hex string.
* @param TOTP_string The input TOTP value as a string.
* @return 1 if valid, 0 otherwise.
*/
int validate(const char *secret_hex, const char *TOTP_string);
#endif // TOTP_H