Noise-C
 All Data Structures Files Functions Variables Typedefs Macros Groups Pages
Data Structures | Functions
Algorithm name lookup API

Data Structures

struct  NoiseProtocolId
 Noise protocol name broken out into separate identifier fields. More...
 

Functions

const char * noise_id_to_name (int category, int id)
 Maps an algorithm identifier to the corresponding name. More...
 
int noise_name_to_id (int category, const char *name, size_t name_len)
 Maps an algorithm name to the corresponding identifier. More...
 
int noise_protocol_id_to_name (char *name, size_t name_len, const NoiseProtocolId *id)
 Formats a protocol name from a set of identifiers for the algorithms that make up the name. More...
 
int noise_protocol_name_to_id (NoiseProtocolId *id, const char *name, size_t name_len)
 Parses a protocol name into a set of identifiers for the algorithms that are indicated by the name. More...
 

Detailed Description


Data Structure Documentation

struct NoiseProtocolId

Noise protocol name broken out into separate identifier fields.

Definition at line 33 of file names.h.

Data Fields
int cipher_id

Cipher algorithm identifier

int dh_id

Diffie-Hellman algorithm identifier

int hash_id

Hash algorithm identifier

int hybrid_id

Hybrid forward secrecy algorithm identifier

int pattern_id

Handshake pattern

int prefix_id

Protocol name prefix

int reserved[4]

Reserved for future use; should be zero

Function Documentation

const char* noise_id_to_name ( int  category,
int  id 
)

Maps an algorithm identifier to the corresponding name.

Parameters
categoryThe category of identifier to look for; one of NOISE_CIPHER_CATEGORY, NOISE_HASH_CATEGORY, NOISE_DH_CATEGORY, NOISE_PATTERN_CATEGORY, NOISE_PREFIX_CATEGORY, NOISE_SIGN_CATEGORY, or zero. Zero indicates "any category".
idThe algorithm identifier to map.
Returns
The NUL-terminated name of the algorithm, or NULL if the id is unknown in the specified category.

The category parameter can be used to restrict the search to algorithms of a certain type. If the id is valid for some other category, that mapping will be ignored.

See Also
noise_name_to_id()

Definition at line 182 of file names.c.

int noise_name_to_id ( int  category,
const char *  name,
size_t  name_len 
)

Maps an algorithm name to the corresponding identifier.

Parameters
categoryThe category of identifier to look for; one of NOISE_CIPHER_CATEGORY, NOISE_HASH_CATEGORY, NOISE_DH_CATEGORY, NOISE_PATTERN_CATEGORY, NOISE_PREFIX_CATEGORY, NOISE_SIGN_CATEGORY, or zero. Zero indicates "any category".
namePoints to the name to map.
name_lenLength of the name in bytes.
Returns
The algorithm identifier, or zero if the name is unknown in the specified category.

The category parameter can be used to restrict the search to algorithms of a certain type. If the name is valid for some other category, that mapping will be ignored.

See Also
noise_id_to_name()

Definition at line 146 of file names.c.

int noise_protocol_id_to_name ( char *  name,
size_t  name_len,
const NoiseProtocolId id 
)

Formats a protocol name from a set of identifiers for the algorithms that make up the name.

Parameters
nameThe buffer to write the protocol name to.
name_lenThe number of bytes of space in the name buffer.
idThe set of identifiers to format.
Returns
NOISE_ERROR_NONE on success.
NOISE_ERROR_INVALID_PARAM if either name or id is NULL.
NOISE_ERROR_INVALID_LENGTH if the name buffer is not large enough to contain the full name.
NOISE_ERROR_UNKNOWN_ID if one of the identifiers in id does not have a known mapping to a name.

This function guarantees to NUL-terminate the name if the function succeeds.

It is recommended that name_len be at least NOISE_MAX_PROTOCOL_NAME bytes in length.

See Also
noise_protocol_name_to_id()

Definition at line 437 of file names.c.

int noise_protocol_name_to_id ( NoiseProtocolId id,
const char *  name,
size_t  name_len 
)

Parses a protocol name into a set of identifiers for the algorithms that are indicated by the name.

Parameters
idThe resulting structure to populate with identifiers.
namePoints to the start of the protocol name.
name_lenThe length of the protocol name in bytes.
Returns
NOISE_ERROR_NONE on success.
NOISE_ERROR_INVALID_PARAM if either id or name is NULL.
NOISE_ERROR_UNKNOWN_NAME if the protocol name could not be parsed.
See Also
noise_protocol_id_to_name()

Definition at line 332 of file names.c.