47 lines
913 B
C
47 lines
913 B
C
/*
|
|
* otpcli - command-line interface for HOTP and TOTP
|
|
* Written in 2020-2021 by Lucas
|
|
*
|
|
* To the extent possible under law, the author(s) have dedicated all
|
|
* copyright and related and neighboring rights to this software to the
|
|
* public domain worldwide. This software is distributed without any
|
|
* warranty.
|
|
*
|
|
* You should have received a copy of the CC0 Public Domain Dedication
|
|
* along with this software. If not, see
|
|
* <http://creativecommons.org/publicdomain/zero/1.0/>.
|
|
*/
|
|
|
|
#include <stdint.h>
|
|
|
|
enum otp_type {
|
|
OTP_HOTP,
|
|
OTP_TOTP,
|
|
};
|
|
|
|
enum otp_hmac {
|
|
OTP_HMAC_SHA1,
|
|
OTP_HMAC_SHA256,
|
|
OTP_HMAC_SHA512,
|
|
};
|
|
|
|
struct otpcfg {
|
|
enum otp_type type;
|
|
enum otp_hmac algorithm;
|
|
unsigned int digits;
|
|
const void *secret;
|
|
size_t secretlen;
|
|
|
|
union {
|
|
struct {
|
|
uint64_t counter;
|
|
} hotp;
|
|
struct {
|
|
uint64_t time;
|
|
unsigned int period;
|
|
} totp;
|
|
} u;
|
|
};
|
|
|
|
int32_t otp(const struct otpcfg *);
|