]> git.cryptolib.org Git - avr-crypto-lib.git/blob - blockcipher_descriptor.h
first lines of a blockcipher abstraction layer
[avr-crypto-lib.git] / blockcipher_descriptor.h
1 /* blockcipher_descriptor.h */
2
3 #ifndef BLOCKCIPHER_DESCRIPTOR_H_
4 #define BLOCKCIPHER_DESCRIPTOR_H_
5 #include <stdint.h>
6 #include <avr/pgmspace.h>
7
8 typedef void(*void_fpt)(void);
9 typedef void(*bc_init1_fpt)(void*, void*);
10 typedef void(*bc_init2_fpt)(void*, uint16_t,void*);
11 typedef void(*bc_enc1_fpt)(void*, void*);
12 typedef void(*bc_enc2_fpt)(void*, void*, void*);
13 typedef void(*bc_dec1_fpt)(void*, void*);
14 typedef void(*bc_dec2_fpt)(void*, void*, void*);
15 typedef void(*bc_free_fpt)(void*);
16
17 typedef union{
18         void_fpt  initvoid;
19         bc_init1_fpt init1;
20         bc_init2_fpt init2;
21 } bc_init_fpt;
22
23 typedef union{
24         void_fpt  encvoid;
25         bc_enc1_fpt enc1;
26         bc_enc2_fpt enc2;
27 } bc_enc_fpt;
28
29 typedef union{
30         void_fpt  decvoid;
31         bc_dec1_fpt dec1;
32         bc_dec2_fpt dec2;
33 } bc_dec_fpt;
34
35 #define BC_INIT_TYPE   0x01
36 #define BC_INIT_TYPE_1 0x00
37 #define BC_INIT_TYPE_2 0x01
38
39 #define BC_ENC_TYPE    0x02
40 #define BC_ENC_TYPE_1  0x00
41 #define BC_ENC_TYPE_2  0x02
42 #
43 #define BC_DEC_TYPE    0x04
44 #define BC_DEC_TYPE_1  0x00
45 #define BC_DEC_TYPE_2  0x04
46
47 #define BCDESC_TYPE_BLOCKCIPHER 0x01
48
49 typedef struct {
50         uint8_t  type; /* 1==blockcipher */
51         uint8_t  flags;
52         PGM_P    name;
53         uint16_t ctxsize_B;
54         uint16_t blocksize_b;
55         bc_init_fpt init;
56         bc_enc_fpt  enc;
57         bc_dec_fpt  dec;
58         bc_free_fpt free;
59         PGM_VOID_P valid_keysize_desc;
60 } bcdesc_t; /* blockcipher descriptor type */
61
62 typedef struct{
63         bcdesc_t* desc_ptr;
64         uint16_t  keysize;
65         void*     ctx;
66 } bcgen_ctx_t;
67
68 #endif /* BLOCKCIPHER_DESCRIPTOR_H_ */
69