Bouffalo SDK  1.0
Bouffalolab Software Development Kit
bflb_sec_sha.h
Go to the documentation of this file.
1 #ifndef _BFLB_SEC_SHA_H
2 #define _BFLB_SEC_SHA_H
3 
4 #include "bflb_core.h"
5 
14 #define SHA_MODE_SHA256 0
15 #define SHA_MODE_SHA224 1
16 #define SHA_MODE_SHA1 2
17 #define SHA_MODE_SHA512 4
18 #define SHA_MODE_SHA384 5
19 #define SHA_MODE_SHA512T224 6
20 #define SHA_MODE_SHA512T256 7
21 
23  uint32_t total[2];
24  __attribute__((aligned(32))) uint8_t sha_buf[64];
25  __attribute__((aligned(32))) uint8_t sha_padding[64];
26  uint8_t sha_feed;
27 };
28 
30  uint32_t total[2];
31  __attribute__((aligned(32))) uint8_t sha_buf[64];
32  __attribute__((aligned(32))) uint8_t sha_padding[64];
33  uint8_t sha_feed;
34 };
35 
37  uint64_t total[2];
38  __attribute__((aligned(32))) uint8_t sha_buf[128];
39  __attribute__((aligned(32))) uint8_t sha_padding[128];
40  uint8_t sha_feed;
41 };
42 
44  uint32_t : 2;
45  uint32_t sha_mode : 3;
46  uint32_t : 1;
47  uint32_t sha_newhash_dis : 1;
48  uint32_t : 2;
49  uint32_t sha_intclr : 1;
50  uint32_t sha_intset : 1;
51  uint32_t : 1;
52  uint32_t sha_mode_ext : 2;
53  uint32_t : 2;
54  uint32_t sha_msglen : 16;
55  uint32_t sha_srcaddr;
56  uint32_t result[16];
57 };
58 
60  uint32_t total[2];
61  __attribute__((aligned(32))) uint8_t sha_buf[64];
62  __attribute__((aligned(32))) uint8_t sha_padding[64];
63  uint32_t link_addr;
64  struct bflb_sha_link_s link_cfg;
65 };
66 
68  uint32_t total[2];
69  __attribute__((aligned(32))) uint8_t sha_buf[64];
70  __attribute__((aligned(32))) uint8_t sha_padding[64];
71  uint32_t link_addr;
72  struct bflb_sha_link_s link_cfg;
73 };
74 
76  uint64_t total[2];
77  __attribute__((aligned(32))) uint8_t sha_buf[128];
78  __attribute__((aligned(32))) uint8_t sha_padding[128];
79  uint32_t link_addr;
80  struct bflb_sha_link_s link_cfg;
81 };
82 
83 #ifdef __cplusplus
84 extern "C" {
85 #endif
86 
93 void bflb_sha_init(struct bflb_device_s *dev, uint8_t mode);
94 
101 void bflb_sha1_start(struct bflb_device_s *dev, struct bflb_sha1_ctx_s *ctx);
102 
109 void bflb_sha256_start(struct bflb_device_s *dev, struct bflb_sha256_ctx_s *ctx);
110 
117 void bflb_sha512_start(struct bflb_device_s *dev, struct bflb_sha512_ctx_s *ctx);
118 
128 int bflb_sha1_update(struct bflb_device_s *dev, struct bflb_sha1_ctx_s *ctx, const uint8_t *input, uint32_t len);
129 
139 int bflb_sha256_update(struct bflb_device_s *dev, struct bflb_sha256_ctx_s *ctx, const uint8_t *input, uint32_t len);
140 
150 int bflb_sha512_update(struct bflb_device_s *dev, struct bflb_sha512_ctx_s *ctx, const uint8_t *input, uint64_t len);
151 
159 void bflb_sha1_finish(struct bflb_device_s *dev, struct bflb_sha1_ctx_s *ctx, uint8_t *output);
160 
168 void bflb_sha256_finish(struct bflb_device_s *dev, struct bflb_sha256_ctx_s *ctx, uint8_t *output);
169 
177 void bflb_sha512_finish(struct bflb_device_s *dev, struct bflb_sha512_ctx_s *ctx, uint8_t *output);
178 
184 void bflb_sha_link_init(struct bflb_device_s *dev);
185 
191 void bflb_sha_link_deinit(struct bflb_device_s *dev);
192 
200 void bflb_sha1_link_start(struct bflb_device_s *dev, struct bflb_sha1_link_ctx_s *ctx);
201 
209 void bflb_sha256_link_start(struct bflb_device_s *dev, struct bflb_sha256_link_ctx_s *ctx, int is224);
210 
218 void bflb_sha512_link_start(struct bflb_device_s *dev, struct bflb_sha512_link_ctx_s *ctx, int is384);
219 
229 int bflb_sha1_link_update(struct bflb_device_s *dev,
230  struct bflb_sha1_link_ctx_s *ctx,
231  const uint8_t *input,
232  uint32_t len);
233 
243 int bflb_sha256_link_update(struct bflb_device_s *dev,
244  struct bflb_sha256_link_ctx_s *ctx,
245  const uint8_t *input,
246  uint32_t len);
247 
257 int bflb_sha512_link_update(struct bflb_device_s *dev,
258  struct bflb_sha512_link_ctx_s *ctx,
259  const uint8_t *input,
260  uint64_t len);
261 
269 void bflb_sha1_link_finish(struct bflb_device_s *dev,
270  struct bflb_sha1_link_ctx_s *ctx,
271  uint8_t *output);
272 
280 void bflb_sha256_link_finish(struct bflb_device_s *dev,
281  struct bflb_sha256_link_ctx_s *ctx,
282  uint8_t *output);
283 
291 void bflb_sha512_link_finish(struct bflb_device_s *dev,
292  struct bflb_sha512_link_ctx_s *ctx,
293  uint8_t *output);
294 
301 
308 
309 #ifdef __cplusplus
310 }
311 #endif
312 
321 #endif
void bflb_sha1_start(struct bflb_device_s *dev, struct bflb_sha1_ctx_s *ctx)
__attribute__((aligned(32))) uint8_t sha_buf[64]
void bflb_sha512_link_start(struct bflb_device_s *dev, struct bflb_sha512_link_ctx_s *ctx, int is384)
void bflb_sha1_link_start(struct bflb_device_s *dev, struct bflb_sha1_link_ctx_s *ctx)
void bflb_sha512_start(struct bflb_device_s *dev, struct bflb_sha512_ctx_s *ctx)
int bflb_sha1_link_update(struct bflb_device_s *dev, struct bflb_sha1_link_ctx_s *ctx, const uint8_t *input, uint32_t len)
int bflb_sha256_link_update(struct bflb_device_s *dev, struct bflb_sha256_link_ctx_s *ctx, const uint8_t *input, uint32_t len)
uint32_t total[2]
Definition: bflb_sec_sha.h:23
int bflb_sha1_update(struct bflb_device_s *dev, struct bflb_sha1_ctx_s *ctx, const uint8_t *input, uint32_t len)
void bflb_sha256_link_finish(struct bflb_device_s *dev, struct bflb_sha256_link_ctx_s *ctx, uint8_t *output)
uint8_t sha_feed
Definition: bflb_sec_sha.h:26
void bflb_sha256_finish(struct bflb_device_s *dev, struct bflb_sha256_ctx_s *ctx, uint8_t *output)
int bflb_sha512_link_update(struct bflb_device_s *dev, struct bflb_sha512_link_ctx_s *ctx, const uint8_t *input, uint64_t len)
int bflb_sha512_update(struct bflb_device_s *dev, struct bflb_sha512_ctx_s *ctx, const uint8_t *input, uint64_t len)
void bflb_sha_link_deinit(struct bflb_device_s *dev)
void bflb_sha512_link_finish(struct bflb_device_s *dev, struct bflb_sha512_link_ctx_s *ctx, uint8_t *output)
void bflb_sha_init(struct bflb_device_s *dev, uint8_t mode)
void bflb_group0_release_sha_access(struct bflb_device_s *dev)
void bflb_sha256_start(struct bflb_device_s *dev, struct bflb_sha256_ctx_s *ctx)
void bflb_group0_request_sha_access(struct bflb_device_s *dev)
void bflb_sha1_finish(struct bflb_device_s *dev, struct bflb_sha1_ctx_s *ctx, uint8_t *output)
void bflb_sha1_link_finish(struct bflb_device_s *dev, struct bflb_sha1_link_ctx_s *ctx, uint8_t *output)
int bflb_sha256_update(struct bflb_device_s *dev, struct bflb_sha256_ctx_s *ctx, const uint8_t *input, uint32_t len)
void bflb_sha256_link_start(struct bflb_device_s *dev, struct bflb_sha256_link_ctx_s *ctx, int is224)
void bflb_sha512_finish(struct bflb_device_s *dev, struct bflb_sha512_ctx_s *ctx, uint8_t *output)
void bflb_sha_link_init(struct bflb_device_s *dev)