wickr-crypto-c

stream_key.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 stream_key_h
23 #define stream_key_h
24
25 #include "crypto_engine.h"
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 #define PACKET_PER_EVO_MIN 1
32 #define PACKET_PER_EVO_DEFAULT 512
33 #define PACKET_PER_EVO_MAX 32768
34
56 struct wickr_stream_key {
57 wickr_cipher_key_t *cipher_key;
58 wickr_buffer_t *evolution_key;
59 wickr_buffer_t *user_data;
60 uint32_t packets_per_evolution;
61 };
62
63 typedef struct wickr_stream_key wickr_stream_key_t;
64
76 wickr_stream_key_t *wickr_stream_key_create(wickr_cipher_key_t *cipher_key, wickr_buffer_t *evolution_key, uint32_t packets_per_evolution);
77
90 wickr_stream_key_t *wickr_stream_key_create_user_data(wickr_cipher_key_t *cipher_key, wickr_buffer_t *evolution_key, uint32_t packets_per_evolution, wickr_buffer_t *user_data);
91
102 wickr_stream_key_t *wickr_stream_key_create_rand(const wickr_crypto_engine_t engine, wickr_cipher_t cipher, uint32_t packets_per_evolution);
103
112 wickr_stream_key_t *wickr_stream_key_copy(const wickr_stream_key_t *stream_key);
113
122 wickr_buffer_t *wickr_stream_key_serialize(const wickr_stream_key_t *key);
123
132 wickr_stream_key_t *wickr_stream_key_create_from_buffer(const wickr_buffer_t *buffer);
133
142 void wickr_stream_key_destroy(wickr_stream_key_t **stream_key);
143
144 #ifdef __cplusplus
145 }
146 #endif
147
148 #endif /* stream_key_h */
wickr_stream_key_copy
wickr_stream_key_t * wickr_stream_key_copy(const wickr_stream_key_t *stream_key)
wickr_stream_key_destroy
void wickr_stream_key_destroy(wickr_stream_key_t **stream_key)
wickr_stream_key_create
wickr_stream_key_t * wickr_stream_key_create(wickr_cipher_key_t *cipher_key, wickr_buffer_t *evolution_key, uint32_t packets_per_evolution)
wickr_stream_key_create_rand
wickr_stream_key_t * wickr_stream_key_create_rand(const wickr_crypto_engine_t engine, wickr_cipher_t cipher, uint32_t packets_per_evolution)
wickr_stream_key_create_from_buffer
wickr_stream_key_t * wickr_stream_key_create_from_buffer(const wickr_buffer_t *buffer)
wickr_stream_key_serialize
wickr_buffer_t * wickr_stream_key_serialize(const wickr_stream_key_t *key)
wickr_stream_key_create_user_data
wickr_stream_key_t * wickr_stream_key_create_user_data(wickr_cipher_key_t *cipher_key, wickr_buffer_t *evolution_key, uint32_t packets_per_evolution, wickr_buffer_t *user_data)
wickr_buffer
Represents an array of bytes and the length of the allocation associated with those bytes.
Definition: buffer.h:51
wickr_cipher_key
Definition: cipher.h:189
wickr_cipher
Represents a cipher that can be used in the crypto_engine. This meta object holds parameters for the ...
Definition: cipher.h:56
wickr_crypto_engine
Interface to a set of cryptographic operations used throughout the library. Currently the default imp...
Definition: crypto_engine.h:53
wickr_stream_key
A data structure representing the stream encoding / decoding key material A stream key holds informat...
Definition: stream_key.h:56
wickr_stream_key::cipher_key
wickr_cipher_key_t * cipher_key
Definition: stream_key.h:57
wickr_stream_key::user_data
wickr_buffer_t * user_data
Definition: stream_key.h:59
wickr_stream_key::packets_per_evolution
uint32_t packets_per_evolution
Definition: stream_key.h:60
wickr_stream_key::evolution_key
wickr_buffer_t * evolution_key
Definition: stream_key.h:58