forked from greendow/SM2-signature-creation-and-verification
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsm3_with_preprocess.h
76 lines (70 loc) · 2.75 KB
/
sm3_with_preprocess.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/**************************************************
* File name: sm3_with_preprocess.h
* Author: HAN Wei
* Author's blog: https://blog.csdn.net/henter/
* Date: Nov 17th, 2018
* Description: declare SM3 hash calculation with
preprocess functions
* Note: SM3 digest with preprocess instead of "pure"
SM3 digest is used as one input item in computation
of SM2 signature.
**************************************************/
#ifndef HEADER_SM3_DIGEST_WTIH_PREPROCESS_COMPUTATION_H
#define HEADER_SM3_DIGEST_WTIH_PREPROCESS_COMPUTATION_H
#ifdef __cplusplus
extern "C" {
#endif
/**************************************************
* Name: sm3_digest_z
* Function: compute digest of leading Z in SM3 preprocess
* Parameters:
id[in] user id
id_len[in] user id length, size in bytes
pub_key[in] SM2 public key
digest[out] digest value on Z
* Return value:
0: function executes successfully
any other value: an error occurs
* Notes:
1. The user id value cannot be NULL. If the specific
value is unknown, the default user id "1234567812345678"
can be used.
2. "pub_key" is a octet string of 65 byte length. It
is a concatenation of 04 || X || Y. X and Y both are
SM2 public key coordinates of 32-byte length.
**************************************************/
int sm3_digest_z(const unsigned char *id,
const int id_len,
const unsigned char *pub_key,
unsigned char *z_digest);
/**************************************************
* Name: sm3_digest_with_preprocess
* Function: compute SM3 digest with preprocess
* Parameters:
message[in] input message
message_len[in] input message length, size in bytes
id[in] user id
id_len[in] user id length, size in bytes
pub_key[in] SM2 public key
digest[out] digest value of SM3 preprocess
* Return value:
0: function executes successfully
any other value: an error occurs
* Notes:
1. The user id value cannot be NULL. If the specific
value is unknown, the default user id "1234567812345678"
can be used.
2. "pub_key" is a octet string of 65 byte length. It
is a concatenation of 04 || X || Y. X and Y both are
SM2 public key coordinates of 32-byte length.
**************************************************/
int sm3_digest_with_preprocess(const unsigned char *message,
const int message_len,
const unsigned char *id,
const int id_len,
const unsigned char *pub_key,
unsigned char *digest);
#ifdef __cplusplus
}
#endif
#endif /* end of HEADER_SM3_DIGEST_WTIH_PREPROCESS_COMPUTATION_H */