API参考
载入中...
搜索中...
未找到
Hitls_session

TLS session 更多...

Hitls_session 的协作图:

宏定义

#define HITLS_SESSION_ID_CTX_MAX_SIZE   32u
 Session id Maximum size of the CTX.
#define HITLS_SESSION_ID_MAX_SIZE   32u
 Maximum size of a session ID

类型定义

typedef int32_t(* HITLS_NewSessionCb) (HITLS_Ctx *ctx, HITLS_Session *session)
 This callback is called when a new session is negotiated. Users can use sessions.
typedef void(* HITLS_SessionRemoveCb) (HITLS_Config *config, HITLS_Session *sess)
 Remove a session.
typedef HITLS_Session *(* HITLS_SessionGetCb) (HITLS_Ctx *ctx, const uint8_t *data, int32_t len, int32_t *copy)
 Get a session based on the session ID.
typedef int32_t(* HITLS_SessionTicketExtProcessCb) (HITLS_Ctx *ctx, const uint8_t *data, int32_t len, void *arg)
 Session ticket extension callback.
typedef int32_t(* HITLS_TicketKeyCb) (uint8_t *keyName, uint32_t keyNameSize, HITLS_CipherParameters *cipher, uint8_t isEncrypt)
 Obtain and verify ticket_key on the server.

函数

int32_t HITLS_CFG_SetSessionTicketSupport (HITLS_Config *config, bool support)
 Set whether to support the session ticket function.
int32_t HITLS_CFG_GetSessionTicketSupport (const HITLS_Config *config, bool *isSupport)
 Query whether the session ticket function is supported.
int32_t HITLS_CFG_SetTicketNums (HITLS_Config *config, uint32_t ticketNums)
 Setting TLS1.3, number of new session tickets sent after a complete link is established.
uint32_t HITLS_CFG_GetTicketNums (HITLS_Config *config)
 Obtain TLS1.3, number of new session tickets sent after complete link establishment.
int32_t HITLS_SetTicketNums (HITLS_Ctx *ctx, uint32_t ticketNums)
 Setting TLS1.3, number of new session tickets sent after complete link establishment
uint32_t HITLS_GetTicketNums (HITLS_Ctx *ctx)
 Obtain TLS1.3, Number of new session tickets sent after complete link establishment.
int32_t HITLS_CFG_SetNewSessionCb (HITLS_Config *config, const HITLS_NewSessionCb newSessionCb)
 Set a callback for negotiating a new session call.
int32_t HITLS_CFG_SetSessionGetCb (HITLS_Config *config, const HITLS_SessionGetCb sessionGetCb)
 Set a callback for obtaining a session based on the session ID.
int32_t HITLS_CFG_SetSessionRemoveCb (HITLS_Config *config, const HITLS_SessionRemoveCb sessionRemoveCb)
 Set a callback for removing a session.
int32_t HITLS_SetSessionTicketExtProcessCb (HITLS_Ctx *ctx, const HITLS_SessionTicketExtProcessCb sessionTicketExtCb, void *arg)
 Set a callback for processing the session ticket extension.
int32_t HITLS_SetSessionTicketExtData (HITLS_Ctx *ctx, uint8_t *data, uint32_t dataSize)
 Set the session ticket extension data.
int32_t HITLS_CFG_SetTicketKeyCallback (HITLS_Config *config, HITLS_TicketKeyCb callback)
 Set the ticket key callback, which is used only by the server, cb can be NULL.
int32_t HITLS_CFG_GetSessionTicketKey (const HITLS_Config *config, uint8_t *key, uint32_t keySize, uint32_t *outSize)
 Obtain the default ticket key of the HiTLS. The key is used to encrypt and decrypt the ticket in the new session ticket when the HITLS_TicketKeyCb callback function is not set.
int32_t HITLS_CFG_SetSessionTicketKey (HITLS_Config *config, const uint8_t *key, uint32_t keySize)
 Set the default ticket key of the HiTLS. The key is used to encrypt and decrypt tickets in the new session ticket when the HITLS_TicketKeyCb callback function is not set.
int32_t HITLS_CFG_SetSessionIdCtx (HITLS_Config *config, const uint8_t *sessionIdCtx, uint32_t len)
 Set the user-specific session ID ctx, only on the server.
int32_t HITLS_CFG_SetSessionCacheMode (HITLS_Config *config, uint32_t mode)
 Set the session cache mode.
int32_t HITLS_CFG_GetSessionCacheMode (HITLS_Config *config, uint32_t *mode)
 Obtain the session cache mode.
