Working model finished

This commit is contained in:
2024-05-11 23:26:56 +05:30
commit 7ec4cca908
10 changed files with 580 additions and 0 deletions

40
include/rfc4226.h Normal file
View File

@@ -0,0 +1,40 @@
#ifndef RFC4226_H
#define RFC4226_H
#include <stdint.h>
#include <stdlib.h>
/*
* Interface API for this library.
*/
uint32_t HOTP(uint8_t* key, size_t kl, uint64_t interval, int digits);
/*
* Step 1 -> Calling hmac function from openssl
* library. It is used to create a 160-bit
* integer value which is processed further.
* It take a string key as an argument and
* a seed value for calculation.
* ->unsigned char* key -> key string
* ->uint64_t interval -> seed value
* |
* |
* -------> This seed value can be integer counter or
* timer value as an argument.
*/
uint8_t* hmac(unsigned char* key, int kl, uint64_t interval);
/*
*
* Step 2 -> This function will truncate some bits to produce
* a binary sequence of 32-bit. The 160-bit binary
* sequence should in big-endian binary format for
* processing.
*/
uint32_t DT(uint8_t* rawData);
#endif

16
include/rfc6238.h Normal file
View File

@@ -0,0 +1,16 @@
#ifndef RFC6238_H
#define RFC6238_H
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include "rfc4226.h"
#define TS 30 /* time step in seconds, default value */
uint32_t TOTP(uint8_t* key, size_t kl, uint64_t time, int digits);
time_t get_time(time_t T0);
#endif