API参考
载入中...
搜索中...
未找到
hitls_crypt_type.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
21
22#ifndef HITLS_CRYPT_TYPE_H
23#define HITLS_CRYPT_TYPE_H
24
25#include <stdint.h>
26#include <stdbool.h>
27#include "bsl_obj.h"
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33typedef void HITLS_Lib_Ctx;
34
40typedef void HITLS_CRYPT_Key;
41
46typedef void HITLS_HASH_Ctx;
47
53typedef void HITLS_HMAC_Ctx;
54
60typedef void HITLS_Cipher_Ctx;
61
62typedef struct BslList HITLS_CIPHER_List;
63
68typedef enum {
69 HITLS_AEAD_CIPHER,
70 HITLS_CBC_CIPHER,
71 HITLS_CIPHER_TYPE_BUTT = 255
72} HITLS_CipherType;
73
78typedef enum {
79 HITLS_CIPHER_NULL = BSL_CID_NULL, // Represents a null value, no encryption or decryption
80 HITLS_CIPHER_AES_128_CBC = BSL_CID_AES128_CBC,
81 HITLS_CIPHER_AES_256_CBC = BSL_CID_AES256_CBC,
82 HITLS_CIPHER_AES_128_GCM = BSL_CID_AES128_GCM,
83 HITLS_CIPHER_AES_256_GCM = BSL_CID_AES256_GCM,
84 HITLS_CIPHER_AES_128_CCM = BSL_CID_AES128_CCM,
85 HITLS_CIPHER_AES_256_CCM = BSL_CID_AES256_CCM,
86 HITLS_CIPHER_AES_128_CCM8 = BSL_CID_AES128_CCM8,
87 HITLS_CIPHER_AES_256_CCM8 = BSL_CID_AES256_CCM8,
88 HITLS_CIPHER_CHACHA20_POLY1305 = BSL_CID_CHACHA20_POLY1305,
89 HITLS_CIPHER_SM4_CBC = BSL_CID_SM4_CBC,
90 HITLS_CIPHER_SM4_GCM = BSL_CID_SM4_GCM,
91 HITLS_CIPHER_SM4_CCM = BSL_CID_SM4_CCM,
92 HITLS_CIPHER_BUTT = BSL_CID_UNKNOWN // Represents an unrecognized algorithm type
93} HITLS_CipherAlgo;
94
99typedef enum {
100 HITLS_HASH_NULL = BSL_CID_NULL, // Represents a null value, no hash operation
101 HITLS_HASH_MD5 = BSL_CID_MD5,
102 HITLS_HASH_SHA1 = BSL_CID_SHA1,
103 HITLS_HASH_SHA_224 = BSL_CID_SHA224,
104 HITLS_HASH_SHA_256 = BSL_CID_SHA256,
105 HITLS_HASH_SHA_384 = BSL_CID_SHA384,
106 HITLS_HASH_SHA_512 = BSL_CID_SHA512,
107 HITLS_HASH_SM3 = BSL_CID_SM3,
108 HITLS_HASH_BUTT = BSL_CID_UNKNOWN // Represents an unrecognized algorithm type
109} HITLS_HashAlgo; // CRYPT_MD_AlgId
110
115typedef enum {
116 HITLS_MAC_NULL = BSL_CID_NULL, // Represents a null value, no MAC operation
117 HITLS_MAC_MD5 = BSL_CID_HMAC_MD5,
118 HITLS_MAC_1 = BSL_CID_HMAC_SHA1,
119 HITLS_MAC_224 = BSL_CID_HMAC_SHA224,
120 HITLS_MAC_256 = BSL_CID_HMAC_SHA256,
121 HITLS_MAC_384 = BSL_CID_HMAC_SHA384,
122 HITLS_MAC_512 = BSL_CID_HMAC_SHA512,
123 HITLS_MAC_SM3 = BSL_CID_HMAC_SM3,
124 HITLS_MAC_AEAD = BSL_CID_MAC_AEAD,
125 HITLS_MAC_BUTT = BSL_CID_UNKNOWN // Represents an unrecognized algorithm type
126} HITLS_MacAlgo;
127
132typedef enum {
133 HITLS_AUTH_NULL,
134 HITLS_AUTH_RSA,
135 HITLS_AUTH_ECDSA,
136 HITLS_AUTH_DSS,
137 HITLS_AUTH_PSK,
138 HITLS_AUTH_SM2,
139 HITLS_AUTH_ANY,
140 HITLS_AUTH_BUTT = 255
141} HITLS_AuthAlgo;
142
147typedef enum {
148 HITLS_KEY_EXCH_NULL,
149 HITLS_KEY_EXCH_ECDHE,
150 HITLS_KEY_EXCH_DHE,
151 HITLS_KEY_EXCH_ECDH,
152 HITLS_KEY_EXCH_DH,
153 HITLS_KEY_EXCH_RSA,
154 HITLS_KEY_EXCH_PSK,
155 HITLS_KEY_EXCH_DHE_PSK,
156 HITLS_KEY_EXCH_ECDHE_PSK,
157 HITLS_KEY_EXCH_RSA_PSK,
158 HITLS_KEY_EXCH_ECC, /* sm2 encrypt */
159 HITLS_KEY_EXCH_BUTT = 255
160} HITLS_KeyExchAlgo;
161
166typedef enum {
167 HITLS_SIGN_RSA_PKCS1_V15 = BSL_CID_RSA,
168 HITLS_SIGN_DSA = BSL_CID_DSA,
169 HITLS_SIGN_ECDSA = BSL_CID_ECDSA,
170 HITLS_SIGN_RSA_PSS = BSL_CID_RSASSAPSS,
171 HITLS_SIGN_ED25519 = BSL_CID_ED25519,
172 HITLS_SIGN_SM2 = BSL_CID_SM2DSA,
173 HITLS_SIGN_BUTT = 255
174} HITLS_SignAlgo;
175
180typedef enum {
181 HITLS_EC_CURVE_TYPE_NAMED_CURVE = 3,
182 HITLS_EC_CURVE_TYPE_BUTT = 255
183} HITLS_ECCurveType;
184
189typedef enum {
190 HITLS_EC_GROUP_SECP256R1 = 23,
191 HITLS_EC_GROUP_SECP384R1 = 24,
192 HITLS_EC_GROUP_SECP521R1 = 25,
193 HITLS_EC_GROUP_BRAINPOOLP256R1 = 26,
194 HITLS_EC_GROUP_BRAINPOOLP384R1 = 27,
195 HITLS_EC_GROUP_BRAINPOOLP512R1 = 28,
196 HITLS_EC_GROUP_CURVE25519 = 29,
197 HITLS_EC_GROUP_SM2 = 41,
198 HITLS_FF_DHE_2048 = 256,
199 HITLS_FF_DHE_3072 = 257,
200 HITLS_FF_DHE_4096 = 258,
201 HITLS_FF_DHE_6144 = 259,
202 HITLS_FF_DHE_8192 = 260,
203 HITLS_HYBRID_X25519_MLKEM768 = 4588,
204 HITLS_HYBRID_ECDH_NISTP256_MLKEM768 = 4587,
205 HITLS_HYBRID_ECDH_NISTP384_MLKEM1024 = 4589,
206 HITLS_NAMED_GROUP_BUTT = 0xFFFFu
207} HITLS_NamedGroup;
208
213typedef enum {
214 HITLS_POINT_FORMAT_UNCOMPRESSED = 0,
215 HITLS_POINT_FORMAT_BUTT = 255
216} HITLS_ECPointFormat;
217
222typedef struct {
223 HITLS_ECCurveType type;
224 union {
225 void *prime;
226 void *char2;
227 HITLS_NamedGroup namedcurve;
228 } param;
230
235typedef struct {
236 HITLS_CipherType type;
237 HITLS_CipherAlgo algo;
238 const uint8_t *key;
239 uint32_t keyLen;
240 const uint8_t *iv;
241 uint32_t ivLen;
242 uint8_t *aad;
244 uint32_t aadLen;
245 const uint8_t *hmacKey;
246 uint32_t hmacKeyLen;
247 HITLS_Cipher_Ctx **ctx;
249
254typedef struct {
255 HITLS_CRYPT_Key *tmpPriKey; /* Local temporary private key. */
256 uint8_t *tmpPeerPubkey; /* Peer temporary public key. */
257 uint32_t tmpPeerPubKeyLen; /* Length of the peer temporary public key. */
258 HITLS_CRYPT_Key *priKey; /* Local private key, which is used for SM2 algorithm negotiation.
259 It is the private key of the encryption certificate. */
260 HITLS_CRYPT_Key *peerPubKey; /* Peer public key, which is used for SM2 algorithm negotiation.
261 It is the public key in the encryption certificate. */
262 bool isClient; /* Client ID, which is used by the SM2 algorithm negotiation key. */
264
269typedef struct {
270 HITLS_HashAlgo hashAlgo; /* Hash algorithm. */
271 const uint8_t *salt; /* Salt value. */
272 uint32_t saltLen; /* Salt value length. */
273 const uint8_t *inputKeyMaterial; /* Input Keying Material. */
274 uint32_t inputKeyMaterialLen; /* Ikm length. */
276
281typedef struct {
282 HITLS_HashAlgo hashAlgo; /* Hash algorithm. */
283 const uint8_t *prk; /* A pseudorandom key of at least HashLen octets. */
284 uint32_t prkLen; /* Prk length. */
285 const uint8_t *info; /* Extended data. */
286 uint32_t infoLen; /* Extend the data length. */
288
289#ifdef __cplusplus
290}
291#endif
292#endif
@ BSL_CID_UNKNOWN
定义 bsl_obj.h:37
定义 bsl_list.h:49
HKDF-Expand Input
定义 hitls_crypt_type.h:281
HKDF-Extract Input
定义 hitls_crypt_type.h:269
Key parameters
定义 hitls_crypt_type.h:235
uint32_t hmacKeyLen
定义 hitls_crypt_type.h:246
const uint8_t * hmacKey
定义 hitls_crypt_type.h:245
HITLS_CipherAlgo algo
定义 hitls_crypt_type.h:237
uint8_t * aad
定义 hitls_crypt_type.h:242
uint32_t keyLen
定义 hitls_crypt_type.h:239
HITLS_CipherType type
定义 hitls_crypt_type.h:236
uint32_t aadLen
定义 hitls_crypt_type.h:244
const uint8_t * key
定义 hitls_crypt_type.h:238
HITLS_Cipher_Ctx ** ctx
定义 hitls_crypt_type.h:247
const uint8_t * iv
定义 hitls_crypt_type.h:240
uint32_t ivLen
定义 hitls_crypt_type.h:241
Elliptic curve parameter
定义 hitls_crypt_type.h:222
void * prime
定义 hitls_crypt_type.h:225
void * char2
定义 hitls_crypt_type.h:226
HITLS_NamedGroup namedcurve
定义 hitls_crypt_type.h:227
HITLS_ECCurveType type
定义 hitls_crypt_type.h:223
sm2 ecdhe negotiation key parameters
定义 hitls_crypt_type.h:254