3 @section Keysize descriptors
4 There are a lot of different block ciphers or cryptographic algorithms in
5 general which put several constrains to the number of bits which can be used
8 Our approach is to find a simple and compact way do specify which lengths are
9 valid and which are not. The system is quite simple, we use a list of patterns
10 (with parameters) and if any matches the keysize is valid, if none matches the
11 keysize is unsupported.
15 @item simple list of valid keysizes
16 @item range of keysizes
17 @item augmented range of keysizes
20 @subsection simple list of valid keysizes
21 The simple keysize list has the following structure:
23 typedef struct{ /* keysize is valid if listed in items */
24 uint8_t n_items; /* number of items (value 0 is reserved) */
25 uint16_t items[]; /* list of valid lengths */
28 First we specify how many keysizes we want to declare valid (this is limited to
29 255 keysizes but that should not impose any real world constrains). And follow
30 it by the keysizes as 16bit unsigned values.
32 If you want to declare a lot of keys please check first the other methods since
33 they may give a more compact definition.
35 @subsection range of keysizes
36 This method specifies an entire range of keys a valid using the following
39 typedef struct{ /* keysize is valid if min<=keysize<=max */
42 }keysize_desc_range_t;
44 So all keysizes between @code{min} and @code{max} (including @code{min} and
45 @code{max}) are valid. Please note that in most cases also keysizes which
46 are not a multiple of 8 (so are not full bytes) are also matched.
47 If you want to avoid this see the augmented range of keysizes.
49 @subsection augmented range of keysizes
50 The augmented range of keysizes uses the following structure:
52 typedef struct{ /* keysize is valid if min<=keysize<=max and if keysize mod distance == offset */
57 }keysize_desc_arg_range_t;
59 The restriction to a range is the same as with the simpler range of keysizes,
60 but also another restriction is imposed. A valid keysize must have a reminder
61 of @code{offset} when divided by @code{distance}. So you can limit a keysize
62 to full bytes by simply setting @code{distance} to @samp{8} and @code{offset}
65 @subsection the actual descriptor
66 The keysize descriptor is a list of the former patterns. Each pattern is
67 preceded by byte designating the type of pattern and the list is terminated
68 by a @code{NULL} byte.
70 The designator byte can have one of the following values:
73 Terminator byte, signals the end of the list
75 simple list of keysizes
77 simple range of keysizes
79 augmented range of keysizes