20#include "bsl_params.h"
22#include "crypt_types.h"
36 HITLS_AUTH_OTP_HOTP = 1,
37 HITLS_AUTH_OTP_TOTP = 2,
42 HITLS_AUTH_OTP_SET_CTX_DIGITS = 1,
43 HITLS_AUTH_OTP_SET_CTX_HASHALGID = 2,
44 HITLS_AUTH_OTP_SET_CTX_TOTP_TIMESTEPSIZE = 3,
45 HITLS_AUTH_OTP_SET_CTX_TOTP_STARTOFFSET = 4,
46 HITLS_AUTH_OTP_SET_CTX_TOTP_VALIDWINDOW = 5,
47 HITLS_AUTH_OTP_GET_CTX_PROTOCOLTYPE = 6,
48 HITLS_AUTH_OTP_GET_CTX_KEY = 7,
49 HITLS_AUTH_OTP_GET_CTX_DIGITS = 8,
50 HITLS_AUTH_OTP_GET_CTX_HASHALGID = 9,
51 HITLS_AUTH_OTP_GET_CTX_TOTP_TIMESTEPSIZE = 10,
52 HITLS_AUTH_OTP_GET_CTX_TOTP_STARTOFFSET = 11,
53 HITLS_AUTH_OTP_GET_CTX_TOTP_VALIDWINDOW = 12,
58 HITLS_AUTH_OTP_CRYPTO_SHA1 = BSL_CID_HMAC_SHA1,
59 HITLS_AUTH_OTP_CRYPTO_SHA256 = BSL_CID_HMAC_SHA256,
60 HITLS_AUTH_OTP_CRYPTO_SHA512 = BSL_CID_HMAC_SHA512
61} HITLS_AUTH_OtpCryptAlgId;
64 HITLS_AUTH_OTP_RANDOM_CB = 1,
65 HITLS_AUTH_OTP_HMAC_CB = 2,
66} HITLS_AUTH_OtpCryptCbType;
85typedef int32_t (*
HITLS_AUTH_OtpHmac)(
void *libCtx,
const char *attrName, int32_t algId,
const uint8_t *key,
86 uint32_t keyLen,
const uint8_t *input, uint32_t inputLen, uint8_t *hmac,
int32_t HITLS_AUTH_OtpGen(HITLS_AUTH_OtpCtx *ctx, const BSL_Param *param, char *otp, uint32_t *otpLen)
Generate an OTP.
定义 otp.c:162
HITLS_AUTH_OtpCtx * HITLS_AUTH_ProviderOtpNewCtx(CRYPT_EAL_LibCtx *libCtx, int32_t protocolType, const char *attrName)
Create a new OTP context object with provider, all library callbacks by default are set when created.
定义 otp_util.c:234
int32_t HITLS_AUTH_OtpValidate(HITLS_AUTH_OtpCtx *ctx, const BSL_Param *param, const char *otp, const uint32_t otpLen, uint64_t *matched)
Validate the OTP.
定义 otp.c:236
void HITLS_AUTH_OtpFreeCtx(HITLS_AUTH_OtpCtx *ctx)
Free a OTP context object.
定义 otp_util.c:287
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_OtpInit(HITLS_AUTH_OtpCtx *ctx, uint8_t *key, uint32_t keyLen)
Set or generate a random OTP key.
定义 otp.c:28
int32_t HITLS_AUTH_OtpSetCryptCb(HITLS_AUTH_OtpCtx *ctx, int32_t cbType, void *cryptCb)
Set cryptographic callback functions for the context. When setting callbacks, the input callbacks wil...
定义 otp_util.c:307
int32_t(* HITLS_AUTH_OtpRandom)(uint8_t *buffer, uint32_t bufferLen)
Generate random bytes.
定义 auth_otp.h:99
HITLS_AUTH_OtpCtx * HITLS_AUTH_OtpNewCtx(int32_t protocolType)
Create a new OTP context object, all library callbacks by default are set when created.
定义 otp_util.c:230
int32_t HITLS_AUTH_OtpCtxCtrl(HITLS_AUTH_OtpCtx *ctx, int32_t cmd, void *param, uint32_t paramLen)
Control interface for getting/setting various parameters in OTP Ctx.
定义 otp_util.c:184
struct Otp_Ctx HITLS_AUTH_OtpCtx
定义 auth_otp.h:33