API参考
载入中...
搜索中...
未找到
crypt_codecskey.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 CRYPT_CODECSKEY_H
17#define CRYPT_CODECSKEY_H
18
19#include "hitls_build.h"
20#ifdef HITLS_CRYPTO_CODECSKEY
21
22#include "bsl_types.h"
23#include "bsl_asn1_internal.h"
24#include "crypt_eal_pkey.h"
25#ifdef HITLS_CRYPTO_KEY_INFO
26#include "bsl_uio.h"
27#endif
28
29#ifdef __cplusplus
30extern "C" {
31#endif /* __cpluscplus */
32
33typedef struct {
34 int32_t version;
35 BslCid keyType;
36 BSL_ASN1_Buffer keyParam;
37 uint8_t *pkeyRawKey;
38 uint32_t pkeyRawKeyLen;
39 void *attrs; // HITLS_X509_Attrs *
40} CRYPT_ENCODE_DECODE_Pk8PrikeyInfo;
41
42#ifdef HITLS_CRYPTO_KEY_DECODE
43
44typedef struct {
45 BslCid keyType;
46 BSL_ASN1_Buffer keyParam;
47 BSL_ASN1_BitString pubKey;
48} CRYPT_DECODE_SubPubkeyInfo;
49
50int32_t CRYPT_DECODE_SubPubkey(uint8_t *buff, uint32_t buffLen, BSL_ASN1_DecTemplCallBack keyInfoCb,
51 CRYPT_DECODE_SubPubkeyInfo *subPubkeyInfo, bool isComplete);
52
53int32_t CRYPT_DECODE_Pkcs8Info(uint8_t *buff, uint32_t buffLen, BSL_ASN1_DecTemplCallBack keyInfoCb,
54 CRYPT_ENCODE_DECODE_Pk8PrikeyInfo *pk8PrikeyInfo);
55
56#ifdef HITLS_CRYPTO_RSA
57int32_t CRYPT_EAL_ParseRsaPssAlgParam(BSL_ASN1_Buffer *param, CRYPT_RSA_PssPara *para);
58#endif
59
60#endif // HITLS_CRYPTO_KEY_DECODE
61
62#ifdef HITLS_CRYPTO_KEY_ENCODE
63
64int32_t CRYPT_ENCODE_Pkcs8Info(CRYPT_ENCODE_DECODE_Pk8PrikeyInfo *pk8PrikeyInfo, BSL_Buffer *asn1);
65
66int32_t CRYPT_EAL_EncodePubKeyBuffInternal(CRYPT_EAL_PkeyCtx *ealPubKey,
67 BSL_ParseFormat format, int32_t type, bool isComplete, BSL_Buffer *encode);
68
69#ifdef HITLS_CRYPTO_RSA
70int32_t CRYPT_EAL_EncodeRsaPssAlgParam(const CRYPT_RSA_PssPara *rsaPssParam, uint8_t **buf, uint32_t *bufLen);
71#endif
72
73#endif // HITLS_CRYPTO_KEY_ENCODE
74
75#if defined(HITLS_CRYPTO_RSA) && (defined(HITLS_CRYPTO_KEY_ENCODE) || defined(HITLS_CRYPTO_KEY_INFO))
76int32_t CRYPT_EAL_InitRsaPrv(const CRYPT_EAL_PkeyCtx *ealPriKey, CRYPT_EAL_PkeyPrv *rsaPrv);
77void CRYPT_EAL_DeinitRsaPrv(CRYPT_EAL_PkeyPrv *rsaPrv);
78int32_t CRYPT_EAL_GetRsaPssPara(CRYPT_EAL_PkeyCtx *key, CRYPT_RSA_PssPara *para, int32_t *padType);
79#endif
80
81#ifdef HITLS_PKI_CMS_ENCRYPTDATA
82// parse PKCS7-EncryptData:only support PBES2 + PBKDF2.
83int32_t CRYPT_EAL_ParseAsn1PKCS7EncryptedData(CRYPT_EAL_LibCtx *libCtx, const char *attrName, BSL_Buffer *encode,
84 const uint8_t *pwd, uint32_t pwdlen, BSL_Buffer *output);
85
86// encode PKCS7-EncryptData:only support PBES2 + PBKDF2.
87int32_t CRYPT_EAL_EncodePKCS7EncryptDataBuff(CRYPT_EAL_LibCtx *libCtx, const char *attrName, BSL_Buffer *data,
88 const void *encodeParam, BSL_Buffer *encode);
89#endif // HITLS_PKI_CMS_ENCRYPTDATA
90
91#ifdef HITLS_CRYPTO_KEY_INFO
92int32_t CRYPT_EAL_PrintPubkey(uint32_t layer, CRYPT_EAL_PkeyCtx *pkey, BSL_UIO *uio);
93
94int32_t CRYPT_EAL_PrintPrikey(uint32_t layer, CRYPT_EAL_PkeyCtx *pkey, BSL_UIO *uio);
95
96#ifdef HITLS_CRYPTO_RSA
97int32_t CRYPT_EAL_PrintRsaPssPara(uint32_t layer, CRYPT_RSA_PssPara *para, BSL_UIO *uio);
98#endif
99#endif // HITLS_CRYPTO_KEY_INFO
100
101int32_t CRYPT_EAL_GetEncodeFormat(const char *format);
102
103int32_t CRYPT_EAL_GetEncodeType(const char *type);
104
105#ifdef __cplusplus
106}
107#endif
108
109#endif // HITLS_CRYPTO_CODECSKEY
110
111#endif // CRYPT_CODECSKEY_H
BslCid
定义 bsl_obj.h:36
struct UIO_ControlBlock BSL_UIO
UIO module control structure
定义 bsl_uio.h:37
struct EAL_PkeyCtx CRYPT_EAL_PkeyCtx
定义 crypt_eal_pkey.h:108
定义 bsl_types.h:40
定义 crypt_eal_pkey.h:68
定义 crypt_types.h:92