wickr-crypto-c
stream_ctx.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_ctx_h
23 #define stream_ctx_h
24 
25 #include "crypto_engine.h"
26 #include "stream_iv.h"
27 #include "stream_key.h"
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
37 typedef enum { STREAM_DIRECTION_ENCODE, STREAM_DIRECTION_DECODE } wickr_stream_direction;
38 
71  uint64_t last_seq;
72  wickr_stream_direction direction;
73  size_t ref_count;
74 };
75 
77 
89 
99 
111 wickr_cipher_result_t *wickr_stream_ctx_encode(wickr_stream_ctx_t *ctx, const wickr_buffer_t *data, const wickr_buffer_t *aad, uint64_t seq_num);
112 
124 wickr_buffer_t *wickr_stream_ctx_decode(wickr_stream_ctx_t *ctx, const wickr_cipher_result_t *data, const wickr_buffer_t *aad, uint64_t seq_num);
125 
134 
143 
144 #ifdef __cplusplus
145 }
146 #endif
147 
148 #endif /* stream_ctx_h */
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_ctx_decode
wickr_buffer_t * wickr_stream_ctx_decode(wickr_stream_ctx_t *ctx, const wickr_cipher_result_t *data, const wickr_buffer_t *aad, uint64_t seq_num)
wickr_stream_iv
A deterministic random IV generator using a 64 byte secure random seed and HMAC-SHA512.
Definition: stream_iv.h:53
wickr_stream_ctx_ref_up
bool wickr_stream_ctx_ref_up(wickr_stream_ctx_t *ctx)
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_ctx::last_seq
uint64_t last_seq
Definition: stream_ctx.h:71
wickr_stream_ctx_create
wickr_stream_ctx_t * wickr_stream_ctx_create(const wickr_crypto_engine_t engine, wickr_stream_key_t *stream_key, wickr_stream_direction direction)
wickr_stream_ctx_copy
wickr_stream_ctx_t * wickr_stream_ctx_copy(const wickr_stream_ctx_t *ctx)
wickr_stream_ctx_encode
wickr_cipher_result_t * wickr_stream_ctx_encode(wickr_stream_ctx_t *ctx, const wickr_buffer_t *data, const wickr_buffer_t *aad, uint64_t seq_num)
wickr_stream_ctx::engine
wickr_crypto_engine_t engine
Definition: stream_ctx.h:68
wickr_stream_ctx_destroy
void wickr_stream_ctx_destroy(wickr_stream_ctx_t **ctx)
wickr_buffer
Represents an array of bytes and the length of the allocation associated with those bytes.
Definition: buffer.h:51
wickr_stream_ctx::ref_count
size_t ref_count
Definition: stream_ctx.h:73
wickr_stream_ctx::direction
wickr_stream_direction direction
Definition: stream_ctx.h:72
wickr_cipher_result
Definition: cipher.h:97
wickr_stream_ctx::key
wickr_stream_key_t * key
Definition: stream_ctx.h:69
wickr_stream_ctx::iv_factory
wickr_stream_iv_t * iv_factory
Definition: stream_ctx.h:70
wickr_stream_ctx
A context that is used for encrypting or decrypting a sequenced stream of data packets The stream con...
Definition: stream_ctx.h:67