From 9ebea46300bd1bc4e3ba51b1c7915e3ba42c471a Mon Sep 17 00:00:00 2001 From: EmilienCourt <emilien.court@telecomnancy.net> Date: Sat, 14 Jan 2023 17:58:03 +0100 Subject: totp : rework and add SHA256/512 (#151) * totp : rework and add SHA256/512 * totp : comment code * totp : fix SHA224/SHA384 and examples * totp : fix bug in totp_face_lfs * totp : init_totp_record to SHA1 * totp : move TOTP-MCU to TOTP, update README and example * totp : SHAX, use size_t n instead of harcoded 8 * clarify what to put in TOTP face Co-authored-by: Emilien <Emilien> Co-authored-by: joeycastillo <joeycastillo@utexas.edu> --- movement/lib/TOTP/example.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 movement/lib/TOTP/example.c (limited to 'movement/lib/TOTP/example.c') diff --git a/movement/lib/TOTP/example.c b/movement/lib/TOTP/example.c new file mode 100644 index 00000000..a218ff8b --- /dev/null +++ b/movement/lib/TOTP/example.c @@ -0,0 +1,27 @@ +#include "TOTP.h" +#include <stdio.h> + +/** + * example.c + */ +void main(void) +{ + uint8_t hmacKey[] = {0x4d, 0x79, 0x4c, 0x65, 0x67, 0x6f, 0x44, 0x6f, 0x6f, 0x72}; // Secret key + TOTP(hmacKey, 10, 7200, SHA1); // Secret key, Key length, Timestep (7200s - 2hours) + + setTimezone(9); // Set timezone + uint32_t newCode = getCodeFromTimestamp(1557414000); // Timestamp Now + + ///////////////// For struct tm ////////////////// + // struct tm datetime; + // datetime.tm_hour = 9; + // datetime.tm_min = 0; + // datetime.tm_sec = 0; + // datetime.tm_mday = 13; + // datetime.tm_mon = 5; + // datetime.tm_year = 2019; + // uint32_t newCode = getCodeFromTimeStruct(datetime); + /////////////////////////////////////////////////// + + printf("Code : %06u\n",newCode); +} -- cgit v1.2.3