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