API参考
载入中...
搜索中...
未找到
hitls_security.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_SECURITY_H
23#define HITLS_SECURITY_H
24
25#include <stdint.h>
26#include "hitls_type.h"
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
38#ifndef HITLS_DEFAULT_SECURITY_LEVEL
39#define HITLS_DEFAULT_SECURITY_LEVEL 1
40#endif
41
46#define HITLS_SECURITY_LEVEL_ZERO 0
47#define HITLS_SECURITY_LEVEL_ONE 1
48#define HITLS_SECURITY_LEVEL_TWO 2
49#define HITLS_SECURITY_LEVEL_THREE 3
50#define HITLS_SECURITY_LEVEL_FOUR 4
51#define HITLS_SECURITY_LEVEL_FIVE 5
52#define HITLS_SECURITY_LEVEL_MIN HITLS_SECURITY_LEVEL_ZERO
53#define HITLS_SECURITY_LEVEL_MAX HITLS_SECURITY_LEVEL_FIVE
54
59#define HITLS_SECURITY_LEVEL_ONE_SECBITS 80
60#define HITLS_SECURITY_LEVEL_TWO_SECBITS 112
61#define HITLS_SECURITY_LEVEL_THREE_SECBITS 128
62#define HITLS_SECURITY_LEVEL_FOUR_SECBITS 192
63#define HITLS_SECURITY_LEVEL_FIVE_SECBITS 256
64
65/* What the "other" parameter contains in security callback */
66/* Mask for type */
67# define HITLS_SECURITY_SECOP_OTHER_TYPE 0xffff0000
68# define HITLS_SECURITY_SECOP_OTHER_NONE 0
69# define HITLS_SECURITY_SECOP_OTHER_CIPHER (1 << 16)
70# define HITLS_SECURITY_SECOP_OTHER_CURVE (2 << 16)
71# define HITLS_SECURITY_SECOP_OTHER_DH (3 << 16)
72# define HITLS_SECURITY_SECOP_OTHER_PKEY (4 << 16)
73# define HITLS_SECURITY_SECOP_OTHER_SIGALG (5 << 16)
74# define HITLS_SECURITY_SECOP_OTHER_CERT (6 << 16)
75
80# define HITLS_SECURITY_SECOP_PEER 0x1000
81
82/* Called to filter ciphers */
83/* Ciphers client supports */
84# define HITLS_SECURITY_SECOP_CIPHER_SUPPORTED (1 | HITLS_SECURITY_SECOP_OTHER_CIPHER)
85/* Cipher shared by client/server */
86# define HITLS_SECURITY_SECOP_CIPHER_SHARED (2 | HITLS_SECURITY_SECOP_OTHER_CIPHER)
87/* Sanity check of cipher server selects */
88# define HITLS_SECURITY_SECOP_CIPHER_CHECK (3 | HITLS_SECURITY_SECOP_OTHER_CIPHER)
89/* Curves supported by client */
90# define HITLS_SECURITY_SECOP_CURVE_SUPPORTED (4 | HITLS_SECURITY_SECOP_OTHER_CURVE)
91/* Curves shared by client/server */
92# define HITLS_SECURITY_SECOP_CURVE_SHARED (5 | HITLS_SECURITY_SECOP_OTHER_CURVE)
93/* Sanity check of curve server selects */
94# define HITLS_SECURITY_SECOP_CURVE_CHECK (6 | HITLS_SECURITY_SECOP_OTHER_CURVE)
95/* Temporary DH key */
96# define HITLS_SECURITY_SECOP_TMP_DH (7 | HITLS_SECURITY_SECOP_OTHER_PKEY)
97/* SSL/TLS version */
98# define HITLS_SECURITY_SECOP_VERSION (9 | HITLS_SECURITY_SECOP_OTHER_NONE)
99/* Session tickets */
100# define HITLS_SECURITY_SECOP_TICKET (10 | HITLS_SECURITY_SECOP_OTHER_NONE)
101/* Supported signature algorithms sent to peer */
102# define HITLS_SECURITY_SECOP_SIGALG_SUPPORTED (11 | HITLS_SECURITY_SECOP_OTHER_SIGALG)
103/* Shared signature algorithm */
104# define HITLS_SECURITY_SECOP_SIGALG_SHARED (12 | HITLS_SECURITY_SECOP_OTHER_SIGALG)
105/* Sanity check signature algorithm allowed */
106# define HITLS_SECURITY_SECOP_SIGALG_CHECK (13 | HITLS_SECURITY_SECOP_OTHER_SIGALG)
107/* Used to get mask of supported public key signature algorithms */
108# define HITLS_SECURITY_SECOP_SIGALG_MASK (14 | HITLS_SECURITY_SECOP_OTHER_SIGALG)
109/* Use to see if compression is allowed */
110# define HITLS_SECURITY_SECOP_COMPRESSION (15 | HITLS_SECURITY_SECOP_OTHER_NONE)
111/* EE key in certificate */
112# define HITLS_SECURITY_SECOP_EE_KEY (16 | HITLS_SECURITY_SECOP_OTHER_CERT)
113/* CA key in certificate */
114# define HITLS_SECURITY_SECOP_CA_KEY (17 | HITLS_SECURITY_SECOP_OTHER_CERT)
115/* CA digest algorithm in certificate */
116# define HITLS_SECURITY_SECOP_CA_MD (18 | HITLS_SECURITY_SECOP_OTHER_CERT)
117/* Peer EE key in certificate */
118# define HITLS_SECURITY_SECOP_PEER_EE_KEY (HITLS_SECURITY_SECOP_EE_KEY | HITLS_SECURITY_SECOP_PEER)
119/* Peer CA key in certificate */
120# define HITLS_SECURITY_SECOP_PEER_CA_KEY (HITLS_SECURITY_SECOP_CA_KEY | HITLS_SECURITY_SECOP_PEER)
121/* Peer CA digest algorithm in certificate */
122# define HITLS_SECURITY_SECOP_PEER_CA_MD (HITLS_SECURITY_SECOP_CA_MD | HITLS_SECURITY_SECOP_PEER)
123
139typedef int32_t (*HITLS_SecurityCb)(const HITLS_Ctx *ctx, const HITLS_Config *config, int32_t option,
140 int32_t bits, int32_t id, void *other, void *exData);
141
151int32_t HITLS_CFG_SetSecurityLevel(HITLS_Config *config, int32_t securityLevel);
152
162int32_t HITLS_CFG_GetSecurityLevel(const HITLS_Config *config, int32_t *securityLevel);
163
174
183
193int32_t HITLS_CFG_SetSecurityExData(HITLS_Config *config, void *securityExData);
194
203
213int32_t HITLS_SetSecurityLevel(HITLS_Ctx *ctx, int32_t securityLevel);
214
224int32_t HITLS_GetSecurityLevel(const HITLS_Ctx *ctx, int32_t *securityLevel);
225
236
245
255int32_t HITLS_SetSecurityExData(HITLS_Ctx *ctx, void *securityExData);
256
265
266#ifdef __cplusplus
267}
268#endif /* end __cplusplus */
269
270#endif /* end HITLS_SECURITY_H */
int32_t HITLS_CFG_SetSecurityExData(HITLS_Config *config, void *securityExData)
Configuring the Security ExData
int32_t HITLS_SetSecurityCb(HITLS_Ctx *ctx, HITLS_SecurityCb securityCb)
Callback function for setting link security
HITLS_SecurityCb HITLS_CFG_GetSecurityCb(const HITLS_Config *config)
Obtain the configured security callback function
void * HITLS_GetSecurityExData(const HITLS_Ctx *ctx)
Obtains the configured Security ExData.
int32_t HITLS_SetSecurityExData(HITLS_Ctx *ctx, void *securityExData)
Setting Security ExData for the Link
int32_t HITLS_CFG_SetSecurityCb(HITLS_Config *config, HITLS_SecurityCb securityCb)
Configure the security callback function.
HITLS_SecurityCb HITLS_GetSecurityCb(const HITLS_Ctx *ctx)
Obtain the Security callback function of the link
int32_t HITLS_SetSecurityLevel(HITLS_Ctx *ctx, int32_t securityLevel)
Set the link security level
int32_t HITLS_CFG_SetSecurityLevel(HITLS_Config *config, int32_t securityLevel)
Configure the security level
void * HITLS_CFG_GetSecurityExData(const HITLS_Config *config)
Obtain the configured Security ExData
int32_t HITLS_GetSecurityLevel(const HITLS_Ctx *ctx, int32_t *securityLevel)
Obtain the link security level
int32_t(* HITLS_SecurityCb)(const HITLS_Ctx *ctx, const HITLS_Config *config, int32_t option, int32_t bits, int32_t id, void *other, void *exData)
Secure Callback Function Prototype
定义 hitls_security.h:139
int32_t HITLS_CFG_GetSecurityLevel(const HITLS_Config *config, int32_t *securityLevel)
Obtain the configured security level.
struct TlsCtx HITLS_Ctx
HITLS context
定义 hitls_type.h:35
struct TlsConfig HITLS_Config
config context
定义 hitls_type.h:41