int32_t HITLS_CFG_SetSessionCacheSize (HITLS_Config *config, uint32_t size)
 Set the maximum number of sessions in the session cache.
int32_t HITLS_CFG_GetSessionCacheSize (HITLS_Config *config, uint32_t *size)
 Obtain the maximum number of sessions in the session cache.
int32_t HITLS_CFG_SetSessionTimeout (HITLS_Config *config, uint64_t timeout)
 Set the session timeout interval.
int32_t HITLS_CFG_GetSessionTimeout (const HITLS_Config *config, uint64_t *timeout)
 Obtain the timeout interval of a session.
int32_t HITLS_IsSessionReused (HITLS_Ctx *ctx, bool *isReused)
 Whether the link is multiplexed with a session
int32_t HITLS_SetSessionIdCtx (HITLS_Ctx *ctx, const uint8_t *sessionIdCtx, uint32_t len)
 Set the user-specific session ID ctx of the HiTLS link, only on the server.
int32_t HITLS_GetSessionTicketKey (const HITLS_Ctx *ctx, uint8_t *key, uint32_t keySize, uint32_t *outSize)
 Obtain the default ticket key of the HiTLS. The key is used to encrypt and decrypt the ticket in the new session ticket when the HITLS_TicketKeyCb callback function is not set.
int32_t HITLS_SetSessionTicketKey (HITLS_Ctx *ctx, const uint8_t *key, uint32_t keySize)
 Set the default ticket key of the HiTLS. The key is used to encrypt and decrypt the ticket in the new session ticket when the HITLS_TicketKeyCb callback function is not set.
int32_t HITLS_SetSession (HITLS_Ctx *ctx, HITLS_Session *session)
 Set the handle for the session information about the HiTLS link.
HITLS_Session * HITLS_GetSession (const HITLS_Ctx *ctx)
 Obtain the handle of the session information and directly obtain the pointer.
HITLS_Session * HITLS_GetDupSession (HITLS_Ctx *ctx)
 Obtain the handle of the copied session information.
HITLS_Session * HITLS_SESS_New (void)
 Apply for a new session.
HITLS_Session * HITLS_SESS_Dup (HITLS_Session *sess)
 Duplicate a session, the number of reference times increases by 1.
void HITLS_SESS_Free (HITLS_Session *sess)
 Release the session information handle.
int32_t HITLS_SESS_SetMasterKey (HITLS_Session *sess, const uint8_t *masterKey, uint32_t masterKeySize)
 Set the master key of a session.
uint32_t HITLS_SESS_GetMasterKeyLen (const HITLS_Session *sess)
 Obtain the master key length of a session.
int32_t HITLS_SESS_GetMasterKey (const HITLS_Session *sess, uint8_t *masterKey, uint32_t *masterKeySize)
 Obtain the master key of a session.
int32_t HITLS_SESS_GetProtocolVersion (const HITLS_Session *sess, uint16_t *version)
 Obtain the session protocol version.
int32_t HITLS_SESS_SetProtocolVersion (HITLS_Session *sess, uint16_t version)
 Set the session protocol version.
int32_t HITLS_SESS_SetCipherSuite (HITLS_Session *sess, uint16_t cipherSuite)
 Set the session password suite.
int32_t HITLS_SESS_GetCipherSuite (const HITLS_Session *sess, uint16_t *cipherSuite)
 Obtain the session password suite.
int32_t HITLS_SESS_SetSessionIdCtx (HITLS_Session *sess, uint8_t *sessionIdCtx, uint32_t sessionIdCtxSize)
 Set the session ID ctx.
int32_t HITLS_SESS_GetSessionIdCtx (const HITLS_Session *sess, uint8_t *sessionIdCtx, uint32_t *sessionIdCtxSize)
 Obtain the session ID ctx.
int32_t HITLS_SESS_SetSessionId (HITLS_Session *sess, uint8_t *sessionId, uint32_t sessionIdSize)
 Set the session ID.
int32_t HITLS_SESS_GetSessionId (const HITLS_Session *sess, uint8_t *sessionId, uint32_t *sessionIdSize)
 Obtain the session ID.
int32_t HITLS_SESS_SetHaveExtMasterSecret (HITLS_Session *sess, uint8_t haveExtMasterSecret)
 Set whether to contain the master key extension.
int32_t HITLS_SESS_GetHaveExtMasterSecret (HITLS_Session *sess, bool *haveExtMasterSecret)
 Obtain the master key extension.
