wickr-crypto-c
node.h
1 /*
2  * Copyright © 2012-2018 Wickr Inc. All rights reserved.
3  *
4  * This code is being released for EDUCATIONAL, ACADEMIC, AND CODE REVIEW PURPOSES
5  * ONLY. COMMERCIAL USE OF THE CODE IS EXPRESSLY PROHIBITED. For additional details,
6  * please see LICENSE
7  *
8  * THE CODE IS MADE AVAILABLE "AS-IS" AND WITHOUT ANY EXPRESS OR
9  * IMPLIED GUARANTEES AS TO FITNESS, MERCHANTABILITY, NON-
10  * INFRINGEMENT OR OTHERWISE. IT IS NOT BEING PROVIDED IN TRADE BUT ON
11  * A VOLUNTARY BASIS ON BEHALF OF THE AUTHOR’S PART FOR THE BENEFIT
12  * OF THE LICENSEE AND IS NOT MADE AVAILABLE FOR CONSUMER USE OR ANY
13  * OTHER USE OUTSIDE THE TERMS OF THIS LICENSE. ANYONE ACCESSING THE
14  * CODE SHOULD HAVE THE REQUISITE EXPERTISE TO SECURE THEIR SYSTEM
15  * AND DEVICES AND TO ACCESS AND USE THE CODE FOR REVIEW PURPOSES
16  * ONLY. LICENSEE BEARS THE RISK OF ACCESSING AND USING THE CODE. IN
17  * PARTICULAR, AUTHOR BEARS NO LIABILITY FOR ANY INTERFERENCE WITH OR
18  * ADVERSE EFFECT THAT MAY OCCUR AS A RESULT OF THE LICENSEE
19  * ACCESSING AND/OR USING THE CODE ON LICENSEE’S SYSTEM.
20  */
21 
22 #ifndef node_h
23 #define node_h
24 
25 #include <stdlib.h>
26 #include "buffer.h"
27 #include "ecdsa.h"
28 #include "eckey.h"
29 #include "devinfo.h"
30 #include "crypto_engine.h"
31 #include "root_keys.h"
32 #include "identity.h"
33 #include "ephemeral_keypair.h"
34 #include "array.h"
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 typedef wickr_array_t wickr_node_array_t;
41 
57 typedef enum {
58  NODE_STATUS_UNKNOWN,
59  NODE_STATUS_VALID,
60  NODE_STATUS_INVALID
62 
85 struct wickr_node {
90  wickr_buffer_t *_status_cache;
91 };
92 
93 typedef struct wickr_node wickr_node_t;
94 
107 
121 bool wickr_node_rotate_keypair(wickr_node_t *node, wickr_ephemeral_keypair_t *new_keypair, bool copy);
122 
133 
142 void wickr_node_destroy(wickr_node_t **node);
143 
158 
168 wickr_node_array_t *wickr_node_array_new(uint32_t node_count);
169 
183 bool wickr_node_array_set_item(wickr_array_t *array, uint32_t index, wickr_node_t *node);
184 
197 wickr_node_t *wickr_node_array_fetch_item(const wickr_array_t *array, uint32_t index);
198 
208 wickr_node_array_t *wickr_node_array_copy(const wickr_node_array_t *array);
209 
220 
232 
243 void wickr_node_array_destroy(wickr_node_array_t **array);
244 
245 #ifdef __cplusplus
246 }
247 #endif
248 
249 #endif /* node_h */
wickr_node_array_t * wickr_node_array_copy(const wickr_node_array_t *array)
wickr_node_status
Definition: node.h:57
void wickr_node_destroy(wickr_node_t **node)
bool wickr_node_array_set_item(wickr_array_t *array, uint32_t index, wickr_node_t *node)
void wickr_node_array_destroy(wickr_node_array_t **array)
Represents an array of bytes and the length of the allocation associated with those bytes.
Definition: buffer.h:51
Represents a message destination at a point in time.
Definition: node.h:85
wickr_node_array_t * wickr_node_array_new(uint32_t node_count)
Represents a key pair used for message key exchanges within the Wickr Messaging Protocol.
Definition: ephemeral_keypair.h:62
wickr_ephemeral_keypair_t * ephemeral_keypair
Definition: node.h:88
wickr_node_t * wickr_node_create(wickr_buffer_t *dev_id, wickr_identity_chain_t *id_chain, wickr_ephemeral_keypair_t *ephemeral_keypair)
wickr_node_status status
Definition: node.h:89
wickr_node_t * wickr_node_array_fetch_item(const wickr_array_t *array, uint32_t index)
bool wickr_node_rotate_keypair(wickr_node_t *node, wickr_ephemeral_keypair_t *new_keypair, bool copy)
bool wickr_node_verify_signature_chain(wickr_node_t *node, const wickr_crypto_engine_t *engine)
wickr_identity_chain_t * id_chain
Definition: node.h:87
wickr_buffer_t * wickr_node_serialize(const wickr_node_t *node)
wickr_node_t * wickr_node_copy(const wickr_node_t *source)
Represents a root -> node relationship as well as it's signature status.
Definition: identity.h:110
Interface to a set of cryptographic operations used throughout the library. Currently the default imp...
Definition: crypto_engine.h:53
wickr_node_t * wickr_node_create_from_buffer(const wickr_buffer_t *buffer, const wickr_crypto_engine_t *engine)
wickr_buffer_t * dev_id
Definition: node.h:86