]> git.cryptolib.org Git - arm-crypto-lib.git/blob - hashfunction_descriptor.h
improving present
[arm-crypto-lib.git] / hashfunction_descriptor.h
1 /* hashfunction_descriptor.h */
2
3 #ifndef HASHFUNCTION_DESCRIPTOR_H_
4 #define HASHFUNCTION_DESCRIPTOR_H_
5 #include <stdint.h>
6
7 #ifndef VOID_FPT
8 #define VOID_FPT
9 typedef void(*void_fpt)(void);
10 #endif
11
12 typedef void(*hf_init_fpt)(void*);
13 typedef void(*hf_nextBlock_fpt)(void*, const void*);
14 typedef void(*hf_lastBlock_fpt)(void*, const void*, uint16_t);
15 typedef void(*hf_ctx2hash_fpt)(void*, void*);
16 typedef void(*hf_free_fpt)(void*);
17 typedef void(*hf_mem_fpt)(void*, const void*, uint32_t);
18
19
20 #define HFDESC_TYPE_HASHFUNCTION 0x02
21
22 typedef struct {
23         /** typefield, always 2 for hash functions */
24         uint8_t  type; /* 2 == hashfunction */
25         /** flags, currently unused should be set to zero */
26         uint8_t  flags;
27         /** name, flash pointer to the name string */
28         const char*    name;
29         /** ctxsize_B, size of the hash context in bytes */
30         uint16_t ctxsize_B;
31         /** blocksize_b, size of an input block in bits */
32         uint16_t blocksize_b;
33         /** hashsize_b, size of the output hash value in bits */
34         uint16_t hashsize_b;
35         /** init, function pointer to the algorithms init function */
36         hf_init_fpt init;
37         /** nextBlock, function pointer to the algorithms nextBlock function */
38         hf_nextBlock_fpt  nextBlock;
39         /** lastBlock, function pointer to the algorithms lastBlock function */
40         hf_lastBlock_fpt  lastBlock;
41         /** ctx2hash, function pointer to the algorithms ctx2hash function */
42         hf_ctx2hash_fpt   ctx2hash;
43         /** free, function pointer to the algorithms free function or NULL if 
44          *  there is no such function */
45         hf_free_fpt free;
46         /** mem, function pointer to a function which hashes a message in RAM
47          *  completely or NULL if there is no such function */
48         hf_mem_fpt mem;
49 } hfdesc_t; /* hashfunction descriptor type */
50
51 typedef struct{
52         hfdesc_t* desc_ptr;
53         void*     ctx;
54 } hfgen_ctx_t;
55
56 #endif /* HASHFUNCTION_DESCRIPTOR_H_ */
57