int32_t HITLS_SESS_SetTimeout (HITLS_Session *sess, uint64_t timeout)
 Set the timeout interval, in seconds.
uint64_t HITLS_SESS_GetTimeout (HITLS_Session *sess)
 Get the timeout interval, in seconds.
bool HITLS_SESS_IsResumable (const HITLS_Session *sess)
 Check whether the session can be recovered. Only simple check is performed, but the validity period is not checked.
bool HITLS_SESS_HasTicket (const HITLS_Session *sess)
 Check whether the session has a ticket.
void * HITLS_SESS_GetUserData (const HITLS_Session *sess)
 Obtain the user data in the session object.
int32_t HITLS_SESS_SetUserData (HITLS_Session *sess, void *userData)
 Set the user data in the session object.
int32_t HITLS_CFG_ClearTimeoutSession (HITLS_Config *config, uint64_t nowTime)
 Clear the timeout session.
int32_t HITLS_CFG_RemoveSession (HITLS_Config *config, HITLS_Session *sess)
 Remove the session.

详细描述

TLS session

类型定义说明

◆ HITLS_NewSessionCb

typedef int32_t(* HITLS_NewSessionCb) (HITLS_Ctx *ctx, HITLS_Session *session)

This callback is called when a new session is negotiated. Users can use sessions.

参数
ctx[IN] ctx context
session[IN] Session handle
返回值
1Success. If a user removes a session, the user needs to release the session handle.
0failed. The user does not use the session.

◆ HITLS_SessionGetCb

typedef HITLS_Session *(* HITLS_SessionGetCb) (HITLS_Ctx *ctx, const uint8_t *data, int32_t len, int32_t *copy)

Get a session based on the session ID.

参数
ctx[IN] Context
data[IN] Session ID data
len[IN] Session ID length
copy[OUT] Whether to copy the session. 1: copy; 0: do not copy
返回值
Sessionhandle, if successful. NULL, if failure.

◆ HITLS_SessionRemoveCb

typedef void(* HITLS_SessionRemoveCb) (HITLS_Config *config, HITLS_Session *sess)

Remove a session.

参数
ctx[IN] Context
sess[IN] Session

◆ HITLS_SessionTicketExtProcessCb

typedef int32_t(* HITLS_SessionTicketExtProcessCb) (HITLS_Ctx *ctx, const uint8_t *data, int32_t len, void *arg)

Session ticket extension callback.

参数
ctx[IN] ctx context
data[IN] Session ticket extension data
len[IN] Session ticket extension data length
arg[IN] User-defined parameter
返回值
1,ifsuccessful.
Forother error codes, see hitls_error.h

◆ HITLS_TicketKeyCb

typedef int32_t(* HITLS_TicketKeyCb) (uint8_t *keyName, uint32_t keyNameSize, HITLS_CipherParameters *cipher, uint8_t isEncrypt)

Obtain and verify ticket_key on the server.

注意
keyName is fixed at 16 bytes, and iv is fixed at 16 bytes. During encryption, the keyName and cipher need to be returned. The encryption type, encryption algorithm, key, iv, and hmacKey need to be filled in. During decryption, the HiTLS transfers the keyName. The user needs to find the corresponding key based on the keyName and return the corresponding encryption type, encryption algorithm, and key. (HiTLS uses the iv value sent by the client, so the iv value does not need to be returned.)
参数
keyName[IN/OUT] name values corresponding to aes_key and hmac_key
keyNameSize[IN] length of keyName
cipher[IN/OUT] Encryption information
isEncrypt[IN] Indicates whether to encrypt data. true: encrypt data. false: decrypt data.
返回
TICKET_KEY_RET_NEED_ALERT : indicates that the function fails to be called. A fatal error occurs. An alert message needs to be sent. TICKET_KEY_RET_FAIL : During encryption, the failure to obtain the key_name is not a fatal error. In this case, the HiTLS sends an empty new session ticket message to the client.During decryption, the key_name matching fails, but it is not a fatal error. If the return value is the same, the HiTLS performs a complete handshake process or uses the session ID to restore the session. TICKET_KEY_RET_SUCCESS : indicates that the encryption is successful. Decryption succeeds. TICKET_KEY_RET_SUCCESS_RENEW : indicates that the encryption is successful. The value is the same as the returned value TICKET_KEY_RET_SUCCESS. If the decryption succeeds and the ticket needs to be renewed or changed, the HiTLS calls the callback again to encrypt the ticket when sending a new session ticket.

