Ordo  0.3.4
Symmetric Cryptography Library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Macros | Typedefs | Enumerations | Functions
identification.h File Reference

Utility. More...

Go to the source code of this file.

Macros

#define PRIM_UNKNOWN
 

Typedefs

typedef int prim_t
 Data type which holds a primitive identifier.
 

Enumerations

enum  PRIM_TYPE
 

Functions

ORDO_PUBLIC int prim_avail (prim_t prim)
 
ORDO_PUBLIC const char * prim_name (prim_t prim)
 
ORDO_PUBLIC enum PRIM_TYPE prim_type (prim_t prim)
 
ORDO_PUBLIC prim_t prim_from_name (const char *name)
 
ORDO_PUBLIC const prim_tprims_by_type (enum PRIM_TYPE type)
 
ORDO_PUBLIC prim_t prim_default (enum PRIM_TYPE type)
 

Detailed Description

Utility.

This header contains definitions assigning an identifier to each primitive in the library - hash functions, block ciphers, modes of operation, and so on - which can then be used in higher level API's for abstraction purposes and more expressive code. This header also provides functionality relating to primitive management, e.g. which primitives are available, etc...

Note the zero ID will always stand for an error situation e.g. a primitive is not available. The zero ID is never a valid primitive identifier.

This also allows for a quick overview of what is implemented in Ordo.

Macro Definition Documentation

#define PRIM_UNKNOWN

Value representing an unknown primitive, defined as zero.

Remarks
You can use this to check for errors or for comparisons.

Enumeration Type Documentation

enum PRIM_TYPE

Enumerates the different types of primitives (values start at 1).

Function Documentation

ORDO_PUBLIC int prim_avail ( prim_t  prim)

Checks whether a primitive is available.

Parameters
[in]primA primitive identifier.
Returns
0 if the primitive is not available, 1 otherwise.
ORDO_PUBLIC const char* prim_name ( prim_t  prim)

Returns the name of a primitive.

Parameters
[in]primA primitive identifier.
Returns
The name of the primitive as a human-readable string, or zero, if the primitive does not exist (i.e. invalid identifier passed).
Remarks
Do not rely on this being constant, use it for display only.
Warning
Will not work if the primitive is not available.
ORDO_PUBLIC enum PRIM_TYPE prim_type ( prim_t  prim)

Returns the type of a given primitive.

Parameters
[in]primA primitive identifier.
Returns
The type of the primitive, or zero on error.
Warning
Will not work if the primitive is not available.
ORDO_PUBLIC prim_t prim_from_name ( const char *  name)

Returns a primitive identifier from a name.

Parameters
[in]nameA primitive name.
Returns
The corresponding primitive identifier, or zero on error.
Warning
Will not work if the primitive is not available.
ORDO_PUBLIC const prim_t* prims_by_type ( enum PRIM_TYPE  type)

Returns a list of available primitives of a given type.

Parameters
[in]typeA primitive type.
Returns
A zero-terminated list of such primitives.
ORDO_PUBLIC prim_t prim_default ( enum PRIM_TYPE  type)

Returns the default available primitive of a given type.

Parameters
[in]typeA primitive type.
Returns
The default primitive, or zero if none exists.
Warning
It is recommended to keep at least one primitive of every type in the library, in order for some software (e.g. the test driver) to work properly, but this is not strictly required (so that heavily stripped builds of the library will still work properly).
The return value of this function depends on which primitives are available, and even though they are loosely prioritized, based on an arbitrary strength/performance scale, there is absolutely no guarantee the primitive returned will be suitable for use (in the context of your application). Use this when you do not care about the characteristics of a primitive beyond its type.