The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
totp.h
Go to the documentation of this file.
1 #pragma once
2 /*
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or (at
6  * your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
16  */
17 
18 /**
19  * $Id: cb7c7d456fd857d1ec64f8175990083ada9e7c95 $
20  * @file lib/totp/base.h
21  * @brief Common functions for TOTP library
22  *
23  * @copyright 2023 The FreeRADIUS server project
24  */
25 RCSIDH(totp_h, "$Id: cb7c7d456fd857d1ec64f8175990083ada9e7c95 $")
26 
27 #include <freeradius-devel/server/request.h>
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 typedef struct {
34  uint32_t time_step; //!< seconds
35  uint32_t otp_length; //!< forced to 6 or 8
36  uint32_t lookback_steps; //!< number of steps to look back
37  uint32_t lookback_interval; //!< interval in seconds between steps
38  uint32_t lookforward_steps; //!< number of steps to look forwards
39 } fr_totp_t;
40 
41 int fr_totp_cmp(fr_totp_t const *cfg, request_t *request, time_t now, uint8_t const *key, size_t keylen, char const *totp) CC_HINT(nonnull(1,4,6));
42 
43 #ifdef __cplusplus
44 }
45 #endif
#define RCSIDH(h, id)
Definition: build.h:482
unsigned int uint32_t
Definition: merged_model.c:33
unsigned char uint8_t
Definition: merged_model.c:30
uint32_t otp_length
forced to 6 or 8
Definition: totp.h:35
uint32_t lookforward_steps
number of steps to look forwards
Definition: totp.h:38
uint32_t lookback_interval
interval in seconds between steps
Definition: totp.h:37
uint32_t lookback_steps
number of steps to look back
Definition: totp.h:36
int fr_totp_cmp(fr_totp_t const *cfg, request_t *request, time_t now, uint8_t const *key, size_t keylen, char const *totp))
Implement RFC 6238 TOTP algorithm (HMAC-SHA1).
Definition: totp.c:71
uint32_t time_step
seconds
Definition: totp.h:34
Definition: totp.h:33
int nonnull(2, 5))