SWE-350 TOTP Generator
Milestone 5
The DE-10 board has six 7-segment displays, this can be used to display and generate a time based one-time pin (TOTP).
Loading...
Searching...
No Matches
blink.c
Go to the documentation of this file.
1
#include <msp430.h>
2
#include <
totp.h
>
3
#include <stdint.h>
4
8
void
main
(
void
)
9
{
10
WDTCTL = WDTPW | WDTHOLD;
// stop watchdog timer
11
P1DIR |= 0x01;
// configure P1.0 as output
12
13
uint8_t hmacKey[] = {0x4d, 0x79, 0x4c, 0x65, 0x67, 0x6f, 0x44, 0x6f, 0x6f, 0x72};
// Secret key
14
TOTP
(hmacKey, 10, 7200);
// Secret key, Key length, Timestep (7200s - 2hours)
15
16
setTimezone
(9);
// Set timezone
17
uint32_t
newCode
=
getCodeFromTimestamp
(1557414000);
// Timestamp Now
18
20
// struct tm datetime;
21
// datetime.tm_hour = 9;
22
// datetime.tm_min = 0;
23
// datetime.tm_sec = 0;
24
// datetime.tm_mday = 13;
25
// datetime.tm_mon = 5;
26
// datetime.tm_year = 2019;
27
// uint32_t newCode = getCodeFromTimeStruct(datetime);
29
30
volatile
unsigned
int
i;
// volatile to prevent optimization
31
32
while
(1)
33
{
34
if
(
newCode
== 0){
// 0 = INPUT HERE
35
P1OUT ^= 0x01;
// toggle P1.0
36
}
37
for
(i=10000; i>0; i--);
// delay
38
}
39
}
TOTP
void TOTP(uint8_t *hmacKey, uint8_t keyLength, uint32_t timeStep)
TOTP Object, main object for the code generator.
Definition
TOTP.c:10
getCodeFromTimestamp
uint32_t getCodeFromTimestamp(uint32_t timeStamp)
Accepts a timestamp from uint32_t, returns the code in uint32_t.
Definition
TOTP.c:29
setTimezone
void setTimezone(uint8_t timezone)
Set the timezone from UTC, Arizona is always -7, so this is what is hard encoded into main.
Definition
TOTP.c:16
TOTP.h
main
void main(void)
Definition
blink.c:8
newCode
uint32_t newCode
Code as a byte array.
Definition
main.c:212
TOTP-MCU-master
blink.c
Generated by
1.12.0