API参考
载入中...
搜索中...
未找到
bsl_pem_internal.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#ifndef BSL_PEM_INTERNAL_H
16#define BSL_PEM_INTERNAL_H
17
18#include "hitls_build.h"
19#ifdef HITLS_BSL_PEM
20#include <stdint.h>
21#include "bsl_types.h"
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27#define BSL_PEM_CERT_BEGIN_STR "-----BEGIN CERTIFICATE-----"
28#define BSL_PEM_CERT_END_STR "-----END CERTIFICATE-----"
29
30#define BSL_PEM_CRL_BEGIN_STR "-----BEGIN X509 CRL-----"
31#define BSL_PEM_CRL_END_STR "-----END X509 CRL-----"
32
33#define BSL_PEM_PUB_KEY_BEGIN_STR "-----BEGIN PUBLIC KEY-----"
34#define BSL_PEM_PUB_KEY_END_STR "-----END PUBLIC KEY-----"
35
36#define BSL_PEM_RSA_PUB_KEY_BEGIN_STR "-----BEGIN RSA PUBLIC KEY-----"
37#define BSL_PEM_RSA_PUB_KEY_END_STR "-----END RSA PUBLIC KEY-----"
38
39#define BSL_PEM_RSA_PRI_KEY_BEGIN_STR "-----BEGIN RSA PRIVATE KEY-----"
40#define BSL_PEM_RSA_PRI_KEY_END_STR "-----END RSA PRIVATE KEY-----"
41
43#define BSL_PEM_EC_PRI_KEY_BEGIN_STR "-----BEGIN EC PRIVATE KEY-----"
44#define BSL_PEM_EC_PRI_KEY_END_STR "-----END EC PRIVATE KEY-----"
45
47#define BSL_PEM_PRI_KEY_BEGIN_STR "-----BEGIN PRIVATE KEY-----"
48#define BSL_PEM_PRI_KEY_END_STR "-----END PRIVATE KEY-----"
49
51#define BSL_PEM_P8_PRI_KEY_BEGIN_STR "-----BEGIN ENCRYPTED PRIVATE KEY-----"
52#define BSL_PEM_P8_PRI_KEY_END_STR "-----END ENCRYPTED PRIVATE KEY-----"
53
54#define BSL_PEM_CERT_REQ_BEGIN_STR "-----BEGIN CERTIFICATE REQUEST-----"
55#define BSL_PEM_CERT_REQ_END_STR "-----END CERTIFICATE REQUEST-----"
56
57/* encode must end in '\0' */
58bool BSL_PEM_IsPemFormat(char *encode, uint32_t encodeLen);
59
60int32_t BSL_PEM_GetAsn1Encode(const char *encode, const uint32_t encodeLen, uint8_t **asn1Encode, uint32_t *asn1Len);
61
62typedef struct {
63 const char *head;
64 const char *tail;
65} BSL_PEM_Symbol;
66
67int32_t BSL_PEM_EncodeAsn1ToPem(uint8_t *asn1Encode, uint32_t asn1Len, BSL_PEM_Symbol *symbol,
68 char **encode, uint32_t *encodeLen);
69
70/* encode must end in '\0' */
71int32_t BSL_PEM_DecodePemToAsn1(char **encode, uint32_t *encodeLen, BSL_PEM_Symbol *symbol, uint8_t **asn1Encode,
72 uint32_t *asn1Len);
73
74int32_t BSL_PEM_GetPemRealEncode(char **encode, uint32_t *encodeLen, BSL_PEM_Symbol *symbol, char **realEncode,
75 uint32_t *realLen);
76
77int32_t BSL_PEM_GetSymbolAndType(char *encode, uint32_t encodeLen, BSL_PEM_Symbol *symbol, const char **type);
78
79#ifdef __cplusplus
80}
81#endif /* __cplusplus */
82#endif /* HITLS_BSL_PEM */
83#endif /* BSL_PEM_INTERNAL_H */