|
AERN: Authenticated Encrypted Relay Network 1.0.0.0a (A1)
A post quantum authenticated and encrypted proxy chain network
|
The AERN topology functions. More...
#include "aern.h"#include "certificate.h"#include "ipinfo.h"#include "list.h"#include "timestamp.h"Go to the source code of this file.
Data Structures | |
| struct | aern_topology_node_state |
| The AERN topology node structure. More... | |
| struct | aern_topology_list_state |
| The AERN topology list structure. More... | |
Macros | |
| #define | AERN_TOPOLOGY_NODE_ENCODED_SIZE |
| The size of an encoded node string. | |
| #define | AERN_TOPOLOGY_NODE_MINIMUM_ISSUER_SIZE 3U |
| The minimum size of an issuer string. | |
| #define | AERN_TOPOLOGY_NODE_NOT_FOUND -1 |
| The value returned when a node is not found. | |
| #define | AERN_NETWORK_TOPOLOGY_MAX_SIZE 1024U |
| The maximum size of the topology. | |
| #define | AERN_NETWORK_TOPOLOGY_NODE_SIZE |
| The size in bytes of a serialized topological node. | |
Typedefs | |
| typedef AERN_EXPORT_API struct aern_topology_node_state | aern_topology_node_state |
| typedef AERN_EXPORT_API struct aern_topology_list_state | aern_topology_list_state |
Functions | |
| AERN_EXPORT_API void | aern_topology_address_from_issuer (char *address, const char *issuer, const aern_topology_list_state *list) |
| Returns an IP address from an issuer string. | |
| AERN_EXPORT_API void | aern_topology_node_add_alias (aern_topology_node_state *node, const char *alias) |
| Add an alias string to an issuer path. | |
| AERN_EXPORT_API bool | aern_topology_nodes_are_equal (const aern_topology_node_state *a, const aern_topology_node_state *b) |
| Compare two topological nodes for equality. | |
| AERN_EXPORT_API uint8_t * | aern_topology_child_add_empty_node (aern_topology_list_state *list) |
| Get an empty node pointer from the topology list. | |
| AERN_EXPORT_API void | aern_topology_child_add_item (aern_topology_list_state *list, const aern_topology_node_state *node) |
| Add a node to the topology list. | |
| AERN_EXPORT_API bool | aern_topology_canonical_to_issuer_name (char *issuer, size_t isslen, const char *domain, const char *cname) |
| Translate a canonical name to an issuer name. | |
| AERN_EXPORT_API bool | aern_topology_issuer_to_canonical_name (char *cname, size_t namelen, const char *issuer) |
| Translate an issuer name to a canonical name. | |
| AERN_EXPORT_API void | aern_topology_child_register (aern_topology_list_state *list, const aern_child_certificate *ccert, const char *address) |
| Register a child to a topology list. | |
| AERN_EXPORT_API void | aern_topology_list_clone (const aern_topology_list_state *tlist, aern_topology_list_state *tcopy) |
| Clone a topology list. | |
| AERN_EXPORT_API void | aern_topology_list_deserialize (aern_topology_list_state *list, const uint8_t *input, size_t inplen) |
| Deserialize a topology list. | |
| AERN_EXPORT_API void | aern_topology_list_dispose (aern_topology_list_state *list) |
| Dispose of the topology list and release memory. | |
| AERN_EXPORT_API void | aern_topology_list_initialize (aern_topology_list_state *list) |
| Initialize the topology list. | |
| AERN_EXPORT_API bool | aern_topology_list_item (const aern_topology_list_state *list, aern_topology_node_state *node, size_t index) |
| Get a node from the index. | |
| AERN_EXPORT_API size_t | aern_topology_list_remove_duplicates (aern_topology_list_state *list) |
| Remove duplicate nodes from the topology. | |
| AERN_EXPORT_API size_t | aern_topology_list_server_count (const aern_topology_list_state *list, aern_network_designations ntype) |
| Get the count of a type of node in the database. | |
| AERN_EXPORT_API size_t | aern_topology_list_serialize (uint8_t *output, const aern_topology_list_state *list) |
| Serialize a topology list. | |
| AERN_EXPORT_API size_t | aern_topology_list_size (const aern_topology_list_state *list) |
| Get the byte size of the serialized list. | |
| AERN_EXPORT_API size_t | aern_topology_list_to_string (const aern_topology_list_state *list, char *output, size_t outlen) |
| Convert the topology list to a printable string. | |
| AERN_EXPORT_API size_t | aern_topology_list_update_pack (uint8_t *output, const aern_topology_list_state *list, aern_network_designations ntype) |
| Pack a node update set to an array. | |
| AERN_EXPORT_API size_t | aern_topology_list_update_unpack (aern_topology_list_state *list, const uint8_t *input, size_t inplen) |
| Unpack a node update set to the topology list. | |
| AERN_EXPORT_API size_t | aern_topology_ordered_server_list (aern_topology_list_state *olist, const aern_topology_list_state *tlist, aern_network_designations ntype) |
| Return a list of nodes of a type, sorted by serial number. | |
| AERN_EXPORT_API void | aern_topology_node_clear (aern_topology_node_state *node) |
| Erase a node structure. | |
| AERN_EXPORT_API void | aern_topology_node_copy (const aern_topology_node_state *source, aern_topology_node_state *destination) |
| Copy a source node to a destination node structure. | |
| AERN_EXPORT_API void | aern_topology_node_deserialize (aern_topology_node_state *node, const uint8_t *input) |
| Deserialize a topological node. | |
| AERN_EXPORT_API size_t | aern_topology_node_encode (const aern_topology_node_state *node, char output[AERN_TOPOLOGY_NODE_ENCODED_SIZE]) |
| Encode a topological node into a printable string. | |
| AERN_EXPORT_API bool | aern_topology_node_exists (const aern_topology_list_state *list, const uint8_t *serial) |
| Queries on the serial number if the node is in the database. | |
| AERN_EXPORT_API int32_t | aern_topology_node_get_index (const aern_topology_list_state *list, const uint8_t *serial) |
| Find the index number of a node in an array. | |
| AERN_EXPORT_API bool | aern_topology_node_find (const aern_topology_list_state *list, aern_topology_node_state *node, const uint8_t *serial) |
| Return the node pointer in the list matching the serial number. | |
| AERN_EXPORT_API bool | aern_topology_node_find_address (const aern_topology_list_state *list, aern_topology_node_state *node, const char *address) |
| Return the node pointer in the list matching the address string. | |
| AERN_EXPORT_API bool | aern_topology_node_find_alias (const aern_topology_list_state *list, aern_topology_node_state *node, const char *alias) |
| Return the node pointer in the list matching the alias string. | |
| AERN_EXPORT_API bool | aern_topology_node_find_ads (const aern_topology_list_state *list, aern_topology_node_state *node) |
| Return the ADC node from the list. | |
| AERN_EXPORT_API bool | aern_topology_node_find_issuer (const aern_topology_list_state *list, aern_topology_node_state *node, const char *issuer) |
| Return the node pointer in the list matching the name string. | |
| AERN_EXPORT_API bool | aern_topology_node_find_root (const aern_topology_list_state *list, aern_topology_node_state *node) |
| Return the ARS server node from the list. | |
| AERN_EXPORT_API void | aern_topology_node_remove (aern_topology_list_state *list, const uint8_t *serial) |
| Find and remove a node from the topology. | |
| AERN_EXPORT_API void | aern_topology_node_remove_duplicate (aern_topology_list_state *list, const char *issuer) |
| Remove a node from the topology with the same issuer name. | |
| AERN_EXPORT_API bool | aern_topology_node_verify_ads (const aern_topology_list_state *list, const aern_child_certificate *ccert) |
| Verify that the ADC certificate matches the hash stored in the topology. | |
| AERN_EXPORT_API bool | aern_topology_node_verify_issuer (const aern_topology_list_state *list, const aern_child_certificate *ccert, const char *issuer) |
| Verify that an issuing node's certificate matches the hash stored in the topology. | |
| AERN_EXPORT_API bool | aern_topology_node_verify_root (const aern_topology_list_state *list, const aern_root_certificate *rcert) |
| Verify that the root certificate matches the hash stored in the topology. | |
| AERN_EXPORT_API size_t | aern_topology_node_serialize (uint8_t *output, const aern_topology_node_state *node) |
| Serialize a topological node structure, including the mfk. | |
| AERN_EXPORT_API void | aern_topology_root_register (aern_topology_list_state *list, const aern_root_certificate *rcert, const char *address) |
| Register a root to a topology list. | |
| AERN_EXPORT_API void | aern_topology_from_file (const char *fpath, aern_topology_list_state *list) |
| Copy a topology list from a file. | |
| AERN_EXPORT_API void | aern_topology_to_file (const aern_topology_list_state *list, const char *fpath) |
| Copy a topology list to a file. | |
The AERN topology functions.
Detailed File Description: This header file defines the functions, macros, structures, and enumerations used by AERN for managing the network topology. The topology functions handle the serialization and deserialization of network node information, conversion between canonical and issuer names, registration and removal of nodes from the topology list, and various lookup and verification operations.
Notes: The issuer parameter composition; network/host.ctype:alias The first segment of an issuer string consists of the network path, which is the network name, appended with a forward slash (network/host). A network name can contain subdomains, each ending in a forward slash, ex. domain/subdomain/host. The network portion of the issuer string represents the network and host names as a path string. The second segment is the host name, and an optional extension preceded by a period (host.type), ex. xyz/mas.ctype. There are three types of devices; root, intra-domain, and inter-domain, which correspond to AERN device types of [root server], [ads, aps, mas, client], and [idg] inter-domain gateways. The third segment of the issuer string is the alias (path:alias), a readable domain alias name, always preceded by a colon. The network name and any subdomains are always preceded by a single forward slash (domain/subdomain). ex. network/sub-network/host. The host name is the network device name, and it is terminated with a colon (path:alias). The alias is a name that represents a compact path or string representation of the network\node path. Example: xyz/mas-1:www.xyz.com The entire issuer string cannot exceed 256 bytes. Periods, dashes, and most other symbols are legal with the exception of the reserved symbols: period, forward slash, and colon (. / :), as well as illegal symbols such as ! @ $ % ^ & * ( ) { } | ; " '. Name to address lookups can be performed by the ADC that can translate a network\node path, or an alias name, to an IP address (IPv4 or IPv6). Inverse lookups can also be performed, which return the issuer string from an IP address. Issuer network paths are mirrored in the storage subsystem and used as storage path substrings (e.g., C:\AERN\xyz\mas), enabling file system certificate retrieval based on the issuer's topological path.
| #define AERN_NETWORK_TOPOLOGY_NODE_SIZE |
The size in bytes of a serialized topological node.
| #define AERN_TOPOLOGY_NODE_ENCODED_SIZE |
The size of an encoded node string.
This macro defines the size of a printable, encoded node string. Its value depends on whether the network is IPv6 or IPv4.
| AERN_EXPORT_API void aern_topology_address_from_issuer | ( | char * | address, |
| const char * | issuer, | ||
| const aern_topology_list_state * | list ) |
Returns an IP address from an issuer string.
This function extracts and returns the network address associated with a given issuer string, using the topology list to resolve the address.
| address | The output buffer to receive the node's network address (max AERN_CERTIFICATE_ADDRESS_SIZE). |
| issuer | [const] The issuer string. |
| list | [const] A pointer to the topology list. |
| AERN_EXPORT_API bool aern_topology_canonical_to_issuer_name | ( | char * | issuer, |
| size_t | isslen, | ||
| const char * | domain, | ||
| const char * | cname ) |
Translate a canonical name to an issuer name.
This function converts a device canonical name into its corresponding issuer name based on the domain.
| issuer | The output issuer string. |
| isslen | The length of the issuer buffer. |
| domain | The domain name. |
| cname | The input device canonical name. |
| AERN_EXPORT_API uint8_t * aern_topology_child_add_empty_node | ( | aern_topology_list_state * | list | ) |
Get an empty node pointer from the topology list.
This function returns a pointer to an empty node entry in the topology list.
| list | A pointer to the topology list. |
| AERN_EXPORT_API void aern_topology_child_add_item | ( | aern_topology_list_state * | list, |
| const aern_topology_node_state * | node ) |
Add a node to the topology list.
This function adds a new node item to the topology list.
| list | A pointer to the topology list. |
| node | [const] The node to add. |
| AERN_EXPORT_API void aern_topology_child_register | ( | aern_topology_list_state * | list, |
| const aern_child_certificate * | ccert, | ||
| const char * | address ) |
Register a child to a topology list.
This function registers a new child node in the topology list based on its certificate.
| list | A pointer to the topology list. |
| ccert | [const] The node's child certificate. |
| address | [const] The node's network address (max AERN_CERTIFICATE_ADDRESS_SIZE). |
| AERN_EXPORT_API void aern_topology_from_file | ( | const char * | fpath, |
| aern_topology_list_state * | list ) |
Copy a topology list from a file.
This function loads a topology list from a file.
| fpath | [const] The full path to the topology list file. |
| list | A pointer to the topology list state to populate. |
| AERN_EXPORT_API bool aern_topology_issuer_to_canonical_name | ( | char * | cname, |
| size_t | namelen, | ||
| const char * | issuer ) |
Translate an issuer name to a canonical name.
This function converts an issuer name back into its canonical form.
| cname | The output canonical name. |
| namelen | The length of the canonical name buffer. |
| issuer | The input issuer name string. |
| AERN_EXPORT_API void aern_topology_list_clone | ( | const aern_topology_list_state * | tlist, |
| aern_topology_list_state * | tcopy ) |
Clone a topology list.
This function creates a clone of the given topology list.
| tlist | [const] A pointer to the source topology list. |
| tcopy | A pointer to the destination topology list. |
| AERN_EXPORT_API void aern_topology_list_deserialize | ( | aern_topology_list_state * | list, |
| const uint8_t * | input, | ||
| size_t | inplen ) |
Deserialize a topology list.
This function deserializes a topology list from a given input array.
| list | A pointer to the topology list state to populate. |
| input | [const] The serialized topology array. |
| inplen | The size of the input array. |
| AERN_EXPORT_API void aern_topology_list_dispose | ( | aern_topology_list_state * | list | ) |
Dispose of the topology list and release memory.
This function releases all memory allocated for the topology list.
| list | A pointer to the topology list state. |
| AERN_EXPORT_API void aern_topology_list_initialize | ( | aern_topology_list_state * | list | ) |
Initialize the topology list.
This function initializes the topology list state.
| list | The topology list state to initialize. |
| AERN_EXPORT_API bool aern_topology_list_item | ( | const aern_topology_list_state * | list, |
| aern_topology_node_state * | node, | ||
| size_t | index ) |
Get a node from the index.
This function retrieves the node at the specified index in the topology list.
| list | The topology list state. |
| node | A pointer to the node structure to populate. |
| index | The index of the node. |
| AERN_EXPORT_API size_t aern_topology_list_remove_duplicates | ( | aern_topology_list_state * | list | ) |
Remove duplicate nodes from the topology.
This function removes duplicate entries from the topology list.
| list | The topology list state. |
| AERN_EXPORT_API size_t aern_topology_list_serialize | ( | uint8_t * | output, |
| const aern_topology_list_state * | list ) |
Serialize a topology list.
This function serializes the topology list into a byte array.
| output | The output buffer for the serialized topology. |
| list | [const] The topology list state. |
| AERN_EXPORT_API size_t aern_topology_list_server_count | ( | const aern_topology_list_state * | list, |
| aern_network_designations | ntype ) |
Get the count of a type of node in the database.
This function counts the number of nodes of a specific type in the topology list.
| list | [const] The topology list state. |
| ntype | The type of node entry to count. |
| AERN_EXPORT_API size_t aern_topology_list_size | ( | const aern_topology_list_state * | list | ) |
Get the byte size of the serialized list.
This function returns the size in bytes of the serialized topology list.
| list | [const] The topology list state. |
| AERN_EXPORT_API size_t aern_topology_list_to_string | ( | const aern_topology_list_state * | list, |
| char * | output, | ||
| size_t | outlen ) |
Convert the topology list to a printable string.
This function converts the topology list into a human?readable string.
| list | [const] The topology list state. |
| output | The output string buffer. |
| outlen | The length of the output buffer. |
| AERN_EXPORT_API size_t aern_topology_list_update_pack | ( | uint8_t * | output, |
| const aern_topology_list_state * | list, | ||
| aern_network_designations | ntype ) |
Pack a node update set to an array.
This function serializes a subset of nodes from the topology list (of a given type) into an array.
| output | The output buffer for the serialized node update set. |
| list | [const] The topology list state. |
| ntype | The type of node entry to pack. |
| AERN_EXPORT_API size_t aern_topology_list_update_unpack | ( | aern_topology_list_state * | list, |
| const uint8_t * | input, | ||
| size_t | inplen ) |
Unpack a node update set to the topology list.
This function deserializes an update set and adds the nodes to the topology list.
| list | The topology list state to update. |
| input | The input serialized node update set. |
| inplen | The length of the input array. |
| AERN_EXPORT_API void aern_topology_node_add_alias | ( | aern_topology_node_state * | node, |
| const char * | alias ) |
Add an alias string to an issuer path.
This function appends an alias to the issuer string of a node.
| node | The network node to update. |
| alias | [const] The host alias to add. |
| AERN_EXPORT_API void aern_topology_node_clear | ( | aern_topology_node_state * | node | ) |
Erase a node structure.
This function clears all data in a topology node structure.
| node | A pointer to the topology node structure to erase. |
| AERN_EXPORT_API void aern_topology_node_copy | ( | const aern_topology_node_state * | source, |
| aern_topology_node_state * | destination ) |
Copy a source node to a destination node structure.
This function copies the contents of one topology node structure to another.
| source | [const] A pointer to the source node structure. |
| destination | A pointer to the destination node structure. |
| AERN_EXPORT_API void aern_topology_node_deserialize | ( | aern_topology_node_state * | node, |
| const uint8_t * | input ) |
Deserialize a topological node.
This function converts a serialized topology node array into a topology node structure.
| node | A pointer to the topology node structure to populate. |
| input | [const] The input serialized topology node data. |
| AERN_EXPORT_API size_t aern_topology_node_encode | ( | const aern_topology_node_state * | node, |
| char | output[AERN_TOPOLOGY_NODE_ENCODED_SIZE] ) |
Encode a topological node into a printable string.
This function encodes a topology node into a human?readable string format.
| node | A pointer to the topology node structure. |
| output | The output buffer for the encoded node string. |
| AERN_EXPORT_API bool aern_topology_node_exists | ( | const aern_topology_list_state * | list, |
| const uint8_t * | serial ) |
Queries on the serial number if the node is in the database.
This function checks whether a node with the specified serial number exists in the topology list.
| list | [const] The topology list state. |
| serial | The serial number to search for. |
| AERN_EXPORT_API bool aern_topology_node_find | ( | const aern_topology_list_state * | list, |
| aern_topology_node_state * | node, | ||
| const uint8_t * | serial ) |
Return the node pointer in the list matching the serial number.
This function finds a node in the topology list that matches the given serial number.
| list | [const] The topology list state. |
| node | A pointer to the destination node structure to populate. |
| serial | [const] The certificate serial number to search for. |
| AERN_EXPORT_API bool aern_topology_node_find_address | ( | const aern_topology_list_state * | list, |
| aern_topology_node_state * | node, | ||
| const char * | address ) |
Return the node pointer in the list matching the address string.
This function searches the topology list for a node that matches the given network address.
| list | [const] The topology list state. |
| node | A pointer to the destination node structure. |
| address | [const] The network address to search for. |
| AERN_EXPORT_API bool aern_topology_node_find_ads | ( | const aern_topology_list_state * | list, |
| aern_topology_node_state * | node ) |
Return the ADC node from the list.
This function finds the ADC node in the topology list.
| list | [const] The topology list state. |
| node | A pointer to the destination node structure. |
| AERN_EXPORT_API bool aern_topology_node_find_alias | ( | const aern_topology_list_state * | list, |
| aern_topology_node_state * | node, | ||
| const char * | alias ) |
Return the node pointer in the list matching the alias string.
This function searches the topology list for a node that matches the given alias.
| list | [const] The topology list state. |
| node | A pointer to the destination node structure. |
| alias | [const] The alias to search for. |
| AERN_EXPORT_API bool aern_topology_node_find_issuer | ( | const aern_topology_list_state * | list, |
| aern_topology_node_state * | node, | ||
| const char * | issuer ) |
Return the node pointer in the list matching the name string.
This function finds a node in the topology list that matches the given issuer name.
| list | [const] The topology list state. |
| node | A pointer to the destination node structure. |
| issuer | [const] The certificate issuer name. |
| AERN_EXPORT_API bool aern_topology_node_find_root | ( | const aern_topology_list_state * | list, |
| aern_topology_node_state * | node ) |
Return the ARS server node from the list.
This function retrieves the ARS server node from the topology list.
| list | [const] The topology list state. |
| node | A pointer to the destination node structure. |
| AERN_EXPORT_API int32_t aern_topology_node_get_index | ( | const aern_topology_list_state * | list, |
| const uint8_t * | serial ) |
Find the index number of a node in an array.
This function searches for a node by its serial number and returns its index in the topology list.
| list | [const] The topology list state. |
| serial | The serial number to search for. |
| AERN_EXPORT_API void aern_topology_node_remove | ( | aern_topology_list_state * | list, |
| const uint8_t * | serial ) |
Find and remove a node from the topology.
This function searches for a node by its serial number and removes it from the topology list.
| list | The topology list state. |
| serial | The serial number of the node to remove (AERN_CERTIFICATE_SERIAL_SIZE bytes). |
| AERN_EXPORT_API void aern_topology_node_remove_duplicate | ( | aern_topology_list_state * | list, |
| const char * | issuer ) |
Remove a node from the topology with the same issuer name.
This function removes duplicate nodes from the topology list that have the same issuer name.
| list | The topology list state. |
| issuer | The issuer name to match for removal. |
| AERN_EXPORT_API size_t aern_topology_node_serialize | ( | uint8_t * | output, |
| const aern_topology_node_state * | node ) |
Serialize a topological node structure, including the mfk.
This function serializes the topology node structure into a byte array.
| output | The output buffer to receive the serialized node. |
| node | [const] A pointer to the topology node structure. |
| AERN_EXPORT_API bool aern_topology_node_verify_ads | ( | const aern_topology_list_state * | list, |
| const aern_child_certificate * | ccert ) |
Verify that the ADC certificate matches the hash stored in the topology.
This function verifies that the ADC certificate in the topology list matches the certificate hash.
| list | [const] The topology list state. |
| ccert | [const] The ADC certificate structure. |
| AERN_EXPORT_API bool aern_topology_node_verify_issuer | ( | const aern_topology_list_state * | list, |
| const aern_child_certificate * | ccert, | ||
| const char * | issuer ) |
Verify that an issuing node's certificate matches the hash stored in the topology.
This function verifies that the certificate for a given issuer matches the stored hash in the topology list.
| list | [const] The topology list state. |
| ccert | [const] The node's certificate structure. |
| issuer | [const] The certificate issuer name. |
| AERN_EXPORT_API bool aern_topology_node_verify_root | ( | const aern_topology_list_state * | list, |
| const aern_root_certificate * | rcert ) |
Verify that the root certificate matches the hash stored in the topology.
This function verifies that the root certificate matches the hash stored in the topology list.
| list | [const] The topology list state. |
| rcert | [const] The root certificate structure. |
| AERN_EXPORT_API bool aern_topology_nodes_are_equal | ( | const aern_topology_node_state * | a, |
| const aern_topology_node_state * | b ) |
Compare two topological nodes for equality.
This function compares two topology node structures and returns true if they are identical.
| a | [const] The first node. |
| b | [const] The second node. |
| AERN_EXPORT_API size_t aern_topology_ordered_server_list | ( | aern_topology_list_state * | olist, |
| const aern_topology_list_state * | tlist, | ||
| aern_network_designations | ntype ) |
Return a list of nodes of a type, sorted by serial number.
This function returns a new topology list containing nodes of a specific type, sorted by their serial number.
| olist | The sorted output topology list. |
| tlist | The unsorted input topology list. |
| ntype | The type of node to filter and sort. |
| AERN_EXPORT_API void aern_topology_root_register | ( | aern_topology_list_state * | list, |
| const aern_root_certificate * | rcert, | ||
| const char * | address ) |
Register a root to a topology list.
This function registers a root certificate into the topology list.
| list | A pointer to the topology list. |
| rcert | [const] The root certificate. |
| address | [const] The network address of the root. |
| AERN_EXPORT_API void aern_topology_to_file | ( | const aern_topology_list_state * | list, |
| const char * | fpath ) |
Copy a topology list to a file.
This function writes the current topology list to a file.
| list | [const] The topology list state. |
| fpath | [const] The destination file path for the topology list. |