函数说明

◆ HITLS_CFG_ClearTimeoutSession()

int32_t HITLS_CFG_ClearTimeoutSession ( HITLS_Config * config,
uint64_t nowTime )

Clear the timeout session.

参数
config[IN] Configuration handle.
nowTime[IN] Current time.
返回值
HITLS_SUCCESS,ifsuccessful.
Forother error codes, see hitls_error.h.

◆ HITLS_CFG_GetSessionCacheMode()

int32_t HITLS_CFG_GetSessionCacheMode ( HITLS_Config * config,
uint32_t * mode )

Obtain the session cache mode.

参数
config[IN] config Context.
mode[OUT] Cache mode, corresponding to the HITLS_SESS_CACHE_MODE enumerated value.
返回
HITLS_SUCCESS, if successful. For details about other error codes, see hitls_error.h.

◆ HITLS_CFG_GetSessionCacheSize()

int32_t HITLS_CFG_GetSessionCacheSize ( HITLS_Config * config,
uint32_t * size )

Obtain the maximum number of sessions in the session cache.

参数
config[IN] Config context.
size[OUT] Maximum number of sessions in the cache.
返回
HITLS_SUCCESS, if successful. For details about other error codes, see hitls_error.h.

◆ HITLS_CFG_GetSessionTicketKey()

int32_t HITLS_CFG_GetSessionTicketKey ( const HITLS_Config * config,
uint8_t * key,
uint32_t keySize,
uint32_t * outSize )

Obtain the default ticket key of the HiTLS. The key is used to encrypt and decrypt the ticket in the new session ticket when the HITLS_TicketKeyCb callback function is not set.

注意
The returned key value is as follows: 16-byte key name + 32-byte AES key + 32-byte HMAC key
参数
config[IN] Config Context.
key[OUT] Obtained ticket key.
keySize[IN] Size of the key array.
outSize[OUT] Size of the obtained ticket key.
返回值
HITLS_SUCCESS,ifsuccessful.
Forother error codes, see hitls_error.h.

◆ HITLS_CFG_GetSessionTicketSupport()

int32_t HITLS_CFG_GetSessionTicketSupport ( const HITLS_Config * config,
bool * isSupport )

Query whether the session ticket function is supported.

参数
config[IN] Config handle
isSupport[OUT] Whether to support the session ticket.
返回值
HITLS_SUCCESS,ifsuccessful.
HITLS_NULL_INPUT,configis null.

◆ HITLS_CFG_GetSessionTimeout()

int32_t HITLS_CFG_GetSessionTimeout ( const HITLS_Config * config,
uint64_t * timeout )

Obtain the timeout interval of a session.

参数
config[IN] Config context.
timeout[OUT] Session timeout interval, in seconds.
返回
HITLS_SUCCESS, if successful. For details about other error codes, see hitls_error.h.

◆ HITLS_CFG_GetTicketNums()

uint32_t HITLS_CFG_GetTicketNums ( HITLS_Config * config)

Obtain TLS1.3, number of new session tickets sent after complete link establishment.

参数
config[IN] config handle
返回
Number of tickets.

◆ HITLS_CFG_RemoveSession()

int32_t HITLS_CFG_RemoveSession ( HITLS_Config * config,
HITLS_Session * sess )

Remove the session.

参数
config[IN] Configuration handle.
sess[IN] Session information handle.
返回值
HITLS_SUCCESS,ifsuccessful.
Forother error codes, see hitls_error.h.

◆ HITLS_CFG_SetNewSessionCb()

int32_t HITLS_CFG_SetNewSessionCb ( HITLS_Config * config,
const HITLS_NewSessionCb newSessionCb )

Set a callback for negotiating a new session call.

参数
config[OUT] config handle
newSessionCb[IN] Callback.
返回值
HITLS_SUCCESS,ifsuccessful.
HITLS_NULL_INPUT,configis null.

◆ HITLS_CFG_SetSessionCacheMode()

int32_t HITLS_CFG_SetSessionCacheMode ( HITLS_Config * config,
uint32_t mode )

Set the session cache mode.

参数
config[OUT] Config context.
mode[IN] Cache mode, corresponding to the HITLS_SESS_CACHE_MODE enumerated value.
返回
HITLS_SUCCESS, if successful. For details about other error codes, see hitls_error.h.

◆ HITLS_CFG_SetSessionCacheSize()

int32_t HITLS_CFG_SetSessionCacheSize ( HITLS_Config * config,
uint32_t size )

