]> git.cryptolib.org Git - avr-crypto-lib.git/blob - keysize_descriptor.h
new and more compact aes
[avr-crypto-lib.git] / keysize_descriptor.h
1 /* keysize_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    keysize_descriptor.h 
21  * \author  Daniel Otte
22  * \email   bg@nerilex.org
23  * \date    2009-01-07
24  * \license GPLv3 or later
25  */
26
27 #ifndef KEYSIZE_DESCRIPTOR_H_
28 #define KEYSIZE_DESCRIPTOR_H_
29
30 #include <stdint.h>
31 #include <avr/pgmspace.h>
32
33 #define KS_TYPE_TERMINATOR 0x00
34 #define KS_TYPE_LIST       0x01
35 #define KS_TYPE_RANGE      0x02
36 #define KS_TYPE_ARG_RANGE  0x03
37
38 #define KS_INT(a) ((a) & 0xFF), ((a) >> 8)
39
40 typedef struct{ /* keysize is valid if listed in items */
41         uint8_t  n_items;  /* number of items (value 0 is reserved) */
42         uint16_t items[]; /* list of valid lengths */
43 }keysize_desc_list_t;
44
45 typedef struct{ /* keysize is valid if min<=keysize<=max */
46         uint16_t min;
47         uint16_t max;
48 }keysize_desc_range_t;
49
50 typedef struct{ /* keysize is valid if min<=keysize<=max and if keysize mod distance == offset */
51         uint16_t min;
52         uint16_t max;
53         uint16_t distance;
54         uint16_t offset;
55 }keysize_desc_arg_range_t;
56
57 uint8_t is_valid_keysize_P(PGM_VOID_P ks_desc, uint16_t keysize);
58 uint16_t get_keysize(PGM_VOID_P ks_desc);
59 uint16_t get_keysizes(PGM_VOID_P ks_desc, uint16_t** list);
60
61
62 #endif /* KEYSIZE_DESCRIPTOR_H_ */