API参考
载入中...
搜索中...
未找到
session_mgr.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 SESSION_MGR_H
17#define SESSION_MGR_H
18
19#include <stdint.h>
20#include <stdbool.h>
21#include "hitls_build.h"
22#include "hitls.h"
23#include "tls.h"
24#include "session.h"
25#include "tls_config.h"
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31/* Application */
32TLS_SessionMgr *SESSMGR_New(HITLS_Lib_Ctx *libCtx);
33
34/* Copy the number of references. The number of references increases by 1 */
35TLS_SessionMgr *SESSMGR_Dup(TLS_SessionMgr *mgr);
36
37/* Release */
38void SESSMGR_Free(TLS_SessionMgr *mgr);
39
40/* Configure the timeout period */
41void SESSMGR_SetTimeout(TLS_SessionMgr *mgr, uint64_t sessTimeout);
42
43/* Obtain the timeout configuration */
44uint64_t SESSMGR_GetTimeout(TLS_SessionMgr *mgr);
45
46/* Set the mode */
47void SESSMGR_SetCacheMode(TLS_SessionMgr *mgr, uint32_t mode);
48
49/* Set the mode: Ensure that the pointer is not null */
50uint32_t SESSMGR_GetCacheMode(TLS_SessionMgr *mgr);
51
52/* Set the maximum number of cache sessions */
53void SESSMGR_SetCacheSize(TLS_SessionMgr *mgr, uint32_t sessCacheSize);
54
55/* Set the maximum number of cached sessions. Ensure that the pointer is not null */
56uint32_t SESSMGR_GetCacheSize(TLS_SessionMgr *mgr);
57
58/* add */
59void SESSMGR_InsertSession(TLS_SessionMgr *mgr, HITLS_Session *sess, bool isStore);
60
61/* Find the matching session and verify the validity of the session (time) */
62HITLS_Session *SESSMGR_Find(TLS_Ctx *ctx, uint8_t *sessionId, uint8_t sessionIdSize);
63
64/* Search for the matching session without checking the validity of the session (time) */
65bool SESSMGR_HasMacthSessionId(TLS_SessionMgr *mgr, uint8_t *sessionId, uint8_t sessionIdSize);
66
67/* Clear timeout sessions */
68void SESSMGR_ClearTimeout(HITLS_Config *config, uint64_t time);
69
70int32_t SESSMGR_RemoveSession(HITLS_Config *config, HITLS_Session *sess);
71
72/* Generate session IDs to prevent duplicate session IDs */
73int32_t SESSMGR_GernerateSessionId(TLS_Ctx *ctx, uint8_t *sessionId, uint32_t sessionIdSize);
74
75void SESSMGR_SetTicketKeyCb(TLS_SessionMgr *mgr, HITLS_TicketKeyCb ticketKeyCb);
76
77HITLS_TicketKeyCb SESSMGR_GetTicketKeyCb(TLS_SessionMgr *mgr);
78
93int32_t SESSMGR_GetTicketKey(const TLS_SessionMgr *mgr, uint8_t *key, uint32_t keySize, uint32_t *outSize);
94
108int32_t SESSMGR_SetTicketKey(TLS_SessionMgr *mgr, const uint8_t *key, uint32_t keySize);
109
121int32_t SESSMGR_EncryptSessionTicket(TLS_Ctx *ctx, const TLS_SessionMgr *sessMgr, const HITLS_Session *sess,
122 uint8_t **ticketBuf, uint32_t *ticketBufSize);
123
148int32_t SESSMGR_DecryptSessionTicket(HITLS_Lib_Ctx *libCtx, const char *attrName,
149 const TLS_SessionMgr *sessMgr, HITLS_Session **sess, const uint8_t *ticketBuf,
150 uint32_t ticketBufSize, bool *isTicketExcept);
151
152#ifdef __cplusplus
153}
154#endif
155
156#endif // SESSION_MGR_H
int32_t(* HITLS_TicketKeyCb)(uint8_t *keyName, uint32_t keyNameSize, HITLS_CipherParameters *cipher, uint8_t isEncrypt)
Obtain and verify ticket_key on the server.
定义 hitls_session.h:259
struct TlsConfig HITLS_Config
config context
定义 hitls_type.h:41