wickr-crypto-c
|
A context that is used for encrypting or decrypting a sequenced stream of data packets The stream context manages the state of stream operations including key evolution management based on the sequence number of the being encrypted / decrypted. The stream context is assigned a direction, and can only be used for encoding OR decoding of packets, and not both. More...
#include <stream_ctx.h>
Data Fields | |
wickr_crypto_engine_t | engine |
wickr_stream_key_t * | key |
wickr_stream_iv_t * | iv_factory |
uint64_t | last_seq |
wickr_stream_direction | direction |
size_t | ref_count |
A context that is used for encrypting or decrypting a sequenced stream of data packets The stream context manages the state of stream operations including key evolution management based on the sequence number of the being encrypted / decrypted. The stream context is assigned a direction, and can only be used for encoding OR decoding of packets, and not both.
Key evolution happens based on sequence number. Keyn+1 is generated by HMAC(Keyn, evolution_key). Gaps in sequence numbers are allowed and if the key needs to evolove multiple times, it will do so in a loop until the key is current, and data ciphering is possible. Sequence numbers can NOT go backwards due to the evolution's use of HMAC. Once Keyn+1 is generated, it is not possible to go back and calculate Keyn.
wickr_stream_ctx::direction |
the direction of this stream context. direction can either be encoding or decoding
wickr_stream_ctx::engine |
crypto engine to be used for cipher operations, as well as key evolution using HMAC
wickr_stream_ctx::iv_factory |
the iv generator that this stream is using to create IVs
wickr_stream_ctx::key |
the current stream key that the stream context is using for encryption or decryption depending on direction the stream key will change over the course of packet encoding due to it's evolutions
wickr_stream_ctx::last_seq |
the most recent sequence number that successfully encrypted or decrypted a packet
wickr_stream_ctx::ref_count |
current reference count of the stream