Set the maximum number of sessions in the session cache.

参数
config[OUT] Config context.
size[IN] Maximum number of sessions in the cache.
返回
HITLS_SUCCESS, if successful. For details about other error codes, see hitls_error.h.

◆ HITLS_CFG_SetSessionGetCb()

int32_t HITLS_CFG_SetSessionGetCb ( HITLS_Config * config,
const HITLS_SessionGetCb sessionGetCb )

Set a callback for obtaining a session based on the session ID.

参数
config[OUT] config handle
sessionGetCb[IN] Callback.
返回值
HITLS_SUCCESS,ifsuccessful.
HITLS_NULL_INPUT,configis null.

◆ HITLS_CFG_SetSessionIdCtx()

int32_t HITLS_CFG_SetSessionIdCtx ( HITLS_Config * config,
const uint8_t * sessionIdCtx,
uint32_t len )

Set the user-specific session ID ctx, only on the server.

注意
session id ctx is different from session id, session recovery can be performed only after session id ctx matching.
参数
config[OUT] Config context.
sessionIdCtx[IN] Session ID Context.
len[IN] Session id context length, a maximum of 32 bytes.
返回
HITLS_SUCCESS, if successful. For other error codes, see hitls_error.h.

◆ HITLS_CFG_SetSessionRemoveCb()

int32_t HITLS_CFG_SetSessionRemoveCb ( HITLS_Config * config,
const HITLS_SessionRemoveCb sessionRemoveCb )

Set a callback for removing a session.

参数
config[OUT] config handle
sessionRemoveCb[IN] Callback.
返回值
HITLS_SUCCESS,ifsuccessful.
HITLS_NULL_INPUT,configis null.

◆ HITLS_CFG_SetSessionTicketKey()

int32_t HITLS_CFG_SetSessionTicketKey ( HITLS_Config * config,
const uint8_t * key,
uint32_t keySize )

Set the default ticket key of the HiTLS. The key is used to encrypt and decrypt tickets in the new session ticket when the HITLS_TicketKeyCb callback function is not set.

注意
The returned key value is as follows: 16-byte key name + 32-byte AES key + 32-byte HMAC key
参数
config[OUT] Config Context.
key[IN] Ticket key to be set.
keySize[IN] Size of the ticket key.
返回值
HITLS_SUCCESS,ifsuccessful.
Forother error codes, see hitls_error.h.

◆ HITLS_CFG_SetSessionTicketSupport()

int32_t HITLS_CFG_SetSessionTicketSupport ( HITLS_Config * config,
bool support )

Set whether to support the session ticket function.

参数
config[OUT] Config handle
support[IN] Whether to support the session ticket. The options are as follows: true: yes; false: no.
返回值
HITLS_SUCCESS,ifsuccessful.
HITLS_NULL_INPUT,configis null.

◆ HITLS_CFG_SetSessionTimeout()

int32_t HITLS_CFG_SetSessionTimeout ( HITLS_Config * config,
uint64_t timeout )

Set the session timeout interval.

参数
config[OUT] Config context.
timeout[IN] Session timeout interval, in seconds.
返回
HITLS_SUCCESS, if successful. For details about other error codes, see hitls_error.h.

◆ HITLS_CFG_SetTicketKeyCallback()

int32_t HITLS_CFG_SetTicketKeyCallback ( HITLS_Config * config,
HITLS_TicketKeyCb callback )

Set the ticket key callback, which is used only by the server, cb can be NULL.

参数
config[OUT] Config Context
callback[IN] Ticket key callback
返回
HITLS_SUCCESS, if successful. For details about other error codes, see hitls_error.h.

◆ HITLS_CFG_SetTicketNums()

int32_t HITLS_CFG_SetTicketNums ( HITLS_Config * config,
uint32_t ticketNums )

Setting TLS1.3, number of new session tickets sent after a complete link is established.

This interface should be called before handshake. The default number is 2. If the number is greater than or equal to 1, only one ticket is sent after the session is resumed. When this parameter is set to 0, the ticket is not sent for the complete handshake and session resumption.

参数
config[OUT] Config handle
ticketNums[IN] Number of new session tickets sent.
返回值
HITLS_SUCCESS,ifsuccessful.
HITLS_NULL_INPUT,configis empty.

◆ HITLS_GetDupSession()

HITLS_Session * HITLS_GetDupSession ( HITLS_Ctx * ctx)

Obtain the handle of the copied session information.

