wickr-crypto-c
identity.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 identity_h
23 #define identity_h
24 
25 #include <stdlib.h>
26 #include "buffer.h"
27 #include "eckey.h"
28 #include "ecdsa.h"
29 #include "crypto_engine.h"
30 #include "root_keys.h"
31 #include "fingerprint.h"
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
44 #define IDENTIFIER_LEN 32
45 
46 
47 /* Define ROOT and NODE identity types */
48 typedef enum { IDENTITY_TYPE_ROOT, IDENTITY_TYPE_NODE } wickr_identity_type;
49 
61 typedef enum { IDENTITY_CHAIN_STATUS_UNKNOWN, IDENTITY_CHAIN_STATUS_VALID, IDENTITY_CHAIN_STATUS_INVALID } wickr_identity_chain_status;
62 
86  wickr_identity_type type;
90 };
91 
92 typedef struct wickr_identity wickr_identity_t;
93 
114  wickr_buffer_t *_status_cache;
115 };
116 
118 
131 wickr_identity_t *wickr_identity_create(wickr_identity_type type, wickr_buffer_t *identifier, wickr_ec_key_t *sig_key, wickr_ecdsa_result_t *signature);
132 
145 
157 
168 
178 
189 
190 
191 
203 
215  wickr_crypto_engine_t engine);
216 
217 
232  const wickr_identity_t *remote_identity,
233  wickr_crypto_engine_t engine);
234 
244 wickr_buffer_t *wickr_identity_chain_serialize(const wickr_identity_chain_t *identity_chain);
245 
256 wickr_identity_chain_t *wickr_identity_chain_create_from_buffer(const wickr_buffer_t *buffer, const wickr_crypto_engine_t *engine);
257 
269 
280 
292 
302 
303 #ifdef __cplusplus
304 }
305 #endif
306 
307 #endif /* identity_h */
wickr_identity_chain_t * wickr_identity_chain_copy(const wickr_identity_chain_t *source)
A signing identity on the Wickr system.
Definition: identity.h:85
void wickr_identity_destroy(wickr_identity_t **identity)
wickr_identity_chain_status status
Definition: identity.h:111
Representation of public and private Elliptic Curve Keypair information as buffers.
Definition: eckey.h:90
wickr_buffer_t * identifier
Definition: identity.h:87
void wickr_identity_chain_destroy(wickr_identity_chain_t **chain)
wickr_identity_t * wickr_node_identity_gen(const wickr_crypto_engine_t *engine, const wickr_identity_t *root_identity)
Represents an array of bytes and the length of the allocation associated with those bytes.
Definition: buffer.h:51
wickr_identity_t * wickr_identity_create(wickr_identity_type type, wickr_buffer_t *identifier, wickr_ec_key_t *sig_key, wickr_ecdsa_result_t *signature)
wickr_identity_type type
Definition: identity.h:86
wickr_identity_t * root
Definition: identity.h:112
Elliptic Curve Digital Signature Algorithm Result.
Definition: ecdsa.h:54
bool wickr_identity_chain_validate(wickr_identity_chain_t *chain, const wickr_crypto_engine_t *engine)
wickr_fingerprint_t * wickr_identity_get_bilateral_fingerprint(const wickr_identity_t *identity, const wickr_identity_t *remote_identity, wickr_crypto_engine_t engine)
wickr_identity_t * wickr_identity_copy(const wickr_identity_t *source)
wickr_fingerprint_t * wickr_identity_get_fingerprint(const wickr_identity_t *identity, wickr_crypto_engine_t engine)
wickr_identity_t * wickr_identity_create_from_buffer(const wickr_buffer_t *buffer, const wickr_crypto_engine_t *engine)
A fingerprint representation of a combination of signature keys / identifiers.
Definition: fingerprint.h:75
wickr_identity_t * node
Definition: identity.h:113
wickr_identity_chain_status
Definition: identity.h:61
wickr_ecdsa_result_t * signature
Definition: identity.h:89
wickr_ecdsa_result_t * wickr_identity_sign(const wickr_identity_t *identity, const wickr_crypto_engine_t *engine, const wickr_buffer_t *data)
wickr_ec_key_t * sig_key
Definition: identity.h:88
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_buffer_t * wickr_identity_serialize(const wickr_identity_t *identity)
wickr_identity_chain_t * wickr_identity_chain_create(wickr_identity_t *root, wickr_identity_t *node)