56 static NoiseIdMapping
const algorithm_names[] = {
148 const NoiseIdMapping *mapping = algorithm_names;
149 int mask = category ?
NOISE_ID(0xFF, 0) : 0;
152 while (mapping->name_len) {
153 if ((mapping->id & mask) == category) {
154 if (mapping->name_len == name_len &&
155 !memcmp(mapping->name, name, name_len)) {
184 const NoiseIdMapping *mapping = algorithm_names;
185 int mask = category ?
NOISE_ID(0xFF, 0) : 0;
188 while (mapping->name_len) {
189 if ((mapping->id & mask) == category) {
190 if (mapping->id ==
id)
191 return mapping->name;
214 static int noise_protocol_parse_field
215 (
int category,
const char *name,
size_t len,
size_t *posn,
216 int is_last,
int *ok)
218 size_t start, field_len;
227 while (*posn < len && name[*posn] !=
'_')
229 field_len = *posn - start;
270 static int noise_protocol_parse_dual_field
271 (
int category,
const char *name,
size_t len,
272 size_t *posn,
int *second_id,
int *ok)
274 size_t start, field_len;
286 while (*posn < len && name[*posn] !=
'_' && name[*posn] !=
'+')
293 field_len = *posn - start;
303 if (name[*posn] ==
'_') {
310 *second_id = noise_protocol_parse_field(category, name, len, posn, 0, ok);
345 id->prefix_id = noise_protocol_parse_field
347 id->pattern_id = noise_protocol_parse_field
349 id->dh_id = noise_protocol_parse_dual_field
351 id->cipher_id = noise_protocol_parse_field
353 id->hash_id = noise_protocol_parse_field
379 static void noise_protocol_format_field
380 (
int category,
int id,
char *name,
size_t len,
size_t *posn,
381 int is_last,
int *err)
383 const char *alg_name;
396 alg_len = strlen(alg_name);
399 if (alg_len >= (len - *posn)) {
403 memcpy(name + *posn, alg_name, alg_len);
408 name[(*posn)++] =
'_';
444 if (name && name_len)
456 noise_protocol_format_field
458 noise_protocol_format_field
461 noise_protocol_format_field
465 noise_protocol_format_field
468 if ((posn + 1) < name_len)
473 noise_protocol_format_field
476 noise_protocol_format_field
478 noise_protocol_format_field
483 for (posn = 0; posn < (
sizeof(
id->reserved) /
sizeof(id->
reserved[0])) &&
#define NOISE_PATTERN_XX
Handshake pattern identifier for "XX".
Noise protocol name broken out into separate identifier fields.
#define NOISE_PATTERN_NX_NOIDH_HFS
#define NOISE_PATTERN_NX_HFS
#define NOISE_ERROR_UNKNOWN_ID
Algorithm identifier is unknown.
#define NOISE_PATTERN_KX
Handshake pattern identifier for "KX".
#define NOISE_PREFIX_CATEGORY
Category for protocol prefixes.
#define NOISE_PATTERN_KX_NOIDH
Handshake pattern identifier for "KXnoidh".
#define NOISE_PATTERN_KX_HFS
#define NOISE_ERROR_INVALID_PARAM
Invalid parameter to function; e.g. a NULL value.
#define NOISE_PATTERN_IK_HFS
#define NOISE_PATTERN_IK
Handshake pattern identifier for "IK".
#define NOISE_ERROR_NONE
Success, no error.
#define NOISE_SIGN_ED25519
Signature algorithm identifier for "Ed25519".
#define NOISE_CIPHER_AESGCM
Cipher identifier for "AESGCM".
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...
#define NOISE_PATTERN_IX
Handshake pattern identifier for "IX".
#define NOISE_PATTERN_NN_HFS
#define NOISE_PATTERN_XN
Handshake pattern identifier for "XN".
#define NOISE_HASH_BLAKE2b
Hash identifier for "BLAKE2b".
#define NOISE_HASH_CATEGORY
Category for hash algorithms.
#define NOISE_PATTERN_KK_HFS
#define NOISE_PATTERN_XK
Handshake pattern identifier for "XK".
#define NOISE_PATTERN_NK
Handshake pattern identifier for "NK".
#define NOISE_PATTERN_XN_HFS
#define NOISE_DH_CATEGORY
Category for Diffie-Hellman algorithms.
#define NOISE_PATTERN_XK_HFS
#define NOISE_DH_CURVE448
Diffie-Hellman identifier for "448".
#define NOISE_PATTERN_KK
Handshake pattern identifier for "KK".
#define NOISE_PATTERN_NK_HFS
#define NOISE_ERROR_UNKNOWN_NAME
Algorithm name is unknown.
#define NOISE_CIPHER_CHACHAPOLY
Cipher identifier for "ChaChaPoly".
#define NOISE_PATTERN_NX_NOIDH
Handshake pattern identifier for "NXnoidh".
#define NOISE_ERROR_INVALID_LENGTH
Invalid length specified for a key, packet, etc.
#define NOISE_DH_NEWHOPE
Diffie-Hellman identifier for "NewHope" (post-quantum, ephemeral key exchanges only).
#define NOISE_HASH_SHA256
Hash identifier for "SHA256".
#define NOISE_PATTERN_K
Handshake pattern identifier for "K".
#define NOISE_PATTERN_IX_NOIDH_HFS
int noise_name_to_id(int category, const char *name, size_t name_len)
Maps an algorithm name to the corresponding identifier.
#define NOISE_CIPHER_CATEGORY
Category for cipher algorithms.
#define NOISE_PATTERN_CATEGORY
Category for handshake patterns.
#define NOISE_PATTERN_IN
Handshake pattern identifier for "IN".
Internal definitions for the library.
#define NOISE_DH_CURVE25519
Diffie-Hellman identifier for "25519".
#define NOISE_PATTERN_IN_HFS
#define NOISE_PATTERN_IK_NOIDH
Handshake pattern identifier for "IKnoidh".
#define NOISE_PATTERN_NX
Handshake pattern identifier for "NX".
#define NOISE_PATTERN_KN_HFS
#define NOISE_PATTERN_XX_HFS
#define NOISE_PREFIX_STANDARD
Protocol prefix identifier for "Noise".
const char * noise_id_to_name(int category, int id)
Maps an algorithm identifier to the corresponding name.
#define NOISE_PATTERN_NN
Handshake pattern identifier for "NN".
#define NOISE_PATTERN_IX_HFS
#define NOISE_ID(ch, num)
Builds an algorithm identifier for the library.
#define NOISE_PATTERN_XX_FALLBACK
Handshake pattern identifier for "XXfallback".
#define NOISE_PATTERN_XX_NOIDH
Handshake pattern identifier for "XXnoidh".
#define NOISE_PATTERN_N
Handshake pattern identifier for "N".
#define NOISE_PATTERN_KN
Handshake pattern identifier for "KN".
#define NOISE_HASH_BLAKE2s
Hash identifier for "BLAKE2s".
#define NOISE_PATTERN_X_NOIDH
Handshake pattern identifier for "Xnoidh".
#define NOISE_HASH_SHA512
Hash identifier for "SHA512".
#define NOISE_PATTERN_IK_NOIDH_HFS
#define NOISE_PREFIX_PSK
Protocol prefix identifier for "NoisePSK".
#define NOISE_PATTERN_XX_FALLBACK_HFS
#define NOISE_PATTERN_KX_NOIDH_HFS
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...
#define NOISE_PATTERN_XX_NOIDH_HFS
#define NOISE_PATTERN_IX_NOIDH
Handshake pattern identifier for "IXnoidh".
#define NOISE_PATTERN_X
Handshake pattern identifier for "X".