]> git.cryptolib.org Git - avr-crypto-lib.git/blob - blockcipher_descriptor.h
switching to simualtion testport
[avr-crypto-lib.git] / blockcipher_descriptor.h
1 /* blockcipher_descriptor.h */
2 /*
3     This file is part of the AVR-Crypto-Lib.
4     Copyright (C) 2006-2015 Daniel Otte (bg@nerilex.org)
5
6     This program is free software: you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation, either version 3 of the License, or
9     (at your option) any later version.
10
11     This program is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 */
19 /**
20  * \file                blockcipher_descriptor.h
21  * \author              Daniel Otte 
22  * \date                2009-02-04
23  * 
24  * \license         GPLv3 or later
25  * 
26  */
27
28 #ifndef BLOCKCIPHER_DESCRIPTOR_H_
29 #define BLOCKCIPHER_DESCRIPTOR_H_
30 #include <stdint.h>
31 #include <avr/pgmspace.h>
32
33
34 #ifndef VOID_FPT
35 #define VOID_FPT
36 typedef void(*void_fpt)(void);
37 #endif
38
39 typedef void(*bc_init1_fpt)(void*, void*);
40 typedef void(*bc_init2_fpt)(void*, uint16_t,void*);
41 typedef void(*bc_enc1_fpt)(void*, void*);
42 typedef void(*bc_enc2_fpt)(void*, void*, void*);
43 typedef void(*bc_dec1_fpt)(void*, void*);
44 typedef void(*bc_dec2_fpt)(void*, void*, void*);
45 typedef void(*bc_free_fpt)(void*);
46
47 typedef union{
48         void_fpt  initvoid;
49         bc_init1_fpt init1;
50         bc_init2_fpt init2;
51 } bc_init_fpt;
52
53 typedef union{
54         void_fpt  encvoid;
55         bc_enc1_fpt enc1;
56         bc_enc2_fpt enc2;
57 } bc_enc_fpt;
58
59 typedef union{
60         void_fpt  decvoid;
61         bc_dec1_fpt dec1;
62         bc_dec2_fpt dec2;
63 } bc_dec_fpt;
64
65 #define BC_INIT_TYPE   0x01
66 #define BC_INIT_TYPE_1 0x00 /* for fix keylength */
67 #define BC_INIT_TYPE_2 0x01 /* keylength is passed as second parameter */
68
69 #define BC_ENC_TYPE    0x02
70 #define BC_ENC_TYPE_1  0x00
71 #define BC_ENC_TYPE_2  0x02
72 #
73 #define BC_DEC_TYPE    0x04
74 #define BC_DEC_TYPE_1  0x00
75 #define BC_DEC_TYPE_2  0x04
76
77 #define BCDESC_TYPE_BLOCKCIPHER 0x01
78
79 typedef struct {
80         uint8_t  type; /* 1==blockcipher */
81         uint8_t  flags;
82         PGM_P    name;
83         uint16_t ctxsize_B;
84         uint16_t blocksize_b;
85         bc_init_fpt init;
86         bc_enc_fpt  enc;
87         bc_dec_fpt  dec;
88         bc_free_fpt free;
89         PGM_VOID_P valid_keysize_desc;
90 } bcdesc_t; /* blockcipher descriptor type */
91
92 typedef struct{
93         bcdesc_t *desc_ptr;
94         uint16_t  keysize;
95         void*     ctx;
96 } bcgen_ctx_t;
97
98 #endif /* BLOCKCIPHER_DESCRIPTOR_H_ */
99