API参考
载入中...
搜索中...
未找到
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
16#ifndef CERT_H
17#define CERT_H
18
19#include <stdint.h>
20#include "hitls_type.h"
21#include "hitls_cert_type.h"
22#include "cipher_suite.h"
23#include "cert_mgr.h"
24#include "tls.h"
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30#define TLS_DEFAULT_VERIFY_DEPTH 20u
31
32#define MAX_PASS_LEN 256
33
34/* tls.handshake.certificate_length Length of a label */
35#define CERT_LEN_TAG_SIZE 3u
36
37/* Used to transfer certificate data in ASN.1 DER format. */
38typedef struct CertItem {
39 uint32_t dataSize; /* Data length */
40 uint8_t *data; /* Data content */
41 struct CertItem *next;
42} CERT_Item;
43
48typedef struct {
49 HITLS_SignAlgo signAlgo; /* signature algorithm */
50 HITLS_HashAlgo hashAlgo; /* hash algorithm */
51 const uint8_t *data; /* signed data */
52 uint32_t dataLen; /* length of the signed data */
53 uint8_t *sign; /* sign */
54 uint32_t signLen; /* signature length */
56
72bool SAL_CERT_IsSignAlgorithmAllowed(const TLS_Ctx *ctx, uint16_t signScheme,
73 const uint16_t *allowList, uint32_t allowListSize);
74
87int32_t SAL_CERT_EncodeCertChain(HITLS_Ctx *ctx, PackPacket *pkt);
88
101int32_t SAL_CERT_ParseCertChain(HITLS_Ctx *ctx, CERT_Item *item, CERT_Pair **certPair);
102
117int32_t SAL_CERT_VerifyCertChain(HITLS_Ctx *ctx, CERT_Pair *certPair, bool isTlcpEncCert);
118
127uint32_t SAL_CERT_GetSignMaxLen(HITLS_Config *config, HITLS_CERT_Key *key);
128
140int32_t SAL_CERT_CreateSign(HITLS_Ctx *ctx, HITLS_CERT_Key *key, CERT_SignParam *signParam);
141
153int32_t SAL_CERT_VerifySign(HITLS_Ctx *ctx, HITLS_CERT_Key *key, CERT_SignParam *signParam);
154
168int32_t SAL_CERT_KeyEncrypt(HITLS_Ctx *ctx, HITLS_CERT_Key *key, const uint8_t *in, uint32_t inLen,
169 uint8_t *out, uint32_t *outLen);
170
184int32_t SAL_CERT_KeyDecrypt(HITLS_Ctx *ctx, HITLS_CERT_Key *key, const uint8_t *in, uint32_t inLen,
185 uint8_t *out, uint32_t *outLen);
186
194HITLS_SignHashAlgo SAL_CERT_GetDefaultSignHashAlgo(HITLS_CERT_KeyType keyType);
195
205uint8_t *SAL_CERT_SrvrGmEncodeEncCert(HITLS_Ctx *ctx, uint32_t *useLen);
206
217uint8_t *SAL_CERT_ClntGmEncodeEncCert(HITLS_Ctx *ctx, CERT_Pair *peerCert, uint32_t *useLen);
218
230
243
244#ifdef __cplusplus
245}
246#endif
247#endif
uint8_t * SAL_CERT_ClntGmEncodeEncCert(HITLS_Ctx *ctx, CERT_Pair *peerCert, uint32_t *useLen)
The client obtains the encoded content of the TLCP encryption certificate.
int32_t SAL_CERT_CheckKeySecbits(HITLS_Ctx *ctx, HITLS_CERT_X509 *cert, HITLS_CERT_Key *key)
Check the secbits of key
int32_t SAL_CERT_KeyDecrypt(HITLS_Ctx *ctx, HITLS_CERT_Key *key, const uint8_t *in, uint32_t inLen, uint8_t *out, uint32_t *outLen)
Use the certificate private key to decrypt, which is used for the RSA cipher suite.
int32_t SAL_CERT_KeyEncrypt(HITLS_Ctx *ctx, HITLS_CERT_Key *key, const uint8_t *in, uint32_t inLen, uint8_t *out, uint32_t *outLen)
Encrypted by the certificate public key, which is used for the RSA cipher suite.
bool SAL_CERT_CheckCertKeyUsage(HITLS_Ctx *ctx, HITLS_CERT_X509 *cert, HITLS_CERT_CtrlCmd keyusage)
Check whether the certificate is an encrypted certificate, a digital signature, or a permission to is...
uint8_t * SAL_CERT_SrvrGmEncodeEncCert(HITLS_Ctx *ctx, uint32_t *useLen)
Encoded content of the TLCP encryption certificate obtained by the server.
void HITLS_CERT_Key
Describes the certificate key
定义 hitls_cert_type.h:49
HITLS_CERT_CtrlCmd
ctrl option
定义 hitls_cert_type.h:85
HITLS_SignHashAlgo
Certificate Signature Algorithm Enumeration
定义 hitls_cert_type.h:177
void HITLS_CERT_X509
Describes the x509 certificate
定义 hitls_cert_type.h:37
HITLS_CERT_KeyType
Certificate Public Key Type
定义 hitls_cert_type.h:162
struct TlsCtx HITLS_Ctx
HITLS context
定义 hitls_type.h:35
struct TlsConfig HITLS_Config
config context
定义 hitls_type.h:41
定义 cert_mgr.h:32
used to transfer the signature parameter
定义 cert.h:48
定义 cert.h:38
定义 tls.h:325