API参考
载入中...
搜索中...
未找到
session.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_H
17#define SESSION_H
18
19#include <stdint.h>
20#include <stdbool.h>
21#include "hitls_build.h"
22#include "sal_time.h"
23#include "hitls_session.h"
24#include "cert.h"
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30#define MAX_MASTER_KEY_SIZE 512u /* <= tls1.2 master keyis 48 bytes. TLS1.3 can be to 256 bytes. */
31
32/* Increments the reference count for session */
33void HITLS_SESS_UpRef(HITLS_Session *sess);
34
35/* Deep copy session */
36HITLS_Session *SESS_Copy(HITLS_Session *src);
37
38/* Disable session */
39void SESS_Disable(HITLS_Session *sess);
40
41/* set peerCert */
42int32_t SESS_SetPeerCert(HITLS_Session *sess, CERT_Pair *peerCert, bool isClient);
43
44/* get peerCert */
45int32_t SESS_GetPeerCert(HITLS_Session *sess, CERT_Pair **peerCert);
46
47/* set ticket */
48int32_t SESS_SetTicket(HITLS_Session *sess, uint8_t *ticket, uint32_t ticketSize);
49
50/* get ticket */
51int32_t SESS_GetTicket(const HITLS_Session *sess, uint8_t **ticket, uint32_t *ticketSize);
52
53/* set hostName */
54int32_t SESS_SetHostName(HITLS_Session *sess, uint32_t hostNameSize, uint8_t *hostName);
55
56/* get hostName */
57int32_t SESS_GetHostName(HITLS_Session *sess, uint32_t *hostNameSize, uint8_t **hostName);
58
59/* Check the validity of the session */
60bool SESS_CheckValidity(HITLS_Session *sess, uint64_t curTime);
61
62uint64_t SESS_GetStartTime(HITLS_Session *sess);
63
64int32_t SESS_SetStartTime(HITLS_Session *sess, uint64_t startTime);
65
66int32_t SESS_SetTicketAgeAdd(HITLS_Session *sess, uint32_t ticketAgeAdd);
67
68uint32_t SESS_GetTicketAgeAdd(const HITLS_Session *sess);
69#ifdef __cplusplus
70}
71#endif
72
73#endif // SESSION_H
定义 cert_mgr.h:32