SemiDrive SSDK Appication Program Interface PTG3.0
sm2.h
Go to the documentation of this file.
1/*****************************************************************************
2 *
3 *
4 *Copyright (c) 2021-2029 Semidrive Incorporated. All rights reserved.
5 *Software License Agreement
6 *
7 ******************************************************************************
8 */
9#ifndef SM2_H
10#define SM2_H
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
16#include <pke.h>
17
18#include "sm2_basic.h"
19
20/*only available for PKE_HP*/
21#define SM2_HIGH_SPEED
22
23/*some sm2 length*/
24#define SM2_BIT_LEN (256)
25#define SM2_BYTE_LEN (32)
26#define SM2_WORD_LEN (8)
27#define SM3_DIGEST_BYTE_LEN SM2_BYTE_LEN
28#define SM2_MAX_ID_BYTE_LEN (1 << 13)
29
30uint32_t sm2_sign(uint8_t E[32], uint8_t rand_k[32], uint8_t priKey[32],
31 uint8_t signature[64]);
32
33uint32_t sm2_verify(uint8_t E[32], uint8_t pubKey[65], uint8_t signature[64]);
34
35uint32_t sm2_encrypt(uint8_t *M, uint32_t MByteLen, uint8_t rand_k[32],
36 uint8_t pubKey[65], sm2_cipher_order_e order, uint8_t *C,
37 uint32_t *CByteLen);
38
39uint32_t sm2_decrypt(uint8_t *C, uint32_t CByteLen, uint8_t priKey[32],
40 sm2_cipher_order_e order, uint8_t *M, uint32_t *MByteLen);
41
42uint32_t sm2_exchangekey(sm2_exchange_role_e role, uint8_t *dA, uint8_t *PB,
43 uint8_t *rA, uint8_t *RA, uint8_t *RB, uint8_t *ZA,
44 uint8_t *ZB, uint32_t kByteLen, uint8_t *KA,
45 uint8_t *S1, uint8_t *SA);
46
47#ifdef PKE_SEC
48
49#define SM2_SEC
50#ifdef SM2_SEC
51
52enum SM2_RET_CODE_S { SM2_SUCCESS_S = 0x3E2FDB1A, SM2_ERROR_S = 0xCBAD735E };
53
54uint32_t sm2_sign_s(uint8_t E[32], uint8_t rand_k[32], uint8_t priKey[32],
55 uint8_t signature[64]);
56
57uint32_t sm2_verify_s(uint8_t E[32], uint8_t pubKey[65], uint8_t signature[64]);
58
59uint32_t sm2_encrypt_s(uint8_t *M, uint32_t MByteLen, uint8_t rand_k[32],
60 uint8_t pubKey[65], sm2_cipher_order_e order, uint8_t *C,
61 uint32_t *CByteLen);
62
63uint32_t sm2_decrypt_s(uint8_t *C, uint32_t CByteLen, uint8_t priKey[32],
64 sm2_cipher_order_e order, uint8_t *M,
65 uint32_t *MByteLen);
66
67uint32_t sm2_exchangekey_s(sm2_exchange_role_e role, uint8_t *dA, uint8_t *PB,
68 uint8_t *rA, uint8_t *RA, uint8_t *RB, uint8_t *ZA,
69 uint8_t *ZB, uint32_t kByteLen, uint8_t *KA,
70 uint8_t *S1, uint8_t *SA);
71
72#endif
73#endif
74
75#ifdef __cplusplus
76}
77#endif
78
79#endif
Semidrive CRYPTO pke header file.
uint32_t sm2_verify(uint8_t E[32], uint8_t pubKey[65], uint8_t signature[64])
uint32_t sm2_decrypt(uint8_t *C, uint32_t CByteLen, uint8_t priKey[32], sm2_cipher_order_e order, uint8_t *M, uint32_t *MByteLen)
uint32_t sm2_sign(uint8_t E[32], uint8_t rand_k[32], uint8_t priKey[32], uint8_t signature[64])
uint32_t sm2_exchangekey(sm2_exchange_role_e role, uint8_t *dA, uint8_t *PB, uint8_t *rA, uint8_t *RA, uint8_t *RB, uint8_t *ZA, uint8_t *ZB, uint32_t kByteLen, uint8_t *KA, uint8_t *S1, uint8_t *SA)
uint32_t sm2_encrypt(uint8_t *M, uint32_t MByteLen, uint8_t rand_k[32], uint8_t pubKey[65], sm2_cipher_order_e order, uint8_t *C, uint32_t *CByteLen)
sm2_exchange_role_e
Definition: sm2_basic.h:42
sm2_cipher_order_e
Definition: sm2_basic.h:49