1 /* keysize_descriptor.h */
3 This file is part of the AVR-Crypto-Lib.
4 Copyright (C) 2009 Daniel Otte (daniel.otte@rub.de)
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.
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.
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/>.
20 * \file keysize_descriptor.h
22 * \email daniel.otte@rub.de
24 * \license GPLv3 or later
27 #ifndef KEYSIZE_DESCRIPTOR_H_
28 #define KEYSIZE_DESCRIPTOR_H_
31 #if (defined(__AVR__))
32 #include <avr\pgmspace.h>
37 #define KS_TYPE_TERMINATOR 0x00
38 #define KS_TYPE_LIST 0x01
39 #define KS_TYPE_RANGE 0x02
40 #define KS_TYPE_ARG_RANGE 0x03
42 #define KS_INT(a) ((a)&0xFF), ((a)>>8)
44 typedef struct{ /* keysize is valid if listed in items */
45 uint8_t n_items; /* number of items (value 0 is reserved) */
46 uint16_t items[]; /* list of valid lengths */
49 typedef struct{ /* keysize is valid if min<=keysize<=max */
52 }keysize_desc_range_t;
54 typedef struct{ /* keysize is valid if min<=keysize<=max and if keysize mod distance == offset */
59 }keysize_desc_arg_range_t;
61 uint8_t is_valid_keysize_P(PGM_VOID_P ks_desc, uint16_t keysize);
62 uint16_t get_keysize(PGM_VOID_P ks_desc);
63 uint16_t get_keysizes(PGM_VOID_P ks_desc, uint16_t** list);
66 #endif /* KEYSIZE_DESCRIPTOR_H_ */