ARMEBS4  revision-26.06.2015
hash.h
Go to the documentation of this file.
1 /************************************************************************//**
2  * \file heivs/hash.h
3  * \brief hash abstraction
4  * \author marc dot pignat at hevs dot ch
5  *
6  * This abstraction will be used to hide hash (md5s, sha-1, crc, ...) functions
7  * \ingroup libheivs_stm32_misc
8  * @{
9  ***************************************************************************/
10 #ifndef HEIVS_HASH_H
11 #define HEIVS_HASH_H
12 
13 #ifdef __cplusplus
14  extern "C" {
15 #endif
16 
17 #include <stddef.h>
18 #include <stdint.h>
19 #include "heivs/error.h"
20 
21 enum hash_state_e
22 {
23  HASH_STATE_IDLE = 0,
24  HASH_STATE_BUSY,
25 };
26 
27 struct heivs_hash_t
28 {
29  const char *name;
30  enum hash_state_e state;
31 
32  status_e (*init)(struct heivs_hash_t *hash, void *state, size_t state_size);
33  status_e (*run)(struct heivs_hash_t *hash, void *state, const void *data, size_t size);
34  status_e (*finish)(struct heivs_hash_t *hash, void *state);
35 
36  const size_t state_size;
37  const size_t hash_size;
38 };
39 
40 status_e hash_init(struct heivs_hash_t *hash, void *state, size_t state_size);
41 status_e hash_run(struct heivs_hash_t *hash, void *state, const void *data, size_t size);
42 status_e hash_finish(struct heivs_hash_t *hash, void *state);
43 
44 #define hash_declare_state(pHash, name) uint32_t name[pHash->state_size/sizeof(uint32_t)]
45 
46 #ifdef __cplusplus
47  }
48 #endif
49 
50 /**
51  * @}
52  */
53 #endif /* HEIVS_HASH_H */
Errors definitions.
status_e
Known errors.
Definition: error.h:21