注意
The number of times that the call is called increases by 1. The call is released by calling HITLS_SESS_Free.
参数
ctx[IN] TLS connection handle
返回
Session information handle

◆ HITLS_GetSession()

HITLS_Session * HITLS_GetSession ( const HITLS_Ctx * ctx)

Obtain the handle of the session information and directly obtain the pointer.

注意
Directly obtain the pointer. Ensure that the invoking is correct and avoid the pointer being a wild pointer.
参数
ctx[IN] TLS connection handle
返回
Session information handle

◆ HITLS_GetSessionTicketKey()

int32_t HITLS_GetSessionTicketKey ( const HITLS_Ctx * ctx,
uint8_t * key,
uint32_t keySize,
uint32_t * outSize )

Obtain the default ticket key of the HiTLS. The key is used to encrypt and decrypt the ticket in the new session ticket when the HITLS_TicketKeyCb callback function is not set.

注意
The returned key value is as follows: 16-byte key name + 32-byte AES key + 32-byte HMAC key
参数
ctx[OUT] TLS connection handle
key[OUT] Obtained ticket key
keySize[IN] Size of the key array
outSize[OUT] Size of the obtained ticket key.
返回值
HITLS_SUCCESS,ifsuccessful.
Forother error codes, see hitls_error.h.

◆ HITLS_GetTicketNums()

uint32_t HITLS_GetTicketNums ( HITLS_Ctx * ctx)

Obtain TLS1.3, Number of new session tickets sent after complete link establishment.

参数
ctx[IN] ctx context
返回
Number of tickets.

◆ HITLS_IsSessionReused()

int32_t HITLS_IsSessionReused ( HITLS_Ctx * ctx,
bool * isReused )

Whether the link is multiplexed with a session

参数
ctx[IN] config Context.
isReused[OUT] Indicates whether to reuse a session.
返回
HITLS_SUCCESS, if successful. For details about other error codes, see hitls_error.h.

◆ HITLS_SESS_Dup()

HITLS_Session * HITLS_SESS_Dup ( HITLS_Session * sess)

Duplicate a session, the number of reference times increases by 1.

参数
sess[IN] Session information handle
返回
Session handle.

◆ HITLS_SESS_Free()

void HITLS_SESS_Free ( HITLS_Session * sess)

Release the session information handle.

参数
sess[IN] Session information handle
返回值
void

◆ HITLS_SESS_GetCipherSuite()

int32_t HITLS_SESS_GetCipherSuite ( const HITLS_Session * sess,
uint16_t * cipherSuite )

Obtain the session password suite.

参数
sess[IN] Session information handle.
cipherSuite[OUT] Cipher suite.
返回值
HITLS_SUCCESS,ifsuccessful.
Forother error codes, see hitls_error.h.

◆ HITLS_SESS_GetHaveExtMasterSecret()

int32_t HITLS_SESS_GetHaveExtMasterSecret ( HITLS_Session * sess,
bool * haveExtMasterSecret )

Obtain the master key extension.

参数
sess[IN] Session information handle.
haveExtMasterSecret[OUT] Whether the master key extension is contained.
返回值
HITLS_SUCCESS,ifsuccessful.
Forother error codes, see hitls_error.h.

◆ HITLS_SESS_GetMasterKey()

int32_t HITLS_SESS_GetMasterKey ( const HITLS_Session * sess,
uint8_t * masterKey,
uint32_t * masterKeySize )

Obtain the master key of a session.

参数
sess[IN] Session information handle.
masterKey[OUT] Master key.
masterKeySize[OUT] Size of the master key.
返回值
HITLS_SUCCESS,ifsuccessful.
Forother error codes, see hitls_error.h.

◆ HITLS_SESS_GetMasterKeyLen()

uint32_t HITLS_SESS_GetMasterKeyLen ( const HITLS_Session * sess)

Obtain the master key length of a session.

参数
sess[IN] Session information handle
返回
Size of the master key

◆ HITLS_SESS_GetProtocolVersion()

int32_t HITLS_SESS_GetProtocolVersion ( const HITLS_Session * sess,
uint16_t * version )

Obtain the session protocol version.

参数
sess[IN] Session information handle.
version[OUT] Protocol version.
返回值
HITLS_SUCCESS,ifsuccessful.
Forother error codes, see hitls_error.h.

◆ HITLS_SESS_GetSessionId()

int32_t HITLS_SESS_GetSessionId ( const HITLS_Session * sess,
uint8_t * sessionId,
uint32_t * sessionIdSize )

