Bouffalo SDK  1.0
Bouffalolab Software Development Kit
bflb_sec_ecdsa.h
Go to the documentation of this file.
1 #ifndef _BFLB_SEC_ECDSA_H
2 #define _BFLB_SEC_ECDSA_H
3 
4 #include "bflb_core.h"
5 
14 #define ECP_SECP256R1 0
15 #define ECP_SECP256K1 1
16 
17 struct bflb_ecdsa_s {
18  uint8_t ecpId;
19  uint8_t pad[3];
20  uint32_t *privateKey;
21  uint32_t *publicKeyx;
22  uint32_t *publicKeyy;
23 };
24 
25 struct bflb_ecdh_s {
26  uint8_t ecpId;
27 };
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
40 int bflb_sec_ecdsa_init(struct bflb_ecdsa_s *handle, uint8_t id);
41 
48 int bflb_sec_ecdsa_deinit(struct bflb_ecdsa_s *handle);
49 
61 int bflb_sec_ecdsa_sign(struct bflb_ecdsa_s *handle, const uint32_t *random_k, const uint32_t *hash, uint32_t hashLenInWord, uint32_t *r, uint32_t *s);
62 
73 int bflb_sec_ecdsa_verify(struct bflb_ecdsa_s *handle, const uint32_t *hash, uint32_t hashLen, const uint32_t *r, const uint32_t *s);
74 
82 int bflb_sec_ecdsa_get_private_key(struct bflb_ecdsa_s *handle, uint32_t *private_key);
83 
93 int bflb_sec_ecdsa_get_public_key(struct bflb_ecdsa_s *handle, const uint32_t *private_key, const uint32_t *pRx, const uint32_t *pRy);
94 
102 int bflb_sec_ecdh_init(struct bflb_ecdh_s *handle, uint8_t id);
103 
110 int bflb_sec_ecdh_deinit(struct bflb_ecdh_s *handle);
111 
123 int bflb_sec_ecdh_get_encrypt_key(struct bflb_ecdh_s *handle, const uint32_t *pkX, const uint32_t *pkY, const uint32_t *private_key, const uint32_t *pRx, const uint32_t *pRy);
124 
134 int bflb_sec_ecdh_get_public_key(struct bflb_ecdh_s *handle, const uint32_t *private_key, const uint32_t *pRx, const uint32_t *pRy);
135 
144 int bflb_sec_ecc_get_random_value(uint32_t *data, uint32_t *max_ref, uint32_t size);
145 
146 #ifdef __cplusplus
147 }
148 #endif
149 
158 #endif
int bflb_sec_ecdh_get_public_key(struct bflb_ecdh_s *handle, const uint32_t *private_key, const uint32_t *pRx, const uint32_t *pRy)
uint8_t ecpId
int bflb_sec_ecdsa_init(struct bflb_ecdsa_s *handle, uint8_t id)
int bflb_sec_ecdh_deinit(struct bflb_ecdh_s *handle)
int bflb_sec_ecdsa_get_public_key(struct bflb_ecdsa_s *handle, const uint32_t *private_key, const uint32_t *pRx, const uint32_t *pRy)
uint32_t * publicKeyy
uint32_t * privateKey
int bflb_sec_ecdsa_deinit(struct bflb_ecdsa_s *handle)
int bflb_sec_ecdsa_get_private_key(struct bflb_ecdsa_s *handle, uint32_t *private_key)
uint32_t * publicKeyx
int bflb_sec_ecdh_get_encrypt_key(struct bflb_ecdh_s *handle, const uint32_t *pkX, const uint32_t *pkY, const uint32_t *private_key, const uint32_t *pRx, const uint32_t *pRy)
int bflb_sec_ecdsa_verify(struct bflb_ecdsa_s *handle, const uint32_t *hash, uint32_t hashLen, const uint32_t *r, const uint32_t *s)
int bflb_sec_ecdsa_sign(struct bflb_ecdsa_s *handle, const uint32_t *random_k, const uint32_t *hash, uint32_t hashLenInWord, uint32_t *r, uint32_t *s)
int bflb_sec_ecc_get_random_value(uint32_t *data, uint32_t *max_ref, uint32_t size)
uint8_t pad[3]
int bflb_sec_ecdh_init(struct bflb_ecdh_s *handle, uint8_t id)