API参考
载入中...
搜索中...
未找到
otp.h
1/*
2 * This file is part of the openHiTLS project.
3 *
4 * openHiTLS is licensed under the Mulan PSL v2.
5 * You can use this software according to the terms and conditions of the Mulan PSL v2.
6 * You may obtain a copy of Mulan PSL v2 at:
7 *
8 * http://license.coscl.org.cn/MulanPSL2
9 *
10 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
11 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
12 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
13 * See the Mulan PSL v2 for more details.
14 */
15
16#ifndef OTP_H
17#define OTP_H
18
19#include <stdint.h>
20#include "bsl_sal.h"
21#include "bsl_types.h"
22#include "auth_params.h"
23#include "auth_otp.h"
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29#define OTP_DEFAULT_DIGITS 6
30#define OTP_MIN_DIGITS 6
31#define OTP_MAX_DIGITS 8
32#define OTP_TOTP_DEFAULT_TIME_STEP_SIZE 30
33#define OTP_TOTP_DEFAULT_START_OFFSET 0
34#define OTP_TOTP_DEFAULT_VALID_WINDOW 1
35
36typedef struct {
40
41typedef struct {
42 uint32_t timeStepSize;
43 BslUnixTime startOffset;
44 uint32_t validWindow;
45} TotpCtx;
46
47/* Main context structure for OTP operations */
48struct Otp_Ctx {
49 CRYPT_EAL_LibCtx *libCtx; // Provider context
50 const char *attrName; // Provider attribute name
51 int32_t protocolType;
52 BSL_Buffer key;
53 uint32_t digits;
54 int32_t hashAlgId;
55 void *ctx; // Protocol-specific fields
56 OtpCryptCb method; // Cryptographic callbacks
57};
58
63OtpCryptCb OtpCryptDefaultCb(void);
64
65#ifdef __cplusplus
66}
67#endif
68
69#endif // OTP_H
Parameter identifiers for authentication control-style APIs.
int32_t(* HITLS_AUTH_OtpHmac)(void *libCtx, const char *attrName, int32_t algId, const uint8_t *key, uint32_t keyLen, const uint8_t *input, uint32_t inputLen, uint8_t *hmac, uint32_t *hmacLen)
Compute HMAC of the key and input data.
定义 auth_otp.h:85
int32_t(* HITLS_AUTH_OtpRandom)(uint8_t *buffer, uint32_t bufferLen)
Generate random bytes.
定义 auth_otp.h:99
int64_t BslUnixTime
Unix Time structure definition.
定义 bsl_sal.h:598
定义 bsl_types.h:40
定义 otp.h:36
定义 otp.h:48
定义 otp.h:41