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