API参考
载入中...
搜索中...
未找到
cipher_suite.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 CIPHER_SUITE_H
17#define CIPHER_SUITE_H
18
19#include <stdint.h>
20#include <stdbool.h>
21#include "hitls_build.h"
22#include "hitls_config.h"
23#include "hitls_crypt_type.h"
24#include "hitls_cert_type.h"
25#include "hitls_type.h"
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31#define TLS_EMPTY_RENEGOTIATION_INFO_SCSV 0x00ffu /* renegotiation cipher suite */
32
33#define TLS_FALLBACK_SCSV 0x5600u /* downgraded protocol cipher suite */
34
35/* cert request Type of the certificate requested */
36typedef enum {
37 /* rfc5246 7.4.4 */
38 CERT_TYPE_RSA_SIGN = 1,
39 CERT_TYPE_DSS_SIGN = 2,
40 CERT_TYPE_RSA_FIXED_DH = 3,
41 CERT_TYPE_DSS_FIXED_DH = 4,
42 /* rfc8422 5.5 */
43 CERT_TYPE_ECDSA_SIGN = 64,
44 CERT_TYPE_UNKNOWN = 255
45} CERT_Type;
46
50typedef struct TlsCipherSuiteInfo {
51 bool enable;
52 const char *name;
53 const char *stdName;
54 uint16_t cipherSuite;
55
56 /* algorithm type */
57 HITLS_CipherAlgo cipherAlg;
58 HITLS_KeyExchAlgo kxAlg;
59 HITLS_AuthAlgo authAlg;
60 HITLS_MacAlgo macAlg;
61 HITLS_HashAlgo hashAlg;
62
68
69 /* key length */
70 uint8_t fixedIvLength;
71 uint8_t encKeyLen;
72 uint8_t macKeyLen;
73
74 /* result length */
75 uint8_t blockLength;
77 uint8_t macLen;
79
80 uint16_t minVersion;
81 uint16_t maxVersion;
82 uint16_t minDtlsVersion;
83 uint16_t maxDtlsVersion;
84 HITLS_CipherType cipherType;
85 int32_t strengthBits;
86} CipherSuiteInfo;
87
91typedef struct {
93 HITLS_SignAlgo signAlg;
94 HITLS_HashAlgo hashAlg;
96
97typedef struct {
99 HITLS_NamedGroup cureName;
101
105typedef struct {
106 uint16_t cipherSuite;
107 CERT_Type certType;
109
121int32_t CFG_GetCipherSuiteInfo(uint16_t cipherSuite, CipherSuiteInfo *cipherInfo);
122
131bool CFG_CheckCipherSuiteSupported(uint16_t cipherSuite);
132
143bool CFG_CheckCipherSuiteVersion(uint16_t cipherSuite, uint16_t minVersion, uint16_t maxVersion);
144
156bool CFG_GetSignParamBySchemes(const HITLS_Ctx *ctx, HITLS_SignHashAlgo scheme, HITLS_SignAlgo *signAlg,
157 HITLS_HashAlgo *hashAlg);
158
166uint8_t CFG_GetCertTypeByCipherSuite(uint16_t cipherSuite);
167
175HITLS_NamedGroup CFG_GetEcdsaCurveNameBySchemes(const HITLS_Ctx *ctx, HITLS_SignHashAlgo scheme);
176
177#define IS_SM_TLS13(cipherSuite) (((cipherSuite) == HITLS_SM4_GCM_SM3) || ((cipherSuite) == HITLS_SM4_CCM_SM3))
178
179#ifdef __cplusplus
180}
181#endif
182
183#endif // CIPHER_SUITE_H
HITLS_SignHashAlgo
Certificate Signature Algorithm Enumeration
定义 hitls_cert_type.h:177
struct TlsCtx HITLS_Ctx
HITLS context
定义 hitls_type.h:35
定义 cipher_suite.h:105
CERT_Type certType
定义 cipher_suite.h:107
uint16_t cipherSuite
定义 cipher_suite.h:106
定义 cipher_suite.h:97
HITLS_SignHashAlgo scheme
定义 cipher_suite.h:98
HITLS_NamedGroup cureName
定义 cipher_suite.h:99
定义 cipher_suite.h:91
HITLS_SignHashAlgo scheme
定义 cipher_suite.h:92
HITLS_HashAlgo hashAlg
定义 cipher_suite.h:94
HITLS_SignAlgo signAlg
定义 cipher_suite.h:93
定义 cipher_suite.h:50
uint16_t maxDtlsVersion
定义 cipher_suite.h:83
const char * name
定义 cipher_suite.h:52
uint16_t maxVersion
定义 cipher_suite.h:81
uint8_t encKeyLen
定义 cipher_suite.h:71
HITLS_CipherType cipherType
定义 cipher_suite.h:84
uint16_t minDtlsVersion
定义 cipher_suite.h:82
uint8_t blockLength
定义 cipher_suite.h:75
uint8_t macLen
定义 cipher_suite.h:77
HITLS_HashAlgo hashAlg
定义 cipher_suite.h:61
HITLS_MacAlgo macAlg
定义 cipher_suite.h:60
HITLS_KeyExchAlgo kxAlg
定义 cipher_suite.h:58
int32_t strengthBits
定义 cipher_suite.h:85
HITLS_AuthAlgo authAlg
定义 cipher_suite.h:59
bool enable
定义 cipher_suite.h:51
HITLS_SignHashAlgo signScheme
定义 cipher_suite.h:67
HITLS_CipherAlgo cipherAlg
定义 cipher_suite.h:57
uint8_t recordIvLength
定义 cipher_suite.h:76
uint16_t minVersion
定义 cipher_suite.h:80
uint16_t cipherSuite
定义 cipher_suite.h:54
uint8_t fixedIvLength
定义 cipher_suite.h:70
const char * stdName
定义 cipher_suite.h:53
uint8_t macKeyLen
定义 cipher_suite.h:72