Ordo
0.3.4
Symmetric Cryptography Library
|
Utility. More...
Go to the source code of this file.
Enumerations | |
enum | ORDO_QUERY { KEY_LEN_Q, BLOCK_SIZE_Q, DIGEST_LEN_Q, IV_LEN_Q } |
Utility.
This header contains declarations for query codes used when querying information from primitives or other library objects. The query must return a length or something relating to size, which is why it is used for key lengths and related quantities.
The query codes provide a lightweight mechanism to select suitable parameters when using the library, and, alternatively, iterating over all possible parameters when necessary, while still retaining some level of abstraction in user code.
All query functions take the following arguments:
size_t
)They have the following properties (where X
stands for the relevant quantity of the concerned primitive, e.g. "valid key length for some block
cipher"):
query(code, 0)
returns the smallest X
.query(code, (size_t)-1)
returns the largest X
.query(code, n) == n
then n
is an X
.n
is less than the largest X
, then query(code, n) > n
.query(code, n + 1) == n
then n
is the largest X
. Otherwise query(code, n + 1)
returns the next X
(in increasing order).The motivation for designing this interface in this fashion is to ensure no information loss occurs when user input is provided to the library. For instance, if the user provides a 160-bit key to AES, he will first query the block cipher key length using KEY_LEN_Q
, suggesting a 160-bit key, and the AES cipher will correctly identify the ideal key length as 192 bits, and not 128 bits (which would lead to part of the key being unused). This allows software using the library to dynamically adjust to whatever cryptographic primitives are in use without compromising security.
enum ORDO_QUERY |
Query codes used by the library. These end in _Q
.