Obtain the session ID.

参数
sess[IN] Session information handle
sessionId[OUT] Session id
sessionIdSize[OUT] Session ID length
返回值
HITLS_SUCCESS,ifsuccessful.
Forother error codes, see hitls_error.h.

◆ HITLS_SESS_GetSessionIdCtx()

int32_t HITLS_SESS_GetSessionIdCtx ( const HITLS_Session * sess,
uint8_t * sessionIdCtx,
uint32_t * sessionIdCtxSize )

Obtain the session ID ctx.

参数
sess[IN] Session information handle.
sessionIdCtx[OUT] Session ID Context.
sessionIdCtxSize[OUT] Session id Context length.
返回值
HITLS_SUCCESS,ifsuccessful.
Forother error codes, see hitls_error.h.

◆ HITLS_SESS_GetTimeout()

uint64_t HITLS_SESS_GetTimeout ( HITLS_Session * sess)

Get the timeout interval, in seconds.

参数
sess[OUT] Session information handle
返回值
HITLS_SUCCESS,ifsuccessful.
Forother error codes, see hitls_error.h.

◆ HITLS_SESS_GetUserData()

void * HITLS_SESS_GetUserData ( const HITLS_Session * sess)

Obtain the user data in the session object.

参数
sess[IN] Pointer to the HITLS session to be printed.
返回
HITLS_NULL_INPUT, the TLS object pointer of the input parameter is null.

◆ HITLS_SESS_HasTicket()

bool HITLS_SESS_HasTicket ( const HITLS_Session * sess)

Check whether the session has a ticket.

参数
sess[IN] Session information handle
返回
Indicates whether a ticket exists.

◆ HITLS_SESS_IsResumable()

bool HITLS_SESS_IsResumable ( const HITLS_Session * sess)

Check whether the session can be recovered. Only simple check is performed, but the validity period is not checked.

参数
sess[IN] Session information handle.
返回
Indicates whether the recovery can be performed.

◆ HITLS_SESS_New()

HITLS_Session * HITLS_SESS_New ( void )

Apply for a new session.

参数
void
返回
Session handle.

◆ HITLS_SESS_SetCipherSuite()

int32_t HITLS_SESS_SetCipherSuite ( HITLS_Session * sess,
uint16_t cipherSuite )

Set the session password suite.

参数
sess[OUT] Session information handle.
cipherSuite[IN] Password suite.
返回值
HITLS_SUCCESS,ifsuccessful.
Forother error codes, see hitls_error.h.

◆ HITLS_SESS_SetHaveExtMasterSecret()

int32_t HITLS_SESS_SetHaveExtMasterSecret ( HITLS_Session * sess,
uint8_t haveExtMasterSecret )

Set whether to contain the master key extension.

参数
sess[OUT] Session information handle.
haveExtMasterSecret[IN] Whether the master key extension is include.
返回值
HITLS_SUCCESS,ifsuccessful.
Forother error codes, see hitls_error.h.

◆ HITLS_SESS_SetMasterKey()

int32_t HITLS_SESS_SetMasterKey ( HITLS_Session * sess,
const uint8_t * masterKey,
uint32_t masterKeySize )

Set the master key of a session.

参数
sess[OUT] Session information handle.
masterKey[IN] Master key.
masterKeySize[IN] Size of the master key.
返回值
HITLS_SUCCESS,ifsuccessful.
Forother error codes, see hitls_error.h.

◆ HITLS_SESS_SetProtocolVersion()

int32_t HITLS_SESS_SetProtocolVersion ( HITLS_Session * sess,
uint16_t version )

Set the session protocol version.

参数
sess[OUT] Session information handle
version[IN] Protocol version
返回值
HITLS_SUCCESS,ifsuccessful.
Forother error codes, see hitls_error.h.

◆ HITLS_SESS_SetSessionId()

int32_t HITLS_SESS_SetSessionId ( HITLS_Session * sess,
uint8_t * sessionId,
uint32_t sessionIdSize )

Set the session ID.

参数
sess[OUT] Session information handle.
sessionId[IN] Session id.
sessionIdSize[IN] The session ID contains a maximum of 32 bytes.
返回值
HITLS_SUCCESS,ifsuccessful.
Forother error codes, see hitls_error.h.

◆ HITLS_SESS_SetSessionIdCtx()

int32_t HITLS_SESS_SetSessionIdCtx ( HITLS_Session * sess,
uint8_t * sessionIdCtx,
uint32_t sessionIdCtxSize )

