]> git.cryptolib.org Git - arm-crypto-lib.git/blob - keysize_descriptor.h
Adding Khazad
[arm-crypto-lib.git] / keysize_descriptor.h
1 /* keysize_descriptor.h */
2 /*
3     This file is part of the AVR-Crypto-Lib.
4     Copyright (C) 2009  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    keysize_descriptor.h 
21  * \author  Daniel Otte
22  * \email   daniel.otte@rub.de
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
32 #define KS_TYPE_TERMINATOR 0x00
33 #define KS_TYPE_LIST       0x01
34 #define KS_TYPE_RANGE      0x02
35 #define KS_TYPE_ARG_RANGE  0x03
36
37 #define KS_INT(a) ((a)&0xFF), ((a)>>8)
38
39 typedef struct{ /* keysize is valid if listed in items */
40         uint8_t  n_items;  /* number of items (value 0 is reserved) */
41         uint16_t items[]; /* list of valid lengths */
42 }keysize_desc_list_t;
43
44 typedef struct{ /* keysize is valid if min<=keysize<=max */
45         uint16_t min;
46         uint16_t max;
47 }keysize_desc_range_t;
48
49 typedef struct{ /* keysize is valid if min<=keysize<=max and if keysize mod distance == offset */
50         uint16_t min;
51         uint16_t max;
52         uint16_t distance;
53         uint16_t offset;
54 }keysize_desc_arg_range_t;
55
56 uint8_t is_valid_keysize_P(const void* ks_desc, uint16_t keysize);
57 uint16_t get_keysize(const void* ks_desc);
58 uint16_t get_keysizes(const void* ks_desc, uint16_t** list);
59
60
61 #endif /* KEYSIZE_DESCRIPTOR_H_ */