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 /** 17 * @defgroup hitls_type 18 * @ingroup hitls 19 * @brief TLS type definition, provides the TLS type required by the user 20 */ 21 22 #ifndef HITLS_TYPE_H 23 #define HITLS_TYPE_H 24 25 #include <stdint.h> 26 27 #ifdef __cplusplus 28 extern "C" { 29 #endif 30 31 /** 32 * @ingroup hitls_type 33 * @brief HITLS context 34 */ 35 typedef struct TlsCtx HITLS_Ctx; 36 37 /** 38 * @ingroup hitls_type 39 * @brief config context 40 */ 41 typedef struct TlsConfig HITLS_Config; 42 43 /** 44 * @ingroup hitls_type 45 * @brief cipherSuite information 46 */ 47 typedef struct TlsCipherSuiteInfo HITLS_Cipher; 48 49 typedef struct TlsSessCtx HITLS_Session; 50 51 typedef struct CertVerifyParamInner HITLS_CertVerifyParam; 52 /** 53 * @ingroup hitls_type 54 * @brief DTLS SCTP authkey length, which is specified in the protocol and can be used to determine the length 55 * when the auth key is set. 56 */ 57 #define DTLS_SCTP_SHARED_AUTHKEY_LEN 64 58 59 /** 60 * @ingroup hitls_type 61 * @brief TLS1.3 key exchange mode: Only PSKs are used for key negotiation. 62 */ 63 #define TLS13_KE_MODE_PSK_ONLY 1u 64 65 /** 66 * @ingroup hitls_type 67 * @brief TLS1.3 key exchange mode: Both PSK and (EC)DHE are used for key negotiation. 68 */ 69 #define TLS13_KE_MODE_PSK_WITH_DHE 2u 70 /** 71 * @ingroup hitls_type 72 * @brief TLS1.3 certificate authentication: The certificate authentication is used and 73 * the (EC)DHE negotiation key is required. 74 */ 75 #define TLS13_CERT_AUTH_WITH_DHE 4u 76 77 /* Sets the number of digits in the version number. */ 78 #define SSLV2_VERSION_BIT 0x00000001U 79 #define SSLV3_VERSION_BIT 0x00000002U 80 #define TLS10_VERSION_BIT 0x00000004U 81 #define TLS11_VERSION_BIT 0x00000008U 82 #define TLS12_VERSION_BIT 0x00000010U 83 #define TLS13_VERSION_BIT 0x00000020U 84 #define TLCP11_VERSION_BIT 0x00000080U 85 #define DTLS10_VERSION_BIT 0x80000000U 86 #define DTLS12_VERSION_BIT 0x40000000U 87 #define DTLCP11_VERSION_BIT 0x00000100U 88 #define TLS_VERSION_MASK (TLS12_VERSION_BIT | TLS13_VERSION_BIT) 89 90 /* Currently, only DTLS12 is supported. DTLS10 is not supported */ 91 #define DTLS_VERSION_MASK DTLS12_VERSION_BIT 92 93 #define STREAM_VERSION_BITS \ 94 (SSLV2_VERSION_BIT | SSLV3_VERSION_BIT | TLS10_VERSION_BIT | TLS11_VERSION_BIT | TLS12_VERSION_BIT | \ 95 TLS13_VERSION_BIT | TLCP11_VERSION_BIT) 96 #define DATAGRAM_VERSION_BITS (DTLS10_VERSION_BIT | DTLS12_VERSION_BIT | DTLCP11_VERSION_BIT) 97 98 #define TLCP_VERSION_BITS (TLCP11_VERSION_BIT | DTLCP11_VERSION_BIT) 99 #define ALL_VERSION (STREAM_VERSION_BITS | DATAGRAM_VERSION_BITS) 100 101 /** 102 * @ingroup hitls_type 103 * @brief HITLS_SESS_CACHE_MODE: mode for storing hitls sessions. 104 */ 105 typedef enum { 106 HITLS_SESS_CACHE_NO, 107 HITLS_SESS_CACHE_CLIENT, 108 HITLS_SESS_CACHE_SERVER, 109 HITLS_SESS_CACHE_BOTH, 110 } HITLS_SESS_CACHE_MODE; 111 112 /** 113 * @ingroup hitls_type 114 * @brief key update message type 115 */ 116 typedef enum { 117 HITLS_UPDATE_NOT_REQUESTED = 0, 118 HITLS_UPDATE_REQUESTED = 1, 119 HITLS_KEY_UPDATE_REQ_END = 255 120 } HITLS_KeyUpdateRequest; 121 122 #define HITLS_MODE_ENABLE_PARTIAL_WRITE 0x00000001U 123 #define HITLS_MODE_ACCEPT_MOVING_WRITE_BUFFER 0x00000002U 124 #define HITLS_MODE_AUTO_RETRY 0x00000004U 125 #define HITLS_MODE_NO_AUTO_CHAIN 0x00000008U 126 #define HITLS_MODE_RELEASE_BUFFERS 0x00000010U 127 #define HITLS_MODE_SEND_CLIENTHELLO_TIME 0x00000020U 128 #define HITLS_MODE_SEND_SERVERHELLO_TIME 0x00000040U 129 #define HITLS_MODE_SEND_FALLBACK_SCSV 0x00000080U 130 #define HITLS_MODE_ASYNC 0x00000100U 131 #define HITLS_MODE_DTLS_SCTP_LABEL_LENGTH_BUG 0x00000400U 132 133 /* close_notify message has been sent to the peer end, turn off the alarm, and the connection is considered closed. */ 134 # define HITLS_SENT_SHUTDOWN 1u 135 # define HITLS_RECEIVED_SHUTDOWN 2u /* Received peer shutdown alert, normal close_notify or fatal error */ 136 137 // Used to mark the current internal status 138 #define HITLS_NOTHING 1u 139 #define HITLS_WRITING 2u 140 #define HITLS_READING 3u 141 #define HITLS_ASYNC_PAUSED 4u 142 #define HITLS_ASYNC_NO_JOBS 5u 143 144 #define HITLS_CC_READ 0x001u /* Read state */ 145 #define HITLS_CC_WRITE 0x002u /* Write status */ 146 147 #ifdef __cplusplus 148 } 149 #endif 150 151 #endif 152