• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 CHANGE_CIPHER_SPEC_H
17 #define CHANGE_CIPHER_SPEC_H
18 
19 #include <stdint.h>
20 #include "hitls_build.h"
21 #include "tls.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /**
28  * @ingroup change cipher spec
29  * @brief CCS initialization function
30  *
31  * @param ctx [IN] SSL context
32  *
33  * @retval HITLS_SUCCESS                Initializition successful.
34  * @retval HITLS_INTERNAL_EXCEPTION     An unexpected internal error occurs.
35  * @retval HITLS_MEMALLOC_FAIL          Failed to apply for memory.
36  */
37 int32_t CCS_Init(TLS_Ctx *ctx);
38 
39 /**
40  * @ingroup change cipher spec
41  * @brief   CCS deinitialization function
42  *
43  * @param   ctx [IN] ssl context
44  *
45  */
46 void CCS_DeInit(TLS_Ctx *ctx);
47 
48 /**
49  * @ingroup change cipher spec
50  * @brief   Check whether the Change cipher spec message is received.
51  *
52  * @param   ctx [IN] TLS context
53  *
54  * @retval  True if the Change cipher spec message is received else false.
55  */
56 bool CCS_IsRecv(const TLS_Ctx *ctx);
57 
58 /**
59  * @ingroup change cipher spec
60  * @brief Send a packet for changing the cipher suite.
61  *
62  * @param ctx [IN] TLS context
63  *
64  * @retval HITLS_SUCCESS                Send successful.
65  * @retval HITLS_INTERNAL_EXCEPTION     An unexpected internal error occurs.
66  * @retval For other error codes, see REC_Write.
67  */
68 int32_t CCS_Send(TLS_Ctx *ctx);
69 
70 /**
71  * @ingroup change cipher spec
72  * @brief Control function
73  *
74  * @param ctx [IN] TLS context
75  * @param cmd [IN] Control command
76  *
77  * @retval HITLS_SUCCESS                succeeded.
78  * @retval HITLS_INTERNAL_EXCEPTION     An unexpected internal error
79  * @retval HITLS_CCS_INVALID_CMD        Invalid instruction
80  */
81 int32_t CCS_Ctrl(TLS_Ctx *ctx, CCS_Cmd cmd);
82 
83 /**
84  * @brief Process CCS message after decryption
85  *
86  * @attention ctx cannot be empty.
87  * @param ctx [IN] tls Context
88  * @param data [IN] ccs data
89  * @param dataLen [IN] ccs data length
90  * @retval HITLS_REC_NORMAL_RECV_UNEXPECT_MSG
91  */
92 int32_t ProcessDecryptedCCS(TLS_Ctx *ctx, const uint8_t *data, uint32_t dataLen);
93 
94 /**
95  * @brief Process plaintext CCS message in TLS13
96  *
97  * @attention ctx cannot be empty.
98  * @param ctx [IN] tls Context
99  * @param data [IN] ccs data
100  * @param dataLen [IN] ccs data length
101  * @retval HITLS_REC_NORMAL_RECV_UNEXPECT_MSG
102  */
103 int32_t ProcessPlainCCS(TLS_Ctx *ctx, const uint8_t *data, uint32_t dataLen);
104 #ifdef __cplusplus
105 }
106 #endif
107 
108 #endif
109