]> git.cryptolib.org Git - arm-crypto-lib.git/blob - blockcipher_descriptor.h
adding trivium
[arm-crypto-lib.git] / blockcipher_descriptor.h
1 /* blockcipher_descriptor.h */
2 /*
3     This file is part of the ARM-Crypto-Lib.
4     Copyright (C) 2008  Daniel Otte (daniel.otte@rub.de)
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
32
33 #ifndef VOID_FPT
34 #define VOID_FPT
35 typedef void(*void_fpt)(void);
36 #endif
37
38 typedef void(*bc_init1_fpt)(void*, void*);
39 typedef void(*bc_init2_fpt)(void*, uint16_t,void*);
40 typedef void(*bc_enc1_fpt)(void*, void*);
41 typedef void(*bc_enc2_fpt)(void*, void*, void*);
42 typedef void(*bc_dec1_fpt)(void*, void*);
43 typedef void(*bc_dec2_fpt)(void*, void*, void*);
44 typedef void(*bc_free_fpt)(void*);
45
46 typedef union{
47         void_fpt  initvoid;
48         bc_init1_fpt init1;
49         bc_init2_fpt init2;
50 } bc_init_fpt;
51
52 typedef union{
53         void_fpt  encvoid;
54         bc_enc1_fpt enc1;
55         bc_enc2_fpt enc2;
56 } bc_enc_fpt;
57
58 typedef union{
59         void_fpt  decvoid;
60         bc_dec1_fpt dec1;
61         bc_dec2_fpt dec2;
62 } bc_dec_fpt;
63
64 #define BC_INIT_TYPE   0x01
65 #define BC_INIT_TYPE_1 0x00
66 #define BC_INIT_TYPE_2 0x01
67
68 #define BC_ENC_TYPE    0x02
69 #define BC_ENC_TYPE_1  0x00
70 #define BC_ENC_TYPE_2  0x02
71 #
72 #define BC_DEC_TYPE    0x04
73 #define BC_DEC_TYPE_1  0x00
74 #define BC_DEC_TYPE_2  0x04
75
76 #define BCDESC_TYPE_BLOCKCIPHER 0x01
77
78 typedef struct {
79         uint8_t  type; /* 1==blockcipher */
80         uint8_t  flags;
81         const char*    name;
82         uint16_t ctxsize_B;
83         uint16_t blocksize_b;
84         bc_init_fpt init;
85         bc_enc_fpt  enc;
86         bc_dec_fpt  dec;
87         bc_free_fpt free;
88         const void* valid_keysize_desc;
89 } bcdesc_t; /* blockcipher descriptor type */
90
91 typedef struct{
92         bcdesc_t* desc_ptr;
93         uint16_t  keysize;
94         void*     ctx;
95 } bcgen_ctx_t;
96
97 #endif /* BLOCKCIPHER_DESCRIPTOR_H_ */
98