YPC  0.2.0
sm2_ecc.h
1 #pragma once
2 #include <cstdint>
3 
4 namespace ypc {
5 namespace crypto {
6 struct sm2_ecc {
7  inline static uint32_t get_private_key_size() { return 32; }
8  inline static uint32_t get_public_key_size() { return 64; }
9 
10  static uint32_t gen_private_key(uint32_t skey_size, uint8_t *skey);
11 
12  static uint32_t generate_pkey_from_skey(const uint8_t *skey,
13  uint32_t skey_size, uint8_t *pkey,
14  uint32_t pkey_size);
15 
16  inline static uint32_t get_signature_size() { return 64; }
17 
18  static uint32_t sign_message(const uint8_t *skey, uint32_t skey_size,
19  const uint8_t *data, uint32_t data_size,
20  uint8_t *sig, uint32_t sig_size);
21 
22  static uint32_t verify_signature(const uint8_t *data, uint32_t data_size,
23  const uint8_t *sig, uint32_t sig_size,
24  const uint8_t *public_key,
25  uint32_t pkey_size);
26 
27  inline static uint32_t get_ecdh_shared_key_size() { return 16; }
28  static uint32_t ecdh_shared_key(const uint8_t *skey, uint32_t skey_size,
29  const uint8_t *public_key, uint32_t pkey_size,
30  uint8_t *shared_key,
31  uint32_t shared_key_size);
32 };
33 } // namespace crypto
34 } // namespace ypc
ypc::crypto::sm2_ecc
Definition: sm2_ecc.h:6