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 27 extern "C" { 28 #endif 29 30 #define MAX_MASTER_KEY_SIZE 256u /* <= tls1.2 master key is 48 bytes. TLS1.3 can be to 256 bytes. */ 31 32 /* Increments the reference count for session */ 33 void HITLS_SESS_UpRef(HITLS_Session *sess); 34 35 /* Deep copy session */ 36 HITLS_Session *SESS_Copy(HITLS_Session *src); 37 38 /* Disable session */ 39 void SESS_Disable(HITLS_Session *sess); 40 41 /* set peerCert */ 42 int32_t SESS_SetPeerCert(HITLS_Session *sess, CERT_Pair *peerCert, bool isClient); 43 44 /* get peerCert */ 45 int32_t SESS_GetPeerCert(HITLS_Session *sess, CERT_Pair **peerCert); 46 47 /* set ticket */ 48 int32_t SESS_SetTicket(HITLS_Session *sess, uint8_t *ticket, uint32_t ticketSize); 49 50 /* get ticket */ 51 int32_t SESS_GetTicket(const HITLS_Session *sess, uint8_t **ticket, uint32_t *ticketSize); 52 53 /* set hostName */ 54 int32_t SESS_SetHostName(HITLS_Session *sess, uint32_t hostNameSize, uint8_t *hostName); 55 56 /* get hostName */ 57 int32_t SESS_GetHostName(HITLS_Session *sess, uint32_t *hostNameSize, uint8_t **hostName); 58 59 /* Check the validity of the session */ 60 bool SESS_CheckValidity(HITLS_Session *sess, uint64_t curTime); 61 62 uint64_t SESS_GetStartTime(HITLS_Session *sess); 63 64 int32_t SESS_SetStartTime(HITLS_Session *sess, uint64_t startTime); 65 66 int32_t SESS_SetTicketAgeAdd(HITLS_Session *sess, uint32_t ticketAgeAdd); 67 68 uint32_t SESS_GetTicketAgeAdd(const HITLS_Session *sess); 69 70 #ifdef __cplusplus 71 } 72 #endif 73 74 #endif // SESSION_H 75