API参考
载入中...
搜索中...
未找到
crypt_encode.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_ENCODE_INTERNAL_H
17#define CRYPT_ENCODE_INTERNAL_H
18
19#include "hitls_build.h"
20#include "bsl_types.h"
21#include "bsl_asn1_internal.h"
22#include "crypt_bn.h"
23#include "crypt_eal_pkey.h"
24
25#ifdef __cplusplus
26extern "C" {
27#endif /* __cpluscplus */
28
29
30#if defined(HITLS_CRYPTO_SM2_SIGN) || defined(HITLS_CRYPTO_DSA) || defined(HITLS_CRYPTO_ECDSA)
39int32_t CRYPT_EAL_GetSignEncodeLen(uint32_t rLen, uint32_t sLen, uint32_t *maxLen);
40
50int32_t CRYPT_EAL_EncodeSign(const BN_BigNum *r, const BN_BigNum *s, uint8_t *encode, uint32_t *encodeLen);
51
61int32_t CRYPT_EAL_DecodeSign(const uint8_t *encode, uint32_t encodeLen, BN_BigNum *r, BN_BigNum *s);
62#endif
63
64#ifdef HITLS_CRYPTO_SM2_CRYPT
65typedef struct {
66 uint8_t *x; // XCoordinate
67 uint8_t *y; // YCoordinate
68 uint8_t *hash; // HASH
69 uint8_t *cipher; // CipherText
70 uint32_t xLen;
71 uint32_t yLen;
72 uint32_t hashLen;
73 uint32_t cipherLen;
74} CRYPT_SM2_EncryptData;
75
86int32_t CRYPT_EAL_GetSm2EncryptDataEncodeLen(uint32_t xLen, uint32_t yLen, uint32_t hashLen, uint32_t dataLen,
87 uint32_t *maxLen);
88
97int32_t CRYPT_EAL_EncodeSm2EncryptData(const CRYPT_SM2_EncryptData *data, uint8_t *encode, uint32_t *encodeLen);
98
107int32_t CRYPT_EAL_DecodeSm2EncryptData(const uint8_t *encode, uint32_t encodeLen, CRYPT_SM2_EncryptData *data);
108#endif
109
110#ifdef __cplusplus
111}
112#endif
113
114#endif // CRYPT_ENCODE_INTERNAL_H