One-time password interfaces.
更多...
|
| typedef struct Otp_Ctx | HITLS_AUTH_OtpCtx |
| typedef 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.
|
| typedef int32_t(* | HITLS_AUTH_OtpRandom) (uint8_t *buffer, uint32_t bufferLen) |
| | Generate random bytes.
|
|
| HITLS_AUTH_OtpCtx * | HITLS_AUTH_OtpNewCtx (int32_t protocolType) |
| | Create a new OTP context object, all library callbacks by default are set when created.
|
| 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.
|
| void | HITLS_AUTH_OtpFreeCtx (HITLS_AUTH_OtpCtx *ctx) |
| | Free a OTP context object.
|
| 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 will be checked. Non-NULL callbacks will override the default callbacks.
|
| int32_t | HITLS_AUTH_OtpInit (HITLS_AUTH_OtpCtx *ctx, uint8_t *key, uint32_t keyLen) |
| | Set or generate a random OTP key.
|
| int32_t | HITLS_AUTH_OtpGen (HITLS_AUTH_OtpCtx *ctx, const BSL_Param *param, char *otp, uint32_t *otpLen) |
| | Generate an OTP.
|
| 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.
|
| 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.
|
One-time password interfaces.
◆ HITLS_AUTH_OtpCtx
◆ HITLS_AUTH_OtpHmac
| typedef 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.
- 参数
-
| libCtx | [IN] Library context. |
| attrName | [IN] Specify expected attribute values. |
| algId | [IN] Algorithm identifier, defined in HITLS_AUTH_OtpCryptAlgId. |
| key | [IN] Key used in HMAC. |
| keyLen | [IN] Length of key. |
| input | [IN] Input data used in HMAC. |
| inputLen | [IN] Length of input data. |
| digest | [OUT] Buffer to store the computed hmac. |
| digestLen | [IN/OUT] Size of hmac buffer/Length of computed hmac. |
- 返回值
-
| 0,if | successful. other error codes, failed. |
◆ HITLS_AUTH_OtpRandom
| typedef int32_t(* HITLS_AUTH_OtpRandom) (uint8_t *buffer, uint32_t bufferLen) |
Generate random bytes.
- 参数
-
| buffer | [IN] Buffer to store random bytes. |
| bufferLen | [IN] Length of buffer. |
- 返回值
-
| 0,if | successful. other error codes, failed. |
◆ HITLS_AUTH_OtpCtxCtrl()
| 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.
- 参数
-
| ctx | [IN] Otp context. |
| cmd | [IN] Command to execute, defined in HITLS_AUTH_OtpCmd. |
| param | [IN/OUT] Command parameters. |
| paramLen | [IN] Length of parameters. |
- 返回值
-
| #HITLS_AUTH_SUCCESS,if | successful. For other error codes, see auth_errno.h. |
◆ HITLS_AUTH_OtpFreeCtx()
Free a OTP context object.
- 参数
-
| ctx | [IN] Context to be freed. |
◆ HITLS_AUTH_OtpGen()
| int32_t HITLS_AUTH_OtpGen |
( |
HITLS_AUTH_OtpCtx * | ctx, |
|
|
const BSL_Param * | param, |
|
|
char * | otp, |
|
|
uint32_t * | otpLen ) |
Generate an OTP.
- 参数
-
| ctx | [IN] Otp context. |
| params | [IN] Params use in generate. |
| otp | [OUT] Buffer to store the OTP. |
| otpLen | [IN/OUT] Size of OTP buffer/Length of generated OTP. |
- 返回值
-
| #HITLS_AUTH_SUCCESS,if | successful. For other error codes, see auth_errno.h. |
◆ HITLS_AUTH_OtpInit()
| int32_t HITLS_AUTH_OtpInit |
( |
HITLS_AUTH_OtpCtx * | ctx, |
|
|
uint8_t * | key, |
|
|
uint32_t | keyLen ) |
Set or generate a random OTP key.
- 参数
-
| ctx | [IN/OUT] Otp context. |
| key | [IN] Key/Secret used in OTP. |
| keyLen | [IN] Length of key. |
- 返回值
-
| #HITLS_AUTH_SUCCESS,if | successful. For other error codes, see auth_errno.h. |
◆ HITLS_AUTH_OtpNewCtx()
Create a new OTP context object, all library callbacks by default are set when created.
- 参数
-
| protocolType | [IN] Type of protocol to use, defined in HITLS_AUTH_OtpType. |
- 返回值
-
◆ HITLS_AUTH_OtpSetCryptCb()
| 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 will be checked. Non-NULL callbacks will override the default callbacks.
- 参数
-
| ctx | [IN/OUT] Otp context. |
| cbType | [IN] Callback type, defined in HITLS_AUTH_OtpCryptCbType. |
| cryptCb | [IN] Callback functions to be set. |
- 返回值
-
| #HITLS_AUTH_SUCCESS,if | successful. For other error codes, see auth_errno.h. |
◆ HITLS_AUTH_OtpValidate()
| 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.
- 参数
-
| ctx | [IN] Otp context. |
| params | [IN] Params used in validate. |
| otp | [IN] OTP to validate. |
| otpLen | [IN] Length of OTP. |
| matched | [OUT] The moving factor (counter/time step) where the match was found, only valid when the validation is successful. This is useful for scenarios such as when a TOTP value should only be used once. This parameter can be NULL if you don't care about it. |
- 返回值
-
| #HITLS_AUTH_SUCCESS,if | successful. For other error codes, see auth_errno.h. |
◆ HITLS_AUTH_ProviderOtpNewCtx()
| 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.
- 参数
-
| libCtx | [IN] Library context |
| protocolType | [IN] Type of protocol to use, defined in HITLS_AUTH_OtpType. |
| attrName | [IN] Specify expected attribute values |
- 返回值
-