API参考
载入中...
搜索中...
未找到
hitls_cert.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_CERT_H
23#define HITLS_CERT_H
24
25#include <stdbool.h>
26#include <stdint.h>
27#include <stddef.h>
28#include "hitls_type.h"
29#include "hitls_cert_type.h"
30#include "hitls_error.h"
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36#define HITLS_CERT_SET_FIRST 1
37#define HITLS_CERT_SET_NEXT 2
38
49int32_t HITLS_CFG_SetVerifyStore(HITLS_Config *config, HITLS_CERT_Store *store, bool isClone);
50
60
71int32_t HITLS_SetVerifyStore(HITLS_Ctx *ctx, HITLS_CERT_Store *store, bool isClone);
72
81
92int32_t HITLS_CFG_SetChainStore(HITLS_Config *config, HITLS_CERT_Store *store, bool isClone);
93
102
113int32_t HITLS_SetChainStore(HITLS_Ctx *ctx, HITLS_CERT_Store *store, bool isClone);
114
123
135int32_t HITLS_CFG_SetCertStore(HITLS_Config *config, HITLS_CERT_Store *store, bool isClone);
136
145
157int32_t HITLS_SetCertStore(HITLS_Ctx *ctx, HITLS_CERT_Store *store, bool isClone);
158
167
177#define HITLS_CFG_SetVerifyDepth(config, depth) \
178 HITLS_CFG_CtrlSetVerifyParams(config, NULL, CERT_STORE_CTRL_SET_VERIFY_DEPTH, depth, NULL)
179
189#define HITLS_CFG_GetVerifyDepth(config, depth) \
190 HITLS_CFG_CtrlGetVerifyParams((HITLS_Config *)(uintptr_t)(config), NULL, CERT_STORE_CTRL_GET_VERIFY_DEPTH, depth)
191
201#define HITLS_SetVerifyDepth(ctx, depth) \
202 HITLS_CtrlSetVerifyParams(ctx, NULL, CERT_STORE_CTRL_SET_VERIFY_DEPTH, depth, NULL)
203
213#define HITLS_GetVerifyDepth(ctx, depth) \
214 HITLS_CtrlGetVerifyParams(ctx, NULL, CERT_STORE_CTRL_GET_VERIFY_DEPTH, depth)
215
227typedef int32_t (*HITLS_PasswordCb)(char *buf, int32_t bufLen, int32_t flag, void *userdata);
228
239
248
258int32_t HITLS_CFG_SetDefaultPasswordCbUserdata(HITLS_Config *config, void *userdata);
259
268
279
288
298int32_t HITLS_SetDefaultPasswordCbUserdata(HITLS_Ctx *ctx, void *userdata);
299
308
322int32_t HITLS_CFG_SetTlcpCertificate(HITLS_Config *config, HITLS_CERT_X509 *cert, bool isClone, bool isTlcpEncCert);
323
338 bool isClone, bool isTlcpEncCertPriKey);
339
350int32_t HITLS_CFG_SetCertificate(HITLS_Config *config, HITLS_CERT_X509 *cert, bool isClone);
351
362int32_t HITLS_CFG_LoadCertFile(HITLS_Config *config, const char *file, HITLS_ParseFormat format);
363
377int32_t HITLS_CFG_LoadCertBuffer(HITLS_Config *config, const uint8_t *buf, uint32_t bufLen, HITLS_ParseFormat format);
378
387
398int32_t HITLS_SetCertificate(HITLS_Ctx *ctx, HITLS_CERT_X509 *cert, bool isClone);
399
410int32_t HITLS_LoadCertFile(HITLS_Ctx *ctx, const char *file, HITLS_ParseFormat format);
411
425int32_t HITLS_LoadCertBuffer(HITLS_Ctx *ctx, const uint8_t *buf, uint32_t bufLen, HITLS_ParseFormat format);
426
440
449
461int32_t HITLS_CFG_SetPrivateKey(HITLS_Config *config, HITLS_CERT_Key *privateKey, bool isClone);
462
473int32_t HITLS_CFG_LoadKeyFile(HITLS_Config *config, const char *file, HITLS_ParseFormat format);
474
487int32_t HITLS_CFG_ProviderLoadKeyFile(HITLS_Config *config, const char *file, const char *format, const char *type);
488
502int32_t HITLS_CFG_LoadKeyBuffer(HITLS_Config *config, const uint8_t *buf, uint32_t bufLen, HITLS_ParseFormat format);
503
518int32_t HITLS_CFG_ProviderLoadKeyBuffer(HITLS_Config *config, const uint8_t *buf, uint32_t bufLen, const char *format,
519 const char *type);
520
530
540
552int32_t HITLS_SetPrivateKey(HITLS_Ctx *ctx, HITLS_CERT_Key *key, bool isClone);
553
564int32_t HITLS_LoadKeyFile(HITLS_Ctx *ctx, const char *file, HITLS_ParseFormat format);
565
577int32_t HITLS_ProviderLoadKeyFile(HITLS_Ctx *ctx, const char *file, const char *format, const char *type);
578
592int32_t HITLS_LoadKeyBuffer(HITLS_Ctx *ctx, const uint8_t *buf, uint32_t bufLen, HITLS_ParseFormat format);
593
606int32_t HITLS_ProviderLoadKeyBuffer(HITLS_Ctx *ctx, const uint8_t *buf, uint32_t bufLen, const char *format,
607 const char *type);
617
626int32_t HITLS_CheckPrivateKey(HITLS_Ctx *ctx);
627
638int32_t HITLS_CFG_AddChainCert(HITLS_Config *config, HITLS_CERT_X509 *cert, bool isClone);
639
652 HITLS_CERT_StoreType storeType, bool isClone);
653
668HITLS_CERT_X509 *HITLS_CFG_ParseCert(HITLS_Config *config, const uint8_t *buf, uint32_t len,
670
685HITLS_CERT_Key *HITLS_CFG_ParseKey(HITLS_Config *config, const uint8_t *buf, uint32_t len,
687
703HITLS_CERT_Key *HITLS_CFG_ProviderParseKey(HITLS_Config *config, const uint8_t *buf, uint32_t len,
704 HITLS_ParseType type, const char *format, const char *encodeType);
705
713
723
732int32_t HITLS_ClearChainCerts(HITLS_Ctx *ctx);
733
743
753
763typedef int (*HITLS_VerifyCb)(int32_t isPreverifyOk, HITLS_CERT_StoreCtx *storeCtx);
764
774int32_t HITLS_CFG_SetVerifyCb(HITLS_Config *config, HITLS_VerifyCb callback);
775
783HITLS_VerifyCb HITLS_CFG_GetVerifyCb(HITLS_Config *config);
784
794int32_t HITLS_SetVerifyCb(HITLS_Ctx *ctx, HITLS_VerifyCb callback);
795
803HITLS_VerifyCb HITLS_GetVerifyCb(HITLS_Ctx *ctx);
804
814int32_t HITLS_SetVerifyResult(HITLS_Ctx *ctx, HITLS_ERROR verifyResult);
815
825int32_t HITLS_GetVerifyResult(const HITLS_Ctx *ctx, HITLS_ERROR *verifyResult);
826
835
844
853
863
873
882
892
901int32_t HITLS_CFG_SetCurrentCert(HITLS_Config *config, long option);
902
911int32_t HITLS_SetCurrentCert(HITLS_Ctx *ctx, long option);
912
913/* If the ClientHello callback is successfully executed, the handshake continues */
914#define HITLS_CERT_CALLBACK_SUCCESS 1
915/* The ClientHello callback fails. Send an alert message and terminate the handshake */
916#define HITLS_CERT_CALLBACK_FAILED 0
917/* The ClientHello callback is suspended. The handshake process is suspended and the callback is called again */
918#define HITLS_CERT_CALLBACK_RETRY (-1)
919
931typedef int32_t (*HITLS_CertCb)(HITLS_Ctx *ctx, void *arg);
932
943int32_t HITLS_CFG_SetCertCb(HITLS_Config *config, HITLS_CertCb certCb, void *arg);
944
955int32_t HITLS_SetCertCb(HITLS_Ctx *ctx, HITLS_CertCb certCb, void *arg);
956
964typedef void (*HITLS_KeyLogCb)(HITLS_Ctx *ctx, const char *line);
965
976
985
998int32_t HITLS_LogSecret(HITLS_Ctx *ctx, const char *label, const uint8_t *secret, size_t secretLen);
999
1016int32_t HITLS_CFG_ParseCAList(HITLS_Config *config, const char *input, uint32_t inputLen, HITLS_ParseType inputType,
1017 HITLS_ParseFormat format, HITLS_TrustedCAList **caList);
1018
1028int32_t HITLS_CFG_BuildCertChain(HITLS_Config *config, HITLS_BUILD_CHAIN_FLAG flag);
1029
1039int32_t HITLS_BuildCertChain(HITLS_Ctx *ctx, HITLS_BUILD_CHAIN_FLAG flag);
1040
1053 HITLS_Config *config, HITLS_CERT_Store *store, uint32_t cmd, int64_t in, void *inArg);
1054
1065int32_t HITLS_CFG_CtrlGetVerifyParams(HITLS_Config *config, HITLS_CERT_Store *store, uint32_t cmd, void *out);
1066
1078int32_t HITLS_CtrlSetVerifyParams(HITLS_Ctx *ctx, HITLS_CERT_Store *store, uint32_t cmd, int64_t in, void *inArg);
1079
1090int32_t HITLS_CtrlGetVerifyParams(HITLS_Ctx *ctx, HITLS_CERT_Store *store, uint32_t cmd, void *out);
1091
1102int32_t HITLS_CFG_LoadCrlFile(HITLS_Config *config, const char *file, HITLS_ParseFormat format);
1103
1117int32_t HITLS_CFG_LoadCrlBuffer(HITLS_Config *config, const uint8_t *buf, uint32_t bufLen, HITLS_ParseFormat format);
1118
1128
1139int32_t HITLS_LoadCrlFile(HITLS_Ctx *ctx, const char *file, HITLS_ParseFormat format);
1140
1154int32_t HITLS_LoadCrlBuffer(HITLS_Ctx *ctx, const uint8_t *buf, uint32_t bufLen, HITLS_ParseFormat format);
1155
1165
1174#define HITLS_CFG_SetVerifyFlags(config, verifyFlags) HITLS_CFG_CtrlSetVerifyParams(config, \
1175 NULL, CERT_STORE_CTRL_SET_VERIFY_FLAGS, verifyFlags, NULL)
1176
1185#define HITLS_CFG_GetVerifyFlags(config, verifyFlags) HITLS_CFG_CtrlGetVerifyParams(config, \
1186 NULL, CERT_STORE_CTRL_GET_VERIFY_FLAGS, verifyFlags)
1187
1196#define HITLS_SetVerifyFlags(ctx, verifyFlags) HITLS_CtrlSetVerifyParams(ctx, \
1197 NULL, CERT_STORE_CTRL_SET_VERIFY_FLAGS, verifyFlags, NULL)
1198
1207#define HITLS_GetVerifyFlags(ctx, verifyFlags) HITLS_CtrlGetVerifyParams(ctx, \
1208 NULL, CERT_STORE_CTRL_GET_VERIFY_FLAGS, verifyFlags)
1209
1220int32_t HITLS_CFG_FreeCert(HITLS_Config *config, HITLS_CERT_X509 *cert);
1221
1232int32_t HITLS_CFG_FreeKey(HITLS_Config *config, HITLS_CERT_Key *key);
1242int32_t HITLS_UseCertificateChainFile(HITLS_Ctx *ctx, const char *file);
1243
1253int32_t HITLS_CFG_UseCertificateChainFile(HITLS_Config *config, const char *file);
1254
1268int32_t HITLS_CFG_UseCertificateChainBuffer(HITLS_Config *config, const uint8_t *buf,
1269 uint32_t bufLen, HITLS_ParseFormat format);
1283int32_t HITLS_UseCertificateChainBuffer(HITLS_Ctx *ctx, const uint8_t *buf,
1284 uint32_t bufLen, HITLS_ParseFormat format);
1285
1295int32_t HITLS_CFG_LoadVerifyFile(HITLS_Config *config, const char *file);
1296
1310int32_t HITLS_CFG_LoadVerifyBuffer(HITLS_Config *config, const uint8_t *buf,
1311 uint32_t bufLen, HITLS_ParseFormat format);
1325int32_t HITLS_LoadVerifyBuffer(HITLS_Ctx *ctx, const uint8_t *buf,
1326 uint32_t bufLen, HITLS_ParseFormat format);
1327
1337int32_t HITLS_CFG_LoadVerifyDir(HITLS_Config *config, const char *path);
1338
1345int32_t HITLS_CFG_LoadDefaultCAPath(HITLS_Config *config);
1346#ifdef __cplusplus
1347}
1348#endif
1349
1350#endif /* HITLS_CERT_H */
HITLS_ParseType
Read data format
定义 hitls_cert_type.h:129
void HITLS_CERT_Key
Describes the certificate key
定义 hitls_cert_type.h:49
HITLS_ParseFormat
Read data format
定义 hitls_cert_type.h:139
void HITLS_CERT_StoreCtx
Describes the certificate
定义 hitls_cert_type.h:61
struct BslList HITLS_CERT_Chain
Describes the certificate chain
定义 hitls_cert_type.h:73
void HITLS_CERT_Store
Describes the certificate
定义 hitls_cert_type.h:55
void HITLS_CERT_X509
Describes the x509 certificate
定义 hitls_cert_type.h:37
struct BslList HITLS_TrustedCAList
Describes the list of trusted CAs
定义 hitls_cert_type.h:67
HITLS_CERT_StoreType
cert store type
定义 hitls_cert_type.h:151
int32_t HITLS_CFG_LoadVerifyBuffer(HITLS_Config *config, const uint8_t *buf, uint32_t bufLen, HITLS_ParseFormat format)
Load the verification certificates from buffer.
int32_t HITLS_CFG_SetDefaultPasswordCb(HITLS_Config *config, HITLS_PasswordCb cb)
Set the default password callback, cb can be NULL.
定义 config_cert.c:193
int32_t HITLS_CtrlSetVerifyParams(HITLS_Ctx *ctx, HITLS_CERT_Store *store, uint32_t cmd, int64_t in, void *inArg)
Set certificate verification parameters.
定义 conn_create.c:918
int32_t HITLS_CFG_SetTlcpCertificate(HITLS_Config *config, HITLS_CERT_X509 *cert, bool isClone, bool isTlcpEncCert)
Add the device certificate by the ShangMi(SM) cipher suites. Only one certificate can be added for ea...
int32_t HITLS_CFG_ClearVerifyCrls(HITLS_Config *config)
Clear all CRLs in the verify store of the configuration.
int32_t HITLS_CFG_FreeKey(HITLS_Config *config, HITLS_CERT_Key *key)
Release the key.
定义 config_cert.c:1089
int32_t HITLS_SetCertStore(HITLS_Ctx *ctx, HITLS_CERT_Store *store, bool isClone)
Set the cert store used by the TLS link.
定义 conn_cert.c:61
HITLS_PasswordCb HITLS_CFG_GetDefaultPasswordCb(HITLS_Config *config)
Callback for obtaining the default password.
定义 config_cert.c:202
HITLS_CERT_Key * HITLS_CFG_GetPrivateKey(HITLS_Config *config)
Obtain the private key of the certificate in use.
定义 config_cert.c:449
int32_t HITLS_CFG_SetCertStore(HITLS_Config *config, HITLS_CERT_Store *store, bool isClone)
Set the cert store used by the TLS configuration.
定义 config_cert.c:159
HITLS_CERT_Store * HITLS_CFG_GetChainStore(const HITLS_Config *config)
Obtain the chain store used by the TLS configuration.
定义 config_cert.c:150
int32_t HITLS_LoadKeyBuffer(HITLS_Ctx *ctx, const uint8_t *buf, uint32_t bufLen, HITLS_ParseFormat format)
Read the private key of the device certificate from the buffer.
定义 conn_cert.c:192
HITLS_PasswordCb HITLS_GetDefaultPasswordCb(HITLS_Ctx *ctx)
Callback for obtaining the default password
定义 conn_cert.c:88
int32_t HITLS_LoadCrlFile(HITLS_Ctx *ctx, const char *file, HITLS_ParseFormat format)
Load CRL from file and add it into the verify store of the TLS context.
int32_t HITLS_CFG_AddCertToStore(HITLS_Config *config, HITLS_CERT_X509 *cert, HITLS_CERT_StoreType storeType, bool isClone)
Add the certificate to the certificate store that is being used by the current config.
定义 config_cert.c:514
int32_t HITLS_CFG_LoadCertBuffer(HITLS_Config *config, const uint8_t *buf, uint32_t bufLen, HITLS_ParseFormat format)
Read the device certificate from the buffer.
定义 config_cert.c:293
int32_t HITLS_LoadCrlBuffer(HITLS_Ctx *ctx, const uint8_t *buf, uint32_t bufLen, HITLS_ParseFormat format)
Load CRL from buffer and add it into the verify store of the TLS context.
int32_t(* HITLS_CertCb)(HITLS_Ctx *ctx, void *arg)
Process the certificate callback.
定义 hitls_cert.h:931
HITLS_CERT_Store * HITLS_GetVerifyStore(const HITLS_Ctx *ctx)
Obtain the verify store used by the TLS link.
定义 conn_cert.c:34
int32_t HITLS_CFG_SetVerifyStore(HITLS_Config *config, HITLS_CERT_Store *store, bool isClone)
Set the verify store used by the TLS configuration, which is used for certificate verification.
定义 config_cert.c:91
HITLS_CERT_Chain * HITLS_CFG_GetChainCerts(HITLS_Config *config)
Obtain the certificate chain that is being used by the current config.
定义 config_cert.c:626
HITLS_TrustedCAList * HITLS_GetCAList(const HITLS_Ctx *ctx)
Obtain the trusted CA list of the current context.
HITLS_CERT_X509 * HITLS_CFG_ParseCert(HITLS_Config *config, const uint8_t *buf, uint32_t len, HITLS_ParseType type, HITLS_ParseFormat format)
Parse Certificate file or buffer to X509.
定义 config_cert.c:562
HITLS_CERT_X509 * HITLS_GetPeerCertificate(const HITLS_Ctx *ctx)
Obtain the peer certificate.
HITLS_CERT_Store * HITLS_CFG_GetVerifyStore(const HITLS_Config *config)
Obtain the verify store used by the TLS configuration.
定义 config_cert.c:116
int32_t HITLS_SetCertificate(HITLS_Ctx *ctx, HITLS_CERT_X509 *cert, bool isClone)
Add a device certificate. Only one certificate can be added for each type.
定义 conn_cert.c:115
int32_t(* HITLS_PasswordCb)(char *buf, int32_t bufLen, int32_t flag, void *userdata)
Password Callback
定义 hitls_cert.h:227
HITLS_TrustedCAList * HITLS_GetPeerCAList(const HITLS_Ctx *ctx)
Obtain the trusted CA list of the peer end.
int32_t HITLS_LogSecret(HITLS_Ctx *ctx, const char *label, const uint8_t *secret, size_t secretLen)
If logging is enabled, the master key is logged
int32_t HITLS_SetCAList(HITLS_Ctx *ctx, HITLS_TrustedCAList *list)
Set the trusted CA list of the current context.
int32_t HITLS_CheckPrivateKey(HITLS_Ctx *ctx)
Check whether the configured certificate matches the private key.
定义 conn_cert.c:210
int32_t HITLS_CFG_LoadCrlFile(HITLS_Config *config, const char *file, HITLS_ParseFormat format)
Load CRL from file and add it into the verify store of the TLS configuration.
int32_t HITLS_ProviderLoadKeyBuffer(HITLS_Ctx *ctx, const uint8_t *buf, uint32_t bufLen, const char *format, const char *type)
Load the private key of the device certificate from the buffer, when the provider is used.
定义 conn_cert.c:182
int32_t HITLS_CFG_RemoveCertAndKey(HITLS_Config *config)
Release all loaded certificates and private keys.
定义 config_cert.c:674
int32_t HITLS_CFG_SetCertificate(HITLS_Config *config, HITLS_CERT_X509 *cert, bool isClone)
Add a device certificate. Only one certificate of each type can be added
定义 config_cert.c:252
int32_t HITLS_SetVerifyCb(HITLS_Ctx *ctx, HITLS_VerifyCb callback)
Set the certificate verification callback function, cb can be NULL.
void(* HITLS_KeyLogCb)(HITLS_Ctx *ctx, const char *line)
Key logging callback
定义 hitls_cert.h:964
int32_t HITLS_CFG_LoadVerifyFile(HITLS_Config *config, const char *file)
Load the verification file from the file.
HITLS_KeyLogCb HITLS_CFG_GetKeyLogCb(HITLS_Config *config)
Callback for obtaining TLS key logs
int32_t HITLS_CFG_LoadCrlBuffer(HITLS_Config *config, const uint8_t *buf, uint32_t bufLen, HITLS_ParseFormat format)
Load CRL from buffer and add it into the verify store of the TLS configuration.
int32_t HITLS_RemoveCertAndKey(HITLS_Ctx *ctx)
Release all loaded certificates and private keys.
定义 conn_cert.c:219
int32_t HITLS_CFG_SetKeyLogCb(HITLS_Config *config, HITLS_KeyLogCb callback)
Sets the callback for recording TLS keys.
int32_t HITLS_CFG_UseCertificateChainFile(HITLS_Config *config, const char *file)
Use the certificate chain file to set the certificate chain.
int32_t HITLS_CFG_ClearExtraChainCerts(HITLS_Config *config)
Release the attached certificate chain.
定义 config_cert.c:664
int32_t HITLS_ClearVerifyCrls(HITLS_Ctx *ctx)
Clear all CRLs in the verify store of the context.
HITLS_VerifyCb HITLS_CFG_GetVerifyCb(HITLS_Config *config)
Obtain the certificate verification callback function.
int32_t HITLS_UseCertificateChainFile(HITLS_Ctx *ctx, const char *file)
Use the certificate chain file to set the certificate chain.
HITLS_CERT_Key * HITLS_CFG_ProviderParseKey(HITLS_Config *config, const uint8_t *buf, uint32_t len, HITLS_ParseType type, const char *format, const char *encodeType)
Parse Certificate file or buffer to X509.
定义 config_cert.c:581
int32_t HITLS_ClearChainCerts(HITLS_Ctx *ctx)
Clear the certificate in the current certificate.
定义 conn_create.c:655
int32_t HITLS_SetVerifyStore(HITLS_Ctx *ctx, HITLS_CERT_Store *store, bool isClone)
Set the verify store used by the TLS link for certificate verification.
定义 conn_cert.c:25
int32_t HITLS_SetVerifyResult(HITLS_Ctx *ctx, HITLS_ERROR verifyResult)
Set the peer certificate verification result of the current context.
定义 conn_ctrl.c:145
int32_t HITLS_BuildCertChain(HITLS_Ctx *ctx, HITLS_BUILD_CHAIN_FLAG flag)
Before establishing a TLS connection, try to form a certificate chain as much as possible according t...
int32_t HITLS_SetPrivateKey(HITLS_Ctx *ctx, HITLS_CERT_Key *key, bool isClone)
Add the private key of the device certificate. Only one private key can be added for each type of cer...
定义 conn_cert.c:153
HITLS_CERT_Key * HITLS_GetPrivateKey(HITLS_Ctx *ctx)
Obtain the private key of the certificate in use.
定义 conn_cert.c:201
int32_t HITLS_CFG_SetPrivateKey(HITLS_Config *config, HITLS_CERT_Key *privateKey, bool isClone)
Add the private key of the device certificate. Only one private key can be added for each type of cer...
定义 config_cert.c:368
int32_t HITLS_LoadCertBuffer(HITLS_Ctx *ctx, const uint8_t *buf, uint32_t bufLen, HITLS_ParseFormat format)
Read the device certificate from the buffer.
定义 conn_cert.c:135
int32_t HITLS_CFG_FreeCert(HITLS_Config *config, HITLS_CERT_X509 *cert)
Release the certificate.
定义 config_cert.c:1079
int32_t HITLS_CFG_LoadVerifyDir(HITLS_Config *config, const char *path)
Load the verification file from the directory.
HITLS_CERT_X509 * HITLS_CFG_GetCertificate(const HITLS_Config *config)
Obtain the device certificate in use.
定义 config_cert.c:320
HITLS_CERT_Store * HITLS_CFG_GetCertStore(const HITLS_Config *config)
Obtain the cert store used by the TLS configuration.
定义 config_cert.c:184
HITLS_CERT_Chain * HITLS_GetPeerCertChain(const HITLS_Ctx *ctx)
Obtain the peer certificate chain.
int32_t HITLS_CFG_CheckPrivateKey(HITLS_Config *config)
Check whether the configured certificate matches the private key.
定义 config_cert.c:458
void * HITLS_CFG_GetDefaultPasswordCbUserdata(HITLS_Config *config)
Obtain the user data used by the password callback.
定义 config_cert.c:220
int32_t HITLS_LoadCertFile(HITLS_Ctx *ctx, const char *file, HITLS_ParseFormat format)
Use a file to set the device certificate.
int32_t HITLS_CFG_SetCurrentCert(HITLS_Config *config, long option)
Set the current certificate to the value based on the option parameter.
定义 config_cert.c:617
int32_t HITLS_CFG_LoadKeyBuffer(HITLS_Config *config, const uint8_t *buf, uint32_t bufLen, HITLS_ParseFormat format)
Read the private key of the device certificate from the buffer.
定义 config_cert.c:430
int32_t HITLS_CFG_SetDefaultPasswordCbUserdata(HITLS_Config *config, void *userdata)
Set the user data used by the password callback.
定义 config_cert.c:211
int32_t HITLS_SetDefaultPasswordCb(HITLS_Ctx *ctx, HITLS_PasswordCb cb)
Set the default password callback, cb can be NULL
定义 conn_cert.c:79
int32_t HITLS_LoadVerifyBuffer(HITLS_Ctx *ctx, const uint8_t *buf, uint32_t bufLen, HITLS_ParseFormat format)
Load the verification certificates from buffer.
int32_t HITLS_CFG_ParseCAList(HITLS_Config *config, const char *input, uint32_t inputLen, HITLS_ParseType inputType, HITLS_ParseFormat format, HITLS_TrustedCAList **caList)
Load the CA file and parse it into a trusted CA list.
int32_t HITLS_LoadKeyFile(HITLS_Ctx *ctx, const char *file, HITLS_ParseFormat format)
Use the file to set the device private key.
int32_t HITLS_GetVerifyResult(const HITLS_Ctx *ctx, HITLS_ERROR *verifyResult)
Return the peer certificate verification result of the current context.
定义 conn_ctrl.c:155
HITLS_CERT_Store * HITLS_GetChainStore(const HITLS_Ctx *ctx)
Obtain the chain store used by the TLS link.
定义 conn_cert.c:52
int32_t HITLS_ProviderLoadKeyFile(HITLS_Ctx *ctx, const char *file, const char *format, const char *type)
Load the private key of the device certificate from the file, when the provider is used.
int32_t HITLS_CFG_UseCertificateChainBuffer(HITLS_Config *config, const uint8_t *buf, uint32_t bufLen, HITLS_ParseFormat format)
Use the certificate chain buffer to set the certificate chain.
定义 config_cert.c:1261
void * HITLS_GetDefaultPasswordCbUserdata(HITLS_Ctx *ctx)
Obtain the user data used by the default password callback.
定义 conn_cert.c:106
int32_t HITLS_CFG_ProviderLoadKeyBuffer(HITLS_Config *config, const uint8_t *buf, uint32_t bufLen, const char *format, const char *type)
Load the private key of the device certificate from the buffer, when the provider is used.
定义 config_cert.c:412
int32_t HITLS_UseCertificateChainBuffer(HITLS_Ctx *ctx, const uint8_t *buf, uint32_t bufLen, HITLS_ParseFormat format)
Use the certificate chain buffer to set the certificate chain.
定义 conn_cert.c:259
int32_t HITLS_CFG_LoadKeyFile(HITLS_Config *config, const char *file, HITLS_ParseFormat format)
Load the private key of the device certificate from the file.
int32_t HITLS_CFG_BuildCertChain(HITLS_Config *config, HITLS_BUILD_CHAIN_FLAG flag)
Before establishing a TLS connection, try to form a certificate chain as much as possible according t...
int32_t HITLS_SetChainStore(HITLS_Ctx *ctx, HITLS_CERT_Store *store, bool isClone)
Set the chain store used by the TLS link to construct the certificate chain.
定义 conn_cert.c:43
int32_t HITLS_CFG_ClearChainCerts(HITLS_Config *config)
Clear the certificate chain associated with the current certificate.
定义 config_cert.c:636
HITLS_CERT_Store * HITLS_GetCertStore(const HITLS_Ctx *ctx)
Obtain the cert store used by the TLS link.
定义 conn_cert.c:70
int32_t HITLS_CFG_CtrlSetVerifyParams(HITLS_Config *config, HITLS_CERT_Store *store, uint32_t cmd, int64_t in, void *inArg)
Set certificate verification parameters.
定义 config_cert.c:1058
int32_t HITLS_CFG_SetCertCb(HITLS_Config *config, HITLS_CertCb certCb, void *arg)
Sets the processing certificate callback function, which checks the passed ctx structure and sets or ...
int32_t HITLS_CFG_ProviderLoadKeyFile(HITLS_Config *config, const char *file, const char *format, const char *type)
Load the private key of the device certificate from the file, when the provider is used.
int32_t HITLS_CFG_SetChainStore(HITLS_Config *config, HITLS_CERT_Store *store, bool isClone)
Set the chain store used by the TLS configuration, which is used to construct the certificate chain.
定义 config_cert.c:125
int32_t HITLS_CFG_AddExtraChainCert(HITLS_Config *config, HITLS_CERT_X509 *cert)
Add a certificate to the attached certificate chain.
定义 config_cert.c:646
int32_t HITLS_SetDefaultPasswordCbUserdata(HITLS_Ctx *ctx, void *userdata)
Set the user data used by the default password callback.
定义 conn_cert.c:97
HITLS_CERT_Key * HITLS_CFG_ParseKey(HITLS_Config *config, const uint8_t *buf, uint32_t len, HITLS_ParseType type, HITLS_ParseFormat format)
Parse Certificate file or buffer to X509.
定义 config_cert.c:599
HITLS_CERT_X509 * HITLS_GetCertificate(const HITLS_Ctx *ctx)
Obtain the local certificate. Returns the most recently added certificate if it is called before the ...
定义 conn_cert.c:144
int32_t HITLS_CFG_CtrlGetVerifyParams(HITLS_Config *config, HITLS_CERT_Store *store, uint32_t cmd, void *out)
Get certificate verification parameters
定义 config_cert.c:1070
HITLS_CERT_Chain * HITLS_CFG_GetExtraChainCerts(HITLS_Config *config)
Obtain the attached certificate chain.
定义 config_cert.c:655
int32_t HITLS_CFG_SetTlcpPrivateKey(HITLS_Config *config, HITLS_CERT_Key *privateKey, bool isClone, bool isTlcpEncCertPriKey)
Add the private key of the device certificate by the ShangMi(SM) cipher suites. Only one private key ...
int32_t HITLS_SetCertCb(HITLS_Ctx *ctx, HITLS_CertCb certCb, void *arg)
Set the certificate processing callback function. The callback can check the passed ctx structure and...
int32_t HITLS_CFG_SetVerifyCb(HITLS_Config *config, HITLS_VerifyCb callback)
Set the certificate verification callback function, cb can be NULL.
HITLS_VerifyCb HITLS_GetVerifyCb(HITLS_Ctx *ctx)
Obtain the certificate verification callback function.
int32_t HITLS_CtrlGetVerifyParams(HITLS_Ctx *ctx, HITLS_CERT_Store *store, uint32_t cmd, void *out)
Get certificate verification parameters.
定义 conn_create.c:927
int32_t HITLS_CFG_LoadCertFile(HITLS_Config *config, const char *file, HITLS_ParseFormat format)
Load the device certificate from the file.
int32_t HITLS_SetCurrentCert(HITLS_Ctx *ctx, long option)
Set the current certificate to the value based on the option parameter.
定义 conn_create.c:794
int32_t HITLS_CFG_AddChainCert(HITLS_Config *config, HITLS_CERT_X509 *cert, bool isClone)
Add the certificate to the certificate chain that is being used by the current config.
定义 config_cert.c:485
struct TlsCtx HITLS_Ctx
HITLS context
定义 hitls_type.h:35
struct TlsConfig HITLS_Config
config context
定义 hitls_type.h:41