API参考
载入中...
搜索中...
未找到
session_type.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_TYPE_H
17#define SESSION_TYPE_H
18
19#include <stdbool.h>
20#include <stdint.h>
21#include "hitls_type.h"
22#include "hitls_session.h"
23#include "tls_config.h"
24#include "cert.h"
25#include "session.h"
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
32 void *lock; /* Thread lock */
33 int32_t references; /* Reference times */
34
35 void *hash; /* hash table */
36
37 uint64_t sessTimeout; /* Session timeout interval, in seconds */
38#ifdef HITLS_TLS_FEATURE_SESSION
39 uint32_t sessCacheSize; /* session cache size: maximum number of sessions */
40 uint32_t sessCacheMode; /* session cache mode */
41
42 /* TLS1.2 session ticket */
43 HITLS_TicketKeyCb ticketKeyCb; /* allows users to customize ticket keys through callback */
44#endif
45 /* key_name: is used to identify a specific set of keys used to protect tickets */
46 uint8_t ticketKeyName[HITLS_TICKET_KEY_NAME_SIZE];
47 uint8_t ticketAesKey[HITLS_TICKET_KEY_SIZE]; /* aes key */
48 uint8_t ticketHmacKey[HITLS_TICKET_KEY_SIZE]; /* hmac key */
49};
50
51struct TlsSessCtx {
52 void *lock; /* Thread lock */
53 /* certificate management context. The certificate interface depends on this field */
54 CERT_MgrCtx *certMgrCtx;
55
56 int32_t references; /* Reference times */
57
58 bool enable; /* Whether to enable the session */
59 bool haveExtMasterSecret; /* Whether an extended master key exists */
60 bool reserved[2]; /* Four-byte alignment */
61
62 uint64_t startTime; /* Start time */
63 uint64_t timeout; /* Timeout interval */
64#ifdef HITLS_TLS_FEATURE_SNI
65 uint32_t hostNameSize; /* Length of the host name */
66 uint8_t *hostName; /* Host name */
67#endif
68
69 uint32_t sessionIdCtxSize; /* Session ID Context Length */
70 uint8_t sessionIdCtx[HITLS_SESSION_ID_CTX_MAX_SIZE]; /* Session ID Context */
71
72 uint32_t sessionIdSize; /* Session ID length */
73 uint8_t sessionId[HITLS_SESSION_ID_MAX_SIZE]; /* session ID */
74 int32_t verifyResult; /* Authentication result */
75
76 CERT_Pair *peerCert; /* Peer certificate */
77
78 uint16_t version; /* Version */
79 uint16_t cipherSuite; /* Cipher suite */
80 uint32_t masterKeySize; /* length of the master key */
81 uint8_t masterKey[MAX_MASTER_KEY_SIZE]; /* Master Key */
82
83 uint32_t ticketSize; /* Session ticket length */
84 uint8_t *ticket; /* Session ticket */
85 uint32_t ticketLifetime; /* Timeout interval of the ticket */
86 uint32_t ticketAgeAdd; /* A random number generated each time a ticket is issued */
87 void *userData;
88};
89
90#define LIBCTX_FROM_SESSION_CTX(sessCtx) ((sessCtx) == NULL) ? \
91 NULL : ((sessCtx)->certMgrCtx == NULL ? NULL : (sessCtx)->certMgrCtx->libCtx)
92#define ATTRIBUTE_FROM_SESSION_CTX(sessCtx) ((sessCtx) == NULL) ? \
93 NULL : ((sessCtx)->certMgrCtx == NULL ? NULL : (sessCtx)->certMgrCtx->attrName)
94
95#ifdef __cplusplus
96}
97#endif
98
99#endif
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
#define HITLS_SESSION_ID_MAX_SIZE
Maximum size of a session ID
定义 hitls_session.h:46
#define HITLS_SESSION_ID_CTX_MAX_SIZE
Session id Maximum size of the CTX.
定义 hitls_session.h:40
定义 cert_mgr.h:32
定义 session_type.h:51
定义 session_type.h:31