wickr-crypto-c
Data Structures | Enumerations | Functions
Wickr_node

Data Structures

struct  wickr_node
 Represents a message destination at a point in time. More...
 

Enumerations

enum  wickr_node_status { NODE_STATUS_UNKNOWN, NODE_STATUS_VALID, NODE_STATUS_INVALID }
 

Functions

wickr_node_twickr_node_create (wickr_buffer_t *dev_id, wickr_identity_chain_t *id_chain, wickr_ephemeral_keypair_t *ephemeral_keypair)
 
bool wickr_node_rotate_keypair (wickr_node_t *node, wickr_ephemeral_keypair_t *new_keypair, bool copy)
 
wickr_node_twickr_node_copy (const wickr_node_t *source)
 
void wickr_node_destroy (wickr_node_t **node)
 
bool wickr_node_verify_signature_chain (wickr_node_t *node, const wickr_crypto_engine_t *engine)
 
wickr_node_array_t * wickr_node_array_new (uint32_t node_count)
 
bool wickr_node_array_set_item (wickr_array_t *array, uint32_t index, wickr_node_t *node)
 
wickr_node_twickr_node_array_fetch_item (const wickr_array_t *array, uint32_t index)
 
wickr_node_array_t * wickr_node_array_copy (const wickr_node_array_t *array)
 
wickr_buffer_twickr_node_serialize (const wickr_node_t *node)
 
wickr_node_twickr_node_create_from_buffer (const wickr_buffer_t *buffer, const wickr_crypto_engine_t *engine)
 
void wickr_node_array_destroy (wickr_node_array_t **array)
 

Detailed Description

Enumeration Type Documentation

◆ wickr_node_status

Node status

UNKNOWN - Signature validation has never been attempted on the node VALID - Signature validation has been attempted and has passed on node INVALID - Signature validation has been attempted and has failed on node

Function Documentation

◆ wickr_node_array_copy()

wickr_node_array_t* wickr_node_array_copy ( const wickr_node_array_t *  array)

Make a deep copy of a node array

Parameters
arraythe array to copy
Returns
a newly allocated wickr_node_array that contains a copy of each element from 'array'

◆ wickr_node_array_destroy()

void wickr_node_array_destroy ( wickr_node_array_t **  array)

Destroy a node array

NOTE: Nodes in the array are not destroyed, only the container array

Parameters
arraythe array to destroy

◆ wickr_node_array_fetch_item()

wickr_node_t* wickr_node_array_fetch_item ( const wickr_array_t *  array,
uint32_t  index 
)

Fetch an item in the node array

NOTE: a fetched node is not copied out of the array, it is still owned by the array

Parameters
arraythe array to fetch from
indexthe index in the array to fetch from
Returns
the node at 'index'. NULL if the index is out of bounds

◆ wickr_node_array_new()

wickr_node_array_t* wickr_node_array_new ( uint32_t  node_count)

Create an array of nodes

Parameters
node_countthe number of nodes the array should hold
Returns
a newly allocated array with enough space to hold 'node_count' nodes

◆ wickr_node_array_set_item()

bool wickr_node_array_set_item ( wickr_array_t *  array,
uint32_t  index,
wickr_node_t node 
)

Set an item in the node array

NOTE: 'node' is not copied into the array, ownership is simply transferred to the array

Parameters
arraythe array to set a node into
indexthe index to place the node into the array
nodethe node to place at 'index' in the array
Returns
true if the insert succeeds, false if the index is out of range

◆ wickr_node_copy()

wickr_node_t* wickr_node_copy ( const wickr_node_t source)

Copy an node

Parameters
sourcethe node to copy
Returns
a newly allocated node holding a deep copy of the properties of 'source'

◆ wickr_node_create()

wickr_node_t* wickr_node_create ( wickr_buffer_t dev_id,
wickr_identity_chain_t id_chain,
wickr_ephemeral_keypair_t ephemeral_keypair 
)

Create a node from components

Parameters
dev_idsee 'wickr_node' property documentation
id_chainsee 'wickr_node' property documentation
ephemeral_keypairsee 'wickr_node' property documentation
Returns
a newly allocated node. Takes ownership of the passed inputs

◆ wickr_node_create_from_buffer()

wickr_node_t* wickr_node_create_from_buffer ( const wickr_buffer_t buffer,
const wickr_crypto_engine_t engine 
)

Create a node from a buffer that was created with 'wickr_node_serialize'

Parameters
bufferthe buffer that contains a serialized representation of a node
enginethe crypto engine to use to import the key components of the node
Returns
deserialized node or null if the deserialization fails

◆ wickr_node_destroy()

void wickr_node_destroy ( wickr_node_t **  node)

Destroy a node

Parameters
nodea pointer to the node to destroy. All properties of '*node' will also be destroyed

◆ wickr_node_rotate_keypair()

bool wickr_node_rotate_keypair ( wickr_node_t node,
wickr_ephemeral_keypair_t new_keypair,
bool  copy 
)

Rotate in a new ephemeral key pair for message sending

NOTE: This function DOES NOT ensure that new_keypair is signed properly. To do that, you must call 'wickr_node_verify_signature_chain' after rotation

Parameters
nodethe node to rotate 'new_keypair' into
new_keypairthe key pair to rotate into place
copyif true, perform a deep copy of 'new_keypair' before rotating
Returns
true if the rotation succeeds, false if the copy fails

◆ wickr_node_serialize()

wickr_buffer_t* wickr_node_serialize ( const wickr_node_t node)

Serialize a node to bytes

Parameters
nodethe node to serialize
Returns
a buffer containing a serialized representation of 'node' or null if serialization fails

◆ wickr_node_verify_signature_chain()

bool wickr_node_verify_signature_chain ( wickr_node_t node,
const wickr_crypto_engine_t engine 
)

Verify the integrity of the signature chain for a node

In order to be valid, the ephemeral keypair's signature must validate with the id_chain's 'node' public signing key. The id_chain's 'node' signature must validate with the id_chain's 'root' public signing key

Parameters
nodethe node to verify
enginea crypto engine capable of verifying EC signatures
Returns
true if the chain validates, false if there are any signature validation failures