wickr-crypto-c

transport_handshake.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 transport_handshake_h
23 #define transport_handshake_h
24
25 #include "identity.h"
26 #include "stream_key.h"
27 #include "transport_packet.h"
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
37 struct wickr_transport_handshake_res_t;
38 typedef struct wickr_transport_handshake_res_t wickr_transport_handshake_res_t;
39
60 typedef enum {
61 TRANSPORT_HANDSHAKE_STATUS_UNKNOWN,
62 TRANSPORT_HANDSHAKE_STATUS_IN_PROGRESS,
63 TRANSPORT_HANDSHAKE_STATUS_PENDING_VERIFICATION,
64 TRANSPORT_HANDSHAKE_STATUS_PENDING_FINALIZATION,
65 TRANSPORT_HANDSHAKE_STATUS_COMPLETE,
66 TRANSPORT_HANDSHAKE_STATUS_FAILED
67 } wickr_transport_handshake_status;
68
78 wickr_transport_handshake_res_t *wickr_transport_handshake_res_create(wickr_stream_key_t *local_key,
79 wickr_stream_key_t *remote_key);
80
89 wickr_transport_handshake_res_t *wickr_transport_handshake_res_copy(const wickr_transport_handshake_res_t *res);
90
97 void wickr_transport_handshake_res_destroy(wickr_transport_handshake_res_t **res);
98
107 const wickr_stream_key_t *wickr_transport_handshake_res_get_local_key(const wickr_transport_handshake_res_t *res);
108
117 const wickr_stream_key_t *wickr_transport_handshake_res_get_remote_key(const wickr_transport_handshake_res_t *res);
118
132 struct wickr_transport_handshake_t;
133 typedef struct wickr_transport_handshake_t wickr_transport_handshake_t;
134
135 /* Callback used to tell the parent transport ctx that the handshake requires a call to `wickr_transport_handshake_verify_identity` to continue */
136 typedef void (*wickr_transport_handshake_identity_callback)(const wickr_transport_handshake_t *handshake,
137 wickr_identity_chain_t *identity,
138 void *user);
139
153 wickr_transport_handshake_t *wickr_transport_handshake_create(wickr_crypto_engine_t engine,
154 wickr_identity_chain_t *local_identity,
155 wickr_identity_chain_t *remote_identity,
156 wickr_transport_handshake_identity_callback identity_callback,
157 uint32_t evo_count,
158 void *user);
159
168 wickr_transport_handshake_t *wickr_transport_handshake_copy(const wickr_transport_handshake_t *handshake);
169
176 void wickr_transport_handshake_destroy(wickr_transport_handshake_t **handshake);
177
188 wickr_transport_packet_t *wickr_transport_handshake_start(wickr_transport_handshake_t *handshake);
189
200 wickr_transport_packet_t *wickr_transport_handshake_process(wickr_transport_handshake_t *handshake,
201 const wickr_transport_packet_t *packet);
202
213 wickr_transport_packet_t *wickr_transport_handshake_verify_identity(const wickr_transport_handshake_t *handshake, bool is_valid);
214
224 wickr_transport_handshake_res_t *wickr_transport_handshake_finalize(wickr_transport_handshake_t *handshake);
225
234 wickr_transport_handshake_status wickr_transport_handshake_get_status(const wickr_transport_handshake_t *handshake);
235
244 const wickr_identity_chain_t *wickr_transport_handshake_get_local_identity(const wickr_transport_handshake_t *handshake);
245
254 const wickr_identity_chain_t *wickr_transport_handshake_get_remote_identity(const wickr_transport_handshake_t *handshake);
255
264 const void *wickr_transport_handshake_get_user_data(const wickr_transport_handshake_t *handshake);
265
274 void wickr_transport_set_user_data(wickr_transport_handshake_t *handshake, void *user);
275
276 #ifdef __cplusplus
277 }
278 #endif
279
280 #endif /* transport_handshake_h */
wickr_transport_handshake_res_create
wickr_transport_handshake_res_t * wickr_transport_handshake_res_create(wickr_stream_key_t *local_key, wickr_stream_key_t *remote_key)
wickr_transport_handshake_process
wickr_transport_packet_t * wickr_transport_handshake_process(wickr_transport_handshake_t *handshake, const wickr_transport_packet_t *packet)
wickr_transport_handshake_res_copy
wickr_transport_handshake_res_t * wickr_transport_handshake_res_copy(const wickr_transport_handshake_res_t *res)
wickr_transport_handshake_get_local_identity
const wickr_identity_chain_t * wickr_transport_handshake_get_local_identity(const wickr_transport_handshake_t *handshake)
wickr_transport_handshake_status
wickr_transport_handshake_status
Definition: transport_handshake.h:60
wickr_transport_handshake_finalize
wickr_transport_handshake_res_t * wickr_transport_handshake_finalize(wickr_transport_handshake_t *handshake)
wickr_transport_handshake_get_remote_identity
const wickr_identity_chain_t * wickr_transport_handshake_get_remote_identity(const wickr_transport_handshake_t *handshake)
wickr_transport_handshake_res_get_remote_key
const wickr_stream_key_t * wickr_transport_handshake_res_get_remote_key(const wickr_transport_handshake_res_t *res)
wickr_transport_handshake_res_get_local_key
const wickr_stream_key_t * wickr_transport_handshake_res_get_local_key(const wickr_transport_handshake_res_t *res)
wickr_transport_handshake_copy
wickr_transport_handshake_t * wickr_transport_handshake_copy(const wickr_transport_handshake_t *handshake)
wickr_transport_set_user_data
void wickr_transport_set_user_data(wickr_transport_handshake_t *handshake, void *user)
wickr_transport_handshake_res_destroy
void wickr_transport_handshake_res_destroy(wickr_transport_handshake_res_t **res)
wickr_transport_handshake_destroy
void wickr_transport_handshake_destroy(wickr_transport_handshake_t **handshake)
wickr_transport_handshake_get_user_data
const void * wickr_transport_handshake_get_user_data(const wickr_transport_handshake_t *handshake)
wickr_transport_handshake_verify_identity
wickr_transport_packet_t * wickr_transport_handshake_verify_identity(const wickr_transport_handshake_t *handshake, bool is_valid)
wickr_transport_handshake_create
wickr_transport_handshake_t * wickr_transport_handshake_create(wickr_crypto_engine_t engine, wickr_identity_chain_t *local_identity, wickr_identity_chain_t *remote_identity, wickr_transport_handshake_identity_callback identity_callback, uint32_t evo_count, void *user)
wickr_transport_handshake_get_status
wickr_transport_handshake_status wickr_transport_handshake_get_status(const wickr_transport_handshake_t *handshake)
wickr_transport_handshake_start
wickr_transport_packet_t * wickr_transport_handshake_start(wickr_transport_handshake_t *handshake)
wickr_crypto_engine
Interface to a set of cryptographic operations used throughout the library. Currently the default imp...
Definition: crypto_engine.h:53
wickr_identity_chain
Represents a root -> node relationship as well as it's signature status.
Definition: identity.h:116
wickr_stream_key
A data structure representing the stream encoding / decoding key material A stream key holds informat...
Definition: stream_key.h:56
wickr_transport_packet
A packet used within the wickr_transport_ctx to package up data and related metadata + authentication...
Definition: transport_packet.h:175