wickr-crypto-c

node.h
1 /*
2 * Copyright © 2012-2020 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
61 } wickr_node_status;
62
87 struct wickr_node {
88 wickr_buffer_t *dev_id;
89 wickr_identity_chain_t *id_chain;
90 wickr_ephemeral_keypair_t *ephemeral_keypair;
91 wickr_node_status status;
92 wickr_buffer_t *_status_cache;
93 };
94
95 typedef struct wickr_node wickr_node_t;
96
108 wickr_node_t *wickr_node_create(wickr_buffer_t *dev_id, wickr_identity_chain_t *id_chain, wickr_ephemeral_keypair_t *ephemeral_keypair);
109
123 bool wickr_node_rotate_keypair(wickr_node_t *node, wickr_ephemeral_keypair_t *new_keypair, bool copy);
124
134 wickr_node_t *wickr_node_copy(const wickr_node_t *source);
135
144 void wickr_node_destroy(wickr_node_t **node);
145
159 bool wickr_node_verify_signature_chain(wickr_node_t *node, const wickr_crypto_engine_t *engine);
160
170 wickr_node_array_t *wickr_node_array_new(uint32_t node_count);
171
185 bool wickr_node_array_set_item(wickr_array_t *array, uint32_t index, wickr_node_t *node);
186
199 wickr_node_t *wickr_node_array_fetch_item(const wickr_array_t *array, uint32_t index);
200
210 wickr_node_array_t *wickr_node_array_copy(const wickr_node_array_t *array);
211
221 wickr_buffer_t *wickr_node_serialize(const wickr_node_t *node);
222
233 wickr_node_t *wickr_node_create_from_buffer(const wickr_buffer_t *buffer, const wickr_crypto_engine_t *engine);
234
245 void wickr_node_array_destroy(wickr_node_array_t **array);
246
247 #ifdef __cplusplus
248 }
249 #endif
250
251 #endif /* node_h */
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)
wickr_node_rotate_keypair
bool wickr_node_rotate_keypair(wickr_node_t *node, wickr_ephemeral_keypair_t *new_keypair, bool copy)
wickr_node_create_from_buffer
wickr_node_t * wickr_node_create_from_buffer(const wickr_buffer_t *buffer, const wickr_crypto_engine_t *engine)
wickr_node_copy
wickr_node_t * wickr_node_copy(const wickr_node_t *source)
wickr_node_array_new
wickr_node_array_t * wickr_node_array_new(uint32_t node_count)
wickr_node_serialize
wickr_buffer_t * wickr_node_serialize(const wickr_node_t *node)
wickr_node_destroy
void wickr_node_destroy(wickr_node_t **node)
wickr_node_array_fetch_item
wickr_node_t * wickr_node_array_fetch_item(const wickr_array_t *array, uint32_t index)
wickr_node_array_destroy
void wickr_node_array_destroy(wickr_node_array_t **array)
wickr_node_array_copy
wickr_node_array_t * wickr_node_array_copy(const wickr_node_array_t *array)
wickr_node_verify_signature_chain
bool wickr_node_verify_signature_chain(wickr_node_t *node, const wickr_crypto_engine_t *engine)
wickr_node_array_set_item
bool wickr_node_array_set_item(wickr_array_t *array, uint32_t index, wickr_node_t *node)
wickr_node_status
wickr_node_status
Definition: node.h:57
wickr_buffer
Represents an array of bytes and the length of the allocation associated with those bytes.
Definition: buffer.h:51
wickr_crypto_engine
Interface to a set of cryptographic operations used throughout the library. Currently the default imp...
Definition: crypto_engine.h:53
wickr_ephemeral_keypair
Represents a key pair used for message key exchanges within the Wickr Messaging Protocol.
Definition: ephemeral_keypair.h:62
wickr_identity_chain
Represents a root -> node relationship as well as it's signature status.
Definition: identity.h:116
wickr_node
Represents a message destination at a point in time.
Definition: node.h:87
wickr_node::id_chain
wickr_identity_chain_t * id_chain
Definition: node.h:89
wickr_node::dev_id
wickr_buffer_t * dev_id
Definition: node.h:88
wickr_node::_status_cache
wickr_buffer_t * _status_cache
Definition: node.h:92
wickr_node::ephemeral_keypair
wickr_ephemeral_keypair_t * ephemeral_keypair
Definition: node.h:90
wickr_node::status
wickr_node_status status
Definition: node.h:91