Set the session ID ctx.

参数
sess[OUT] Session information handle.
sessionIdCtx[IN] Session ID Context.
sessionIdCtxSize[IN] Session ID Context length. The maximum length is 32 bytes.
返回值
HITLS_SUCCESS,ifsuccessful.
Forother error codes, see hitls_error.h.

◆ HITLS_SESS_SetTimeout()

int32_t HITLS_SESS_SetTimeout ( HITLS_Session * sess,
uint64_t timeout )

Set the timeout interval, in seconds.

参数
sess[OUT] Session information handle
timeout[IN] Timeout interval, in seconds.
返回值
HITLS_SUCCESS,ifsuccessful.
Forother error codes, see hitls_error.h.

◆ HITLS_SESS_SetUserData()

int32_t HITLS_SESS_SetUserData ( HITLS_Session * sess,
void * userData )

Set the user data in the session object.

参数
userData[IN] Pointer to the user data.
sess[IN] Pointer to the HITLS session to be printed.
返回值
HITLS_SUCCESSif successful.
Forother error codes, see hitls_error.h.

◆ HITLS_SetSession()

int32_t HITLS_SetSession ( HITLS_Ctx * ctx,
HITLS_Session * session )

Set the handle for the session information about the HiTLS link.

注意
Used only by the client.
参数
ctx[OUT] TLS connection handle
session[IN] Session information handle.
返回值
HITLS_SUCCESS,ifsuccessful.
Forother error codes, see hitls_error.h.

◆ HITLS_SetSessionIdCtx()

int32_t HITLS_SetSessionIdCtx ( HITLS_Ctx * ctx,
const uint8_t * sessionIdCtx,
uint32_t len )

Set the user-specific session ID ctx of the HiTLS link, only on the server.

注意
session id ctx is different from sessio id, session recovery can be performed only after session id ctx matching.
参数
ctx[OUT] Config context.
sessionIdCtx[IN] Session ID Context.
len[IN] Session ID context length, which cannot exceed 32 bytes.
返回
HITLS_SUCCESS, if successful. For details about other error codes, see hitls_error.h.

◆ HITLS_SetSessionTicketExtData()

int32_t HITLS_SetSessionTicketExtData ( HITLS_Ctx * ctx,
uint8_t * data,
uint32_t dataSize )

Set the session ticket extension data.

参数
ctx[OUT] config handle
data[IN] Session ticket extension data.
dataSize[IN] Size of the session ticket extension data.
返回值
HITLS_SUCCESS,ifsuccessful.
HITLS_NULL_INPUT,configis null.
HITLS_MEMCPY_FAIL,memorycopy fails.

◆ HITLS_SetSessionTicketExtProcessCb()

int32_t HITLS_SetSessionTicketExtProcessCb ( HITLS_Ctx * ctx,
const HITLS_SessionTicketExtProcessCb sessionTicketExtCb,
void * arg )

Set a callback for processing the session ticket extension.

参数
ctx[OUT] config handle
extSessionTicketCb[IN] Callback.
arg[IN] User-defined parameter
返回值
HITLS_SUCCESS,ifsuccessful.
HITLS_NULL_INPUT,configis null.

◆ HITLS_SetSessionTicketKey()

int32_t HITLS_SetSessionTicketKey ( HITLS_Ctx * ctx,
const uint8_t * key,
uint32_t keySize )

Set the default ticket key of the HiTLS. The key is used to encrypt and decrypt the ticket in the new session ticket when the HITLS_TicketKeyCb callback function is not set.

注意
The returned key value is as follows: 16-byte key name + 32-byte AES key + 32-byte HMAC key
参数
ctx[OUT] TLS connection handle.
key[IN] Ticket key to be set.
keySize[IN] Size of the ticket key.
返回值
HITLS_SUCCESS,ifsuccessful.
Forother error codes, see hitls_error.h.

◆ HITLS_SetTicketNums()

int32_t HITLS_SetTicketNums ( HITLS_Ctx * ctx,
uint32_t ticketNums )

Setting TLS1.3, number of new session tickets sent after complete link establishment

This interface should be called before handshake. The default number is 2. If the number is greater than or equal to 1, only one ticket is sent after the session is resumed. When this parameter is set to 0, tickets will not be sent for the complete handshake and session recovery.

参数
ctx[OUT] ctx context
ticketNums[IN] Number of sent new session tickets.
返回值
HITLS_SUCCESS,ifsuccessful.
HITLS_NULL_INPUT,ctxis null.